Adding framework for different port scans

This commit is contained in:
Sarah Jamie Lewis 2016-04-11 22:10:59 -07:00
parent ef4611b810
commit c15840886d
1 changed files with 53 additions and 30 deletions

View File

@ -7,6 +7,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"strings"
) )
type OnionScan struct { type OnionScan struct {
@ -27,8 +28,34 @@ func Configure(torProxyAddress string) *OnionScan {
func (os *OnionScan) Scan(hiddenService string) (*report.OnionScanReport, error) { func (os *OnionScan) Scan(hiddenService string) (*report.OnionScanReport, error) {
// Remove Extra Prefix
// TODO: Add support for HTTPS?
if strings.HasPrefix(hiddenService, "http://") {
hiddenService = hiddenService[7:]
}
if strings.HasSuffix(hiddenService, "/") {
hiddenService = hiddenService[0 : len(hiddenService)-1]
}
report := report.NewOnionScanReport(hiddenService) report := report.NewOnionScanReport(hiddenService)
// It's Port Scanning Time.
log.Printf("Checking %s ssh(22)\n", hiddenService)
_, err := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":22")
if err != nil {
log.Printf("Failed to connect to service on port 22\n")
} else {
// TODO SSH Checking
}
log.Printf("Checking %s http(80)\n", hiddenService)
// It's Port Scanning Time.
_, err = socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":80")
if err != nil {
log.Printf("Failed to connect to service on port 80\n")
} else {
// FIXME This should probably be moved to it's own file now.
response, err := os.Client.Get("http://" + hiddenService) response, err := os.Client.Get("http://" + hiddenService)
if err != nil { if err != nil {
@ -40,11 +67,6 @@ func (os *OnionScan) Scan(hiddenService string) (*report.OnionScanReport, error)
report.ServerVersion = response.Header.Get("Server") report.ServerVersion = response.Header.Get("Server")
log.Printf("\tServer Version: %s\n", report.ServerVersion) log.Printf("\tServer Version: %s\n", report.ServerVersion)
// Initial attempt at grabbing X-Powered-By header response
log.Printf("Attempting to grab additional header information..\n")
report.ServerPoweredBy = response.Header.Get("X-Powered-By")
log.Printf("\tX-Powered-By: %s\n", report.ServerPoweredBy)
// Apache mod-status Check // Apache mod-status Check
os.ScanPage(hiddenService, "/server-status", report, scans.ApacheModStatus) os.ScanPage(hiddenService, "/server-status", report, scans.ApacheModStatus)
os.ScanPage(hiddenService, "/", report, scans.StandardPageScan) os.ScanPage(hiddenService, "/", report, scans.StandardPageScan)
@ -63,6 +85,7 @@ func (os *OnionScan) Scan(hiddenService string) (*report.OnionScanReport, error)
// Common with torshops created onions // Common with torshops created onions
os.ScanPage(hiddenService, "/products", report, scans.CheckDirectoryListing) os.ScanPage(hiddenService, "/products", report, scans.CheckDirectoryListing)
os.ScanPage(hiddenService, "/products/cat", report, scans.CheckDirectoryListing) os.ScanPage(hiddenService, "/products/cat", report, scans.CheckDirectoryListing)
}
return report, nil return report, nil
} }