2016-04-10 00:04:22 +00:00
|
|
|
package report
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2016-04-25 02:46:28 +00:00
|
|
|
"github.com/s-rah/onionscan/utils"
|
2016-04-24 17:28:59 +00:00
|
|
|
"io/ioutil"
|
2016-04-10 00:04:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ExifTag struct {
|
2016-04-24 17:28:59 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
Value string `json:"value"`
|
2016-04-10 00:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ExifImage struct {
|
2016-04-24 17:28:59 +00:00
|
|
|
Location string `json:"location"`
|
|
|
|
ExifTags []ExifTag `json:"exifTags"`
|
2016-04-10 00:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type OnionScanReport struct {
|
2016-04-24 17:28:59 +00:00
|
|
|
WebDetected bool `json:"webDetected"`
|
|
|
|
SSHDetected bool `json:"sshDetected"`
|
|
|
|
RicochetDetected bool `json:"ricochetDetected"`
|
|
|
|
IRCDetected bool `json:"ircDetected"`
|
|
|
|
FTPDetected bool `json:"ftpDetected"`
|
|
|
|
SMTPDetected bool `json:"smtpDetected"`
|
|
|
|
|
|
|
|
BitcoinDetected bool `json:"bitcoinDetected"`
|
|
|
|
|
|
|
|
HiddenService string `json:"hiddenService"`
|
|
|
|
ServerPoweredBy string `json:"serverPoweredBy"`
|
|
|
|
ServerVersion string `json:"serverVersion"`
|
|
|
|
FoundApacheModStatus bool `json:"foundApacheModStatus"`
|
|
|
|
RelatedOnionServices []string `json:"relatedOnionServices"`
|
|
|
|
RelatedClearnetDomains []string `json:"relatedOnionDomains"`
|
|
|
|
LinkedSites []string `json:"linkedSites"`
|
2016-05-24 10:13:00 +00:00
|
|
|
InternalPages []string `json:"InternalPages"`
|
2016-04-24 17:28:59 +00:00
|
|
|
IP []string `json:"ipAddresses"`
|
|
|
|
OpenDirectories []string `json:"openDirectories"`
|
|
|
|
ExifImages []ExifImage `json:"exifImages"`
|
|
|
|
InterestingFiles []string `json:"interestingFiles"`
|
|
|
|
PageReferencedDirectories []string `json:"pageReferencedDirectories"`
|
2016-05-10 01:42:19 +00:00
|
|
|
PGPKeys []string `json:"pgpKeys"`
|
2016-04-24 17:28:59 +00:00
|
|
|
|
2016-04-25 09:29:27 +00:00
|
|
|
Hashes []string `json:"hashes"`
|
|
|
|
SSHKey string `json:"sshKey"`
|
|
|
|
Snapshot string `json:"snapshot"`
|
|
|
|
PageTitle string `json:"pageTitle"`
|
|
|
|
ResponseHeaders map[string]string `json:"responseHeaders"`
|
2016-04-25 02:46:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func LoadReportFromFile(filename string) (OnionScanReport, error) {
|
2016-04-24 17:28:59 +00:00
|
|
|
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 {
|
2016-04-25 09:29:27 +00:00
|
|
|
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) {
|
2016-04-24 17:28:59 +00:00
|
|
|
osr.RelatedOnionServices = append(osr.RelatedOnionServices, service)
|
2016-04-10 00:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (osr *OnionScanReport) AddRelatedClearnetDomain(domain string) {
|
2016-04-24 17:28:59 +00:00
|
|
|
osr.RelatedClearnetDomains = append(osr.RelatedClearnetDomains, domain)
|
2016-04-10 00:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (osr *OnionScanReport) AddInterestingFile(file string) {
|
2016-04-24 17:28:59 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2016-04-25 02:46:28 +00:00
|
|
|
func (osr *OnionScanReport) AddLinkedSite(site string) {
|
|
|
|
osr.LinkedSites = append(osr.LinkedSites, site)
|
|
|
|
utils.RemoveDuplicates(&osr.LinkedSites)
|
|
|
|
}
|
|
|
|
|
2016-05-24 10:13:00 +00:00
|
|
|
func (osr *OnionScanReport) AddInternalPage(site string) {
|
|
|
|
osr.InternalPages = append(osr.InternalPages, site)
|
|
|
|
utils.RemoveDuplicates(&osr.InternalPages)
|
|
|
|
}
|
|
|
|
|
2016-05-10 01:42:19 +00:00
|
|
|
func (osr *OnionScanReport) AddPGPKey(key string) {
|
|
|
|
osr.PGPKeys = append(osr.PGPKeys, key)
|
|
|
|
utils.RemoveDuplicates(&osr.PGPKeys)
|
|
|
|
}
|
|
|
|
|
2016-04-25 09:29:27 +00:00
|
|
|
func (osr *OnionScanReport) AddResponseHeader(name string, value string) {
|
2016-04-25 09:29:27 +00:00
|
|
|
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) {
|
2016-04-24 17:28:59 +00:00
|
|
|
report, err := json.Marshal(osr)
|
2016-04-10 00:04:22 +00:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
2016-04-24 17:28:59 +00:00
|
|
|
}
|
2016-04-10 00:04:22 +00:00
|
|
|
return string(report), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (osr *OnionScanReport) AddExifImage(location string) {
|
2016-04-24 17:28:59 +00:00
|
|
|
osr.ExifImages = append(osr.ExifImages, ExifImage{location, []ExifTag{}})
|
2016-04-10 00:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (osr *OnionScanReport) AddExifTag(name string, value string) {
|
2016-04-24 17:28:59 +00:00
|
|
|
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
|
|
|
}
|