From 4874bee9309a185097edec94ca64e38b0606cc4d Mon Sep 17 00:00:00 2001 From: JosephGregg Date: Wed, 25 May 2016 11:56:21 -0400 Subject: [PATCH] Create mongodb_scanner.go Adding mongodb checks. Mongodb is often not password protected, leaving databases exposed. Additionally, mongodb can reveal identifying information about the host. --- onionscan.go | 6 +++++- protocol/mongodb_scanner.go | 26 ++++++++++++++++++++++++++ report/onionscanreport.go | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 protocol/mongodb_scanner.go diff --git a/onionscan.go b/onionscan.go index 06bf2d8..2ab23da 100644 --- a/onionscan.go +++ b/onionscan.go @@ -53,7 +53,11 @@ func (os *OnionScan) Scan(hiddenService string) (*report.OnionScanReport, error) smps := new(protocol.SMTPProtocolScanner) smps.ScanProtocol(hiddenService, os.Config, report) - if !report.WebDetected && !report.SSHDetected && !report.RicochetDetected && !report.BitcoinDetected && !report.IRCDetected && !report.FTPDetected && !report.SMTPDetected { + //MongoDb + mdbps := new(protocol.MongoDBProtocolScanner) + mdbps.ScanProtocol(hiddenService, os.Config, report) + + if !report.WebDetected && !report.SSHDetected && !report.RicochetDetected && !report.BitcoinDetected && !report.IRCDetected && !report.FTPDetected && !report.SMTPDetected && !report.MongoDBDetected { fmt.Printf("Unable to connect to this Tor Hidden Service on any known protocol.\n") return nil, errors.New("Unable to connect to this Tor Hidden Service on any known protocol.") } diff --git a/protocol/mongodb_scanner.go b/protocol/mongodb_scanner.go new file mode 100644 index 0000000..e070aab --- /dev/null +++ b/protocol/mongodb_scanner.go @@ -0,0 +1,26 @@ +package protocol + +import ( + "github.com/s-rah/onionscan/config" + "github.com/s-rah/onionscan/report" + "h12.me/socks" + "log" +) + +type MongoDBProtocolScanner struct { +} + +func (rps *MongoDBProtocolScanner) ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport) { + // MongoDB + log.Printf("Checking %s MongoDB(27017)\n", hiddenService) + _, err := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)("", hiddenService+":27017") + if err != nil { + log.Printf("Failed to connect to service on port 27017\n") + report.MongoDBDetected = false + } else { + log.Printf("Detected possible MongoDB instance\n") + // TODO: Actual Analysis + report.MongoDBDetected = true + } + +} diff --git a/report/onionscanreport.go b/report/onionscanreport.go index 27f5097..16b98eb 100644 --- a/report/onionscanreport.go +++ b/report/onionscanreport.go @@ -25,6 +25,7 @@ type OnionScanReport struct { SMTPDetected bool `json:"smtpDetected"` BitcoinDetected bool `json:"bitcoinDetected"` + MongoDBDetected bool `json:"mongodbDetected"` HiddenService string `json:"hiddenService"` ServerPoweredBy string `json:"serverPoweredBy"`