> For the complete documentation index, see [llms.txt](https://simon-6.gitbook.io/simoncyber/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simon-6.gitbook.io/simoncyber/ctf-writeups/picoctf-2025/general-rules/rust-fixme-1-easy.md).

# Rust fixme 1 (Easy)

<figure><img src="/files/nXdHsyVIrFKKPqctjypA" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/fyP73h2Qjh0VflJjVf7P" alt=""><figcaption></figcaption></figure>

***

I'm not too particular interested in learning Rust as it's mainly used for offensive puporses but let's just try one. Loading up the code, I fixed the println statement. It was before println?, which just didn't match the syntax of any code.&#x20;

The first thing to do is to install rust.&#x20;

```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

After that, you could just run riles using "rustc".

<figure><img src="/files/EtgJJEjKdSArr2HH4zP6" alt=""><figcaption></figcaption></figure>

***

The fixes were quite simple, just syntax errors such as ending with a semicolon or using a return statement.

```rust
use xor_cryptor::XORCryptor;

fn main() {
    // Key for decryption
    let key = String::from("CSUCKS") // How do we end statements in Rust?

    // Encrypted flag values
    let hex_values = ["41", "30", "20", "63", "4a", "45", "54", "76", "01", "1c", "7e", "59", "63", "e1", "61", "25", "7f", "5a", "60", "50", "11", "38", "1f", "3a", "60", "e9", "62", "20", "0c", "e6", "50", "d3", "35"];

    // Convert the hexadecimal strings to bytes and collect them into a vector
    let encrypted_buffer: Vec<u8> = hex_values.iter()
        .map(|&hex| u8::from_str_radix(hex, 16).unwrap())
        .collect();

    // Create decrpytion object
    let res = XORCryptor::new(&key);
    if res.is_err() {
        ret; // How do we return in rust?
    }
    let xrc = res.unwrap();

    // Decrypt flag and print it out
    let decrypted_buffer = xrc.decrypt_vec(encrypted_buffer);
    println!(
        ":?", // How do we print out a variable in the println function? 
        String::from_utf8_lossy(&decrypted_buffer)
    );
}
```

However, I couldn't make it work with the rustc command since it imported a module. I needed to use cargo which ran with it. You would then need to run these commands.&#x20;

```
cargo build
cargo run
```

After that, you'll get the flag.&#x20;
