Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

Hac4u samakshkaushik at gmail.com
Mon Apr 23 13:24:20 EDT 2018


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


More information about the Python-list mailing list