def TemplateCompleteScreen(self, Task, FileLocation, FileName, ModuleInt): ''' Function takes in output data and presents it to user. ''' self.TitleScreen() p = " [*] Email Template Generation has been completed:\n" line = """{0} Task Performed:\t\t{1} File Location: \t\t{2} Email File:\t\t\t{3} """.format(Helpers.color(p, green=True), Task.Name, FileLocation, FileName) print line # Now check if they want to open the file p = Helpers.color( " [>] ", status=True) + "Would you like to view the generated template? (y) or (n): " while True: a = raw_input(p) if a.lower() == "y": self.TemplateFinalRender(FileLocation, FileName, Task) break if a.lower() == "n": break p = Helpers.color( " [>] ", status=True) + "Would you like to return to Current Module? (y) or (n): " while True: a = raw_input(p) if a.lower() == "y": self.TemplateMenu(Task, ModuleInt) break if a.lower() == "n": self.TaskSelector() print line
def ModuleCommands(self): print Helpers.color("\n Available Template Commands:\n", status=True) print "\tCommand\t\tDescription" print "\t-------\t\t-----------" for item in self.TemplateCommands: print "\t%s%s" % ('{0: <16}'.format("[" + item[0] + "]").ljust(5), '{0: <16}'.format(item[1]))
def ListModules(self): self.TitleScreen() print Helpers.color( "\n [*] Available Modules are:\t\t\t\t Core Options:\t\t\tSophistication:", blue=True) print " -------------------------\t\t\t\t -------------\t\t\t---------------" lastBase = None x = 1 for name in self.Modules: parts = name.split("/") if lastBase and parts[0] != lastBase: print "" lastBase = parts[0] SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() if x < 10: print " %s) %s" % (str(x).ljust(1), '{0: <24}'.format( name).ljust(50)) + Task.CoreOptions.ljust( 32) + "[" + Task.Sophistication + "]" if x >= 10: print " %s) %s" % (str(x).ljust(1), '{0: <24}'.format( name).ljust(50)) + Task.CoreOptions.ljust( 32) + "[" + Task.Sophistication + "]" x += 1 print ""
def TemplateRender(self, Task): ''' This function will return the location output This will default to the ~/Desktop/ folder ''' try: EmailRender = Task.Render() # print EmailRender RenderName = Task.RenderName with open(RenderName, "w+") as myfile: myfile.write(EmailRender) try: # time.sleep(0) if ".eml" in RenderName: subprocess.check_call(["icedove", RenderName]) else: temp = subprocess.check_call(["iceweasel", RenderName]) # time.sleep(5) except Exception as e: print Helpers.color(" [!] Is a default browser installed?") # now remove temp file # time.sleep(2) os.remove(RenderName) except Exception as e: print e
def TemplatePrint(self, Task): ''' This function will print to the console the output of the email. ''' try: EmailRender = Task.Render() RenderName = Task.RenderName with open(RenderName, "w+") as myfile: myfile.write(EmailRender) try: # time.sleep(0) temp = "\n" temp += subprocess.check_output(["w3m", "-dump", "-T", "text/html", RenderName]) print Helpers.Reindent(temp, 1) # time.sleep(5) except Exception as e: print Helpers.color(" [!] Is w3m installed (run Setup.sh)?") print e # now remove temp file # time.sleep(2) os.remove(RenderName) except Exception as e: print e
def TemplateMenu(self, Task, ModuleInt): # start with Template menu and printing out the modules self.TitleScreen() p = "\n Template Loaded: " + Helpers.color(Task.Name, status=True) print p + "\n\n" self.TemplateRequiredOptions(Task) self.ModuleCommands() # setup module commands and required lists cmddict = self.TemplateCmdLoopCommands(Task) # now call cmd loop CmdLoop.start_loop(cmddict) while True: try: a = CmdLoop.input_loop() # a = raw_input(Helpers.color(p,status=True)) if a.startswith("set") or a.startswith("s"): try: Split = Helpers.GetWords(a) if Split[0].lower() == "set" or Split[0].lower( ) == "s": self.TemplateSet(Task, Split, a) except Exception as e: print e print Helpers.color( " [!] You must use [set] with Value", firewall=True) if a.startswith("edit") or a.startswith("e"): try: Split = Helpers.GetWords(a) if Split[0].lower() == "edit" or Split[0].lower( ) == "e": self.TemplateEdit(Task, Split, a) except Exception as e: print Helpers.color( " [!] You must use [edit] with Value", firewall=True) if a.lower() == "gen" or a.lower() == "g" or a.lower( ) == "run": self.TemplateGen(Task, ModuleInt) if a.lower() == "info" or a.lower() == "i": self.Template_Info(Task) if a.lower() == "view" or a.lower() == "v": self.TemplateView(Task) if a.lower() == "print" or a.lower() == "p": self.TemplatePrint(Task) if a.lower() == "render" or a.lower() == "r": self.TemplateRender(Task) if a.lower() == "back" or a.lower() == "b": self.TaskSelector() if a.lower() == "help" or a.lower() == "h" or a.lower() == "?": self.ModuleHelp() if a.lower() == "exit": Helpers.Exit() except Exception as e: print a
def TitleScreen(self): os.system('clear') # stolen from Veil :) p = "[Twitter]" w = "[Web]" print " ============================================================" print " Current: " + self.version + " | SimplyTemplate | " + Helpers.color(w, status=True) + ": CyberSyndicates.com" print " ============================================================" print " " + Helpers.color(p, status=True) + ": @CyberSyndicates | " + Helpers.color(p, status=True) + ": @Killswitch_gui" print " ============================================================"
def TemplateView(self, Task): FileName = Task.SampleImage try: subprocess.check_call(["xdg-open", FileName]) except Exception as e: s = "status 4" if s in str(e): print Helpers.color(" [!] Sorry no image submitted yet!") else: print Helpers.color(" [!] Is a default image viewer installed?")
def Template_Info(self, Task): try: self.TitleScreen() print Helpers.color("\n Template Information:\n", status=True) for item in self.TemplateInfo: task = "Task." + str(item.rstrip(":")) if task == "Task.Sophistication": if eval(task).lower() == "high": print "\t" + item + "\t\t" + Helpers.color(eval(task), green=True) if eval(task).lower() == "medium": print "\t" + item + "\t\t" + Helpers.color(eval(task), firewall=True) if eval(task).lower() == "low": print "\t" + item + "\t\t" + Helpers.color(eval(task), warning=True) elif task == "Task.SampleImage": print "\t" + item + "\t\t" + eval(task) elif task == "Task.Info": print Helpers.FormatLong("Info:", Task.Info, spacing=24) else: print "\t" + item + "\t\t\t" + eval(task) # https://github.com/Veil-Framework/Veil-Evasion/blob/master/modules/common/controller.py # Taken from line 246 print Helpers.color("\n Template Required Options:\n", status=True) print " Setting\t\tValue Set\t\t\tDescription of Setting" print " -------\t\t---------\t\t\t----------------------" for key in sorted(Task.RequiredOptions.iterkeys()): print " %s%s%s" % ('{0: <16}'.format(key).ljust(23), '{0: <8}'.format(Task.RequiredOptions[key][0]).ljust(32), Task.RequiredOptions[key][1]) except Exception as e: print e p = " [!] Please select a valid Module number\n" print Helpers.color(p, firewall=True) return
def ModuleSelection(self, selection): ModuleInt = int(selection[1]) try: SelectedModule = self.Dmodules[ModuleInt] Task = SelectedModule.TemplateModule() return Task except Exception as e: print e p = " [!] Please select a valid Module number" print Helpers.color(p, firewall=True) return
def TemplateGen(self, Task, ModuleInt): ''' This Function takes in the template Task Object It will run the pre-defined Class Call ''' try: FileLocation = self.TemplateLocation() Name = self.TemplateName(Task) Task.Generate(FileLocation, Name, Verbose=False) self.TemplateCompleteScreen(Task, FileLocation, Name, ModuleInt) except Exception as e: p = " [!] Major issue with template gen: " + str(e) print Helpers.color(p, warning=True)
def TemplateMenu(self, Task, ModuleInt): # start with Template menu and printing out the modules self.TitleScreen() p = "\n Template Loaded: " + Helpers.color(Task.Name, status=True) print p + "\n\n" self.TemplateRequiredOptions(Task) self.ModuleCommands() # setup module commands and required lists cmddict = self.TemplateCmdLoopCommands(Task) # now call cmd loop CmdLoop.start_loop(cmddict) while True: try: a = CmdLoop.input_loop() # a = raw_input(Helpers.color(p,status=True)) if a.startswith("set") or a.startswith("s"): try: Split = Helpers.GetWords(a) if Split[0].lower() == "set" or Split[0].lower() == "s": self.TemplateSet(Task, Split, a) except Exception as e: print e print Helpers.color(" [!] You must use [set] with Value", firewall=True) if a.startswith("edit") or a.startswith("e"): try: Split = Helpers.GetWords(a) if Split[0].lower() == "edit" or Split[0].lower() == "e": self.TemplateEdit(Task, Split, a) except Exception as e: print Helpers.color(" [!] You must use [edit] with Value", firewall=True) if a.lower() == "gen" or a.lower() == "g" or a.lower() == "run": self.TemplateGen(Task, ModuleInt) if a.lower() == "info" or a.lower() == "i": self.Template_Info(Task) if a.lower() == "view" or a.lower() == "v": self.TemplateView(Task) if a.lower() == "print" or a.lower() == "p": self.TemplatePrint(Task) if a.lower() == "render" or a.lower() == "r": self.TemplateRender(Task) if a.lower() == "back" or a.lower() == "b": self.TaskSelector() if a.lower() == "help" or a.lower() == "h" or a.lower() == "?": self.ModuleHelp() if a.lower() == "exit": Helpers.Exit() except Exception as e: print a
def TemplateSet(self, Task, Value, Raw): try: option = Value[1] if Value[1] not in Task.RequiredOptions: print Helpers.color(" [!] Invalid option specified.", firewall=True) else: Raw = Raw.strip(Value[0]) Raw = Raw.lstrip(' ') Raw = Raw.lstrip(Value[1]) Raw = Raw.lstrip(' ') Task.RequiredOptions[option][0] = Raw return except Exception as e: print e print Helpers.color(" [!] Error in setting option, likely invalid option name.", firewall=True)
def TemplateRequiredOptions(self, Task): ''' Function for required option for "only" a template. ''' try: # https://github.com/Veil-Framework/Veil-Evasion/blob/master/modules/common/controller.py # Taken from line 246 print Helpers.color("\n Template Required Options:\n", status=True) print " Setting\t\tValue Set\t\t\tDescription of Setting" print " -------\t\t---------\t\t\t----------------------" for key in sorted(Task.RequiredOptions.iterkeys()): print " %s%s%s" % ('{0: <16}'.format(key).ljust(23), '{0: <8}'.format(Task.RequiredOptions[key][0]).ljust(32), Task.RequiredOptions[key][1]) except Exception as e: print e p = " [!] Please select a valid Module number\n" print Helpers.color(p, firewall=True) return
def ModuleRequiredOptions(self, selection): ModuleInt = int(selection[1]) try: SelectedModule = self.Dmodules[ModuleInt] Task = SelectedModule.TemplateModule() # https://github.com/Veil-Framework/Veil-Evasion/blob/master/modules/common/controller.py # Taken from line 246 print Helpers.color("\n Template Required Options:\n", status=True) print " Setting\t\tValue Set\t\tDescription of Setting" print " -------\t\t---------\t\t----------------------" for key in sorted(Task.RequiredOptions.iterkeys()): print " %s%s%s" % ('{0: <16}'.format(key).ljust(10), '{0: <8}'.format(Task.RequiredOptions[key][0]).ljust(30), Task.RequiredOptions[key][1]) except Exception as e: print e p = " [!] Please select a valid Module number\n" print Helpers.color(p, firewall=True) return
def TemplateFinalRender(self, FilePath, FileName, Task): ''' This function will open the Produced .MHT file ''' try: # print EmailRender Path = str(FilePath) + str(FileName) try: time.sleep(1) if ".eml" in Path: subprocess.check_call(["icedove", "-File", Path]) else: subprocess.check_call(["iceweasel", Path]) # time.sleep(5) except Exception as e: print Helpers.color(" [!] Is a Iceweasel browser installed? (Run Setup)") except Exception as e: print e
def TemplateRender(self, Task): ''' This function will return the location output This will default to the ~/Desktop/ folder ''' try: EmailRender = Task.Render() f = open("temp.html", 'w') f.write(EmailRender) f.close try: time.sleep(1) subprocess.check_call(["gnome-open", "temp.html"]) except Exception as e: print Helpers.color(" [!] Is a default browser installed?") # now remove temp file time.sleep(3) os.remove("temp.html") except Exception as e: print e
def TemplateEdit(self, Task, Value, Raw): try: try: if Task.RequiredText: EditValue = True except: EditValue = False print Helpers.color(" [!] Template does not support edit yet!") if EditValue: if Value[1] not in Task.RequiredText: print Helpers.color(" [!] Invalid option specified.", firewall=True) else: Text = Task.RequiredText[Value[1]][0] raw = TemplateEdit.root(Text) if raw: Task.RequiredText[Value[1]][0] = raw return # raw = TemplateEdit.root(str(self.RequiredText["TextBlock1"][0])) except Exception as e: print e
def ListModules(self): self.TitleScreen() print Helpers.color("\n [*] Available Modules are:\t\t\t\t Core Options:\t\t\tSophistication:", blue=True) print " -------------------------\t\t\t\t -------------\t\t\t---------------" lastBase = None x = 1 for name in self.Modules: parts = name.split("/") if lastBase and parts[0] != lastBase: print "" lastBase = parts[0] SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() if x < 10: print " %s) %s" % (str(x).ljust(1), '{0: <24}'.format(name).ljust(50)) + Task.CoreOptions.ljust(32) + "[" + Task.Sophistication + "]" if x >= 10: print " %s) %s" % (str(x).ljust(1), '{0: <24}'.format(name).ljust(50)) + Task.CoreOptions.ljust(32) + "[" + Task.Sophistication + "]" x += 1 print ""
def ListSearchModules(self, ModuleList, ModuleList2): ''' Takes an array of Modules to print rather than all modules. ''' self.TitleScreen() if ModuleList: print Helpers.color("\n [*] Core Options Search Results are:\t\t\tCore Options:\t\tSophistication:", blue=True) print " --------------------------------\t\t\t-------------\t\t---------------" x = 1 for name in ModuleList: SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() print "\n %s" % (Helpers.color('{0: <24}'.format(name).ljust(50), status=True)) + Helpers.color(Task.CoreOptions.ljust(33), status=True) + "[" + Helpers.color(Task.Sophistication, status=True) + "]\n" print Helpers.FormatLong("Module Info:",Task.Info, spacing=16) x += 1 print "" if ModuleList2: print Helpers.color("\n [*] Sophistication Search Results are:\t\tCore Options:\t\tSophistication:", blue=True) print " ----------------------------------\t\t\t-------------\t\t---------------" x = 1 for name in ModuleList2: SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() print "\n %s" % (Helpers.color('{0: <24}'.format(name).ljust(50), status=True)) + Helpers.color(Task.CoreOptions.ljust(33), status=True) + "[" + Helpers.color(Task.Sophistication, status=True) + "]\n" print Helpers.FormatLong("Module Info:",Task.Info, spacing=16) x += 1 print ""
def TemplateRequiredOptions(self, Task): ''' Function for required option for "only" a template. ''' try: # https://github.com/Veil-Framework/Veil-Evasion/blob/master/modules/common/controller.py # Taken from line 246 print Helpers.color("\n Template Required Options:\n", status=True) print " Setting\t\tValue Set\t\t\tDescription of Setting" print " -------\t\t---------\t\t\t----------------------" for key in sorted(Task.RequiredOptions.iterkeys()): print " %s%s%s" % ('{0: <16}'.format(key).ljust(23), '{0: <8}'.format(Task.RequiredOptions[key][0]).ljust(32), Task.RequiredOptions[key][1]) try: if Task.RequiredText: print Helpers.color("\n Template TextEdit Options:\n", status=True) print " Setting\t\tValue Set\t\t\tDescription of Setting" print " -------\t\t---------\t\t\t----------------------" for key in sorted(Task.RequiredText.iterkeys()): print " %s%s%s" % ('{0: <16}'.format(key).ljust(23), '{0: <8}'.format(Task.RequiredText[key][0].replace("\n", "")[0:25] + str('..')).ljust(32), Task.RequiredText[key][1]) except Exception as e: pass except Exception as e: print e p = " [!] Please select a valid Module number\n" print Helpers.color(p, firewall=True) return
def TemplateLocation(self): ''' This function will return the location output This will default to the ~/Desktop/ folder ''' while True: try: p = " [>] Output Location (Default ~/Desktop/):" a = raw_input(Helpers.color(p,status=True)) if a: return a else: a = "/root/Desktop/" return a except Exception as e: print e
def TemplateName(self, Task): ''' This function will return the location output This will default to the ~/Desktop/ folder ''' while True: try: name = Task.OutputName p = " [>] Output Name (Default: " + name + "):" a = raw_input(Helpers.color(p, status=True)) if a: return a else: a = name return a except Exception as e: print e
def TemplateLocation(self): ''' This function will return the location output This will default to the ~/Desktop/ folder ''' while True: try: p = " [>] Output Location (Default ~/Desktop/):" a = raw_input(Helpers.color(p, status=True)) if a: return a else: home = expanduser("~") a = str(home) + "/Desktop/" return a except Exception as e: print e
def ListSearchModules(self, ModuleList, ModuleList2, ModuleList3): ''' Takes an array of Modules to print rather than all modules. ''' self.TitleScreen() if ModuleList: print Helpers.color("\n [*] Core Options Search Results are:\t\t\tCore Options:\t\tSophistication:", blue=True) print " --------------------------------\t\t\t-------------\t\t---------------" x = 1 for name in ModuleList: SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() print "\n %s" % (Helpers.color('{0: <24}'.format(name).ljust(50), status=True)) + Helpers.color(Task.CoreOptions.ljust(33), status=True) + "[" + Helpers.color(Task.Sophistication, status=True) + "]\n" print Helpers.FormatLong("Module Info:", Task.Info, spacing=16) x += 1 print "" if ModuleList2: print Helpers.color("\n [*] Sophistication Search Results are:\t\tCore Options:\t\tSophistication:", blue=True) print " ----------------------------------\t\t\t-------------\t\t---------------" x = 1 for name in ModuleList2: SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() print "\n %s" % (Helpers.color('{0: <24}'.format(name).ljust(50), status=True)) + Helpers.color(Task.CoreOptions.ljust(33), status=True) + "[" + Helpers.color(Task.Sophistication, status=True) + "]\n" print Helpers.FormatLong("Module Info:", Task.Info, spacing=16) x += 1 print "" if ModuleList3: print Helpers.color("\n [*] Name Search Results are:\t\tCore Options:\t\tSophistication:", blue=True) print " ----------------------------------\t\t\t-------------\t\t---------------" x = 1 for name in ModuleList3: SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() print "\n %s" % (Helpers.color('{0: <24}'.format(name).ljust(50), status=True)) + Helpers.color(Task.CoreOptions.ljust(33), status=True) + "[" + Helpers.color(Task.Sophistication, status=True) + "]\n" print Helpers.FormatLong("Module Info:", Task.Info, spacing=16) x += 1 print ""
def PromptSelection(self): # We also have to strip off and verfiy the number # make sure we strip when checking command p = " [>] " a = raw_input(Helpers.color(p,status=True)) # Gives me a list of words of ints try: Split = Helpers.GetWords(a) if Split[0].lower() == "use" or Split[0].lower() == "u": # we will use this to select our module of choice # it will call a seprate function to handle the Int # of the requested module Task = self.ModuleSelection(Split) self.TemplateMenu(Task, Split) if Split[0].lower() == "info" or Split[0].lower() == "i": self.ModuleInfo(Split) except Exception as e: pass if a.lower() == "help" or a.lower() == "h" or a.lower() == "?": self.ModuleHelp() try: if Split[0].lower() == "search" or Split[0].lower() == "s": self.ModuleSearch(Split) except Exception as e: pass if a.lower() == "list" or a.lower() == "l": self.ListModules() self.PromptSelection() if a.lower() == "update" or a.lower() == "u": Helpers.SelfUpdate() if a.lower() == "exit": Helpers.Exit() else: self.PromptSelection() return a
def ModuleCommands(self): print Helpers.color("\n Available Template Commands:\n", status=True) print "\tCommand\t\tDescription" print "\t-------\t\t-----------" for item in self.TemplateCommands: print "\t%s%s" % ('{0: <16}'.format("["+item[0]+"]").ljust(5), '{0: <16}'.format(item[1]))
def ModuleSearch(self, SearchTerm): ''' Takes in a array of strings and searched by them ''' SophisticationList = [] CoreOptionsList = [] NameList = [] # check for less than 2x items if len(SearchTerm) <= 1: # make sure they are using the correct items to search p = " [!] Please search by one of the options (sophistication)-(options)-(name) HINT-use tab" print Helpers.color(p, firewall=True) return # check for no search value if len(SearchTerm) <= 2: # make sure they are using the correct items to search p = " [!] Please use a search term!" print Helpers.color(p, firewall=True) return # search SophisticationList if SearchTerm[1] in 'sophistication': try: for name in self.Modules: try: SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() Sophistication = Task.Sophistication if SearchTerm[2].lower() in Sophistication.lower(): # add in the matching Result SophisticationList.append(str(name)) except: pass except Exception as e: print e if SearchTerm[1] in 'options': try: for name in self.Modules: try: SelectedModule = self.Modules[name] Task = SelectedModule.TemplateModule() CoreOptions = Task.CoreOptions if SearchTerm[2] in CoreOptions.lower(): # add in the matching Result CoreOptionsList.append(str(name)) except: pass except Exception as e: print e if SearchTerm[1] in 'name': try: for name in self.Modules: try: if SearchTerm[2].lower() in name.lower(): # add in the matching Result NameList.append(str(name)) except: pass except Exception as e: print e self.ListSearchModules(CoreOptionsList, SophisticationList, NameList)
def TemplateView(self, Task): FileName = Task.SampleImage try: subprocess.check_call(["xdg-open", FileName]) except Exception as e: print Helpers.color(" [!] Is a default image viewer installed?")