88import configparser
99import requests
1010import time
11+ import logging
12+ from Helpers import Download
1113from Helpers import helpers
1214from Helpers import Parser
1315from 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
0 commit comments