Crates.io | ctf_tcp_utils |
lib.rs | ctf_tcp_utils |
version | 0.5.0 |
source | src |
created_at | 2023-06-28 13:06:41.138383 |
updated_at | 2024-09-13 09:28:08.258044 |
description | TCP helpers for CTFs |
homepage | |
repository | https://github.com/YetiBarBar/ctf_tcp_utils |
max_upload_size | |
id | 902096 |
size | 8,558 |
Wrapper library for TCP based CTF
Wrapper to manage TCP connections in CTF challs.
fn main() -> anyhow::Result<()> {
let url = "challenge.com";
let port = 4242;
let mut tcp_handle = ctf_tcp_utils::TcpHandler::new(&url, port)?;
let input = tcp_handle.read_to_string();
println!("{input}");
let answer = process(&input);
println!("{answer}");
tcp_handle.write_answer(&answer);
let result = tcp_handle.read_to_string();
println!("{result}");
Ok(())
}
If the CTF requires to repeat the same business logic in a loop, you can try:
fn main()-> anyhow::Result<()> {
let result: String = ctf_tcp_utils::CtfLoopResponder::new()
.url("challenge.com")
.port(4242)
.timeout(250)
.responder_func(|input| {
// Insert logic here!
})
.connect_and_work()?;
println!("{result}");
Ok(())
}