-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'laanwj-2016_10_web_hidden_service_key' into onionscan-0.2
- Loading branch information
Showing
12 changed files
with
188 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,8 @@ notifications: | |
email: | ||
recipients: | ||
- [email protected] | ||
|
||
script: | ||
- go test -v ./... | ||
- GOFMT=$(gofmt -d .) && echo "$GOFMT" | ||
- test -z "$GOFMT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package deanonymization | ||
|
||
import ( | ||
"crypto/rsa" | ||
"crypto/sha1" | ||
"crypto/x509" | ||
"encoding/asn1" | ||
"encoding/base32" | ||
"encoding/pem" | ||
"fmt" | ||
"github.com/s-rah/onionscan/config" | ||
"github.com/s-rah/onionscan/report" | ||
"net/url" | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
func PrivateKey(osreport *report.OnionScanReport, report *report.AnonymityReport, osc *config.OnionScanConfig) { | ||
for _, id := range osreport.Crawls { | ||
crawlRecord, _ := osc.Database.GetCrawlRecord(id) | ||
|
||
uri, _ := url.Parse(crawlRecord.URL) | ||
if crawlRecord.Page.Status == 200 && strings.HasSuffix(uri.Path, "/private_key") { | ||
privateKeyRegex := regexp.MustCompile("-----BEGIN RSA PRIVATE KEY-----((?s).*)-----END RSA PRIVATE KEY-----") | ||
foundPrivateKey := privateKeyRegex.FindAllString(crawlRecord.Page.Snapshot, -1) | ||
for _, keyString := range foundPrivateKey { | ||
osc.LogInfo(fmt.Sprintf("Found Potential Private Key")) | ||
block, _ := pem.Decode([]byte(keyString)) | ||
if block == nil || block.Type != "RSA PRIVATE KEY" { | ||
osc.LogInfo("Could not parse privacy key: no valid PEM data found") | ||
continue | ||
} | ||
|
||
privateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes) | ||
if err != nil { | ||
osc.LogInfo("Could not parse private key") | ||
continue | ||
} | ||
|
||
// DER Encode the Public Key | ||
publicKeyBytes, _ := asn1.Marshal(rsa.PublicKey{ | ||
N: privateKey.PublicKey.N, | ||
E: privateKey.PublicKey.E, | ||
}) | ||
|
||
h := sha1.New() | ||
h.Write(publicKeyBytes) | ||
sha1bytes := h.Sum(nil) | ||
|
||
data := base32.StdEncoding.EncodeToString(sha1bytes) | ||
hostname := strings.ToLower(data[0:16]) | ||
osc.LogInfo(fmt.Sprintf("Found Private Key for Host %s.onion", hostname)) | ||
report.PrivateKeyDetected = true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ type Page struct { | |
Links []Element | ||
Scripts []Element | ||
Snapshot string | ||
Raw []byte | ||
Hash string | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.