Skip to content

Commit 7b72b70

Browse files
Logging / PEP8
1 parent 0e32f56 commit 7b72b70

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

Modules/GoogleXLSXSearch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def search(self):
6767
time.sleep(1)
6868
if self.verbose:
6969
p = '[*] Google XLSX Search on page: ' + str(self.Counter)
70-
self.logger.error(
70+
self.logger.info(
7171
"Google XLSX Search on page: " + str(self.Counter))
7272
print helpers.color(p, firewall=True)
7373
try:

Modules/PasteBinSearch.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import configparser
99
import requests
1010
import time
11+
import logging
12+
from Helpers import Download
1113
from Helpers import helpers
1214
from Helpers import Parser
1315
from bs4 import BeautifulSoup
@@ -21,6 +23,7 @@ def __init__(self, Domain, verbose=False):
2123
self.description = "Uses pastebin to search for emails, parses them out of the"
2224
config = configparser.ConfigParser()
2325
try:
26+
self.logger = logging.getLogger("SimplyEmail.PasteBinSearch")
2427
config.read('Common/SimplyEmail.ini')
2528
self.Domain = Domain
2629
self.Quanity = int(config['GooglePasteBinSearch']['StartQuantity'])
@@ -31,20 +34,26 @@ def __init__(self, Domain, verbose=False):
3134
self.verbose = verbose
3235
self.urlList = []
3336
self.Text = ""
34-
except:
37+
except Exception as e:
38+
self.logger.critical(
39+
'PasteBinSearch module failed to __init__: ' + str(e))
3540
print helpers.color("[*] Major Settings for PasteBinSearch are missing, EXITING!\n", warning=True)
3641

3742
def execute(self):
43+
self.logger.debug("PasteBinSearch started")
3844
self.search()
3945
FinalOutput, HtmlResults = self.get_emails()
4046
return FinalOutput, HtmlResults
4147

4248
def search(self):
49+
dl = Download.Download(self.verbose)
4350
while self.Counter <= self.Limit and self.Counter <= 100:
4451
time.sleep(1)
4552
if self.verbose:
4653
p = '[*] Google Search for PasteBin on page: ' + \
4754
str(self.Counter)
55+
self.logger.info(
56+
"GooglePasteBinSearch on page: " + str(self.Counter))
4857
print helpers.color(p, firewall=True)
4958
try:
5059
url = "http://www.google.com/search?num=" + str(self.Quanity) + "&start=" + str(self.Counter) + \
@@ -53,23 +62,34 @@ def search(self):
5362
except Exception as e:
5463
error = "[!] Major issue with Google Search for PasteBin:" + \
5564
str(e)
65+
self.logger.error(
66+
"GooglePasteBinSearch could not create URL: " + str(e))
5667
print helpers.color(error, warning=True)
5768

5869
try:
5970
r = requests.get(url, headers=self.UserAgent)
6071
except Exception as e:
6172
error = "[!] Fail during Request to PasteBin (Check Connection):" + str(
6273
e)
74+
self.logger.error(
75+
"Fail during Request to PasteBin (Check Connection): " + str(e))
6376
print helpers.color(error, warning=True)
6477
try:
6578
RawHtml = r.content
79+
try:
80+
# check for captcha in the source
81+
dl.GoogleCaptchaDetection(RawHtml)
82+
except Exception as e:
83+
self.logger.error("Issue checking for captcha: " + str(e))
6684
soup = BeautifulSoup(RawHtml, "lxml")
6785
for a in soup.select('.r a'):
6886
# remove urls like pastebin.com/u/Anonymous
6987
if "/u/" not in str(a['href']):
7088
self.urlList.append(a['href'])
7189
except Exception as e:
7290
error = "[!] Fail during parsing result: " + str(e)
91+
self.logger.error(
92+
"PasteBinSearch Fail during parsing result: " + str(e))
7393
print helpers.color(error, warning=True)
7494
self.Counter += 100
7595
# Now take all gathered URL's and gather the Raw content needed
@@ -80,10 +100,13 @@ def search(self):
80100
self.Text += data.content
81101
except Exception as e:
82102
error = "[!] Connection Timed out on PasteBin Search:" + str(e)
103+
self.logger.error(
104+
"Connection Timed out on PasteBin raw download: " + str(e))
83105
print helpers.color(error, warning=True)
84106

85107
if self.verbose:
86108
p = '[*] Searching PasteBin Complete'
109+
self.logger.info("Searching PasteBin Complete")
87110
print helpers.color(p, firewall=True)
88111

89112
def get_emails(self):
@@ -92,4 +115,5 @@ def get_emails(self):
92115
Parse.urlClean()
93116
FinalOutput = Parse.GrepFindEmails()
94117
HtmlResults = Parse.BuildResults(FinalOutput, self.name)
118+
self.logger.debug("PasteBinSearch completed search")
95119
return FinalOutput, HtmlResults

Modules/RedditPostSearch.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import configparser
99
import requests
1010
import time
11+
import logging
1112
from Helpers import helpers
1213
from Helpers import Parser
1314

@@ -20,6 +21,7 @@ def __init__(self, Domain, verbose=False):
2021
self.description = "Uses RedditPosts to search for emails, and Parse the raw results ATM"
2122
config = configparser.ConfigParser()
2223
try:
24+
self.logger = logging.getLogger("SimplyEmail.RedditPostSearch")
2325
config.read('Common/SimplyEmail.ini')
2426
self.Domain = Domain
2527
self.UserAgent = {
@@ -28,10 +30,13 @@ def __init__(self, Domain, verbose=False):
2830
self.Counter = int(config['RedditPostSearch']['QueryStart'])
2931
self.verbose = verbose
3032
self.Html = ""
31-
except:
33+
except Exception as e:
34+
self.logger.critical(
35+
'RedditPostSearch module failed to load: ' + str(e))
3236
print helpers.color("[*] Major Settings for RedditPostSearch are missing, EXITING!\n", warning=True)
3337

3438
def execute(self):
39+
self.logger.debug("RedditPostSearch started")
3540
self.search()
3641
FinalOutput, HtmlResults = self.get_emails()
3742
return FinalOutput, HtmlResults
@@ -41,19 +46,25 @@ def search(self):
4146
time.sleep(1)
4247
if self.verbose:
4348
p = '[*] RedditPost Search on result: ' + str(self.Counter)
49+
self.logger.debug(
50+
"RedditPost Search on result: " + str(self.Counter))
4451
print helpers.color(p, firewall=True)
4552
try:
4653
url = "https://www.reddit.com/search?q=%40" + str(self.Domain) + \
4754
"&restrict_sr=&sort=relevance&t=all&count=" + str(self.Counter) + \
4855
'&after=t3_3mkrqg'
4956
except Exception as e:
5057
error = "[!] Major issue with RedditPost search:" + str(e)
58+
self.logger.error(
59+
"Major issue with RedditPostSearch: " + str(e))
5160
print helpers.color(error, warning=True)
5261
try:
5362
r = requests.get(url, headers=self.UserAgent)
5463
except Exception as e:
5564
error = "[!] Fail during Request to Reddit (Check Connection):" + \
5665
str(e)
66+
self.logger.error(
67+
"Fail during Request to Reddit (Check Connection): " + str(e))
5768
print helpers.color(error, warning=True)
5869
results = r.content
5970
self.Html += results
@@ -66,4 +77,5 @@ def get_emails(self):
6677
Parse.urlClean()
6778
FinalOutput = Parse.GrepFindEmails()
6879
HtmlResults = Parse.BuildResults(FinalOutput, self.name)
80+
self.logger.debug("RedditPostSearch completed search")
6981
return FinalOutput, HtmlResults

Modules/SearchPGP.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
import requests
33
import configparser
4+
import logging
45
from Helpers import Parser
56
from Helpers import helpers
67

@@ -21,15 +22,19 @@ def __init__(self, domain, verbose=False):
2122
config = configparser.ConfigParser()
2223
self.results = ""
2324
try:
25+
self.logger = logging.getLogger("SimplyEmail.SearchPGP")
2426
config.read('Common/SimplyEmail.ini')
2527
self.server = str(config['SearchPGP']['KeyServer'])
2628
self.hostname = str(config['SearchPGP']['Hostname'])
2729
self.UserAgent = str(config['GlobalSettings']['UserAgent'])
2830
self.verbose = verbose
29-
except:
31+
except Exception as e:
32+
self.logger.critical(
33+
'SearchPGP module failed to __init__: ' + str(e))
3034
print helpers.color("[*] Major Settings for SearchPGP are missing, EXITING!\n", warning=True)
3135

3236
def execute(self):
37+
self.logger.debug("SearchPGP started")
3338
self.process()
3439
FinalOutput, HtmlResults = self.get_emails()
3540
return FinalOutput, HtmlResults
@@ -38,17 +43,21 @@ def process(self):
3843
try:
3944
url = "http://pgp.rediris.es:11371/pks/lookup?search=" + \
4045
self.domain + "&op=index"
46+
self.logger.info("Requesting PGP keys")
4147
r = requests.get(url)
4248
except Exception as e:
4349
error = "[!] Major issue with PGP Search:" + str(e)
50+
self.logger.error("Major issue with PGP search: " + str(e))
4451
print helpers.color(error, warning=True)
4552
if self.verbose:
4653
p = '[*] Searching PGP Complete'
54+
self.logger.info("SearchPGP Completed search")
4755
print helpers.color(p, firewall=True)
4856
self.results = r.content
4957

5058
def get_emails(self):
5159
Parse = Parser.Parser(self.results)
5260
FinalOutput = Parse.GrepFindEmails()
5361
HtmlResults = Parse.BuildResults(FinalOutput, self.name)
62+
self.logger.debug("SearchPGP completed search")
5463
return FinalOutput, HtmlResults

Modules/WhoisAPISearch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, domain, verbose=False):
2929
self.UserAgent = str(config['GlobalSettings']['UserAgent'])
3030
except Exception as e:
3131
self.logger.critical(
32-
'WhoisAPISearch module failed to load: ' + str(e))
32+
'WhoisAPISearch module failed to __init__: ' + str(e))
3333
print helpers.color("[*] Major Settings for Search Whois are missing, EXITING!\n", warning=True)
3434

3535
def execute(self):

Modules/Whoisolgy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, domain, verbose=False):
3030
self.verbose = verbose
3131
except Exception as e:
3232
self.logger.critical(
33-
'Whoisology module failed to load: ' + str(e))
33+
'Whoisology module failed to __init__: ' + str(e))
3434
print helpers.color("[*] Major Settings for Search Whoisology are missing, EXITING!\n", warning=True)
3535

3636
def execute(self):

0 commit comments

Comments
 (0)