MCPcopy
hub / github.com/Gallopsled/pwntools / read

Function read

pwnlib/adb/adb.py:610–641  ·  view source on GitHub ↗

Download a file from the device, and extract its contents. Arguments: path(str): Path to the file on the device. target(str): Optional, location to store the file. Uses a temporary file by default. callback(callable): See the documentation for ``a

(path, target=None, callback=None)

Source from the content-addressed store, hash-verified

608@context.quietfunc
609@with_device
610def read(path, target=None, callback=None):
611 """Download a file from the device, and extract its contents.
612
613 Arguments:
614 path(str): Path to the file on the device.
615 target(str): Optional, location to store the file.
616 Uses a temporary file by default.
617 callback(callable): See the documentation for
618 ``adb.protocol.AdbClient.read``.
619
620 Examples:
621
622 .. doctest::
623 :skipif: skip_android
624
625 >>> print(adb.read('/proc/version').decode('utf-8')) # doctest: +ELLIPSIS
626 Linux version ...
627 >>> adb.read('/does/not/exist')
628 Traceback (most recent call last):
629 ...
630 PwnlibException: Could not stat '/does/not/exist'
631 """
632 with AdbClient() as c:
633 stat = c.stat(path)
634 if not stat:
635 log.error('Could not stat %r' % path)
636 data = c.read(path, stat['size'], callback=callback)
637
638 if target:
639 misc.write(target, data)
640
641 return data
642
643@context.quietfunc
644@with_device

Callers 11

uptimeFunction · 0.70
boot_timeFunction · 0.70
pullFunction · 0.70
kallsymsMethod · 0.70
versionMethod · 0.70
cmdlineMethod · 0.70
lastmsgMethod · 0.70
dataMethod · 0.70
iter_proc_partitionsMethod · 0.70
mainFunction · 0.50
append_exampleFunction · 0.50

Calls 5

AdbClientClass · 0.90
errorMethod · 0.80
statMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected