Advertisement
Guest User

Untitled

a guest
May 14th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "bufio"
  5. "fmt"
  6. "os"
  7. "time"
  8. "strings"
  9. "net"
  10. )
  11.  
  12. func main() {
  13.  
  14. f, err := os.OpenFile("/log", os.O_RDWR|os.O_APPEND, os.ModeNamedPipe)
  15. if err != nil {
  16. fmt.Fprintf(os.Stderr, "error opening file: %v", err)
  17. }
  18. defer f.Close()
  19.  
  20. args := os.Args
  21.  
  22. host, port, _ := net.SplitHostPort(args[1])
  23. ip := net.ParseIP(host)
  24.  
  25. reader := bufio.NewReader(os.Stdin)
  26.  
  27. attempts := 0
  28. for {
  29. fmt.Printf("localhost login: ")
  30. user, _ := reader.ReadString('\n')
  31. time.Sleep(250 * time.Millisecond)
  32.  
  33. fmt.Printf("Password: ")
  34. pass, _ := reader.ReadString('\n')
  35.  
  36. fmt.Fprintf(f, "Username: %s Password: %s From: %s:%s\n", strings.Trim(user, "\r\n\t "), strings.Trim(pass, "\r\n\t "), ip, port)
  37.  
  38. time.Sleep(1000 * time.Millisecond)
  39. fmt.Printf("Login incorrect\n")
  40. time.Sleep(500 * time.Millisecond)
  41. attempts++
  42. if attempts >= 3 { os.Exit(1) }
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement