mirror of https://github.com/pwndbg/pwndbg.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
703 B
Python
30 lines
703 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
import gdb
|
|
import gef.remote
|
|
import tempfile
|
|
|
|
def get(path):
|
|
"""
|
|
Retrieves the contents of the specified file on the system
|
|
where the current process is being debugged.
|
|
|
|
Returns:
|
|
A byte array, or None.
|
|
"""
|
|
local_path = path
|
|
|
|
if gef.remote.is_remote():
|
|
local_path = tempfile.mktemp()
|
|
error = gdb.execute('remote get %s %s' % (path, local_path),
|
|
to_string=True)
|
|
|
|
if error:
|
|
raise OSError("Could not download remote file %r:\n" \
|
|
"Error: %s" % (path, error))
|
|
|
|
with open(local_path,'rb') as f:
|
|
return f.read()
|
|
|
|
|