go styling; move config to own package, retain scan in package main
This commit is contained in:
parent
de0676cca7
commit
d3d2adefdd
|
@ -0,0 +1,15 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
import ()
|
||||||
|
|
||||||
|
type OnionscanConfig struct {
|
||||||
|
TorProxyAddress string
|
||||||
|
DirectoryDepth int
|
||||||
|
}
|
||||||
|
|
||||||
|
func Configure(torProxyAddress string, directoryDepth int) *OnionscanConfig {
|
||||||
|
onionScan := new(OnionscanConfig)
|
||||||
|
onionScan.TorProxyAddress = torProxyAddress
|
||||||
|
onionScan.DirectoryDepth = directoryDepth
|
||||||
|
return onionScan
|
||||||
|
}
|
6
main.go
6
main.go
|
@ -3,10 +3,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"github.com/s-rah/onionscan/protocol"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -39,8 +39,8 @@ func main() {
|
||||||
log.SetOutput(ioutil.Discard)
|
log.SetOutput(ioutil.Discard)
|
||||||
}
|
}
|
||||||
|
|
||||||
onionScan := protocol.Configure(*torProxyAddress, *directoryDepth)
|
onionScanConfig := config.Configure(*torProxyAddress, *directoryDepth)
|
||||||
report, err := onionScan.Scan(hiddenService)
|
report, err := onionscan(onionScanConfig, hiddenService)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error running scanner: %s", err)
|
log.Fatalf("Error running scanner: %s", err)
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
|
"github.com/s-rah/onionscan/protocol"
|
||||||
|
"github.com/s-rah/onionscan/report"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func onionscan(onionscanConfig *config.OnionscanConfig, 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)
|
||||||
|
|
||||||
|
// HTTP
|
||||||
|
hps := new(protocol.HTTPProtocolScanner)
|
||||||
|
hps.ScanProtocol(hiddenService, onionscanConfig, report)
|
||||||
|
|
||||||
|
// SSH
|
||||||
|
sps := new(protocol.SSHProtocolScanner)
|
||||||
|
sps.ScanProtocol(hiddenService, onionscanConfig, report)
|
||||||
|
|
||||||
|
// Ricochet
|
||||||
|
rps := new(protocol.RicochetProtocolScanner)
|
||||||
|
rps.ScanProtocol(hiddenService, onionscanConfig, report)
|
||||||
|
|
||||||
|
// Bitcoin
|
||||||
|
bps := new(protocol.BitcoinProtocolScanner)
|
||||||
|
bps.ScanProtocol(hiddenService, onionscanConfig, report)
|
||||||
|
|
||||||
|
//IRC
|
||||||
|
ips := new(protocol.IRCProtocolScanner)
|
||||||
|
ips.ScanProtocol(hiddenService, onionscanConfig, report)
|
||||||
|
|
||||||
|
//FTP
|
||||||
|
fps := new(protocol.FTPProtocolScanner)
|
||||||
|
fps.ScanProtocol(hiddenService, onionscanConfig, report)
|
||||||
|
|
||||||
|
//SMTP
|
||||||
|
smps := new(protocol.SMTPProtocolScanner)
|
||||||
|
smps.ScanProtocol(hiddenService, onionscanConfig, report)
|
||||||
|
|
||||||
|
return report, nil
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"github.com/s-rah/onionscan/report"
|
"github.com/s-rah/onionscan/report"
|
||||||
"h12.me/socks"
|
"h12.me/socks"
|
||||||
"log"
|
"log"
|
||||||
|
@ -9,10 +10,10 @@ import (
|
||||||
type BitcoinProtocolScanner struct {
|
type BitcoinProtocolScanner struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rps *BitcoinProtocolScanner) ScanProtocol(hiddenService string, os *ProtocolConfig, report *report.OnionScanReport) {
|
func (rps *BitcoinProtocolScanner) ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport) {
|
||||||
// Bitcoin
|
// Bitcoin
|
||||||
log.Printf("Checking %s Bitcoin(8333)\n", hiddenService)
|
log.Printf("Checking %s Bitcoin(8333)\n", hiddenService)
|
||||||
_, err := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":8333")
|
_, err := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)("", hiddenService+":8333")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to connect to service on port 8333\n")
|
log.Printf("Failed to connect to service on port 8333\n")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"github.com/s-rah/onionscan/report"
|
"github.com/s-rah/onionscan/report"
|
||||||
"h12.me/socks"
|
"h12.me/socks"
|
||||||
"log"
|
"log"
|
||||||
|
@ -9,10 +10,10 @@ import (
|
||||||
type FTPProtocolScanner struct {
|
type FTPProtocolScanner struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sps *FTPProtocolScanner) ScanProtocol(hiddenService string, os *ProtocolConfig, report *report.OnionScanReport) {
|
func (sps *FTPProtocolScanner) ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport) {
|
||||||
// FTP
|
// FTP
|
||||||
log.Printf("Checking %s FTP(22)\n", hiddenService)
|
log.Printf("Checking %s FTP(22)\n", hiddenService)
|
||||||
_, err := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":21")
|
_, err := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)("", hiddenService+":21")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to connect to service on port 21\n")
|
log.Printf("Failed to connect to service on port 21\n")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"github.com/s-rah/onionscan/report"
|
"github.com/s-rah/onionscan/report"
|
||||||
"github.com/s-rah/onionscan/scans"
|
"github.com/s-rah/onionscan/scans"
|
||||||
"github.com/s-rah/onionscan/utils"
|
"github.com/s-rah/onionscan/utils"
|
||||||
|
@ -22,17 +23,17 @@ var (
|
||||||
"/products", "/products/cat"}
|
"/products", "/products/cat"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (hps *HTTPProtocolScanner) ScanProtocol(hiddenService string, os *ProtocolConfig, report *report.OnionScanReport) {
|
func (hps *HTTPProtocolScanner) ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport) {
|
||||||
|
|
||||||
// HTTP
|
// HTTP
|
||||||
log.Printf("Checking %s http(80)\n", hiddenService)
|
log.Printf("Checking %s http(80)\n", hiddenService)
|
||||||
_, err := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":80")
|
_, err := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)("", hiddenService+":80")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to connect to service on port 80\n")
|
log.Printf("Failed to connect to service on port 80\n")
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Found potential service on http(80)\n")
|
log.Printf("Found potential service on http(80)\n")
|
||||||
report.WebDetected = true
|
report.WebDetected = true
|
||||||
dialSocksProxy := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)
|
dialSocksProxy := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)
|
||||||
transportConfig := &http.Transport{
|
transportConfig := &http.Transport{
|
||||||
Dial: dialSocksProxy,
|
Dial: dialSocksProxy,
|
||||||
}
|
}
|
||||||
|
@ -64,7 +65,7 @@ func (hps *HTTPProtocolScanner) ScanProtocol(hiddenService string, os *ProtocolC
|
||||||
directories := append(CommonDirectories, report.PageReferencedDirectories...)
|
directories := append(CommonDirectories, report.PageReferencedDirectories...)
|
||||||
utils.RemoveDuplicates(&directories)
|
utils.RemoveDuplicates(&directories)
|
||||||
for _, directory := range directories {
|
for _, directory := range directories {
|
||||||
hps.ScanPage(hiddenService, directory, report, scans.CheckDirectoryListing(os.DirectoryDepth))
|
hps.ScanPage(hiddenService, directory, report, scans.CheckDirectoryListing(onionscanConfig.DirectoryDepth))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("\n")
|
log.Printf("\n")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"github.com/s-rah/onionscan/report"
|
"github.com/s-rah/onionscan/report"
|
||||||
"h12.me/socks"
|
"h12.me/socks"
|
||||||
"log"
|
"log"
|
||||||
|
@ -9,10 +10,10 @@ import (
|
||||||
type IRCProtocolScanner struct {
|
type IRCProtocolScanner struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rps *IRCProtocolScanner) ScanProtocol(hiddenService string, os *ProtocolConfig, report *report.OnionScanReport) {
|
func (rps *IRCProtocolScanner) ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport) {
|
||||||
// IRC
|
// IRC
|
||||||
log.Printf("Checking %s IRC(6667)\n", hiddenService)
|
log.Printf("Checking %s IRC(6667)\n", hiddenService)
|
||||||
_, err := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":6667")
|
_, err := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)("", hiddenService+":6667")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to connect to service on port 6667\n")
|
log.Printf("Failed to connect to service on port 6667\n")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
package protocol
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/s-rah/onionscan/report"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ProtocolConfig struct {
|
|
||||||
TorProxyAddress string
|
|
||||||
DirectoryDepth int
|
|
||||||
}
|
|
||||||
|
|
||||||
func Configure(torProxyAddress string, directoryDepth int) *ProtocolConfig {
|
|
||||||
onionScan := new(ProtocolConfig)
|
|
||||||
onionScan.TorProxyAddress = torProxyAddress
|
|
||||||
onionScan.DirectoryDepth = directoryDepth
|
|
||||||
return onionScan
|
|
||||||
}
|
|
||||||
|
|
||||||
func (os *ProtocolConfig) 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)
|
|
||||||
|
|
||||||
// HTTP
|
|
||||||
hps := new(HTTPProtocolScanner)
|
|
||||||
hps.ScanProtocol(hiddenService, os, report)
|
|
||||||
|
|
||||||
// SSH
|
|
||||||
sps := new(SSHProtocolScanner)
|
|
||||||
sps.ScanProtocol(hiddenService, os, report)
|
|
||||||
|
|
||||||
// Ricochet
|
|
||||||
rps := new(RicochetProtocolScanner)
|
|
||||||
rps.ScanProtocol(hiddenService, os, report)
|
|
||||||
|
|
||||||
// Bitcoin
|
|
||||||
bps := new(BitcoinProtocolScanner)
|
|
||||||
bps.ScanProtocol(hiddenService, os, report)
|
|
||||||
|
|
||||||
//IRC
|
|
||||||
ips := new(IRCProtocolScanner)
|
|
||||||
ips.ScanProtocol(hiddenService, os, report)
|
|
||||||
|
|
||||||
//FTP
|
|
||||||
fps := new(FTPProtocolScanner)
|
|
||||||
fps.ScanProtocol(hiddenService, os, report)
|
|
||||||
|
|
||||||
//SMTP
|
|
||||||
smps := new(SMTPProtocolScanner)
|
|
||||||
smps.ScanProtocol(hiddenService, os, report)
|
|
||||||
|
|
||||||
return report, nil
|
|
||||||
}
|
|
|
@ -1,9 +1,10 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"github.com/s-rah/onionscan/report"
|
"github.com/s-rah/onionscan/report"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProtocolScanner interface {
|
type ProtocolScanner interface {
|
||||||
ScanProtocol(hiddenService string, os *ProtocolConfig, report *report.OnionScanReport)
|
ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"github.com/s-rah/onionscan/report"
|
"github.com/s-rah/onionscan/report"
|
||||||
"h12.me/socks"
|
"h12.me/socks"
|
||||||
"log"
|
"log"
|
||||||
|
@ -9,10 +10,10 @@ import (
|
||||||
type RicochetProtocolScanner struct {
|
type RicochetProtocolScanner struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rps *RicochetProtocolScanner) ScanProtocol(hiddenService string, os *ProtocolConfig, report *report.OnionScanReport) {
|
func (rps *RicochetProtocolScanner) ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport) {
|
||||||
// Ricochet
|
// Ricochet
|
||||||
log.Printf("Checking %s ricochet(9878)\n", hiddenService)
|
log.Printf("Checking %s ricochet(9878)\n", hiddenService)
|
||||||
_, err := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":9878")
|
_, err := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)("", hiddenService+":9878")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to connect to service on port 9878\n")
|
log.Printf("Failed to connect to service on port 9878\n")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"github.com/s-rah/onionscan/report"
|
"github.com/s-rah/onionscan/report"
|
||||||
"h12.me/socks"
|
"h12.me/socks"
|
||||||
"log"
|
"log"
|
||||||
|
@ -9,10 +10,10 @@ import (
|
||||||
type SMTPProtocolScanner struct {
|
type SMTPProtocolScanner struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sps *SMTPProtocolScanner) ScanProtocol(hiddenService string, os *ProtocolConfig, report *report.OnionScanReport) {
|
func (sps *SMTPProtocolScanner) ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport) {
|
||||||
// SMTP
|
// SMTP
|
||||||
log.Printf("Checking %s SMTP(25)\n", hiddenService)
|
log.Printf("Checking %s SMTP(25)\n", hiddenService)
|
||||||
_, err := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":25")
|
_, err := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)("", hiddenService+":25")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to connect to service on port 25\n")
|
log.Printf("Failed to connect to service on port 25\n")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/s-rah/onionscan/config"
|
||||||
"github.com/s-rah/onionscan/report"
|
"github.com/s-rah/onionscan/report"
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
"h12.me/socks"
|
"h12.me/socks"
|
||||||
|
@ -14,10 +15,10 @@ import (
|
||||||
type SSHProtocolScanner struct {
|
type SSHProtocolScanner struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sps *SSHProtocolScanner) ScanProtocol(hiddenService string, os *ProtocolConfig, report *report.OnionScanReport) {
|
func (sps *SSHProtocolScanner) ScanProtocol(hiddenService string, onionscanConfig *config.OnionscanConfig, report *report.OnionScanReport) {
|
||||||
// SSH
|
// SSH
|
||||||
log.Printf("Checking %s ssh(22)\n", hiddenService)
|
log.Printf("Checking %s ssh(22)\n", hiddenService)
|
||||||
conn, err := socks.DialSocksProxy(socks.SOCKS5, os.TorProxyAddress)("", hiddenService+":22")
|
conn, err := socks.DialSocksProxy(socks.SOCKS5, onionscanConfig.TorProxyAddress)("", hiddenService+":22")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to connect to service on port 22\n")
|
log.Printf("Failed to connect to service on port 22\n")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue