From 6ab0a595e7613d285b524f5643e828373f881fb4 Mon Sep 17 00:00:00 2001 From: Emile Date: Thu, 27 Jun 2019 00:19:44 +0200 Subject: done --- stdin-service/main.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 stdin-service/main.go (limited to 'stdin-service/main.go') diff --git a/stdin-service/main.go b/stdin-service/main.go new file mode 100644 index 0000000..39843a1 --- /dev/null +++ b/stdin-service/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "flag" + "io/ioutil" + "log" + "os" + "net" + "fmt" +) + +var ( + inputFile = flag.String("file", "default.txt", "input file") + host = flag.String("h", "localhost", "the host to pee against") + port = flag.Int("p", 1337, "the port to use") + protocol = flag.String("protocol", "tcp", "the protocol to use") +) + +func main() { + flag.Parse() + + dat, err := ioutil.ReadFile(*inputFile) + if err != nil { + log.Printf("Error reading file: %v", err) + os.Exit(1) + } + + conn, _ := net.Dial(*protocol, fmt.Sprintf("%s:%d", *host, *port)) + + writtenBytes, err := conn.Write(dat) + if err != nil { + log.Printf("Error accepting: %v", err) + os.Exit(1) + } + fmt.Printf("Written %d bytes", writtenBytes) + + +} -- cgit 1.4.1