onionscan/report/onionscanreport.go

142 lines
4.6 KiB
Go
Raw Permalink Normal View History

2016-04-10 00:04:22 +00:00
package report
import (
"encoding/json"
"github.com/s-rah/onionscan/utils"
"io/ioutil"
2016-04-10 00:04:22 +00:00
)
type ExifTag struct {
Name string `json:"name"`
Value string `json:"value"`
2016-04-10 00:04:22 +00:00
}
type ExifImage struct {
Location string `json:"location"`
ExifTags []ExifTag `json:"exifTags"`
2016-04-10 00:04:22 +00:00
}
type PGPKey struct {
ArmoredKey string `json:"armoredKey"`
Identity string `json:"identity"`
FingerPrint string `json:"fingerprint"`
}
2016-04-10 00:04:22 +00:00
type OnionScanReport struct {
2016-06-05 18:54:01 +00:00
HiddenService string `json:"hiddenService"`
// Summary
WebDetected bool `json:"webDetected"`
SSHDetected bool `json:"sshDetected"`
RicochetDetected bool `json:"ricochetDetected"`
IRCDetected bool `json:"ircDetected"`
FTPDetected bool `json:"ftpDetected"`
SMTPDetected bool `json:"smtpDetected"`
2016-06-05 18:54:01 +00:00
BitcoinDetected bool `json:"bitcoinDetected"`
MongoDBDetected bool `json:"mongodbDetected"`
VNCDetected bool `json:"vncDetected"`
// Web Specific
ServerPoweredBy string `json:"serverPoweredBy"`
ServerVersion string `json:"serverVersion"`
FoundApacheModStatus bool `json:"foundApacheModStatus"`
RelatedOnionServices []string `json:"relatedOnionServices"`
RelatedClearnetDomains []string `json:"relatedOnionDomains"`
LinkedSites []string `json:"linkedSites"`
InternalPages []string `json:"internalPages"`
IP []string `json:"ipAddresses"`
OpenDirectories []string `json:"openDirectories"`
ExifImages []ExifImage `json:"exifImages"`
InterestingFiles []string `json:"interestingFiles"`
PageReferencedDirectories []string `json:"pageReferencedDirectories"`
PGPKeys []PGPKey `json:"pgpKeys"`
2016-06-05 18:54:01 +00:00
Hashes []string `json:"hashes"`
Snapshot string `json:"snapshot"`
PageTitle string `json:"pageTitle"`
ResponseHeaders map[string]string `json:"responseHeaders"`
// SSH
SSHKey string `json:"sshKey"`
// FTP
FTPFingerprint string `json:"ftpFingerprint"`
FTPBanner string `json:"ftpBanner"`
2016-06-05 18:54:01 +00:00
// SMTP
SMTPFingerprint string `json:"smtpFingerprint"`
SMTPBanner string `json:"smtpBanner"`
}
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
2016-04-10 00:04:22 +00:00
}
func NewOnionScanReport(hiddenService string) *OnionScanReport {
return &OnionScanReport{HiddenService: hiddenService, ResponseHeaders: make(map[string]string)}
2016-04-10 00:04:22 +00:00
}
func (osr *OnionScanReport) AddOpenDirectory(dir string) {
osr.OpenDirectories = append(osr.OpenDirectories, dir)
}
func (osr *OnionScanReport) AddRelatedOnionService(service string) {
osr.RelatedOnionServices = append(osr.RelatedOnionServices, service)
2016-04-10 00:04:22 +00:00
}
func (osr *OnionScanReport) AddRelatedClearnetDomain(domain string) {
osr.RelatedClearnetDomains = append(osr.RelatedClearnetDomains, domain)
2016-04-10 00:04:22 +00:00
}
func (osr *OnionScanReport) AddInterestingFile(file string) {
osr.InterestingFiles = append(osr.InterestingFiles, file)
2016-04-10 00:04:22 +00:00
}
func (osr *OnionScanReport) AddIPAddress(ip string) {
osr.IP = append(osr.IP, ip)
}
func (osr *OnionScanReport) AddLinkedSite(site string) {
osr.LinkedSites = append(osr.LinkedSites, site)
utils.RemoveDuplicates(&osr.LinkedSites)
}
func (osr *OnionScanReport) AddInternalPage(site string) {
osr.InternalPages = append(osr.InternalPages, site)
utils.RemoveDuplicates(&osr.InternalPages)
}
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)
}
2016-04-25 09:29:27 +00:00
func (osr *OnionScanReport) AddResponseHeader(name string, value string) {
osr.ResponseHeaders[name] = value
2016-04-25 09:29:27 +00:00
}
2016-04-10 00:04:22 +00:00
func (osr *OnionScanReport) Serialize() (string, error) {
report, err := json.Marshal(osr)
2016-04-10 00:04:22 +00:00
if err != nil {
return "", err
}
2016-04-10 00:04:22 +00:00
return string(report), nil
}
func (osr *OnionScanReport) AddExifImage(location string) {
osr.ExifImages = append(osr.ExifImages, ExifImage{location, []ExifTag{}})
2016-04-10 00:04:22 +00:00
}
func (osr *OnionScanReport) AddExifTag(name string, value string) {
osr.ExifImages[len(osr.ExifImages)-1].ExifTags = append(osr.ExifImages[len(osr.ExifImages)-1].ExifTags, ExifTag{name, value})
}
func (osr *OnionScanReport) AddPageReferencedDirectory(directory string) {
osr.PageReferencedDirectories = append(osr.PageReferencedDirectories, directory)
2016-04-10 00:04:22 +00:00
}