| skipped 44 lines |
45 | 45 | | var realResult []string |
46 | 46 | | result := make(map[string]string) |
47 | 47 | | if !core.FileExists(massOutput) { |
| 48 | + | core.ErrorF("Output not found: %v", massOutput) |
48 | 49 | | return realResult |
49 | 50 | | } |
| 51 | + | core.InforF("Parsing result from: %v", massOutput) |
50 | 52 | | data := core.GetFileContent(massOutput) |
51 | 53 | | rawResult := ParsingMasscan(data) |
| 54 | + | |
| 55 | + | if len(rawResult) == 0 { |
| 56 | + | core.ErrorF("Output not found: %v", massOutput) |
| 57 | + | } |
| 58 | + | |
52 | 59 | | // get flat output for easily parse to other tools |
53 | 60 | | if options.Scan.Flat { |
54 | 61 | | for k, v := range rawResult { |
55 | 62 | | for _, port := range v { |
56 | | - | realResult = append(realResult, fmt.Sprintf("%v:%v", k, port)) |
| 63 | + | info := fmt.Sprintf("%v:%v", k, port) |
| 64 | + | realResult = append(realResult, info) |
57 | 65 | | } |
58 | 66 | | } |
59 | 67 | | return realResult |
60 | 68 | | } |
61 | 69 | | |
62 | | - | // group them by host |
| 70 | + | // group them by host in verbose mode |
63 | 71 | | for k, v := range rawResult { |
64 | 72 | | result[k] += fmt.Sprintf("%v", strings.Join(v, ",")) |
65 | 73 | | } |
66 | | - | |
67 | 74 | | for k, v := range result { |
68 | 75 | | realResult = append(realResult, fmt.Sprintf("%v - %v", k, v)) |
69 | 76 | | } |
70 | 77 | | |
71 | 78 | | return realResult |
72 | | - | } |
73 | | - | |
74 | | - | type nmap struct { |
75 | 79 | | } |
76 | 80 | | |
77 | 81 | | // RunNmap run nmap command and return list of port open |
| skipped 84 lines |
162 | 166 | | func ParsingMasscan(raw string) map[string][]string { |
163 | 167 | | result := make(map[string][]string) |
164 | 168 | | data := strings.Split(raw, "\n") |
| 169 | + | if len(data) == 0 { |
| 170 | + | core.ErrorF("Invalid Masscan data") |
| 171 | + | return result |
| 172 | + | } |
165 | 173 | | |
166 | 174 | | for _, line := range data { |
167 | 175 | | if !strings.Contains(line, "Host: ") { |
| skipped 63 lines |