MCPcopy Create free account
hub / github.com/HexHive/NASS / do_invoke

Method do_invoke

tools/gef.py:5645–5699  ·  view source on GitHub ↗
(self, argv: List[str])

Source from the content-addressed store, hash-verified

5643
5644 @only_if_gdb_running
5645 def do_invoke(self, argv: List[str]) -> None:
5646 if len(argv) != 2:
5647 self.usage()
5648 return
5649
5650 haystack = argv[0]
5651 needle = argv[1]
5652
5653 info(f"Searching for addresses in '{Color.yellowify(haystack)}' "
5654 f"that point to '{Color.yellowify(needle)}'")
5655
5656 if haystack == "binary":
5657 haystack = get_filepath()
5658
5659 if needle == "binary":
5660 needle = get_filepath()
5661
5662 needle_sections = []
5663 haystack_sections = []
5664
5665 if "0x" in haystack:
5666 start, end = parse_string_range(haystack)
5667 haystack_sections.append((start, end, ""))
5668
5669 if "0x" in needle:
5670 start, end = parse_string_range(needle)
5671 needle_sections.append((start, end))
5672
5673 for sect in gef.memory.maps:
5674 if haystack in sect.path:
5675 haystack_sections.append((sect.page_start, sect.page_end, os.path.basename(sect.path)))
5676 if needle in sect.path:
5677 needle_sections.append((sect.page_start, sect.page_end))
5678
5679 step = gef.arch.ptrsize
5680 unpack = u32 if step == 4 else u64
5681
5682 for hstart, hend, hname in haystack_sections:
5683 try:
5684 mem = gef.memory.read(hstart, hend - hstart)
5685 except gdb.MemoryError:
5686 continue
5687
5688 for i in range(0, len(mem), step):
5689 target = unpack(mem[i:i+step])
5690 for nstart, nend in needle_sections:
5691 if target >= nstart and target < nend:
5692 deref = DereferenceCommand.pprint_dereferenced(hstart, int(i / step))
5693 if hname != "":
5694 name = Color.colorify(hname, "yellow")
5695 gef_print(f"{name}: {deref}")
5696 else:
5697 gef_print(f" {deref}")
5698
5699 return
5700
5701
5702@register

Callers

nothing calls this directly

Calls 9

infoFunction · 0.85
get_filepathFunction · 0.85
parse_string_rangeFunction · 0.85
gef_printFunction · 0.85
usageMethod · 0.80
yellowifyMethod · 0.80
pprint_dereferencedMethod · 0.80
colorifyMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected