refactor: removed debug code
This commit is contained in:
parent
c142af62f1
commit
798eda764f
@ -1,4 +1,4 @@
|
||||
use std::{net::Ipv4Addr, collections::HashMap};
|
||||
use std::{io::prelude::*, net::Ipv4Addr, collections::HashMap};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use tokio::time::{Duration, interval};
|
||||
@ -9,21 +9,12 @@ use pcap_sys::packets::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
// commented out because it's hard to easily input an IP by command line with docker compose
|
||||
// let mut args = std::env::args();
|
||||
// args.next();
|
||||
// let target = args.next()
|
||||
// .map(|s| s.parse::<Ipv4Addr>().ok())
|
||||
// .flatten()
|
||||
// .ok_or(anyhow!("Please specify a target IP"))?;
|
||||
|
||||
// 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: Ipv4Addr = "172.19.0.2".parse().unwrap();
|
||||
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 (ifname, src_mac, dst_mac, srcip) = {
|
||||
let socket = netlink::Socket::new()?;
|
||||
@ -40,41 +31,9 @@ async fn main() -> anyhow::Result<()> {
|
||||
.unwrap_or(std::cmp::Ordering::Equal)
|
||||
});
|
||||
|
||||
println!("-=- Addrs -=-");
|
||||
for addr in addrs.iter() {
|
||||
println!("addr: {:?}, {}", addr.local(), addr.ifindex());
|
||||
}
|
||||
println!("-=- Routes -=-");
|
||||
for route in routes_inner.iter() {
|
||||
println!("route: {:?}", route.dst());
|
||||
|
||||
for hop in route.hop_iter() {
|
||||
println!("\thop: {:?}, {}", hop.gateway(), hop.ifindex());
|
||||
}
|
||||
}
|
||||
println!("-=- Neighs -=-");
|
||||
for neigh in neighs.iter() {
|
||||
println!("neigh: {:?}, {:?}, {}", neigh.dst(), neigh.lladdr(), neigh.ifindex());
|
||||
}
|
||||
println!("-=- Links -=-");
|
||||
for link in links.iter() {
|
||||
println!("link {:?}: {:?}, {}", link.name(), link.addr(), link.ifindex());
|
||||
}
|
||||
|
||||
let (ifname, srcip, srcmac, dstmac) = route::get_macs_and_src_for_ip(&addrs, &routes, &neighs, &links, target)
|
||||
.ok_or(anyhow!("unable to find a route to the IP"))?;
|
||||
|
||||
/*let srcip = route::get_srcip_for_dstip(&routes, target)
|
||||
.ok_or(anyhow!("Unable to find a route to the IP"))?;
|
||||
|
||||
let (srcip, target_link, dst_mac) = route::get_neigh_for_addr(&routes, &neighs, &links, &srcip.into())
|
||||
.ok_or(anyhow!("Unable to find local interface to use"))?;*/
|
||||
|
||||
dbg!(srcmac);
|
||||
dbg!(dstmac);
|
||||
dbg!(srcip);
|
||||
dbg!(target);
|
||||
|
||||
( ifname, srcmac, dstmac, srcip )
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user