def DecloakifyFile( cloakedFile, cipherFilePath ):

	decloakedFile = raw_input( "Save decloaked data to filename (default: 'decloaked.file'): " )

	if decloakedFile == "":
		decloakedFile = "decloaked.file"

	try:
		decloakify.Decloakify( cloakedFile, cipherFilePath, decloakedFile )

		print ""
		print "File '" + cloakedFile + "' decloaked and saved to '" + decloakedFile + "'"
		print ""
	except:
		print ""
		print "!!! Oh noes! Error decloaking file (did you select the same cipher it was cloaked with?)"
		print ""

	choice = raw_input("Press return to continue... ")

	return
def DecloakifyFile():

    decloakTempFile = "decloakTempFile.txt"

    print ""
    print "====  Decloakify a Cloaked File  ===="
    print ""
    sourceFile = raw_input(
        "Enter filename to decloakify (e.g. /foo/bar/MyBoringList.txt): ")
    print ""
    decloakedFile = raw_input(
        "Save decloaked data to filename (default: 'decloaked.file'): ")
    print ""

    if decloakedFile == "":
        decloakedFile = "decloaked.file"

    # Reviewing the cloaked file within cloakifyFactory will save a little time for those who
    # forgot the format of the cloaked file and don't want to hop into a new window just to look

    choice = raw_input("Preview cloaked file? (y/n default=n): ")

    if choice == "y":
        print ""

        try:
            with open(sourceFile) as file:
                cloakedPreview = file.readlines()
                i = 0
                while (i < 20):
                    print cloakedPreview[i],
                    i = i + 1
            print ""
        except:
            print ""
            print "!!! Well that didn't go well. Verify that '", sourceFile, "'"
            print "!!! is in the current working directory or the filepath you gave."
            print ""

    choice = raw_input(
        "Was noise added to the cloaked file? (y/n default=n): ")

    if choice == "y":
        noiseNum = SelectNoise()

        stripColumns = 2

        # No upper bound checking, relies on SelectNoise() returning valid value, fix in next release
        if noiseNum >= 0:
            try:
                # Remove Noise, overwrite the source file with the stripped contents
                print "Removing noise from noise generator:", gNoiseScripts[
                    noiseNum]
                os.system("./removeNoise.py %s %s %s" %
                          (stripColumns, sourceFile, decloakTempFile))

                # Copy decloak temp filename to sourceFile so that Decloakify() gets the right filename
                sourceFile = decloakTempFile
            except:
                print "!!! Error while removing noise from file. Was calling 'removeNoise.py'.\n"

    cipherNum = SelectCipher()

    print "Decloaking file using cipher: ", gCipherFiles[cipherNum]

    # Call Decloakify()
    try:
        decloakify.Decloakify(sourceFile, "ciphers/" + gCipherFiles[cipherNum],
                              decloakedFile)

        print ""
        print "Decloaked file", sourceFile, ", saved to", decloakedFile
    except:
        print ""
        print "!!! Oh noes! Error decloaking file (did you select the same cipher it was cloaked with?)"
        print ""

    try:
        os.system("rm -f %s" % (decloakTempFile))
    except:
        print ""
        print "!!! Oh noes! Error while deleting temporary file:", decloakTempFile
        print ""

    choice = raw_input("Press return to continue... ")
Exemple #3
0
def DecloakifyFile():

	decloakTempFile = "decloakTempFile.txt"

	print("")
	print("====  Decloakify a Cloaked File  ====")
	print("")
	sourceFile = input("Enter filename to decloakify (e.g. /foo/bar/MyBoringList.txt): ")
	print("")
	decloakedFile = input("Save decloaked data to filename (default: 'decloaked.file'): ")
	print("")

	if decloakedFile == "":
		decloakedFile = "decloaked.file"

	# Reviewing the cloaked file within cloakifyFactory will save a little time for those who
	# forgot the format of the cloaked file and don't want to hop into a new window just to look

	choice = input("Preview cloaked file? (y/n default=n): ")

	if choice == "y":
		print("")
		try:
			with open(sourceFile, encoding="utf-8") as file:
				for _ in range(20):
					print(file.readline())
			print("")
		except:
			print("")
			print("!!! Well that didn't go well. Verify that '", sourceFile, "'")
			print("!!! is in the current working directory or the filepath you gave.")
			print("")
		
	choice = input("Was noise added to the cloaked file? (y/n default=n): ")

	if choice == "y":
		noisePath = SelectFile(gNoiseScripts, NOISE_GENERATOR)

		stripColumns = 2

		# No upper bound checking, relies on SelectNoise() returning valid value, fix in next release
		try:
			# Remove Noise, overwrite the source file with the stripped contents
			print(f"Removing noise from cloaked file.")
			removeNoise(stripColumns, sourceFile, decloakTempFile)

			# Copy decloak temp filename to sourceFile so that Decloakify() gets the right filename
			sourceFile = decloakTempFile
		except:
			print("!!! Error while removing noise from file.\n")

	cipherPath = SelectFile(gCipherFiles, CIPHER)

	choice = input("Was a password used for this file? (y/n default=n): ")

	password = None
	if choice == "y":
		password = getPassword()

	print(f"Decloaking file using cipher: {cipherPath}")

	# Call Decloakify()
	try:
		decloakify.Decloakify(sourceFile, os.path.join(".", "ciphers", cipherPath), decloakedFile, password)

		print("")
		print(f"Decloaked file {sourceFile}, saved to {decloakedFile}")
	except:
		print("")
		print("!!! Oh noes! Error decloaking file (did you select the same cipher it was cloaked with?)")
		print("")

	try:
		os.remove(decloakTempFile)
	except:
		print("")
		print("!!! Oh noes! Error while deleting temporary file:", decloakTempFile)
		print("")

	choice = input("Press return to continue... ")