예제 #1
0
def main():
    """
    A full command to obfuscate an application:

    python3 -m obfuscapk.cli -p -i -w /working/dir/path -d /path/to/obfuscated.apk \
    -o DebugRemoval -o LibEncryption -o CallIndirection -o MethodRename \
    -o AssetEncryption -o MethodOverload -o ConstStringEncryption \
    -o ResStringEncryption -o ArithmeticBranch -o FieldRename -o Nop -o Goto \
    -o ClassRename -o Reflection -o AdvancedReflection -o Reorder -o RandomManifest \
    -o Rebuild -o NewSignature -o NewAlignment \
    -o VirusTotal -k virus_total_key_1 -k virus_total_key_2 \
    /path/to/original.apk
    """

    # Verify that the external dependencies are available even before showing the help
    # message: this way, if the help message is displayed correctly it means that all
    # the needed external tools are available and ready to be used.
    check_external_tool_dependencies()

    arguments = get_cmd_args()

    if arguments.apk_file:
        arguments.apk_file = arguments.apk_file.strip(" '\"")

    if arguments.working_dir:
        arguments.working_dir = arguments.working_dir.strip(" '\"")

    if arguments.destination:
        arguments.destination = arguments.destination.strip(" '\"")

    if arguments.virus_total_key:
        arguments.virus_total_key = [
            key.strip(" '\"") for key in arguments.virus_total_key
        ]

    if arguments.keystore_file:
        arguments.keystore_file = arguments.keystore_file.strip(" '\"")

    if arguments.keystore_password:
        arguments.keystore_password = arguments.keystore_password.strip(" '\"")

    if arguments.key_alias:
        arguments.key_alias = arguments.key_alias.strip(" '\"")

    if arguments.key_password:
        arguments.key_password = arguments.key_password.strip(" '\"")

    perform_obfuscation(
        arguments.apk_file,
        arguments.obfuscator,
        arguments.working_dir,
        arguments.destination,
        arguments.interactive,
        arguments.ignore_libs,
        arguments.virus_total_key,
        arguments.keystore_file,
        arguments.keystore_password,
        arguments.key_alias,
        arguments.key_password,
    )
예제 #2
0
 def test_valid_external_tools(self):
     # If something is wrong an exception will be thrown and the test will fail.
     check_external_tool_dependencies()