Skip to content

Commit

Permalink
fix pyfoca output that contains ascii control chars also fix reportge…
Browse files Browse the repository at this point in the history
…n scrape output formatting
  • Loading branch information
bharshbarger committed Sep 20, 2017
1 parent b5a4007 commit 83b0745
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 188 deletions.
18 changes: 9 additions & 9 deletions AutOSINT.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,30 @@ def run_queries(self):
"""invoke all the queries. assumption is that every run will want all data"""

#verified
self.whois_result = self.whois_query_module.run(self.args, self.lookup_list, self.report_directory)
#self.whois_result = self.whois_query_module.run(self.args, self.lookup_list, self.report_directory)

#verified
self.dns_result = self.dns_query_module.run(self.args, self.lookup_list, self.report_directory)
#self.dns_result = self.dns_query_module.run(self.args, self.lookup_list, self.report_directory)

#needs work
self.haveibeenpwned_result = self.haveibeenpwned_api_module.run(self.args, self.lookup_list, self.report_directory)
#self.haveibeenpwned_result = self.haveibeenpwned_api_module.run(self.args, self.lookup_list, self.report_directory)

#verified
self.google_dork_result = self.google_dork_module.run(self.args, self.lookup_list, self.report_directory)
#self.google_dork_result = self.google_dork_module.run(self.args, self.lookup_list, self.report_directory)

#verified
self.shodan_query_result = self.shodan_search_module.run(self.args, self.lookup_list, self.report_directory, self.api_key_directory)
#self.shodan_query_result = self.shodan_search_module.run(self.args, self.lookup_list, self.report_directory, self.api_key_directory)

#verified
self.pastebin_scrape_urls_result = self.pastebin_scrape_module.run(self.args, self.lookup_list, self.report_directory, self.api_key_directory)
#self.pastebin_scrape_urls_result = self.pastebin_scrape_module.run(self.args, self.lookup_list, self.report_directory, self.api_key_directory)

#verified
self.theharvester_module_result = self.theharvester_module.run(self.args, self.lookup_list, self.report_directory)
#self.theharvester_module_result = self.theharvester_module.run(self.args, self.lookup_list, self.report_directory)

self.cred_leak_search_result = self.cred_leaks_module.run(self.args, self.lookup_list, self.start_time, self.report_directory)
#self.cred_leak_search_result = self.cred_leaks_module.run(self.args, self.lookup_list, self.start_time, self.report_directory)

#needs work
self.scrape_result = self.web_scraper_module.run(self.args, self.lookup_list, self.report_directory, self.api_key_directory)
#self.scrape_result = self.web_scraper_module.run(self.args, self.lookup_list, self.report_directory, self.api_key_directory)

#pyfoca has to be present
self.pyfoca_module_result = self.pyfoca_module.run(self.args, self.lookup_list, self.report_directory)
Expand Down
39 changes: 18 additions & 21 deletions modules/pyfoca.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,37 @@
import subprocess

class Pyfoca():
"""class to run pyfoca on supplied domain"""
def __init__(self):
#init lists
self.pyfoca_result = []
self.ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')

def run(self, args, lookup, reportDir):



#init lists
pyfocaResult=[]
ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')

#based on domain or ip, enumerate with index and value
for i, l in enumerate(lookup):

#open file to write to
pyfocaFile=open(reportDir+l+'/'+l+'_pyfoca.txt','w')
pyfocaFile = open(reportDir + l + '/' + l + '_pyfoca.txt','w')

#run pyfoca with -d domain. should automagically do metadata
try:
print ('[+] Running pyfoca -d %s' % l)
pyfocaCmd = subprocess.Popen(['pyfoca', '-d', str(l)], stdout = subprocess.PIPE).communicate()[0].split('\r\n')
print('[+] Running pyfoca -d {}'.format(l))
pyfocaCmd = subprocess.Popen(['pyfoca', '-p 5','-d ', str(l)], stdout = subprocess.PIPE).communicate()[0].split('\r\n')
except:
print ('[-] Error running pyfoca. Make sure it is in your PATH and you are connected to the Internet')
pyfocaResult.append('Error running pyfoca')
print('[-] Error running pyfoca. Make sure it is in your PATH and you are connected to the Internet')
self.pyfoca_result.append('Error running pyfoca')
pyfocaFile.writelines('Error running pyfoca')
continue


#pyfocaCmd = ansi_escape.sub('', pyfocaCmd, re.S)

#append output
pyfocaFile.writelines(str(pyfocaCmd))
pyfocaResult.append(str(pyfocaCmd))
for a in pyfocaCmd:
fixed_output = self.ansi_escape.sub('', str(a).strip())
if args.verbose is True:
print(fixed_output)

#spew if verbose
if args.verbose is True:
for p in pyfocaResult:print ''.join(p)
#append output
pyfocaFile.writelines(fixed_output)
self.pyfoca_result.append(fixed_output)

return pyfocaResult
return self.pyfoca_result
Loading

0 comments on commit 83b0745

Please sign in to comment.