diff --git a/__pycache__/dumper.cpython-310.pyc b/__pycache__/dumper.cpython-310.pyc new file mode 100644 index 0000000..8c866bb Binary files /dev/null and b/__pycache__/dumper.cpython-310.pyc differ diff --git a/__pycache__/utils.cpython-310.pyc b/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000..4e99080 Binary files /dev/null and b/__pycache__/utils.cpython-310.pyc differ diff --git a/dumper.py b/dumper.py index 3e04e0e..4e580c0 100644 --- a/dumper.py +++ b/dumper.py @@ -21,7 +21,7 @@ def dump_to_file(agent,base,size,error,directory): def splitter(agent,base,size,max_size,error,directory): times = size/max_size diff = size % max_size - if diff is 0: + if diff == 0: logging.debug("Number of chunks:"+str(times+1)) else: logging.debug("Number of chunks:"+str(times)) @@ -33,7 +33,7 @@ def splitter(agent,base,size,max_size,error,directory): dump_to_file(agent, cur_base, max_size, error, directory) cur_base = cur_base + max_size - if diff is not 0: + if diff != 0: logging.debug("Save bytes: "+str(hex(cur_base))+" till "+str(hex(cur_base+diff))) dump_to_file(agent, cur_base, diff, error, directory) diff --git a/fridump.py b/fridump.py index e9a5dc2..e96113e 100644 --- a/fridump.py +++ b/fridump.py @@ -27,8 +27,7 @@ def MENU(): formatter_class=argparse.RawDescriptionHelpFormatter, description=textwrap.dedent("")) - parser.add_argument('process', - help='the process that you will be injecting to') + parser.add_argument('-A', '--appname', help='the application name that you will be injecting to', required=False) parser.add_argument('-o', '--out', type=str, metavar="dir", help='provide full output directory path. (def: \'dump\')') parser.add_argument('-U', '--usb', action='store_true', @@ -39,6 +38,7 @@ def MENU(): help="dump read-only parts of memory. More data, more errors") parser.add_argument('-s', '--strings', action='store_true', help='run strings on all dump files. Saved in output dir.') + parser.add_argument('-p', '--pid', help='attach direct to a process id', required=False) parser.add_argument('--max-size', type=int, metavar="bytes", help='maximum size of dump file in bytes (def: 20971520)') args = parser.parse_args() @@ -50,13 +50,14 @@ def MENU(): arguments = MENU() # Define Configurations -APP_NAME = arguments.process +APP_NAME = arguments.appname DIRECTORY = "" USB = arguments.usb DEBUG_LEVEL = logging.INFO STRINGS = arguments.strings MAX_SIZE = 20971520 PERMS = 'rw-' +pid = 0 if arguments.read_only: PERMS = 'r--' @@ -69,12 +70,25 @@ def MENU(): # Start a new Session session = None try: + if arguments.pid is not None: + pid = arguments.pid + pass + else: + for a in frida.get_usb_device().enumerate_applications(): + if a.identifier == APP_NAME: + pid = a.pid + break + pass + + print(f"[+] attaching to process with Id of {pid}") if USB: - session = frida.get_usb_device().attach(APP_NAME) + session = frida.get_usb_device().attach(int(pid)) else: - session = frida.attach(APP_NAME) + session = frida.attach(int(pid)) + except Exception as e: - print("Can't connect to App. Have you connected the device?") + print(e) + print("[-] Can't connect to App. Have you connected the device?") logging.debug(str(e)) sys.exit() @@ -83,22 +97,22 @@ def MENU(): if arguments.out is not None: DIRECTORY = arguments.out if os.path.isdir(DIRECTORY): - print("Output directory is set to: " + DIRECTORY) + print("[*] Output directory is set to: " + DIRECTORY) else: - print("The selected output directory does not exist!") + print("[*] The selected output directory does not exist!") sys.exit(1) else: - print("Current Directory: " + str(os.getcwd())) + print("[*] Current Directory: " + str(os.getcwd())) DIRECTORY = os.path.join(os.getcwd(), "dump") - print("Output directory is set to: " + DIRECTORY) + print("[*] Output directory is set to: " + DIRECTORY) if not os.path.exists(DIRECTORY): - print("Creating directory...") + print("[*] Creating directory...") os.makedirs(DIRECTORY) mem_access_viol = "" -print("Starting Memory dump...") +print("[+] Starting Memory dump...") script = session.create_script( """'use strict'; @@ -116,7 +130,7 @@ def MENU(): script.on("message", utils.on_message) script.load() -agent = script.exports +agent = script.exports_sync ranges = agent.enumerate_ranges(PERMS) if arguments.max_size is not None: diff --git a/utils.py b/utils.py index be6c0f6..ccb285d 100644 --- a/utils.py +++ b/utils.py @@ -20,6 +20,7 @@ def printProgress (times, total, prefix ='', suffix ='', decimals = 2, bar = 100 def strings(filename, directory, min=4): strings_file = os.path.join(directory, "strings.txt") path = os.path.join(directory, filename) + print(path) with open(path, encoding='Latin-1') as infile: str_list = re.findall("[\x20-\x7E]+\x00", infile.read()) with open(strings_file, "a") as st: