def main():
    if sys.version_info[0] != 3:
        print(ERROR_COLOUR + "[-] Intensio-Obfuscator only support Python 3.x")
        sys.exit(0)

    if sys.platform != "win32" and sys.platform != "linux":
        print(ERROR_COLOUR + "[-] This tool support [windows - Linux] only !")
        sys.exit(0)

    try:
        from core.utils.intensio_design import INTENSIO_BANNER
        from core.utils.intensio_utils import Utils
        from core.utils.intensio_usage import Args
        from core.utils.intensio_error  import EXIT_SUCCESS, ERROR_BAD_ENVIRONMENT, ERROR_INVALID_PARAMETER, \
                                                ERROR_BAD_ARGUMENTS, ERROR_INVALID_FUNCTION, ERROR_FILE_NOT_FOUND
        from core.obfuscation.intensio_replace import Replace
        from core.obfuscation.intensio_padding import Padding
        from core.obfuscation.intensio_analyze import Analyze
        from core.obfuscation.intensio_remove import Remove
    except ImportError as e:
        print(ERROR_COLOUR + "[-] {0}\n".format(e))
        sys.exit(0)

    args = Args()
    utils = Utils()

    if len(sys.argv) > 1 and len(sys.argv) <= 16:
        pass
    else:
        print(ERROR_COLOUR + "[-] Incorrect number of arguments\n")
        args.GetArgHelp()
        sys.exit(ERROR_BAD_ARGUMENTS)

    if args.GetArgsValue().input:
        if args.GetArgsValue().output:
            if args.GetArgsValue().code:
                if args.GetArgsValue().code == "python":
                    if args.GetArgsValue().mixerlevel:
                        if re.match(r"^lower$|^medium$|^high$",
                                    args.GetArgsValue().mixerlevel):
                            if not args.GetArgsValue().paddingscripts and not args.GetArgsValue().replacetostr \
                                and not args.GetArgsValue().removecommentaries and not args.GetArgsValue().removeprint \
                                and not args.GetArgsValue().replacetohex and not args.GetArgsValue().replacefilesname:
                                print(
                                    ERROR_COLOUR +
                                    "\n[-] Need at least one argument [-rts --replacetostr] or [-ps --paddingscripts] \
                                    or [-rc --removecommentaries] or [-rp --removeprint] or [-rth --replacetohex] or [-rfn, --replacefilesname]"
                                )
                                sys.exit(ERROR_BAD_ARGUMENTS)
                        else:
                            print(
                                ERROR_COLOUR +
                                "[-] Incorrect level of mixerlevel, [lower - medium - high] only supported\n"
                            )
                            sys.exit(ERROR_INVALID_PARAMETER)
                    else:
                        print(
                            ERROR_COLOUR +
                            "[-] Mixerlevel [-m --mixerlevel] argument missing\n"
                        )
                        sys.exit(ERROR_BAD_ARGUMENTS)
                else:
                    print(
                        ERROR_COLOUR +
                        "[-] '{0}' Incorrect code argument, [python] only supported\n"
                        .format(args.GetArgsValue().Code))
                    sys.exit(ERROR_INVALID_PARAMETER)
            else:
                print(ERROR_COLOUR + "[-] Code [-c --code] argument missing\n")
                sys.exit(ERROR_BAD_ARGUMENTS)
        else:
            print(ERROR_COLOUR + "[-] Output [-o --output] argument missing\n")
            sys.exit(ERROR_BAD_ARGUMENTS)
    else:
        print(ERROR_COLOUR + "[-] Input [-i --input] argument missing\n")
        sys.exit(ERROR_BAD_ARGUMENTS)

    for line in INTENSIO_BANNER.split("\n"):
        time.sleep(0.05)
        print(BANNER_COLOUR + line)

    # -- Analysis and set up of the work environment -- #
    print(
        SECTION_COLOUR +
        "\n\n*********************** [ Analyze and setup environment ] ************************\n"
    )
    analyzeData = Analyze()

    if (analyzeData.InputAvailable(
            args.GetArgsValue().input,
            args.GetArgsValue().code,
            args.GetArgsValue().verbose) == EXIT_SUCCESS):
        print("\n[+] Analyze input argument '{0}' -> ".format(
            args.GetArgsValue().input) + SUCESS_COLOUR + "Successful")
    else:
        print("[-] Analyze input '{0}' -> ".format(args.GetArgsValue().input) +
              FAILED_COLOUR + "failed\n")
        sys.exit(ERROR_INVALID_FUNCTION)

    if (analyzeData.OutputAvailable(
            args.GetArgsValue().input,
            args.GetArgsValue().code,
            args.GetArgsValue().output,
            args.GetArgsValue().verbose) == EXIT_SUCCESS):
        print("\n[+] Analyze and setup output argument environment '{0}' -> ".
              format(args.GetArgsValue().output) + SUCESS_COLOUR +
              "Successful")
    else:
        print(
            "[-] Analyze output '{0}' -> ".format(args.GetArgsValue().output) +
            FAILED_COLOUR + "failed\n")
        sys.exit(ERROR_INVALID_FUNCTION)

    # -- Obfuscation process -- #
    print(
        SECTION_COLOUR +
        "\n\n********************** [ Obfuscation remove commentaries ] **********************\n"
    )
    if args.GetArgsValue().removecommentaries:
        removeData = Remove()

        if (removeData.Commentaries(
                args.GetArgsValue().code,
                args.GetArgsValue().output) == EXIT_SUCCESS):
            print("[+] Obfuscation remove commentaries -> " + SUCESS_COLOUR +
                  "Successful")
        else:
            print("\n[-] Obfuscation remove commentaries -> " + FAILED_COLOUR +
                  "Failed")
    else:
        print("[!] Obfuscation remove commentaries no asked !")

    print(
        SECTION_COLOUR +
        "\n\n*************** [ Obfuscation replace strings to strings mixed ] ****************\n"
    )
    if args.GetArgsValue().replacetostr:
        replaceData = Replace()

        if (replaceData.StringsToStrings(
                args.GetArgsValue().code,
                args.GetArgsValue().output,
                args.GetArgsValue().mixerlevel,
                args.GetArgsValue().verbose) == EXIT_SUCCESS):
            print("[+] Obfuscation replace strings to strings mixed -> " +
                  SUCESS_COLOUR + "Successful")
        else:
            print("\n[-] Obfuscation replace strings to strings mixed -> " +
                  FAILED_COLOUR + "Failed")
    else:
        print("[!] Obfuscation replace strings to strings mixed no asked !")

    print(
        SECTION_COLOUR +
        "\n\n************************ [ Obfuscation padding scripts ] ************************\n"
    )
    if args.GetArgsValue().paddingscripts:
        paddingData = Padding()

        if (paddingData.AddRandomScripts(
                args.GetArgsValue().code,
                args.GetArgsValue().output,
                args.GetArgsValue().mixerlevel) == EXIT_SUCCESS):
            print("[+] Obfuscation padding random scripts -> " +
                  SUCESS_COLOUR + "Successful")
        else:
            print("\n[-] Obfuscation padding random scripts -> " +
                  FAILED_COLOUR + "Failed")
    else:
        print("[!] Obfuscation add random scripts no asked !")

    print(
        SECTION_COLOUR +
        "\n\n************************* [ Obfuscation remove print ] **************************\n"
    )
    if args.GetArgsValue().removeprint:

        if (removeData.PrintFunctions(
                args.GetArgsValue().code,
                args.GetArgsValue().output) == EXIT_SUCCESS):
            print("[+] Obfuscation remove print functions -> " +
                  SUCESS_COLOUR + "Successful")
        else:
            print("\n[-] Obfuscation remove print functions -> " +
                  FAILED_COLOUR + "Failed")
    else:
        print("[!] Obfuscation remove print functions no asked !")

    print(
        SECTION_COLOUR +
        "\n\n********************** [ Obfuscation replace files name ] ***********************\n"
    )
    if args.GetArgsValue().replacefilesname:
        if args.GetArgsValue().replacetostr:
            pass
        else:
            replaceData = Replace()

        if (replaceData.FilesName(
                args.GetArgsValue().code,
                args.GetArgsValue().output,
                args.GetArgsValue().mixerlevel,
                args.GetArgsValue().verbose) == EXIT_SUCCESS):
            print("\n[+] Obfuscation replace files name -> " + SUCESS_COLOUR +
                  "Successful")
        else:
            print("\n[-] Obfuscation replace files name -> " + FAILED_COLOUR +
                  "Failed")
    else:
        print("[!] Obfuscation replace files name no asked !")

    print(
        SECTION_COLOUR +
        "\n\n******************** [ Obfuscation replace strings to hex ] *********************\n"
    )
    if args.GetArgsValue().replacetohex:
        if args.GetArgsValue().replacetostr or args.GetArgsValue(
        ).replacefilesname:
            pass
        else:
            replaceData = Replace()

        if (replaceData.StringsToHex(
                args.GetArgsValue().code,
                args.GetArgsValue().output,
                args.GetArgsValue().mixerlevel) == EXIT_SUCCESS):
            print("\n[+] Obfuscation replace strings to hex -> " +
                  SUCESS_COLOUR + "Successful\n")
        else:
            print("\n[-] Obfuscation replace strings to hex -> " +
                  FAILED_COLOUR + "Failed\n")
    else:
        print("[!] Obfuscation replace strings to hex no asked !\n")

    # -- Remove if python pyc file(s) in output directory -- #
    if (removeData.TrashFiles(args.GetArgsValue().code,
                              args.GetArgsValue().output) >= 0):
        pass
    else:
        print(
            SECTION_COLOUR +
            "\n**************************** [ Remove pyc files ] *****************************\n"
        )
        print("\n[-] Remove .pyc files in {0} directory -> " + FAILED_COLOUR +
              "Failed\n".format(args.GetArgsValue().output))
Ejemplo n.º 2
0
def main():
    if sys.version_info[0] != 3:
        print("[-] Intensio-Obfuscator only support Python 3.x")
        sys.exit(0)

    if sys.platform != "win32" and sys.platform != "linux":
        print("[-] This tool support [windows - Linux] only !")
        sys.exit(0)

    try:
        from core.utils.intensio_design import INTENSIO_BANNER
        from core.utils.intensio_utils import Utils
        from core.utils.intensio_usage import Args
        from core.utils.intensio_error import EXIT_SUCCESS, ERROR_BAD_ENVIRONMENT, ERROR_INVALID_PARAMETER, ERROR_BAD_ARGUMENTS,\
                                                ERROR_INVALID_FUNCTION, ERROR_FILE_NOT_FOUND
        from core.obfuscation.intensio_replace import ReplaceWords
        from core.obfuscation.intensio_padding import Padding
        from core.obfuscation.intensio_analyze import Analyze
        from core.obfuscation.intensio_remove import Remove
    except ImportError as e:
        print("[-] {0}\n".format(e))
        sys.exit(0)

    args = Args()
    utils = Utils()

    if len(sys.argv) > 1 and len(sys.argv) <= 14:
        pass
    else:
        print("[-] Incorrect number of arguments\n")
        args.GetArgHelp()
        sys.exit(ERROR_BAD_ARGUMENTS)

    if args.GetArgsValue().input:
        if args.GetArgsValue().output:
            if args.GetArgsValue().code:
                if re.match(r"^python$", args.GetArgsValue().code):
                    if args.GetArgsValue().mixerlevel:
                        if re.match(r"^lower$|^medium$|^high$",
                                    args.GetArgsValue().mixerlevel):
                            if not args.GetArgsValue().padding and not args.GetArgsValue().replace \
                                and not args.GetArgsValue().rcommentaries and not args.GetArgsValue().rprint:
                                print(
                                    "\n[-] Need at least one argument [-r --replace] or [-p --padding] or [-rc --rcommentaries] or [-rp --rprint]"
                                )
                                sys.exit(ERROR_BAD_ARGUMENTS)
                        else:
                            print(
                                "[-] Incorrect level of mixerlevel, [lower - medium - high] only supported\n"
                            )
                            sys.exit(ERROR_INVALID_PARAMETER)
                    else:
                        print(
                            "[-] Mixerlevel [-m --mixerlevel] argument missing\n"
                        )
                        sys.exit(ERROR_BAD_ARGUMENTS)
                else:
                    print(
                        "[-] '{0}' Incorrect code argument, [python] only supported\n"
                        .format(args.GetArgsValue().Code))
                    sys.exit(ERROR_INVALID_PARAMETER)
            else:
                print("[-] Code [-c --code] argument missing\n")
                sys.exit(ERROR_BAD_ARGUMENTS)
        else:
            print("[-] Output [-o --output] argument missing\n")
            sys.exit(ERROR_BAD_ARGUMENTS)
    else:
        print("[-] Input [-i --input] argument missing\n")
        sys.exit(ERROR_BAD_ARGUMENTS)

    for line in INTENSIO_BANNER.split("\n"):
        time.sleep(0.05)
        print(line)

    # -- Analysis and set up of the work environment -- #
    print(
        "\n\n*********************** [ Analyze and setup environment ] ************************\n"
    )
    analyze = Analyze()

    if (analyze.InputAvailable(args.GetArgsValue().input,
                               args.GetArgsValue().code,
                               args.GetArgsValue().verbose) == EXIT_SUCCESS):
        print("\n[+] Analyze input argument '{0}' -> Successful".format(
            args.GetArgsValue().input))
    else:
        print("[-] Analyze input '{0}' failed\n".format(
            args.GetArgsValue().input))
        sys.exit(ERROR_INVALID_FUNCTION)

    if (analyze.OutputAvailable(args.GetArgsValue().input,
                                args.GetArgsValue().code,
                                args.GetArgsValue().output,
                                args.GetArgsValue().verbose) == EXIT_SUCCESS):
        print(
            "\n[+] Analyze and setup output argument environment '{0}' -> Successful"
            .format(args.GetArgsValue().output))
    else:
        print("[-] Analyze output '{0}' failed\n".format(
            args.GetArgsValue().output))
        sys.exit(ERROR_INVALID_FUNCTION)

    # -- Obfuscation process -- #
    print(
        "\n\n************************** [ Obfuscation Rcommentaries ] **************************\n"
    )
    if args.GetArgsValue().rcommentaries:
        removeData = Remove()

        if (removeData.Commentaries(
                args.GetArgsValue().code,
                args.GetArgsValue().output) == EXIT_SUCCESS):
            print("[+] Obfuscation Rcommentaries -> Successful")
        else:
            print("\n[-] Obfuscation Rcommentaries -> Failed")
    else:
        print("[!] Obfuscation Rcommentaries no asked !")

    print(
        "\n\n***************************** [ Obfuscation Replace ] *****************************\n"
    )
    if args.GetArgsValue().replace:
        replaceWords = ReplaceWords()

        if (replaceWords.VarsDefinedByUser(
                args.GetArgsValue().code,
                args.GetArgsValue().output,
                args.GetArgsValue().mixerlevel,
                args.GetArgsValue().verbose) == EXIT_SUCCESS):
            print("[+] Obfuscation Replace -> Successful")
        else:
            print("\n[-] Obfuscation Replace -> Failed")
    else:
        print("[!] Obfuscation Replace no asked !")

    print(
        "\n\n***************************** [ Obfuscation Padding ] *****************************\n"
    )
    if args.GetArgsValue().padding:
        paddingScripts = Padding()

        if (paddingScripts.AddScripts(
                args.GetArgsValue().code,
                args.GetArgsValue().output,
                args.GetArgsValue().mixerlevel) == EXIT_SUCCESS):
            print("[+] Obfuscation Padding -> Successful")
        else:
            print("\n[-] Obfuscation Padding -> Failed")
    else:
        print("[!] Obfuscation Padding no asked !")

    print(
        "\n\n****************************** [ Obfuscation Rprint ] *****************************\n"
    )
    if args.GetArgsValue().rprint:

        if (removeData.PrintFunc(args.GetArgsValue().code,
                                 args.GetArgsValue().output) == EXIT_SUCCESS):
            print("[+] Obfuscation Rprint -> Successful\n")
        else:
            print("\n[-] Obfuscation Rprint -> Failed\n")
    else:
        print("[!] Obfuscation Rprint no asked !\n")
def main():
    if sys.version_info[0] != 3:
        print("[-] Intensio-Obfuscator only support Python 3.x")
        sys.exit(0)

    if sys.platform != "win32" and sys.platform != "linux":
        print("[-] This tool support [windows - Linux] only !")
        sys.exit(0)

    try:
        from core.lolz.intensio_bullshit import BestFunctionOfTheWorld
        from core.lolz.intensio_design_skill import INTENSIO_BANNER
        from core.utils.intensio_utils import Utils
        from core.utils.intensio_usage import Args
        from core.utils.intensio_error import EXIT_SUCCESS, ERROR_BAD_ENVIRONMENT, ERROR_INVALID_PARAMETER, ERROR_BAD_ARGUMENTS,\
                                                ERROR_INVALID_FUNCTION, ERROR_FILE_NOT_FOUND
        from core.obfuscation.intensio_replace import Replace
        from core.obfuscation.intensio_padding import Padding
        from core.obfuscation.intensio_analyze import Analyze
        from core.obfuscation.intensio_remove import Remove
    except ImportError as e:
        print("[-] {0}\n".format(e))
        sys.exit(0)

    args    = Args()
    utils   = Utils()

    if len(sys.argv) > 1 and len(sys.argv) <= 14:
        if args.GetArgsValue().onefile == False and args.GetArgsValue().multiplefiles == False:
            print("[-] [-f --onefile] or [-d --multiple] argument unspecifed")
            sys.exit(ERROR_BAD_ARGUMENTS)

        if args.GetArgsValue().input:
            if args.GetArgsValue().output:
                for line in INTENSIO_BANNER.split("\n"):
                    time.sleep(0.05)
                    print(line)

                if args.GetArgsValue().secret:
                    if (BestFunctionOfTheWorld("YES-YES-YES!!") == EXIT_SUCCESS):
                        pass
                    else:
                        sys.exit(ERROR_INVALID_FUNCTION)

                print("\n\n*********************** [ Analyze and setup environment ] ***********************\n")
                # -- Analysis and set up of the work environment -- #
                if args.GetArgsValue().code:
                    if re.match(r"^python$", args.GetArgsValue().code):
                        analyze = Analyze()

                        if (analyze.InputAvailable(args.GetArgsValue().onefile, args.GetArgsValue().input, args.GetArgsValue().code) == EXIT_SUCCESS):
                            print("[+] Analyze input argument '{0}' -> Successful".format(args.GetArgsValue().input))

                            if (analyze.OutputAvailable(args.GetArgsValue().onefile, args.GetArgsValue().input, args.GetArgsValue().code, args.GetArgsValue().output) == EXIT_SUCCESS):
                                print("[+] Analyze and setup output argument environment '{0}' -> Successful".format(args.GetArgsValue().output))

                                if args.GetArgsValue().mixer:
                                    if re.match(r"(^lower$)|(^medium$)|(^high$)", args.GetArgsValue().mixer):
                                        if not args.GetArgsValue().padding and not args.GetArgsValue().replace and not args.GetArgsValue().remove:
                                            print("\n[-] Need at least one argument [-r --replace] or [-p --padding] or [-rm -remove]")
                                            sys.exit(ERROR_BAD_ARGUMENTS)
                                        else:
                                            print("\n\n***************************** [ Obfuscation Replace ] ****************************\n")
                                            if args.GetArgsValue().replace:
                                                replace = Replace()

                                                if (replace.VarsDefinedByUser(args.GetArgsValue().onefile, args.GetArgsValue().code, args.GetArgsValue().output, args.GetArgsValue().mixer) == EXIT_SUCCESS):
                                                    print("[+] Obfuscation Replace -> Successful")
                                                else:
                                                    print("[-] Obfuscation Replace -> Failed")
                                            else:
                                                print("[!] Obfuscation Replace no asked !")

                                            print("\n\n***************************** [ Obfuscation Padding ] ****************************\n")
                                            if args.GetArgsValue().padding:
                                                paddingScripts = Padding()

                                                if (paddingScripts.AddScripts(args.GetArgsValue().onefile, args.GetArgsValue().code, args.GetArgsValue().output, args.GetArgsValue().mixer) == EXIT_SUCCESS):
                                                    print("[+] Obfuscation Padding -> Successful")
                                                else:
                                                    print("[-] Obfuscation Padding -> Failed")
                                            else:
                                                print("[!] Obfuscation Padding no asked !")

                                            print("\n\n***************************** [ Obfuscation Remove ] *****************************\n")
                                            if args.GetArgsValue().remove:
                                                removeData = Remove()

                                                if (removeData.Commentaries(args.GetArgsValue().onefile, args.GetArgsValue().code, args.GetArgsValue().output) == EXIT_SUCCESS):
                                                    print("[+] Obfuscation Remove -> Successful\n")
                                                else:
                                                    print("[-] Obfuscation Remove -> Failed\n")
                                            else:
                                                print("[!] Obfuscation Remove no asked !\n")
                                    else:
                                        print("[-] Incorrect level of mixer, [lower - medium - high] only supported\n")
                                        sys.exit(ERROR_INVALID_PARAMETER)
                                else:
                                    print("[-] Mixer [-m --mixer] argument missing\n")
                                    sys.exit(ERROR_BAD_ARGUMENTS)
                            else:
                                print("[-] Analyze output '{0}' failed\n".format(args.GetArgsValue().output))
                                sys.exit(ERROR_INVALID_FUNCTION)
                        else:
                            print("[-] Analyze input '{0}' failed\n".format(args.GetArgsValue().input))
                            sys.exit(ERROR_INVALID_FUNCTION)
                    else:
                        print("[-] '{0}' Incorrect code argument, [python] only currently supported\n".format(args.GetArgsValue().Code))
                        sys.exit(ERROR_INVALID_PARAMETER)
                else:
                    print("[-] Code [-c --code] argument missing\n")
                    sys.exit(ERROR_BAD_ARGUMENTS)
            else:
                print("[-] Output [-o --output] argument missing\n")
                sys.exit(ERROR_BAD_ARGUMENTS)
        else:
            print("[-] Input [-i --input] argument missing\n")
            sys.exit(ERROR_BAD_ARGUMENTS)
    else:
        print("[-] Incorrect number of arguments\n")
        args.GetArgHelp()
        sys.exit(ERROR_BAD_ARGUMENTS)