attempts to get v3 fingerprint

This commit is contained in:
Dan Ballard 2016-05-29 20:55:09 -07:00
parent aa8f8aff57
commit e1760189a0
1 changed files with 25 additions and 0 deletions

View File

@ -3,9 +3,12 @@ package scans
import ( import (
"github.com/s-rah/onionscan/report" "github.com/s-rah/onionscan/report"
"golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp"
"golang.org/x/crypto/openpgp/armor"
//pgpPacket "golang.org/x/crypto/openpgp/packet"
"log" "log"
"regexp" "regexp"
"strings" "strings"
"bytes"
) )
type PGPContentScan struct { type PGPContentScan struct {
@ -17,6 +20,27 @@ func (cs *PGPContentScan) ScanContent(content string, report *report.OnionScanRe
foundPGP := pgpRegexp.FindAllString(content, -1) foundPGP := pgpRegexp.FindAllString(content, -1)
for _, keyString := range foundPGP { for _, keyString := range foundPGP {
log.Printf("\tFound key: %s\n", keyString) log.Printf("\tFound key: %s\n", keyString)
buf := bytes.NewBuffer([]byte(keyString))
block, err := armor.Decode(buf)
if err != nil {
log.Printf("error decoding: %s\n", err)
} else {
log.Printf("Block: %s\n", block)
log.Printf("body: %s\n", block.Body)
//packet, err := pgpPacket.Read(block.Body)
/*if err != nil {
log.Printf("Read error: %s", err)
}*/
/*pk, ok := packet.(*pgpPacket.PublicKeyV3)
if !ok {
log.Printf("failed to parse, got: %s", packet)
}*/
//log.Printf("fingerprint: %s\n", pk.Fingerprint)
}
keys, err := openpgp.ReadArmoredKeyRing(strings.NewReader(keyString)); keys, err := openpgp.ReadArmoredKeyRing(strings.NewReader(keyString));
if err != nil { if err != nil {
log.Printf("ERROR: %s\n", err) log.Printf("ERROR: %s\n", err)
@ -33,6 +57,7 @@ func (cs *PGPContentScan) ScanContent(content string, report *report.OnionScanRe
pubkey := keys[0].Subkeys[0].PublicKey pubkey := keys[0].Subkeys[0].PublicKey
log.Printf("pubkey: %X", pubkey.Fingerprint) log.Printf("pubkey: %X", pubkey.Fingerprint)
//pk3 := pubkey.(*pgpPacket.PublicKeyV3)
report.AddPGPKey(keyString) report.AddPGPKey(keyString)
} }