Question: I need to develop a Python script to process the memory dump and identify unique strings of 5-12 characters along with the number of occurrences

I need to develop a Python script to process the memory dump and identify unique strings of 5-12 characters along with the number of occurrences of each unique string. Then display the resulting list of strings and occurrences in a prettytable sorted by the highest number of occurrences.

This is the code I have so far, but I am not quite sure where to go from here to get the output i need. Help would be greatly appreciated.

import sys import re from binascii import hexlify from prettytable import PrettyTable

#Regular expression wPatt = re.compile(b'[a-zA-Z]{5,12}')

# File Chunk Size CHUNK_SIZE = 10240

# Pretty Table

tbl = PrettyTable(['Words', 'Occurrences'])

''' Main Code '''

with open('mem.raw', 'rb') as binaryFile: # Opens the file as read-only binary while True: chunk = binaryFile.read(CHUNK_SIZE) if chunk: uniqueWords = wPatt.findall(chunk) wordDict = {}

for eachWord in uniqueWords: lowerCaseWord = eachWord.lower() try: occurrences = wordDict[lowerCaseWord] occurrences += 1 wordDict[lowerCaseWord] = occurrences except: wordDict[lowerCaseWord] = 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!