Exemple #1
0
def main():
    GnuPG.main()  # initialises the GnuPG engine

    print("Do you wish to (e)ncrypt a message or (d)ecrypt a file?")
    choice = input("> ")

    if choice.lower() == "e":
        print("Please enter the Keybase username of the recipient")
        username = input(">")

        print("Please enter the email of the recipient")
        email = input(">")

        print("Please enter the path to the file you wish to encrypt and sign")
        path_to_file = input(">")

        print("%s %s %s" %
              (username, email, os.path.realpath(path_to_file)))  # DEBUG
        GnuPG.import_key(username)
        GnuPG.encrypt_message(path_to_file, email)
        file_size = os.path.getsize(path_to_file + '.gpg')

        gaps = getGaps(file_size)
        print(gaps)

        print(
            "Please enter the directory that you wish to place the outputted files (leave blank for this dir)"
        )
        path_to_output = input(">")
        if path_to_output == "":
            path_to_output = "./"

        GapFillerStego.place(path_to_file + '.gpg', gaps, path_to_output)

    elif choice.lower() == "d":
        print(
            "Please enter the path to the file you wish to check for encrypted content"
        )
        path_to_file = input(">")
        print(
            "Please enter the directory that you wish to place the outputted file (leave blank for this dir)"
        )
        path_to_output = input(">")
        if path_to_output == "":
            path_to_output = "./"

        print("%s" % (os.path.realpath(path_to_file)))
        ciphertext_path = GapFillerStego.retrieve(path_to_file, path_to_output)
        if ciphertext_path is not None:
            GnuPG.decrypt_message(ciphertext_path)
    elif choice.lower() == "exit":
        exit(0)
    else:
        print("Invalid input, please try again")
        main()
Exemple #2
0
def main():
    GnuPG.main()  # initialises the GnuPG engine
    gaps_placed = 0
    gaps_retrieved = 0

    print("Please enter the Keybase username of the recipient")
    username = input(">")

    if username == "auto1":  # Use this to automate multiple runs and reduce the amount of typing
        username = ""
        email = ""
        path_to_file = "out.txt"
        path_to_output = ""
    else:
        print("Please enter the email of the recipient")
        email = input(">")

        print("Please enter the path to the file you wish to encrypt and sign")
        path_to_file = input(">")

        print(
            "Please enter the directory that you wish to place the outputted files"
        )
        path_to_output = input(">")

    print("%s %s %s" %
          (username, email, os.path.realpath(path_to_file)))  # DEBUG
    GnuPG.import_key(username)
    GnuPG.encrypt_message(path_to_file, email)
    file_size = os.path.getsize(path_to_file + '.gpg')

    gaps = getGaps(file_size)
    print(gaps)
    gaps_placed = len(gaps)

    for x in gaps:
        GapFillerStego.place(path_to_file + '.gpg', [x], path_to_output)

    print(
        "Please enter the directory that you wish to place the outputted files"
    )
    msg_output = input(">")

    for root, dirs, files in os.walk(path_to_output):
        for name in files:  # for each file in path
            success = GapFillerStego.retrieve(os.path.join(root, name),
                                              os.path.realpath(msg_output))
            if success is not None:
                gaps_retrieved = gaps_retrieved + 1

    print("Gaps Placed - %s, Gaps Retrieved - %s, Percentage Recovered - %s" %
          (gaps_placed, gaps_retrieved,
           ((gaps_retrieved / gaps_placed) * 100)))