forked from s-rah/onionscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onionscanreport.go
119 lines (100 loc) · 3.37 KB
/
onionscanreport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package report
import (
"crypto/x509"
"encoding/json"
"io/ioutil"
"time"
)
type PGPKey struct {
ArmoredKey string `json:"armoredKey"`
Identity string `json:"identity"`
FingerPrint string `json:"fingerprint"`
}
type BitcoinService struct {
Detected bool `json:"detected"`
UserAgent string `json:"userAgent"`
ProtocolVersion int `json:"prototocolVersion"`
OnionPeers []string `json:"onionPeers"`
}
type OnionScanReport struct {
HiddenService string `json:"hiddenService"`
DateScanned time.Time `json:"dateScanned"`
Online bool `json:"online"`
PerformedScans []string `json:"performedScans"`
// Summary
WebDetected bool `json:"webDetected"`
TLSDetected bool `json:"tlsDetected"`
SSHDetected bool `json:"sshDetected"`
RicochetDetected bool `json:"ricochetDetected"`
IRCDetected bool `json:"ircDetected"`
FTPDetected bool `json:"ftpDetected"`
SMTPDetected bool `json:"smtpDetected"`
BitcoinDetected bool `json:"bitcoinDetected"`
MongoDBDetected bool `json:"mongodbDetected"`
VNCDetected bool `json:"vncDetected"`
XMPPDetected bool `json:"xmppDetected"`
SkynetDetected bool `json:"skynetDetected"`
// Site Specific
Crawls map[string]int `json:"crawls"`
// Page Content
PGPKeys []PGPKey `json:"pgpKeys"`
// TLS
Certificates []x509.Certificate `json:"certificates"`
// Bitcoin
BitcoinServices map[string]*BitcoinService `json:"bitcoinServices"`
// SSH
SSHKey string `json:"sshKey"`
SSHBanner string `json:"sshBanner"`
// FTP
FTPFingerprint string `json:"ftpFingerprint"`
FTPBanner string `json:"ftpBanner"`
// SMTP
SMTPFingerprint string `json:"smtpFingerprint"`
SMTPBanner string `json:"smtpBanner"`
// Meta Info
NextAction string `json:"lastAction"`
TimedOut bool `json:"timedOut"`
Error error `json:"error"`
// Sub Reports
AnonymityReport *AnonymityReport `json:"identifierReport"`
SimpleReport *SimpleReport `json:"simpleReport"`
}
// LoadReportFromFile creates an OnionScan report from a json encoded file.
func LoadReportFromFile(filename string) (OnionScanReport, error) {
dat, err := ioutil.ReadFile(filename)
if err != nil {
return OnionScanReport{}, err
}
res := OnionScanReport{}
err = json.Unmarshal(dat, &res)
return res, err
}
// NewOnionScanReport creates a new OnionScan report for the given hidden service.
func NewOnionScanReport(hiddenService string) *OnionScanReport {
report := new(OnionScanReport)
report.HiddenService = hiddenService
report.DateScanned = time.Now()
report.Crawls = make(map[string]int)
report.PerformedScans = []string{}
report.BitcoinServices = make(map[string]*BitcoinService)
return report
}
// AddPGPKey adds a new PGP Key to the Report
func (osr *OnionScanReport) AddPGPKey(armoredKey, identity, fingerprint string) {
osr.PGPKeys = append(osr.PGPKeys, PGPKey{armoredKey, identity, fingerprint})
//TODO map of fingerprint:PGPKeys? and utils.RemoveDuplicates(&osr.PGPKeys)
}
// AddBitcoinService adds a new Bitcoin Service to the Report
func (osr *OnionScanReport) AddBitcoinService(name string) *BitcoinService {
var s = new(BitcoinService)
osr.BitcoinServices[name] = s
return s
}
// Serialize converts the report to a JSON representation
func (osr *OnionScanReport) Serialize() (string, error) {
report, err := json.Marshal(osr)
if err != nil {
return "", err
}
return string(report), nil
}