2019-01-11 10:09:47 +08:00
|
|
|
from lib.core import *
|
2018-12-28 08:49:56 +08:00
|
|
|
from parsers import myparser
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
2019-01-06 17:50:07 +08:00
|
|
|
class SearchPgp:
|
2018-12-28 08:49:56 +08:00
|
|
|
|
|
|
|
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'
|
2018-12-28 08:49:56 +08:00
|
|
|
|
|
|
|
def process(self):
|
2019-01-14 07:58:38 +08:00
|
|
|
print('\tSearching results.')
|
2018-12-28 08:49:56 +08:00
|
|
|
try:
|
2019-01-14 07:58:38 +08:00
|
|
|
url = 'http://' + self.server + '/pks/lookup?search=' + self.word + '&op=index'
|
2018-12-28 08:49:56 +08:00
|
|
|
headers = {
|
|
|
|
'Host': self.hostname,
|
2019-01-06 17:50:07 +08:00
|
|
|
'User-agent': Core.get_user_agent()
|
2018-12-28 08:49:56 +08:00
|
|
|
}
|
|
|
|
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))
|
2018-12-28 08:49:56 +08:00
|
|
|
|
|
|
|
def get_emails(self):
|
2019-01-06 17:50:07 +08:00
|
|
|
rawres = myparser.Parser(self.results, self.word)
|
2018-12-28 08:49:56 +08:00
|
|
|
return rawres.emails()
|
|
|
|
|
|
|
|
def get_hostnames(self):
|
2019-01-06 17:50:07 +08:00
|
|
|
rawres = myparser.Parser(self.results, self.word)
|
2018-12-28 08:49:56 +08:00
|
|
|
return rawres.hostnames()
|