@@ -2,10 +2,12 @@ package main
2
2
3
3
import (
4
4
"bufio"
5
+ "bytes"
5
6
"crypto/tls"
6
7
"encoding/json"
7
8
"flag"
8
9
"fmt"
10
+ "io"
9
11
"log"
10
12
"math/rand"
11
13
"net"
@@ -57,7 +59,7 @@ func main() {
57
59
maxstrategy := flag .String ("maxstrategy" , "fastest" , "How to select servers if more are found than wanted (fastest, random)" )
58
60
parallel := flag .Int ("parallel" , 8 , "How many connections per server to run in parallel" )
59
61
60
- log .Println ("LDAP Nom Nom - anonymously bruteforce your way to Active Directory usernames" )
62
+ log .Println ("LDAP Nom Nom - quietly and anonymously bruteforce your way to Active Directory usernames" )
61
63
62
64
flag .Parse ()
63
65
@@ -75,9 +77,8 @@ func main() {
75
77
}
76
78
defer output .Close ()
77
79
78
- var pb * progressbar.ProgressBar
79
- input := os .Stdin
80
80
var pbmax int
81
+ input := os .Stdin
81
82
if * inputname != "" {
82
83
input , err = os .Open (* inputname )
83
84
if err != nil {
@@ -87,14 +88,26 @@ func main() {
87
88
88
89
if * outputname != "" {
89
90
// Count lines
90
- linescanner := bufio .NewScanner (input )
91
- linescanner .Split (bufio .ScanLines )
92
- var lines int
93
- for linescanner .Scan () {
94
- lines ++
91
+ stat , _ := input .Stat ()
92
+ pb := progressbar .DefaultBytes (stat .Size ())
93
+ pb .Describe ("Counting lines" )
94
+ buf := make ([]byte , 128 * 1024 )
95
+ lineSep := []byte {'\n' }
96
+ br := bufio .NewReaderSize (input , 16 * 1024 * 1024 )
97
+ for {
98
+ c , err := br .Read (buf )
99
+ pbmax += bytes .Count (buf [:c ], lineSep )
100
+ pb .Add (c )
101
+
102
+ if err == io .EOF {
103
+ break
104
+ }
105
+ if err != nil {
106
+ log .Fatalf ("failed to read from input file: %s" , err )
107
+ }
95
108
}
96
- input .Seek (0 , os . SEEK_SET )
97
- pbmax = lines
109
+ input .Seek (0 , io . SeekStart )
110
+ pb . Finish ()
98
111
}
99
112
}
100
113
@@ -404,9 +417,10 @@ func main() {
404
417
}
405
418
}()
406
419
420
+ var pb * progressbar.ProgressBar
407
421
if pbmax != 0 {
408
422
pb = progressbar .NewOptions (pbmax ,
409
- progressbar .OptionSetDescription ("Progress " ),
423
+ progressbar .OptionSetDescription ("Usernames nom'ed " ),
410
424
progressbar .OptionShowIts (),
411
425
)
412
426
}
0 commit comments