Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function hook triggered dumping #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The following are the main flags that can be used with fridump:
-r, --read-only dump read-only parts of memory. More data, more errors
-s, --strings run strings on all dump files. Saved in output dir.
--max-size bytes maximum size of dump file in bytes (def: 20971520)
--hook pattern ApiResolver pattern specifying functions to hook with memory dumping action
-n, --count maximum number of dumps to take

To find the name of a local process, you can use:

Expand All @@ -34,7 +36,8 @@ Examples:
fridump -u Safari - Dump the memory of an iOS device associated with the Safari app
fridump -u -s com.example.WebApp - Dump the memory of an Android device and run strings on all dump files
fridump -r -o [full_path] - Dump the memory of a local application and save it to the specified directory

fridump -n 3 --hook 'imports:*!write' - dump memory whenever an imported 'write' function is executed, limit to 3 times.

More examples can be found [here](http://pentestcorner.com/introduction-to-fridump/)

Installation
Expand Down
78 changes: 39 additions & 39 deletions dumper.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import os
import logging
# Reading bytes from session and saving it to a file
def dump_to_file(session,base,size,error,directory):
try:
filename = str(hex(base))+'_dump.data'
dump = session.read_bytes(base, size)
f = open(os.path.join(directory,filename), 'wb')
f.write(dump)
f.close()
return error
except:
print "Oops, memory access violation!"
return error
#Read bytes that are bigger than the max_size value, split them into chunks and save them to a file
def splitter(session,base,size,max_size,error,directory):
times = size/max_size
diff = size % max_size
if diff is 0:
logging.debug("Number of chunks:"+str(times+1))
else:
logging.debug("Number of chunks:"+str(times))
global cur_base
cur_base = base
for time in range(times):
logging.debug("Save bytes: "+str(hex(cur_base))+" till "+str(hex(cur_base+max_size)))
dump_to_file(session, cur_base, max_size, error, directory)
cur_base = cur_base + max_size
if diff is not 0:
logging.debug("Save bytes: "+str(hex(cur_base))+" till "+str(hex(cur_base+diff)))
dump_to_file(session, cur_base, diff, error, directory)
import os
import logging

# Reading bytes from session and saving it to a file

def dump_to_file(session,base,size,error,directory):
try:
filename = str(hex(base))+'_dump.data'
dump = session.read_bytes(base, size)
f = open(os.path.join(directory,filename), 'wb')
f.write(dump)
f.close()
return error
except:
print("Oops, memory access violation!")

return error

#Read bytes that are bigger than the max_size value, split them into chunks and save them to a file

def splitter(session,base,size,max_size,error,directory):
times = int(size/max_size)
diff = size % max_size
if diff is 0:
logging.debug("Number of chunks:"+str(times+1))
else:
logging.debug("Number of chunks:"+str(times))
global cur_base
cur_base = base

for time in range(times):
logging.debug("Save bytes: "+str(hex(cur_base))+" till "+str(hex(cur_base+max_size)))
dump_to_file(session, cur_base, max_size, error, directory)
cur_base = cur_base + max_size

if diff is not 0:
logging.debug("Save bytes: "+str(hex(cur_base))+" till "+str(hex(cur_base+diff)))
dump_to_file(session, cur_base, diff, error, directory)

Loading