def returnPortInfo(self): auditNumber, revisionNumber = self.selectAuditRev() if auditNumber != None and revisionNumber != None: revision_with_values = self.db.check_tableHostsValues4ThisRevision(auditNumber, revisionNumber) if revision_with_values != -1: lastHostID = self.cHN.selectHostID(auditNumber, revisionNumber) if lastHostID != -1: portsIDavailableList = self.showListPortsIDandPortsNames(lastHostID) if portsIDavailableList != -1: portID = self.ask.ask4ListOptionNumber(portsIDavailableList) self.scanDB.showPortInfo(portID) portVersionDictionary = self.scanDB.getPortVersionAsDictionary(portID) if portVersionDictionary['product'] != 'None': portInfo = portVersionDictionary['product'] portInfo = str(portInfo.encode('utf-8')) # avoid error UnicodeEncodeError: 'ascii' codec can't encode character ... in position ...: ordinal not in range(128) return portInfo else: return -1 else: return -1 else: return -1 else: print color('rojo', 'No hosts discovered for this revision') return -1 else: return -1
def workWithAudits(): portInfoVersionProduct = mNmap.returnPortInfo() if portInfoVersionProduct != -1: menuWebs(portInfoVersionProduct) else: print color('rojo', 'No useful information for automatic search\n')
def downloadStart(self, download_exploit_id): file_name = self.exploits[download_exploit_id].split("/")[-1] print color('cyan', 'Downloading exploit') url = 'https://raw.githubusercontent.com/offensive-security/exploit-database/master/' + self.exploits[ download_exploit_id] urllib.urlretrieve(url, "modules/exploit-finder/exploits/" + file_name) print color('cyan', 'Exploit downloaded')
def showOptions(optionsList): indexesAvailable = [0] for index, option in enumerate(optionsList): index += 1 # index 0 is Exit print color('magenta', str(index) + '. ' + option) indexesAvailable.append(index) print color('rojo', '0. Exit') return indexesAvailable
def addWord(self): newWord = '' while newWord == '': newWord = raw_input('Type new word: ') file = open(self.filePathAndName, 'a') file.write('\n'+newWord) # write information in file file.close() # end work with file print color('cyan', 'Word added')
def addWord(self): newWord = '' while newWord == '': newWord = raw_input('Type new word: ') file = open(self.filePathAndName, 'a') file.write('\n' + newWord) # write information in file file.close() # end work with file print color('cyan', 'Word added')
def askExploitID(self, exploitsIDavailable): exploitID = "" while exploitID == '': exploitID = raw_input('Type ID >> ') if exploitID not in exploitsIDavailable: print color('rojo', '\nInvalid Exploit Id\n') exploitID = '' return exploitID
def selectAuditRev(self): print color('bcyan', 'Select audit') auditsDBallInfo = self.db.retrieve_auditsAllInfo() auditNumber, auditName = self.sAR.selectExistingAudit(auditsDBallInfo) print color('bcyan', 'Select revision') revisions4AuditDBAllInfo = self.db.retrieve_revisonAllInfoByAuditID(auditNumber) revisionNumber, revisionName = self.sAR.selectExistingRevision(revisions4AuditDBAllInfo) return auditNumber, revisionNumber
def ask4parameters(self, scanCustomNotAllowedOptions): parameters="" while parameters == "": parameters = raw_input('Type parameters for the scan: ') if self.ck.checkInString(parameters, scanCustomNotAllowedOptions) == 1: parameters = "" print color('rojo', 'Thanks for using this tool\nThe specified parameter is not available\nRemember, this tool save information in a database and input/output information is controlled\nOptions not allowed: '+str(scanCustomNotAllowedOptions)+'\nTry another parameter') return parameters
def showOptions(optionsList): indexesAvailable = [0] for index,option in enumerate(optionsList): index += 1 # index 0 is Exit print color('magenta', str(index)+'. '+option) indexesAvailable.append(index) print color('rojo', '0. Exit') return indexesAvailable
def askExploitID(self): download_exploit_id = "" while download_exploit_id == "": download_exploit_id = raw_input("Type exploit's ID: ") if download_exploit_id not in self.exploits.keys(): print color('rojo', '\nInvalid Exploit ID\n') download_exploit_id = "" return download_exploit_id
def ms(option): if (option == 'all' or option == 'no0today') and possibilities['0today'] == False: print color( 'rojo', 'Warning. 0day.today website not allowed. Check installations: BeautifulSoup, mechanize' ) if option == 'notCorrectOption': output.default('Not correct option was selected')
def askOverwriteFile(self, fileName): print color('rojo', 'File ' +str(fileName)+ ' already exists') print color('cyan', 'Options:\n1.Overwrite \n2.New file') fileOptions = '' while fileOptions!=1 and fileOptions!=2: fileOptions = self.ask4number() if fileOptions == 2: fileOptions = -1 return fileOptions
def changeHostName(self): # give an indicative name for each host self.__check_audit_rev(1) if self.auditNumber != None and self.revisionNumber != None: revision_with_values = self.db.check_tableHostsValues4ThisRevision(self.auditNumber, self.revisionNumber) if revision_with_values != -1: self.cn.changeName(self.auditNumber, self.revisionNumber) else: print color('rojo', 'No hosts discovered for this revision')
def askNumber(self): # return number (type int) or '' (advising invalid syntax) number = raw_input ('>> ') # string if self.ck.checkStrIsInt(number) == -1: number = '' print color('rojo', '\nInvalid option\n') else: number = self.cf.convertString2Int(number) return number
def checkNetworkConnection(self, myIP): if myIP == None: print color('rojo', "\nYou haven't got network connection\n") return -1 elif self.ck.checkIPstartsWith127(myIP) == -1: print color('rojo', 'Are you sure you have network connection?') return 1 else: return 1
def __menu__(path = ''): root_path = 'modules/usb-rubber-ducky-manager/apps/' self.directories,self.files = list_dir_file(root_path+path) c = 1 for d in self.directories: print color('magenta', str(c)+" - "+d) c+=1 for f in self.files: print color('azul', str(c)+" - "+f) c+=1
def saveInFile(self, what2save, fileName): filePathAndName = os.path.join(self.save_path, fileName) try: what2save = str(what2save) except: what2save = str(what2save.encode('utf-8')) # avoid error UnicodeEncodeError: 'ascii' codec can't encode character ... in position ...: ordinal not in range(128) file = open(filePathAndName,'w') # create file file.write(what2save) # write information in file file.close() print color('cyan', 'Exploit downloaded')
def exploit0toadySearch(self, newSearch, silenceMode = 1): print color('cyan', 'Connecting to 0day.today website') br = self.init0today() if silenceMode != 1: print "Searching '" + newSearch + "'" br, contents, exploitsInfo = self.startSearch(br, newSearch) exploitsID = self.showFreeExploits(exploitsInfo) if exploitsID == -1: print color('rojo', "No free searches for '" + newSearch + "' in http://0day.today/ \n") return br, contents, exploitsInfo, newSearch, exploitsID
def saveInFile(self, what2save, fileName): filePathAndName = os.path.join(self.save_path, fileName) try: what2save = str(what2save) except: what2save = str( what2save.encode('utf-8') ) # avoid error UnicodeEncodeError: 'ascii' codec can't encode character ... in position ...: ordinal not in range(128) file = open(filePathAndName, 'w') # create file file.write(what2save) # write information in file file.close() print color('cyan', 'Exploit downloaded')
def exploit0toadySearch(self, newSearch, silenceMode=1): print color('cyan', 'Connecting to 0day.today website') br = self.init0today() if silenceMode != 1: print "Searching '" + newSearch + "'" br, contents, exploitsInfo = self.startSearch(br, newSearch) exploitsID = self.showFreeExploits(exploitsInfo) if exploitsID == -1: print color( 'rojo', "No free searches for '" + newSearch + "' in http://0day.today/ \n") return br, contents, exploitsInfo, newSearch, exploitsID
def reload_service(translate, output, log): _ = translate output.default(color('magenta',_('Restarting Service...') + 'Apache')) command_restart = '/etc/init.d/apache2 reload' restart = subprocess.Popen(command_restart, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) restart_error = restart.stderr.read() if restart_error != '': output.error(color('amarillo', restart_error)) output.error(color('rojo',_('Failed to restart service or warnings out'))) log.write(_('Failed service or warnings out'), 1) else: output.default(color('verde', _('Restart service ok'))) log.write(_('Restart service ok'))
def reload_service(translate, output, log): import subprocess _ = translate output.default(color('magenta',_('Restarting Service...') + 'Bind9')) command_restart = '/etc/init.d/bind9 restart' restart = subprocess.Popen(command_restart, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) restart_error = restart.stderr.read() if restart_error != '': output.error(color('rojo',_('Failed to restart service'))) log.write(_('Failed to restart service'), 1) else: output.default(color('verde', _('Restart service ok'))) log.write(_('Restart service ok'))
def info(output, translate, log, module=""): interpret = translate.init("helpSystem") _ = interpret.ugettext if module == "": msg = style("bold", _("General System Help\n")) msg += color("cyan", _("help NumberProgram / help of module\n")) msg += color("cyan", _("newmodule NameProgram / Create a New Module\n")) msg += color("cyan", _("newmodulemenu NameProgram / Create a New Module with menu\n")) msg += color("cyan", _("modules / Show List Modules\n")) msg += color("cyan", _("clear / Clean Screen\n")) msg += color("cyan", _("license / Show License\n")) msg += color("cyan", _("version / Show Version\n")) msg += color("rojo", _("exit / Exit to program")) output.default(msg) else: try: ruta = "modules/" + module sys.path.append(ruta) modules = __import__("ini_" + module) infoModule = modules.help.info(translate) output.default(str(module) + " -> " + str(infoModule)) except: msg = _(module + " module has no help") salida.error(msg) log.write(msg, 1)
def portsFile(self): # create a .txt file, one per port indicated, with hosts IP up with those ports open # check if a revision and audit were selected self.__check_audit_rev(1) if self.auditNumber!= None and self.revisionNumber != None: revision_with_values = self.db.check_tableHostsValues4ThisRevision(self.auditNumber, self.revisionNumber) if revision_with_values != -1: # ask ports to export ports2File = self.ask.ask4ports2search()[1] # list of int numbers as strings, with all ports if ports2File != None: for port in ports2File: self.__createFile4port(port) else: print color('rojo', 'No hosts discovered for this revision')
def userSystem(output): import getpass user = getpass.getuser() if user != "root": output.error(color("rojo", "You need root user")) sys.exit(0)
def download_exploit(self, browser, contents, exploitsIDavailable): download_exploit = "" while download_exploit == "": download_exploit = raw_input('Download exploit y/n?: ') if download_exploit == 'y': download_exploit_id = '' while download_exploit_id == '': download_exploit_id = raw_input("Type exploit's ID: ") if download_exploit_id in exploitsIDavailable: self.downloadStart(browser, download_exploit_id) else: print color('rojo', '\nInvalid Exploit Id\n') download_exploit_id = '' elif download_exploit != 'n': print color('rojo', '\nInvalid Option\n') self.download_exploit(browser, contents, exploitsIDavailable)
def allInfoHost(self): # create a .txt file or print at console the information associated to a host # this option must have into account myIP because DB can have other IP with equal value # check if a revision and audit were selected self.__check_audit_rev(1) if self.auditNumber != None and self.revisionNumber != None: revision_with_values = self.db.check_tableHostsValues4ThisRevision(self.auditNumber, self.revisionNumber) if revision_with_values != -1: # ask how to get the information modeHostInformation = self.ask.askOptionAllInfoHost() # int if modeHostInformation != 0: hostsIP_longFormat = self.ask.ask4hosts2workOptions(self.auditNumber, self.revisionNumber, None)[1] if hostsIP_longFormat != -1: for hostIP in hostsIP_longFormat: self.__createFile4host(hostIP, modeHostInformation) else: print color('rojo', 'No hosts discovered for this revision')
def hosts2completeFormat(self,hostsIPnmapFormat): # variables: # - input # -- hostsIPnmapFormat: string. Hosts ip at nmap format # - output # -- ip2scan: touple of strings. Hosts ip at complete format # example 1. hosts ip of class C: '192.168,169.1.1-3,199' -> ('192.168.1.1', '192.168.1.2', '192.168.1.3', '192.168.1.199', '192.169.1.1', '192.169.1.2', '192.169.1.3', '192.169.1.199') # example 2. hosts ip of any class: '190-191,193.168.1.3,4' -> ('190.168.1.3', '190.168.1.4', '191.168.1.3', '191.168.1.4', '193.168.1.3', '193.168.1.4') if self.ck.checkCharacter(hostsIPnmapFormat) == 1: print color('rojo', 'Invalid syntax') return -1 if self.ck.checkSlash(hostsIPnmapFormat) == -1 and self.ck.checkComa(hostsIPnmapFormat) == -1 and self.ck.checkDash(hostsIPnmapFormat) == -1: # only one IP has been introduced ip2scan = self.convertString2List(hostsIPnmapFormat) return ip2scan else: try: # separate hosts ip introduced # create a list formed with parts separated by comas ip2scan = [] # save hosts IP at complete format if self.ck.checkSlash(hostsIPnmapFormat) == 1: # detects if any slash has been used # ip range indicated using slash [ipBase, ipFirstHost, ipLastHost, ipBroadcast, mask, numberHosts]=self.cIP.calculate_ip(hostsIPnmapFormat) ip2scan.extend(self.createRange4completeIP(ipFirstHost, ipLastHost)) else: # if no slash used, then a dash can be used # obtain each part of the ip introduced: ip = ip1.ip2.ip3.ip4 [ip1, ip2, ip3, ip4] = self.createListDotParts(hostsIPnmapFormat) # get list of numbers range for each part of the IP: ip1_listNumbers = self.createRange4ipPart(ip1) ip2_listNumbers = self.createRange4ipPart(ip2) ip3_listNumbers = self.createRange4ipPart(ip3) ip4_listNumbers = self.createRange4ipPart(ip4) # create a list with all hosts ip to scan for ip1 in ip1_listNumbers: for ip2 in ip2_listNumbers: for ip3 in ip3_listNumbers: for ip4 in ip4_listNumbers: ip2add = '%s.%s.%s.%s' %(ip1,ip2,ip3, ip4) ip2scan.append(ip2add) # ip2scan = list(set(ip2scan)) # eliminate repeated values # ip2scan.reverse() # eliminate repeated values inverts list order return ip2scan except: print color('rojo', 'Invalid syntax') return -1
def showListPortsIDandPortsNames(self, lastHostID): portsNumber4hostID = self.scanDB.getPortsNumber(lastHostID) # list of one or more integers. Example [80, 21, 22, 23] portsOpenID = self.scanDB.getPortsOpenID(lastHostID, portsNumber4hostID) # list of tuples. Example [(1,), (2,), (3,), (4,)] if portsOpenID == -1: print color('rojo', 'Not scanned ports for this host') else: portsOpenID = self.cf.eliminateTuplesAtList(portsOpenID) # list or a int portsOpenID = self.cf.createList(portsOpenID) # list portsOpenNumber = self.db.retrieve_portNumber_byPortsID(self.cf.createTuple(portsOpenID)) # list of tuples. Example [(80,), (21,), (22,), (23,)] portsOpenNumber = self.cf.eliminateTuplesAtList(portsOpenNumber) # list or int portsOpenNumber = self.cf.createList(portsOpenNumber) # list portsIDandNumber = self.cf.createListOfTuplesFrom2Lists(portsOpenID, portsOpenNumber) print color('verde', 'Available ports for this host') print color('verde','id number') print color('verde','-----------') for portIDandNumber in portsIDandNumber: print color('verde', str(portIDandNumber[0])+'. ' + str(portIDandNumber[1])) print '' # blank line return portsOpenID # list
def showFreeExploits(self, exploitsInfo): #exploitsInfo, type: dict if len(exploitsInfo.keys()) != 0: exploitsID = exploitsInfo.keys() exploitsID = sorted(exploitsID) # ascendent order exploitsFreeID = [] for exploitID in exploitsID: if exploitsInfo[exploitID][1] == 'free': exploitsFreeID.append(exploitID) if len(exploitsFreeID) != 0: for exploitID in exploitsFreeID: print exploitsInfo[exploitID][0] + " --> " + color( 'azul', 'http://0day.today/exploit/' + exploitID) + " - " + color('rojo', 'ID: ' + exploitID) return exploitsID else: return -1 else: return -1
def askExploitID(self, exploitsIDdb_list, exploitsID0today_list=[]): websWithExploit =[] if exploitsID0today_list == -1: exploitsID0today_list = [] download_exploit_id = "" while download_exploit_id == "": download_exploit_id = raw_input("Type exploit's ID: ") if download_exploit_id not in exploitsIDdb_list and download_exploit_id not in exploitsID0today_list: print color('rojo', '\nInvalid Exploit ID\n') download_exploit_id = "" if download_exploit_id in exploitsIDdb_list: websWithExploit.append('db') if exploitsID0today_list != []: if download_exploit_id in exploitsID0today_list: websWithExploit.append('0today') if 'db' in websWithExploit and '0today' in websWithExploit: print color('rojo', 'Same ID in both webs. Please, download it using only one web') download_exploit_id = -1 websWithExploit = [-1] return download_exploit_id, websWithExploit
def ask4hosts2workOptions(self, auditNumber, revisionNumber, myIP): # get ip to scan option2scan = self.ask4hostsOption() if option2scan == 0: hosts2scan_shortFormat = -1 hosts2scan_longFormat = -1 elif option2scan == 1: # check if the discovery option was maded for this revision discoveryDone = self.db.check_tableHostsValues4ThisRevision(auditNumber, revisionNumber) # check values at hosts table for this revision if discoveryDone == 1: # scan all discovered hosts, down hosts too because they can change to up hosts2scan_longFormat = self.db.retrieve_hostsIP_byRevision(auditNumber, revisionNumber) hosts2scan_shortFormat, hosts2scan_longFormat = self.cf.getShortLongFormatFromLongFormat(hosts2scan_longFormat, myIP) print "Hosts: " + str(self.cf.convertListTuple2string(hosts2scan_longFormat)) print "Number of hosts: " + str(len(hosts2scan_longFormat)) else: print color('rojo', 'No hosts ip discovered for this revision') hosts2scan_shortFormat, hosts2scan_longFormat = self.askHostsIP(myIP) elif option2scan == 2: hosts2scan_shortFormat, hosts2scan_longFormat = self.askHostsIP(myIP) return [hosts2scan_shortFormat, hosts2scan_longFormat] # -hosts2scan_shortFormat example: '192.168.1.1,2' -hosts2scan_longFormat example ('192.168.1.1','192.168.1.2')
def searchExploit(self, newSearch): dic_search = newSearch.split(" ") exist_exploit = False with open('modules/exploit-finder/files.csv') as csvfile: reader = csv.DictReader(csvfile) print color('cyan', 'Searching in exploit-db') for row in reader: flag = True for x in dic_search: if x.lower() not in row['description'].lower(): flag = False break if flag: self.exploits.update({row['id']: row['file']}) print row['description'] + " --> " + color( 'azul', 'https://www.exploit-db.com/exploits/' + str(row['id']) + '/') + " - " + color( 'rojo', 'ID: ' + str(row['id'])) exist_exploit = True if exist_exploit == False: self.exploits = {} print color( 'rojo', "No searches for '" + newSearch + "' in exploit-db database \n") return self.exploits.keys()
def askExploitID(self, exploitsIDdb_list, exploitsID0today_list=[]): websWithExploit = [] if exploitsID0today_list == -1: exploitsID0today_list = [] download_exploit_id = "" while download_exploit_id == "": download_exploit_id = raw_input("Type exploit's ID: ") if download_exploit_id not in exploitsIDdb_list and download_exploit_id not in exploitsID0today_list: print color('rojo', '\nInvalid Exploit ID\n') download_exploit_id = "" if download_exploit_id in exploitsIDdb_list: websWithExploit.append('db') if exploitsID0today_list != []: if download_exploit_id in exploitsID0today_list: websWithExploit.append('0today') if 'db' in websWithExploit and '0today' in websWithExploit: print color( 'rojo', 'Same ID in both webs. Please, download it using only one web') download_exploit_id = -1 websWithExploit = [-1] return download_exploit_id, websWithExploit
def ask4hostsOption(self): print color('bcyan', 'Select IP') print color('cyan', '1. IP discovered \n2. Specify IP') print color('rojo', '0. Exit') option2scan = '' while option2scan != 0 and option2scan != 1 and option2scan != 2: option2scan = self.ask4number() return option2scan
def askMenu(self): print 'Select option' print color('magenta', '1. Repeat search manually') print color('magenta', '2. Repeat search without words indicated in ' + str(self.fileBlackWordsName)) print color('rojo', '0. Exit') option = '' while option not in ['0','1','2']: option = raw_input('Repeat search >> ') return option
def deleteWord(self): word2delete = '' wordInFile = False while word2delete == '': word2delete = raw_input('Type word to delete: ') file = open(self.filePathAndName, 'r') lines = file.readlines() #list file.close() for line in lines: if word2delete in line: wordInFile = True try: lines.remove(word2delete+'\n') except: lines.remove(word2delete) # last word added # necessary write words again f = open(self.filePathAndName, 'w') # create file for line in lines: f.write(line) f.close() if wordInFile == False: print color('rojo', 'Word not in file\n') else: print color('cyan', 'Word deleted')
def deleteWord(self): word2delete = '' wordInFile = False while word2delete == '': word2delete = raw_input('Type word to delete: ') file = open(self.filePathAndName, 'r') lines = file.readlines() #list file.close() for line in lines: if word2delete in line: wordInFile = True try: lines.remove(word2delete + '\n') except: lines.remove(word2delete) # last word added # necessary write words again f = open(self.filePathAndName, 'w') # create file for line in lines: f.write(line) f.close() if wordInFile == False: print color('rojo', 'Word not in file\n') else: print color('cyan', 'Word deleted')
def askMenu(self): print 'Select option' print color('magenta', '1. Repeat search manually') print color( 'magenta', '2. Repeat search without words indicated in ' + str(self.fileBlackWordsName)) print color('rojo', '0. Exit') option = '' while option not in ['0', '1', '2']: option = raw_input('Repeat search >> ') return option
def showFreeExploits(self, exploitsInfo): #exploitsInfo, type: dict if len(exploitsInfo.keys()) != 0: exploitsID = exploitsInfo.keys() exploitsID = sorted(exploitsID) # ascendent order exploitsFreeID = [] for exploitID in exploitsID: if exploitsInfo[exploitID][1] == 'free': exploitsFreeID.append(exploitID) if len(exploitsFreeID) != 0: for exploitID in exploitsFreeID: print exploitsInfo[exploitID][0] + " --> " + color('azul', 'http://0day.today/exploit/' + exploitID) + " - " + color('rojo', 'ID: ' + exploitID) return exploitsID else: return -1 else: return -1
def searchExploit(self, newSearch): dic_search = newSearch.split(" ") exist_exploit = False with open('modules/exploit-finder/files.csv') as csvfile: reader = csv.DictReader(csvfile) print color('cyan', 'Searching in exploit-db') for row in reader: flag = True for x in dic_search: if x.lower() not in row['description'].lower(): flag = False break if flag: self.exploits.update({row['id']: row['file']}) print row['description'] + " --> " + color('azul', 'https://www.exploit-db.com/exploits/' + str( row['id']) + '/') + " - " + color('rojo', 'ID: ' + str(row['id'])) exist_exploit = True if exist_exploit == False: self.exploits = {} print color('rojo', "No searches for '" + newSearch + "' in exploit-db database \n") return self.exploits.keys()
def update_database(self): print color('cyan', 'Downloading Database') url = 'https://raw.githubusercontent.com/offensive-security/exploit-database/master/files.csv' urllib.urlretrieve(url, "modules/exploit-finder/files.csv")
def __init__(self, output, translate, log, installer,options): #- imports necessary import sys, os, ConfigParser from teco import color, style sys.path.append('modules/usb-rubber-ducky-manager/Encoder') from Encoder import Encoder self.directories = [] self.files = [] self.dir_before = [] #- Operations #- Example: output.default('Usb Rubber Ducky Manager') def __menu__(path = ''): root_path = 'modules/usb-rubber-ducky-manager/apps/' self.directories,self.files = list_dir_file(root_path+path) c = 1 for d in self.directories: print color('magenta', str(c)+" - "+d) c+=1 for f in self.files: print color('azul', str(c)+" - "+f) c+=1 def list_dir_file(root_path): files = [] directories = [] for f in os.listdir(root_path): check = root_path+"/"+f if os.path.isfile(check): files.append(f) elif os.path.isdir(check): directories.append(f) return directories, files def option1(): output.default('Has seleccionado la opcion 1') def option2(): output.default('Has seleccionado la opcion 2') __menu__() control = True while control == True: options.set_completer(help.complete) cadena = "" for x in self.dir_before: cadena = cadena+" "+x sentencia = raw_input("Usb Rubber Ducky Manager "+cadena+" >> ") if sentencia == 'exit': sys.exit() elif sentencia == 'version': output.default(help.version()) elif sentencia == 'menu' or sentencia == 'ls': dir_extend = "" for d in self.dir_before: dir_extend = dir_extend + d + "/" __menu__(dir_extend) elif sentencia == 'help': output.default(help.help()) elif int(sentencia) == 0: dir_extend = "" if len(self.dir_before) != 0: self.dir_before.remove(self.dir_before[-1]) for j in self.dir_before: dir_extend = dir_extend + j + "/" __menu__(dir_extend) elif (int(sentencia) <= len(self.directories)) and (int(sentencia)>0): self.dir_before.append(self.directories[int(sentencia)-1]) dir_extend = "" for d in self.dir_before: dir_extend = dir_extend + d + "/" __menu__(dir_extend) elif (int(sentencia) > len(self.directories)) and (int(sentencia) <= (len(self.directories)+len(self.files))): dir_extend = "" for d in self.dir_before: dir_extend = dir_extend + d + "/" print 'modules/usb-rubber-ducky-manager/apps/'+dir_extend+self.files[int(sentencia)-len(self.directories)-1] duck_path = 'modules/usb-rubber-ducky-manager/apps/'+dir_extend+self.files[int(sentencia)-len(self.directories)-1] config = ConfigParser.ConfigParser() if not config.read(duck_path): output.default("No existe el archivo de instalación") sys.exit() else: print color('magenta', "1 - Information Script") print color('azul', "2 - Compile Script") option = raw_input("Usb Rubber Ducky Manager >> ") while option == "": option = raw_input("Usb Rubber Ducky Manager >> ") if option == "1": title = config.get('info','title') description = config.get('info','description') print color('rojo', "Title:") print title print color('rojo', "Description:") print description elif option == "2": delimiter = config.get('delimiter','key') duck_script = config.get('script_command','cuak') data = config.items('data') for x in data: new_string = raw_input("usb-rubber-ducky-manager - "+x[1]+" >> ") old_string =delimiter+x[0]+delimiter duck_script = duck_script.replace(old_string,new_string) print duck_script commands = duck_script.split('\n') path = 'modules/usb-rubber-ducky-manager/precompile/apps/'+dir_extend path_compile = 'modules/usb-rubber-ducky-manager/compile/apps/'+dir_extend file_save = path+self.files[int(sentencia)-len(self.directories)-1] file_save_compile = path_compile+self.files[int(sentencia)-len(self.directories)-1].split(".")[0]+".bin" if not os.path.exists(path): os.makedirs(path) if not os.path.exists(path_compile): os.makedirs(path_compile) log = open(file_save, 'w') for x in commands: log.write(x) log.write("\n") log.close() encoder_rubber = Encoder() encoder_rubber.compile(['encoder','-i',file_save,'-o',file_save_compile]) else: output.default('No ha seleccionado una opcion correcta') else: output.default('No ha seleccionado una opcion correcta')
def createFile(self): if self.checkFileExists() == -1: open(self.filePathAndName, 'w') # create file print color('rojo', "File didn't exist. A new one was created")
def downloadStart(self, br, download_exploit_id): print color('cyan', 'Downloading exploit') exploit = self.getExploitByID(br, download_exploit_id) self.saveInFile(exploit, download_exploit_id + '.txt')