def getDirsFromGobuster(url, cookie, token): if (token in pids_of_token.keys()): process = subprocess.Popen([ 'gobuster', 'dir', '--random-agent', '-u', url, '-w', dictionary_dir, '-c', cookie, '-t', '10', '-q', '-z', '--no-error' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: pids_of_token[token].append(process.pid) # If process finish successfully process.wait() if (token in pids_of_token.keys()): pids_of_token[token].remove(process.pid) re, err = process.communicate() if (process.returncode != 1): return (re) else: return "wrong URL" else: return "wrong URL" except: return "wrong URL" return "wrong URL"
def getDataFromJoomscan(url, token): sys.path = [] sys.path.append('/root/python_tool/joomscan/') # Delete all old report subprocess.run('rm -rf reports/*', shell=True, cwd='/root/python_tool/joomscan') if (token in pids_of_token.keys()): # Run command process = subprocess.Popen( ['perl', 'joomscan.pl', '--url', url, '-ec'], cwd='/root/python_tool/joomscan', stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: pids_of_token[token].append(process.pid) process.wait() if (token in pids_of_token.keys()): pids_of_token[token].remove(process.pid) re, err = process.communicate() if (process.returncode != 1): return True else: return False else: return False except: return False return False
def getDataFromFierce(url, token): tsd, td, tsu = extract(url) url = td + '.' + tsu reportName = 'fierce_' + token + '.report' # Delete duplicate file subprocess.run(['rm', reportName], cwd='/root/python_tool/fierce/') if (token in pids_of_token.keys()): process = subprocess.Popen(['perl','fierce.pl','-file', reportName,'-dns',url], cwd='/root/python_tool/fierce', stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: pids_of_token[token].append(process.pid) process.wait() if (token in pids_of_token.keys()): pids_of_token[token].remove(process.pid) re, err = process.communicate() if (process.returncode != 1): return True else: return False return False except: return False return False
def before_request_func(): try: token = request.args['token'] if (token not in pids_of_token.keys()): pids_of_token[token] = [] except: print("Pass")
def getDataFromCmseek(url, token): reportFolder = init_result_dir(url) path = '/root/python_tool/CMSeeK/Result' reportPath = os.path.join(path, reportFolder) tsd, td, tsu = extract(url) domain = tsd + '.' + td + '.' + tsu domain = domain[1:len(domain) - 1] if ( domain[0] == '.' and domain[len(domain) - 1] == '.') else domain[1:] if ( domain[0] == '.') else domain[:len(domain) - 1] if (domain[len(domain) - 1] == '.') else domain if (domain == ''): return "Can not get data from cmseek", None if (token in pids_of_token.keys()): process = subprocess.Popen( ['python', 'cmseek.py', '-o', '-u', url, '--batch'], cwd='/root/python_tool/CMSeeK/', stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: pids_of_token[token].append(process.pid) process.wait() if (token in pids_of_token.keys()): pids_of_token[token].remove(process.pid) re, err = process.communicate() if (process.returncode != 1): return re, reportPath else: return "Can not get data from cmseek", None else: return "Can not get data from cmseek", None except: return "Can not get data from cmseek", None return "Can not get data from cmseek", None
def getDataFromDroopescan(url, token): if (token in pids_of_token.keys()): process = subprocess.Popen(['droopescan','scan','-u',url,'-o' 'json', '-t','10','-e','a'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: pids_of_token[token].append(process.pid) process.wait() if (token in pids_of_token.keys()): pids_of_token[token].remove(process.pid) re, err = process.communicate() if (process.returncode != 1): return re else: return "Can not get data from droopescan" else: return "Can not get data from droopescan" except: return "Can not get data from droopescan" return "Can not get data from droopescan"
def kill_all_process(): token = request.args['token'] # Wait all tools have gone to api-server time.sleep(15) if (token in pids_of_token.keys()): for pid in pids_of_token[token]: # Kill each tool related to token os.kill(pid, signal.SIGKILL) # Delete token out of pids_of_token del pids_of_token[token] return jsonify("OK")
def getDataFromNmap(url, token): #Convert domain to ip tsd, td, tsu = extract(url) url = tsd + '.' + td + '.' + tsu url = url[1: len(url)-1] if (url[0] == '.' and url[len(url)-1] == '.') else url[1:] if (url[0] == '.') else url[:len(url)-1] if (url[len(url)-1] == '.') else url if (url == ''): return "Can not get data from nmap" try: ip = socket.gethostbyname(url) except: return "Can not get data from nmap" reportNameTXT = 'nmap_' + token + '.report_1' reportNameXML = 'nmap_' + token + '.report_2' subprocess.run(['rm', reportNameTXT, reportNameXML], cwd='/root/python_tool/nmap_tool') #Run nmap with related ip if (token in pids_of_token.keys()): process = subprocess.Popen(['nmap','-A','-sV','-T4','-oN', reportNameTXT,'--script','vuln', '-oX', reportNameXML,ip], cwd='/root/python_tool/nmap_tool', stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: pids_of_token[token].append(process.pid) process.wait() if (token in pids_of_token.keys()): pids_of_token[token].remove(process.pid) re, err = process.communicate() if (process.returncode != 1): return "Success" else: return "Can not get data from nmap" return "Can not get data from nmap" except: return "Can not get data from nmap" return "Can not get data from nmap"