Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "time"
- "strings"
- "net"
- )
- func main() {
- f, err := os.OpenFile("/log", os.O_RDWR|os.O_APPEND, os.ModeNamedPipe)
- if err != nil {
- fmt.Fprintf(os.Stderr, "error opening file: %v", err)
- }
- defer f.Close()
- args := os.Args
- host, port, _ := net.SplitHostPort(args[1])
- ip := net.ParseIP(host)
- reader := bufio.NewReader(os.Stdin)
- attempts := 0
- for {
- fmt.Printf("localhost login: ")
- user, _ := reader.ReadString('\n')
- time.Sleep(250 * time.Millisecond)
- fmt.Printf("Password: ")
- pass, _ := reader.ReadString('\n')
- 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)
- time.Sleep(1000 * time.Millisecond)
- fmt.Printf("Login incorrect\n")
- time.Sleep(500 * time.Millisecond)
- attempts++
- if attempts >= 3 { os.Exit(1) }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement