Skip to content

Commit

Permalink
Merge pull request #5 from killswitch-GUI/dev
Browse files Browse the repository at this point in the history
Merge v0.4
  • Loading branch information
killswitch-GUI committed Nov 11, 2015
2 parents 8c9148a + afb67ff commit 009a874
Show file tree
Hide file tree
Showing 19 changed files with 301 additions and 92 deletions.
75 changes: 58 additions & 17 deletions Common/TaskController.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ def __init__(self):
# create required array
self.Emails = []
self.ConsumerList = []
self.HtmlList = []
self.Tasks = []
self.version = "0.3"
self.version = "0.4"
self.ResultsList = []

def ConfigSectionMap(section):
Expand All @@ -60,7 +61,7 @@ def TestModule(self, module, domain):
module.execute()

# Handler for each Process that will call all the modules in the Queue
def ExecuteModule(self, Task_queue, Results_queue, domain):
def ExecuteModule(self, Task_queue, Results_queue, Html_queue, domain):
while True:
Task = Task_queue.get()
# If the queue is emepty exit this proc
Expand All @@ -76,15 +77,17 @@ def ExecuteModule(self, Task_queue, Results_queue, domain):
# Try to start the module
try:
# Emails will be returned as a list
Emails = Module.execute()
Emails, HtmlResults = Module.execute()
if Emails:
count = len(Emails)
Length = "[*] " + Module.name + \
": Gathered " + str(count) + " Email(s)!"
print helpers.color(Length, status=True)
for Email in Emails:
Results_queue.put(Email)
#Task_queue.task_done()
for Email in HtmlResults:
Html_queue.put(Email)
# Task_queue.task_done()
else:
Message = "[*] " + Module.name + \
" has completed with no Email(s)"
Expand All @@ -101,7 +104,7 @@ def printer(self, FinalEmailList):
# Building out the Text file that will be outputted
Date = time.strftime("%d/%m/%Y")
Time = time.strftime("%I:%M:%S")
PrintTitle = "\t----------------------------------\n"
PrintTitle = "\t----------------------------------\n"
PrintTitle += "\tEmail Recon: " + Date + " " + Time + "\n"
PrintTitle += "\t----------------------------------\n"
x = 0
Expand All @@ -122,10 +125,10 @@ def printer(self, FinalEmailList):
print helpers.color("[*] Completed output!", status=True)
return x

def HtmlPrinter(self, FinalEmailList, Domain):
def HtmlPrinter(self, HtmlFinalEmailList, Domain):
# Builds the HTML file
# try:
Html = HtmlBootStrapTheme.HtmlBuilder(FinalEmailList, Domain)
Html = HtmlBootStrapTheme.HtmlBuilder(HtmlFinalEmailList, Domain)
Html.BuildHtml()
Html.OutPutHTML()
# except Exception as e:
Expand All @@ -136,21 +139,32 @@ def CleanResults(self, domain):
# Clean Up results, remove dupplicates and enforce strict Domain reuslts (future)
# Set Timeout or you wont leave the While loop
SecondList = []
HtmlSecondList = []
# Validate the domain.. this can mess up but i dont want to miss
# anything
for item in self.ConsumerList:
if domain in item:
SecondList.append(item)
FinalList = []
HtmlFinalList = []
# now the same for Html Results with magic
for item in self.HtmlList:
if domain in item:
HtmlSecondList.append(item)
# Itt over all items in the list
for item in SecondList:
# Check if the value is in the new list
if item not in FinalList:
# Add item to list and put back in the Queue
FinalList.append(item)
# results_queue.put(item)
# Check to see we have dups (we will have dup emails)
# But no Dup Sources (which we want)
for item in HtmlSecondList:
if item not in HtmlFinalList:
HtmlFinalList.append(item)
print helpers.color("[*] Completed Cleaning Results", status=True)
return FinalList
return FinalList, HtmlFinalList

def Consumer(self, Results_queue):
while True:
Expand All @@ -162,6 +176,16 @@ def Consumer(self, Results_queue):
except:
pass

def HtmlConsumer(self, Html_queue):
while True:
try:
item = Html_queue.get()
if item is None:
break
self.HtmlList.append(item)
except:
pass

def TaskSelector(self, domain):
# Here it will check the Que for the next task to be completed
# Using the Dynamic loaded modules we can easly select which module is up
Expand All @@ -170,6 +194,7 @@ def TaskSelector(self, domain):
# Build our Queue of work for emails that we will gather
Task_queue = multiprocessing.Queue()
Results_queue = multiprocessing.Queue()
Html_queue = multiprocessing.Queue()

# How many proc will we have, pull from config file, setting up the
# config file handler
Expand All @@ -187,7 +212,7 @@ def TaskSelector(self, domain):
procs = []
for thread in range(total_proc):
procs.append(multiprocessing.Process(
target=self.ExecuteModule, args=(Task_queue, Results_queue, domain)))
target=self.ExecuteModule, args=(Task_queue, Results_queue, Html_queue, domain)))
for p in procs:
p.daemon = True
p.start()
Expand All @@ -204,6 +229,10 @@ def TaskSelector(self, domain):
t = threading.Thread(target=self.Consumer, args=(Results_queue,))
t.daemon = True
t.start()
# Start Html Consumer / Trying to keep these seprate
t2 = threading.Thread(target=self.HtmlConsumer, args=(Html_queue,))
t2.daemon = True
t2.start()
# Enter this loop so we know when to terminate the Consumer thread
# This multiprocessing.active_children() is also Joining!
while True:
Expand All @@ -212,11 +241,13 @@ def TaskSelector(self, domain):
# We want to wait till we have no procs left, before we join
if len(LeftOver) == 0:
# Block untill all results are consumed
time.sleep(2)
time.sleep(1)
Results_queue.put(None)
Html_queue.put(None)
# t.join()
try:
FinalEmailList = self.CleanResults(domain)
FinalEmailList, HtmlFinalEmailList = self.CleanResults(
domain)
except Exception as e:
error = "[!] Something went wrong with parsing results:" + \
str(e)
Expand All @@ -229,7 +260,7 @@ def TaskSelector(self, domain):
print helpers.color(error, warning=True)
Results_queue.close()
try:
self.HtmlPrinter(FinalEmailList, domain)
self.HtmlPrinter(HtmlFinalEmailList, domain)
except Exception as e:
error = "[!] Something went wrong with HTML results:" + \
str(e)
Expand All @@ -241,6 +272,7 @@ def TaskSelector(self, domain):
# Launches a single thread to output results
self.CompletedScreen(FinalCount, domain)


# This is the Test version of the multi proc above, this function
# Helps with testing only one module at a time. Helping with proper
# Module Dev and testing before intergration
Expand All @@ -250,6 +282,8 @@ def TestModule(self, domain, module):
total_proc = int(1)
Task_queue = multiprocessing.JoinableQueue()
Results_queue = multiprocessing.Queue()
Html_queue = multiprocessing.Queue()

for Task in self.modules:
if module in Task:
Task_queue.put(Task)
Expand All @@ -259,7 +293,7 @@ def TestModule(self, domain, module):
procs = []
for thread in range(total_proc):
procs.append(multiprocessing.Process(
target=self.ExecuteModule, args=(Task_queue, Results_queue, domain)))
target=self.ExecuteModule, args=(Task_queue, Results_queue, Html_queue, domain)))
for p in procs:
p.daemon = True
p.start()
Expand All @@ -276,6 +310,10 @@ def TestModule(self, domain, module):
t = threading.Thread(target=self.Consumer, args=(Results_queue,))
t.daemon = True
t.start()
# Start Html Consumer / Trying to keep these seprate
t2 = threading.Thread(target=self.HtmlConsumer, args=(Html_queue,))
t2.daemon = True
t2.start()
# Enter this loop so we know when to terminate the Consumer thread
# This multiprocessing.active_children() is also Joining!
while True:
Expand All @@ -284,11 +322,13 @@ def TestModule(self, domain, module):
# We want to wait till we have no procs left, before we join
if len(LeftOver) == 0:
# Block untill all results are consumed
time.sleep(2)
time.sleep(1)
Results_queue.put(None)
Html_queue.put(None)
# t.join()
try:
FinalEmailList = self.CleanResults(domain)
FinalEmailList, HtmlFinalEmailList = self.CleanResults(
domain)
except Exception as e:
error = "[!] Something went wrong with parsing results:" + \
str(e)
Expand All @@ -301,7 +341,7 @@ def TestModule(self, domain, module):
print helpers.color(error, warning=True)
Results_queue.close()
try:
self.HtmlPrinter(FinalEmailList, domain)
self.HtmlPrinter(HtmlFinalEmailList, domain)
except Exception as e:
error = "[!] Something went wrong with HTML results:" + \
str(e)
Expand Down Expand Up @@ -387,4 +427,5 @@ def CompletedScreen(self, FinalCount, domain):
sys.exit(0)
if Answer in "YES":
# gnome-open cisco.doc
subprocess.Popen(("gnome-open",HtmlSaveFile), stdout=subprocess.PIPE)
subprocess.Popen(
("gnome-open", HtmlSaveFile), stdout=subprocess.PIPE)
8 changes: 7 additions & 1 deletion Helpers/HtmlBootStrapTheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# encoding=utf8
import sys
from Helpers import helpers
import ast

# This Classes main goal is to build the HTML output file using all self
# contained CSS and JS
Expand All @@ -12,6 +13,7 @@ class HtmlBuilder:
def __init__(self, Emails, Domain):
self.Emails = Emails
self.Domain = Domain
self.Source = ""
self.HTML = ""
reload(sys)
sys.setdefaultencoding('utf8')
Expand Down Expand Up @@ -80,10 +82,14 @@ def BuildHtml(self):
x = 1

for Email in self.Emails:
# This converts a List of Dict from String
# To a actual Dict item
Email = ast.literal_eval(Email)
line = "\t\t<tr>\n"
line += "\t\t\t<td>" + str(x) + "</td>\n"
line += "\t\t\t<td>" + str(self.Domain) + "</td>\n"
line += "\t\t\t<td>" + str(Email) + "</td>\n"
line += "\t\t\t<td>" + str(Email['Email']) + "</td>\n"
line += "\t\t\t<td>" + str(Email['Source']) + "</td>\n"
line += "\t\t</tr>\n"
x += 1
EmailTables += str(line)
Expand Down
12 changes: 12 additions & 0 deletions Helpers/Parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,15 @@ def CleanListOutput(self):
for item in self.InputData:
FinalOutput.append(item.rstrip("\n"))
return FinalOutput

def BuildResults(self,InputList,ModuleName):
# Will use a generator expression to assign
# emails to Keys and place into a list
FinalOutput = []
ModuleName = '"' + str(ModuleName) + '"'
# build dict and append to list
for email in InputList:
email = '"' + str(email) + '"'
ListItem = "{'Email': " + email + ", 'Source': " + ModuleName + "}"
FinalOutput.append(ListItem)
return FinalOutput
8 changes: 4 additions & 4 deletions Modules/AskSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __init__(self, Domain):

def execute(self):
self.process()
FinalOutput = self.get_emails()
return FinalOutput
FinalOutput, HtmlResults = self.get_emails()
return FinalOutput, HtmlResults

def process(self):
while self.Counter <= self.PageLimit:
Expand All @@ -58,5 +58,5 @@ def get_emails(self):
Parse.genericClean()
Parse.urlClean()
FinalOutput = Parse.GrepFindEmails()
print FinalOutput
return FinalOutput
HtmlResults = Parse.BuildResults(FinalOutput,self.name)
return FinalOutput, HtmlResults
7 changes: 4 additions & 3 deletions Modules/CanaryBinSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def __init__(self, domain):

def execute(self):
self.process()
FinalOutput = self.get_emails()
return FinalOutput
FinalOutput, HtmlResults = self.get_emails()
return FinalOutput, HtmlResults

def process(self):
# Get all the Pastebin raw items
Expand Down Expand Up @@ -96,4 +96,5 @@ def get_emails(self):
Parse.genericClean()
Parse.urlClean()
FinalOutput = Parse.GrepFindEmails()
return FinalOutput
HtmlResults = Parse.BuildResults(FinalOutput,self.name)
return FinalOutput, HtmlResults
7 changes: 4 additions & 3 deletions Modules/EmailHunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def __init__(self, domain):

def execute(self):
self.process()
FinalOutput = self.get_emails()
return FinalOutput
FinalOutput, HtmlResults = self.get_emails()
return FinalOutput, HtmlResults

def process(self):
try:
Expand All @@ -57,4 +57,5 @@ def get_emails(self):
# Make sure you remove any newlines
Parse = Parser.Parser(self.results)
FinalOutput = Parse.CleanListOutput()
return FinalOutput
HtmlResults = Parse.BuildResults(FinalOutput,self.name)
return FinalOutput, HtmlResults
7 changes: 4 additions & 3 deletions Modules/FlickrSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def __init__(self, domain):

def execute(self):
self.process()
FinalOutput = self.get_emails()
return FinalOutput
FinalOutput, HtmlResults = self.get_emails()
return FinalOutput, HtmlResults

def process(self):
try:
Expand All @@ -46,4 +46,5 @@ def process(self):
def get_emails(self):
Parse = Parser.Parser(self.results)
FinalOutput = Parse.GrepFindEmails()
return FinalOutput
HtmlResults = Parse.BuildResults(FinalOutput,self.name)
return FinalOutput, HtmlResults
7 changes: 4 additions & 3 deletions Modules/GitHubCodeSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def __init__(self, domain):

def execute(self):
self.process()
FinalOutput = self.get_emails()
return FinalOutput
FinalOutput, HtmlResults = self.get_emails()
return FinalOutput, HtmlResults

def process(self):
# Get all the USER code Repos
Expand Down Expand Up @@ -96,4 +96,5 @@ def get_emails(self):
Parse.genericClean()
Parse.urlClean()
FinalOutput = Parse.GrepFindEmails()
return FinalOutput
HtmlResults = Parse.BuildResults(FinalOutput,self.name)
return FinalOutput, HtmlResults
7 changes: 4 additions & 3 deletions Modules/GitHubGistSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def __init__(self, domain):

def execute(self):
self.process()
FinalOutput = self.get_emails()
return FinalOutput
FinalOutput, HtmlResults = self.get_emails()
return FinalOutput, HtmlResults

def process(self):
# Get all the USER code Repos
Expand Down Expand Up @@ -74,4 +74,5 @@ def get_emails(self):
Parse.genericClean()
Parse.urlClean()
FinalOutput = Parse.GrepFindEmails()
return FinalOutput
HtmlResults = Parse.BuildResults(FinalOutput,self.name)
return FinalOutput, HtmlResults
Loading

0 comments on commit 009a874

Please sign in to comment.