yellow~ opinionated web scanning pipeline for pentesters in a hurry |
| git clone https://github.com/djnnvx/yellow.git |
| log | files | refs | archive | README | LICENSE |
file.go (975B)
1 package helper 2 3 import ( 4 "bufio" 5 "fmt" 6 "io" 7 "iter" 8 "os" 9 "strings" 10 ) 11 12 type FileScanner struct { 13 io.Closer 14 reader *bufio.Reader 15 path string 16 } 17 18 func LoadTargetFile(targetPath string) *FileScanner { 19 file, err := os.Open(targetPath) 20 if err != nil { 21 fmt.Printf("[!] Could not open target file %q: %v\n", targetPath, err) 22 os.Exit(1) 23 } 24 25 fmt.Println("[+] Loaded targets from", targetPath) 26 return &FileScanner{file, bufio.NewReader(file), targetPath} 27 } 28 29 // Lines streams the file with no line-length cap. A read failure exits instead 30 // of ending the run short with nothing to show for it. 31 func (f *FileScanner) Lines() iter.Seq[string] { 32 return func(yield func(string) bool) { 33 for { 34 line, err := f.reader.ReadString('\n') 35 if t := strings.TrimSpace(line); t != "" && !yield(t) { 36 return 37 } 38 if err != nil { 39 if err != io.EOF { 40 fmt.Printf("[!] Could not read target file %q: %v\n", f.path, err) 41 os.Exit(1) 42 } 43 return 44 } 45 } 46 } 47 }