diff options
author | Emile <hanemile@protonmail.com> | 2019-06-27 00:19:44 +0200 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-06-27 00:19:44 +0200 |
commit | 6ab0a595e7613d285b524f5643e828373f881fb4 (patch) | |
tree | d77e9dc2cb2b2566fcf7cb01dbfcce17349b60a0 /stdin-service/main.go | |
parent | 0f5cb0951020f6dac2a43008eb059176bbf4c84d (diff) |
done
Diffstat (limited to 'stdin-service/main.go')
-rw-r--r-- | stdin-service/main.go | 38 |
1 files changed, 38 insertions, 0 deletions
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) + + +} |