7 unstable releases (3 breaking)

0.4.1 Mar 13, 2024
0.4.0 Feb 26, 2024
0.3.0 Feb 25, 2024
0.2.4 Feb 25, 2024
0.1.0 Jun 28, 2023

#1327 in Network programming

Download history 3/week @ 2024-02-16 414/week @ 2024-02-23 66/week @ 2024-03-01 135/week @ 2024-03-08 22/week @ 2024-03-15 3/week @ 2024-03-22 24/week @ 2024-03-29 10/week @ 2024-04-05

389 downloads per month

MIT/Apache

8KB
139 lines

ctf_tcp_helper

Wrapper library for TCP based CTF

Description

Wrapper to manage TCP connections in CTF challs.

Usage

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(())
}

Dependencies

~295–760KB
~18K SLoC