PPaste!

flagrs

Home - All the pastes - Authored by Thooms

Raw version

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// I am a setuid binary in your $PATH
extern crate rand;
use rand::Rng;
use std::io::{self, Read, Write};
use std::fs::File;
use std::str;


fn main() {
    let n: u64 = rand::thread_rng().next_u64();
    println!("Could you please type this number back to me?");
    println!("{}", n);

    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    if s.trim().parse() != Ok(n) {
        println!("I guess not :(");
        return;
    }

    let mut f = match File::open("flag.txt") {
        Ok(f) => f,
        Err(_) => {
            println!("Cannot open file");
            return;
        }
    };
    let mut s = Vec::new();
    f.read_to_end(&mut s).unwrap();

    let mut stderr = io::stderr();
    stderr.write(&s).unwrap();
    stderr.flush().unwrap();
}