diff options
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) + + +} |