2016-05-03 16:31:56 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/s-rah/onionscan/config"
|
|
|
|
"github.com/s-rah/onionscan/protocol"
|
|
|
|
"github.com/s-rah/onionscan/report"
|
2016-05-24 12:13:00 +02:00
|
|
|
"github.com/s-rah/onionscan/utils"
|
2016-05-03 16:31:56 +02:00
|
|
|
"strings"
|
2016-07-31 02:00:42 +02:00
|
|
|
"time"
|
2016-05-03 16:31:56 +02:00
|
|
|
)
|
|
|
|
|
2016-05-05 16:21:38 +02:00
|
|
|
type OnionScan struct {
|
|
|
|
Config *config.OnionscanConfig
|
|
|
|
}
|
|
|
|
|
2016-07-31 02:00:42 +02:00
|
|
|
func (os *OnionScan) PerformNextAction(report *report.OnionScanReport) {
|
|
|
|
switch report.NextAction {
|
|
|
|
case "web":
|
|
|
|
wps := new(protocol.HTTPProtocolScanner)
|
|
|
|
wps.ScanProtocol(report.HiddenService, os.Config, report)
|
2016-07-31 20:30:53 +02:00
|
|
|
report.NextAction = "tls"
|
|
|
|
case "tls":
|
|
|
|
tps := new(protocol.TLSProtocolScanner)
|
|
|
|
tps.ScanProtocol(report.HiddenService, os.Config, report)
|
2016-07-31 02:00:42 +02:00
|
|
|
report.NextAction = "ssh"
|
|
|
|
case "ssh":
|
|
|
|
sps := new(protocol.SSHProtocolScanner)
|
|
|
|
sps.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "irc"
|
|
|
|
case "irc":
|
|
|
|
ips := new(protocol.IRCProtocolScanner)
|
|
|
|
ips.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "ricochet"
|
|
|
|
case "ricochet":
|
|
|
|
rps := new(protocol.RicochetProtocolScanner)
|
|
|
|
rps.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "ftp"
|
|
|
|
case "ftp":
|
|
|
|
fps := new(protocol.FTPProtocolScanner)
|
|
|
|
fps.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "smtp"
|
|
|
|
case "smtp":
|
|
|
|
smps := new(protocol.SMTPProtocolScanner)
|
|
|
|
smps.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "mongodb"
|
|
|
|
case "mongodb":
|
|
|
|
mdbps := new(protocol.MongoDBProtocolScanner)
|
|
|
|
mdbps.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "vnc"
|
|
|
|
case "vnc":
|
|
|
|
vncps := new(protocol.VNCProtocolScanner)
|
|
|
|
vncps.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "xmpp"
|
|
|
|
case "xmpp":
|
|
|
|
xmppps := new(protocol.XMPPProtocolScanner)
|
|
|
|
xmppps.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "bitcoin"
|
|
|
|
case "bitcoin":
|
|
|
|
bps := new(protocol.BitcoinProtocolScanner)
|
|
|
|
bps.ScanProtocol(report.HiddenService, os.Config, report)
|
|
|
|
report.NextAction = "none"
|
|
|
|
case "none":
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
report.NextAction = "web"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-07 08:29:29 +02:00
|
|
|
func (os *OnionScan) Scan(hiddenService string, out chan *report.OnionScanReport) {
|
2016-05-03 16:31:56 +02:00
|
|
|
|
|
|
|
// Remove Extra Prefix
|
2016-05-24 12:13:00 +02:00
|
|
|
hiddenService = utils.WithoutProtocol(hiddenService)
|
2016-05-03 16:31:56 +02:00
|
|
|
|
|
|
|
if strings.HasSuffix(hiddenService, "/") {
|
|
|
|
hiddenService = hiddenService[0 : len(hiddenService)-1]
|
|
|
|
}
|
|
|
|
|
|
|
|
report := report.NewOnionScanReport(hiddenService)
|
|
|
|
|
2016-07-31 02:00:42 +02:00
|
|
|
for report.NextAction != "none" {
|
|
|
|
os.PerformNextAction(report)
|
|
|
|
if time.Now().Sub(report.DateScanned).Seconds() > os.Config.Timeout.Seconds() {
|
|
|
|
report.TimedOut = true
|
|
|
|
report.NextAction = "none"
|
|
|
|
}
|
|
|
|
}
|
2016-06-10 23:17:00 +02:00
|
|
|
|
2016-06-07 08:29:29 +02:00
|
|
|
out <- report
|
2016-05-03 16:31:56 +02:00
|
|
|
}
|