def main(): #Later pcap files should be input USERNAME = sys.argv[1] + '_' PASWWD_PCAP = sys.argv[2] IV_PCAP = sys.argv[3] KEY_PCAP = sys.argv[4] MESSAGE_PCAP = sys.argv[5] #Create password file pcap.getPasswd(PASWWD_PCAP, USERNAME + PASWWD_FILE) #Create IV file pcap.getIV(IV_PCAP, USERNAME + IV_FILE) #Create IV file pcap.getZip(KEY_PCAP, USERNAME + KEY_FILE) #Create IV file pcap.getCipherMessage(MESSAGE_PCAP, USERNAME + MESSAGE_FILE)
def main(): #cryptPs = ['epZ3maUPg.5bM', 'toDomUXturxgE', 'arjTn5JkJn1eQ', 'pa9dUC4SyB.Ok', 'sswsoxTKa60Ck', 'areI1u8PUKnCE', 'arEuwZJu/coYM', 'itTr4l7DBqOTg', 'pa8f6N7v.ZWtE', 'sso2.6YcMAD36', #'itDjFKQjy2AoA', 'ssa8iK1EEkU7Q', 'sssSFzvWQNGbM', 'ss1BZQcb/ZlTs', 'top4SXdRhypNg', 'epEkR5mNJ.KN6', 'pajwdHh82DFAA', 'epA6qvwC.NxW.', 'pa51cvzXQFikI', 'epWP3sY5xFY/c'] cryptPs, packetNames, outNames = [],[],[] pname = "../captpcap1/pcapData" n = 0 for i in range(101): j = i + n packetNames.append(pname + str(j) + '.pcap') outNames.append(packetNames[i] + '.out') pcap.getPasswd( packetNames[i], outNames[i]) #Obtain encrypted password cryptFile = open(outNames[i], "r") cryptedPass = cryptFile.readline().strip()+' ' cryptPs.append(cryptedPass) PASS_OUTPUTFILE = "../dPasswrods0" #inFile = "../captpcap1/" + sys.argv[1] #outFile = "passwordsOUT" #pcap.getPasswd( inFile, outFile) #----------------------------NSA Request-------------------------------- requests(cryptPs, PASS_OUTPUTFILE) #----------------------------Write passwords to files-------------------------------- """"passwd_plains = []
def automation(usernames, passwdPCAPFiles, keyPCAPFiles, ivPCAPFiles, msgPCAPFiles): numberOfUsers = len(usernames) #------------------------CREATE NEW DIRECTORIES FOR ALL USERS------------------------ print "Creating directories for all users..." DATA_FOLDERS, OUT_FOLDERS, DMSG_FOLDERS = forAllCreateDirectories( usernames) #-------------------------------Generate input pcap file paths------------------------- USERNAMES, PASWWD_PCAPS, IV_PCAPS, KEY_PCAPS, MESSAGE_PCAPS = [],[],[],[],[] for i in range(numberOfUsers): #User input should be the username followed by 4 PCAP files USERNAMES.append(usernames[i] + '_') PASWWD_PCAPS.append(PCAP_DIRECTORY + passwdPCAPFiles[i]) IV_PCAPS.append(PCAP_DIRECTORY + ivPCAPFiles[i]) KEY_PCAPS.append(PCAP_DIRECTORY + keyPCAPFiles[i]) MESSAGE_PCAPS.append(PCAP_DIRECTORY + msgPCAPFiles[i]) #--------------------------Generate output data file, and extract data ---------------------------- print "Extracting data from PCAP files..." start = time.time() passwd_files, iv_files, key_files, message_files = [], [], [], [] for i in range(numberOfUsers): #Username specific file names (extract from corresponding pcap files) passwd_files.append(DATA_FOLDERS[i] + USERNAMES[i] + PASWWD_FILE) iv_files.append(DATA_FOLDERS[i] + USERNAMES[i] + IV_FILE) key_files.append(DATA_FOLDERS[i] + USERNAMES[i] + KEY_FILE) message_files.append(DATA_FOLDERS[i] + USERNAMES[i] + MESSAGE_FILE) #Generate data files from PCAP files pcap.getPasswd(PASWWD_PCAPS[i], passwd_files[i]) pcap.getIV(IV_PCAPS[i], iv_files[i]) pcap.getZip(KEY_PCAPS[i], key_files[i]) pcap.getCipherMessage(MESSAGE_PCAPS[i], message_files[i]) #Stop and print timer end = time.time() print "Data extracted after", str(end - start), "seconds." #----------------------------NSA/Crack Request-------------------------------- print "Cracking passwords" #Start timer start = time.time() #print("Starting timer") #requests(passwd_files, PASS_OUTPUTFILE) requestToCracker(passwd_files, PASS_OUTPUTFILE) #Stop and print timer end = time.time() print "All", str(numberOfUsers), "passwords cracked after", str( end - start), "seconds." #----------------------------Write passwords to files-------------------------------- print "Writing password to corresponding user files." passwd_plains = [] #Get file contents to a list with open(PASS_OUTPUTFILE) as f: content = f.readlines() passwds = [] for i in range(numberOfUsers): #obtain password p = content[i].strip() p = p.split(" ")[1] passwds.append(p) #create plain password file path passwd_plains.append(OUT_FOLDERS[i] + USERNAMES[i] + PASSWORD_PLAIN) #write password plain file pFile = open(passwd_plains[i], "w") pFile.write(passwds[i] + '\n') pFile.close() #--------------------------Unzip Keys---------------------------- print "Unzipping key files..." key_plains = [] for i in range(numberOfUsers): #Unzip and create key file key_plains.append(OUT_FOLDERS[i] + USERNAMES[i] + KEY_PLAIN) unzip.unzipFile(key_files[i], key_plains[i], passwds[i]) #--------------------------Parse Key---------------------------- print "Parsing Keys..." parsed_keys = [] for i in range(numberOfUsers): parsed_keys.append(OUT_FOLDERS[i] + USERNAMES[i] + KEY_PARSED) keyParser.keyParsing(key_plains[i], parsed_keys[i]) #--------------------------Decrypt (AES-128)--------------------------- print "First Layer Decryption..." for i in range(numberOfUsers): decrypt.callDecryptShell(message_files[i], iv_files[i], parsed_keys[i], DMSG_FOLDERS[i]) #-----------------------------Delete files-------------- for i in range(numberOfUsers): deleteBinaryFiles(DMSG_FOLDERS[i]) #--------------------------Decrypt all three messages--------------------------- shProcess = Popen(["mv", "../user*", "../dataProcessedPhase4"]) # Wait for process to complete. shProcess.wait() callToCaesarCrack() callToAffineCrack() callToChainRotCrack() print "DONE"
def main(): #------------------------CREATE NEW DIRECTORY------------------------ USERNAME = sys.argv[1] DATA_FOLDER = "../" + USERNAME + "Data/" if not os.path.exists(DATA_FOLDER): os.makedirs(DATA_FOLDER) OUT_FOLDER = "../" + USERNAME + "Output/" if not os.path.exists(OUT_FOLDER): os.makedirs(OUT_FOLDER) DMSG_FOLDER = OUT_FOLDER + "decriptedMessage/" if not os.path.exists(DMSG_FOLDER): os.makedirs(DMSG_FOLDER) #-------------------------------USER INPUT------------------------- #User input should be the username followed by 4 PCAP files USERNAME = USERNAME + '_' PASWWD_PCAP = PCAP_DIRECTORY + sys.argv[2] IV_PCAP = PCAP_DIRECTORY + sys.argv[3] KEY_PCAP = PCAP_DIRECTORY + sys.argv[4] MESSAGE_PCAP = PCAP_DIRECTORY + sys.argv[5] #--------------------------PCAP -> DATA FILES ---------------------------- #username specific file names (extract from corresponding pcap files) passwd_file = DATA_FOLDER + USERNAME + PASWWD_FILE iv_file = DATA_FOLDER + USERNAME + IV_FILE key_file = DATA_FOLDER + USERNAME + KEY_FILE message_file = DATA_FOLDER + USERNAME + MESSAGE_FILE #Generate data files from PCAP files pcap.getPasswd(PASWWD_PCAP, passwd_file) pcap.getIV(IV_PCAP, iv_file) pcap.getZip(KEY_PCAP, key_file) pcap.getCipherMessage(MESSAGE_PCAP, message_file) #----------------------------NSA Request-------------------------------- #Obtain encrypted password cryptFile = open(passwd_file, "r") cryptedPass = cryptFile.readline().strip() + ' ' #!!!Later on change port to be random and check if its used #Send request in a child process userProcess = mp.Process(target=nsa.NSA_user, args=((LOCAL_HOST, LOCAL_PORT, cryptedPass))) userProcess.start() #Listener passwd_plain = OUT_FOLDER + USERNAME + PASSWORD_PLAIN nsa.NSA_listener('', LOCAL_PORT, passwd_plain) #Join child process userProcess.join() #--------------------------Unzip Key---------------------------- #Obtain password pFile = open(passwd_plain, "r") password = pFile.read() pFile.close() #Get the second part password = password.split(" ") password = password[1] password = password[:-1] print password #Unzip and create key file key_plain = OUT_FOLDER + USERNAME + KEY_PLAIN unzip.unzipFile(key_file, key_plain, password) #--------------------------Parse Key---------------------------- key_parsed = OUT_FOLDER + USERNAME + KEY_PARSED keyParser.keyParsing(key_plain, key_parsed) #--------------------------Decrypt--------------------------- key_parsed = OUT_FOLDER + USERNAME + KEY_PARSED decrypt.callDecryptShell(message_file, iv_file, key_parsed, DMSG_FOLDER)