Skip to content

Instantly share code, notes, and snippets.

@rsmudge
Last active May 3, 2024 16:02
Show Gist options
  • Select an option

  • Save rsmudge/e15c2a1bd47c3be1ad7b429beec9eac4 to your computer and use it in GitHub Desktop.

Select an option

Save rsmudge/e15c2a1bd47c3be1ad7b429beec9eac4 to your computer and use it in GitHub Desktop.

Revisions

  1. rsmudge revised this gist Aug 11, 2020. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions search.cna
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # search for and reproduce output that matches a specific regex.
    alias search {
    local('$regex $entry $event $bid $out');
    local('$regex $regex2 $entry $event $bid $out $when');

    # take all of the args, without processing/parsing as normal.
    if (strlen($0) > 7) {
    @@ -13,11 +13,14 @@ alias search {

    btask($1, "Search log with\cE $regex $+ \o");

    # transform our regex to make it multi-line and ismatch friendly.
    $regex2 = "(?ms).* $+ $regex $+ .*?";

    # query our beacon log and walk *everything*
    foreach $entry (data_query("beaconlog")) {
    ($event, $bid, $out, $when) = $entry;
    if ($bid eq $1 && $event eq "beacon_output" && $out hasmatch $regex) {
    if ($bid eq $1 && $event eq "beacon_output" && "Output at*matches*:*" !iswm $out && $out ismatch $regex2) {
    blog($1, "Output at\cE " . dstamp($when) . " \omatches\cB $regex $+ \cE:\o\n\n $+ $out");
    }
    }
    }
    }
  2. rsmudge created this gist Aug 11, 2020.
    23 changes: 23 additions & 0 deletions search.cna
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # search for and reproduce output that matches a specific regex.
    alias search {
    local('$regex $entry $event $bid $out');

    # take all of the args, without processing/parsing as normal.
    if (strlen($0) > 7) {
    $regex = substr($0, 7);
    }
    else {
    berror($1, "search [regex]");
    return;
    }

    btask($1, "Search log with\cE $regex $+ \o");

    # query our beacon log and walk *everything*
    foreach $entry (data_query("beaconlog")) {
    ($event, $bid, $out, $when) = $entry;
    if ($bid eq $1 && $event eq "beacon_output" && $out hasmatch $regex) {
    blog($1, "Output at\cE " . dstamp($when) . " \omatches\cB $regex $+ \cE:\o\n\n $+ $out");
    }
    }
    }