self.padawan = InspectionPadawan(reader, heap)
self.prompt = "(grok) "
+ def do_da(self, address):
+ """
+ Print ASCII string starting at specified address.
+ """
+ address = int(address, 16)
+ string = ""
+ while self.reader.IsValidAddress(address):
+ code = self.reader.ReadU8(address)
+ if code < 128:
+ string += chr(code)
+ else:
+ break
+ address += 1
+ if string == "":
+ print "Not an ASCII string at %s" % self.reader.FormatIntPtr(address)
+ else:
+ print "%s\n" % string
+
def do_dd(self, address):
"""
Interpret memory at the given address (if available) as a sequence
else:
print "Page header is not available!"
- def do_da(self, address):
- """
- Print ASCII string starting at specified address.
- """
- address = int(address, 16)
- string = ""
- while self.reader.IsValidAddress(address):
- code = self.reader.ReadU8(address)
- if code < 128:
- string += chr(code)
- else:
- break
- address += 1
- if string == "":
- print "Not an ASCII string at %s" % self.reader.FormatIntPtr(address)
- else:
- print "%s\n" % string
-
def do_k(self, arguments):
"""
Teach V8 heap layout information to the inspector. This increases
"""
self.padawan.PrintKnowledge()
- def do_km(self, address):
+ def do_kd(self, address):
"""
Teach V8 heap layout information to the inspector. Set the first
- map-space page by passing any pointer into that page.
+ data-space page by passing any pointer into that page.
"""
address = int(address, 16)
page_address = address & ~self.heap.PageAlignmentMask()
- self.padawan.known_first_map_page = page_address
+ self.padawan.known_first_data_page = page_address
- def do_kd(self, address):
+ def do_km(self, address):
"""
Teach V8 heap layout information to the inspector. Set the first
- data-space page by passing any pointer into that page.
+ map-space page by passing any pointer into that page.
"""
address = int(address, 16)
page_address = address & ~self.heap.PageAlignmentMask()
- self.padawan.known_first_data_page = page_address
+ self.padawan.known_first_map_page = page_address
def do_kp(self, address):
"""
page_address = address & ~self.heap.PageAlignmentMask()
self.padawan.known_first_pointer_page = page_address
+ def do_list(self, smth):
+ """
+ List all available memory regions.
+ """
+ def print_region(reader, start, size, location):
+ print " %s - %s (%d bytes)" % (reader.FormatIntPtr(start),
+ reader.FormatIntPtr(start + size),
+ size)
+ print "Available memory regions:"
+ self.reader.ForEachMemoryRegion(print_region)
+
def do_s(self, word):
"""
Search for a given word in available memory regions. The given word
"""
raise NotImplementedError
- def do_list(self, smth):
+ def do_u(self, args):
"""
- List all available memory regions.
+ u 0x<address> 0x<size>
+ Unassemble memory in the region [address, address + size)
"""
- def print_region(reader, start, size, location):
- print " %s - %s (%d bytes)" % (reader.FormatIntPtr(start),
- reader.FormatIntPtr(start + size),
- size)
- print "Available memory regions:"
- self.reader.ForEachMemoryRegion(print_region)
-
+ args = args.split(' ')
+ start = int(args[0], 16)
+ size = int(args[1], 16)
+ lines = self.reader.GetDisasmLines(start, size)
+ for line in lines:
+ print FormatDisasmLine(start, self.heap, line)
+ print
EIP_PROXIMITY = 64