theHarvester/discovery/pgpsearch.py

35 lines
1,001 B
Python
Raw Normal View History

2019-01-11 10:09:47 +08:00
from lib.core import *
from parsers import myparser
import requests
class SearchPgp:
def __init__(self, word):
self.word = word
self.results = ""
2019-01-14 07:58:38 +08:00
self.server = 'pgp.mit.edu'
self.hostname = 'pgp.mit.edu'
def process(self):
2019-01-14 07:58:38 +08:00
print('\tSearching results.')
try:
2019-01-14 07:58:38 +08:00
url = 'http://' + self.server + '/pks/lookup?search=' + self.word + '&op=index'
headers = {
'Host': self.hostname,
'User-agent': Core.get_user_agent()
}
h = requests.get(url=url, headers=headers)
self.results = h.text
self.results += self.results
except Exception as e:
2019-01-14 07:58:38 +08:00
print('Unable to connect to PGP server: ', str(e))
def get_emails(self):
rawres = myparser.Parser(self.results, self.word)
return rawres.emails()
def get_hostnames(self):
rawres = myparser.Parser(self.results, self.word)
return rawres.hostnames()