You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.5 KiB

  1. package main
  2. import (
  3. "github.com/s-rah/onionscan/config"
  4. "github.com/s-rah/onionscan/protocol"
  5. "github.com/s-rah/onionscan/report"
  6. "github.com/s-rah/onionscan/utils"
  7. "strings"
  8. "time"
  9. )
  10. type OnionScan struct {
  11. Config *config.OnionscanConfig
  12. }
  13. func (os *OnionScan) PerformNextAction(report *report.OnionScanReport) {
  14. switch report.NextAction {
  15. case "web":
  16. wps := new(protocol.HTTPProtocolScanner)
  17. wps.ScanProtocol(report.HiddenService, os.Config, report)
  18. report.NextAction = "tls"
  19. case "tls":
  20. tps := new(protocol.TLSProtocolScanner)
  21. tps.ScanProtocol(report.HiddenService, os.Config, report)
  22. report.NextAction = "ssh"
  23. case "ssh":
  24. sps := new(protocol.SSHProtocolScanner)
  25. sps.ScanProtocol(report.HiddenService, os.Config, report)
  26. report.NextAction = "irc"
  27. case "irc":
  28. ips := new(protocol.IRCProtocolScanner)
  29. ips.ScanProtocol(report.HiddenService, os.Config, report)
  30. report.NextAction = "ricochet"
  31. case "ricochet":
  32. rps := new(protocol.RicochetProtocolScanner)
  33. rps.ScanProtocol(report.HiddenService, os.Config, report)
  34. report.NextAction = "ftp"
  35. case "ftp":
  36. fps := new(protocol.FTPProtocolScanner)
  37. fps.ScanProtocol(report.HiddenService, os.Config, report)
  38. report.NextAction = "smtp"
  39. case "smtp":
  40. smps := new(protocol.SMTPProtocolScanner)
  41. smps.ScanProtocol(report.HiddenService, os.Config, report)
  42. report.NextAction = "mongodb"
  43. case "mongodb":
  44. mdbps := new(protocol.MongoDBProtocolScanner)
  45. mdbps.ScanProtocol(report.HiddenService, os.Config, report)
  46. report.NextAction = "vnc"
  47. case "vnc":
  48. vncps := new(protocol.VNCProtocolScanner)
  49. vncps.ScanProtocol(report.HiddenService, os.Config, report)
  50. report.NextAction = "xmpp"
  51. case "xmpp":
  52. xmppps := new(protocol.XMPPProtocolScanner)
  53. xmppps.ScanProtocol(report.HiddenService, os.Config, report)
  54. report.NextAction = "bitcoin"
  55. case "bitcoin":
  56. bps := new(protocol.BitcoinProtocolScanner)
  57. bps.ScanProtocol(report.HiddenService, os.Config, report)
  58. report.NextAction = "none"
  59. case "none":
  60. return
  61. default:
  62. report.NextAction = "web"
  63. }
  64. }
  65. func (os *OnionScan) Scan(hiddenService string, out chan *report.OnionScanReport) {
  66. // Remove Extra Prefix
  67. hiddenService = utils.WithoutProtocol(hiddenService)
  68. if strings.HasSuffix(hiddenService, "/") {
  69. hiddenService = hiddenService[0 : len(hiddenService)-1]
  70. }
  71. report := report.NewOnionScanReport(hiddenService)
  72. for report.NextAction != "none" {
  73. os.PerformNextAction(report)
  74. if time.Now().Sub(report.DateScanned).Seconds() > os.Config.Timeout.Seconds() {
  75. report.TimedOut = true
  76. report.NextAction = "none"
  77. }
  78. }
  79. out <- report
  80. }