-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsmtpEnum.go
91 lines (74 loc) · 1.68 KB
/
smtpEnum.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Enumerate users via SMTP service
@sha0coder
*/
package main
import (
"bufio"
"flag"
"fmt"
"net"
"os"
"strings"
"time"
)
func check(err error, msg string) {
if err != nil {
fmt.Println(msg)
os.Exit(1)
}
}
func loadWordlist(wordlist string, c chan string) {
file, err := os.Open(wordlist)
check(err, "Can't load the wordlist")
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
c <- scanner.Text()
}
c <- "[EOF1337]"
close(c)
}
func main() {
var smtp *string = flag.String("smtp", "", "ip:port of the smtp server")
var wlfile *string = flag.String("wl", "", "users wordlist")
var host *string = flag.String("host", "", "users wordlist")
var verbose *bool = flag.Bool("v", false, "verbose")
flag.Parse()
c := make(chan string, 6)
go loadWordlist(*wlfile, c)
conn, err := net.Dial("tcp", *smtp)
check(err, "cant connect")
read := bufio.NewReader(conn)
str, _ := read.ReadString('\n')
fmt.Println(str)
if *verbose {
fmt.Printf("helo %s\n", *host)
}
fmt.Fprintf(conn, "helo %s\n", *host)
str, _ = read.ReadString('\n')
if *verbose {
fmt.Println(str)
fmt.Println("mail from: <[email protected]>")
}
//fmt.Fprintf(conn, "mail from: <[email protected]>\n")
//read.ReadString('\n')
for w := range c {
if w == "[EOF1337]" {
fmt.Println("end.\n")
os.Exit(1)
}
fmt.Fprintf(conn, "VRFY %s\n", w)
str, _ := read.ReadString('\n')
if *verbose {
fmt.Println(str)
}
if strings.Contains(str, "Sender ok") || strings.Contains(str, "Recipient ok") || strings.Contains(str, "Ok") {
fmt.Printf("=> %s\n", w)
} else if !*verbose {
fmt.Printf("\r%s ", w)
}
time.Sleep(10 * time.Second)
}
fmt.Println("end.")
}