I have a raw data of size nearly 10GB. I would like to find a text string and 
print the memory address at which it is stored.

This is my code

import os
import re
filename="filename.dmp"
read_data=2**24
searchtext="bd:mongo:"
he=searchtext.encode('hex')
with open(filename, 'rb') as f:
    while True:
        data= f.read(read_data)
        if not data:
            break
        elif searchtext in data:
            print "Found"
            try:
                offset=hex(data.index(searchtext))
                print offset
            except ValueError:
                print 'Not Found'                       
        else:
            continue


The address I am getting is
#0x2c0900
#0xb62300

But the actual positioning is
# 652c0900
# 652c0950
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to