forked from s-rah/onionscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onionscan.go
101 lines (95 loc) · 2.88 KB
/
onionscan.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
92
93
94
95
96
97
98
99
100
101
package onionscan
import (
"fmt"
"github.com/s-rah/onionscan/config"
"github.com/s-rah/onionscan/protocol"
"github.com/s-rah/onionscan/report"
"time"
)
// OnionScan runs the main procol level scans
type OnionScan struct {
Config *config.OnionScanConfig
}
// GetAllActions returns a list of all possible protocol level scans.
func (os *OnionScan) GetAllActions() []string {
return []string{
"web",
"tls",
"ssh",
"irc",
"ricochet",
"ftp",
"smtp",
"mongodb",
"vnc",
"xmpp",
"bitcoin",
"bitcoin_test",
"litecoin",
"dogecoin",
}
}
// PerformNextAction determined which scan to run next, and runs it.
func (os *OnionScan) PerformNextAction(report *report.OnionScanReport, nextAction string) error {
switch nextAction {
case "web":
wps := new(protocol.HTTPProtocolScanner)
wps.ScanProtocol(report.HiddenService, os.Config, report)
case "tls":
tps := new(protocol.TLSProtocolScanner)
tps.ScanProtocol(report.HiddenService, os.Config, report)
case "ssh":
sps := new(protocol.SSHProtocolScanner)
sps.ScanProtocol(report.HiddenService, os.Config, report)
case "irc":
ips := new(protocol.IRCProtocolScanner)
ips.ScanProtocol(report.HiddenService, os.Config, report)
case "ricochet":
rps := new(protocol.RicochetProtocolScanner)
rps.ScanProtocol(report.HiddenService, os.Config, report)
case "ftp":
fps := new(protocol.FTPProtocolScanner)
fps.ScanProtocol(report.HiddenService, os.Config, report)
case "smtp":
smps := new(protocol.SMTPProtocolScanner)
smps.ScanProtocol(report.HiddenService, os.Config, report)
case "mongodb":
mdbps := new(protocol.MongoDBProtocolScanner)
mdbps.ScanProtocol(report.HiddenService, os.Config, report)
case "vnc":
vncps := new(protocol.VNCProtocolScanner)
vncps.ScanProtocol(report.HiddenService, os.Config, report)
case "xmpp":
xmppps := new(protocol.XMPPProtocolScanner)
xmppps.ScanProtocol(report.HiddenService, os.Config, report)
case "bitcoin", "bitcoin_test", "litecoin", "litecoin_test", "dogecoin", "dogecoin_test":
bps := protocol.NewBitcoinProtocolScanner(nextAction)
bps.ScanProtocol(report.HiddenService, os.Config, report)
case "none":
return nil
default:
return fmt.Errorf("Unknown scanner %s", nextAction)
}
return nil
}
// Do performs all configured protocol level scans in this run.
func (os *OnionScan) Do(osreport *report.OnionScanReport) error {
for _, nextAction := range os.Config.Scans {
err := os.PerformNextAction(osreport, nextAction)
if err != nil {
os.Config.LogInfo(fmt.Sprintf("Error: %s", err))
} else {
osreport.PerformedScans = append(osreport.PerformedScans, nextAction)
}
if time.Now().Sub(osreport.DateScanned).Seconds() > os.Config.Timeout.Seconds() {
osreport.TimedOut = true
break
}
}
if len(osreport.PerformedScans) != 0 {
osreport.NextAction = osreport.PerformedScans[len(osreport.PerformedScans)-1]
} else {
osreport.NextAction = "none"
}
return nil
}