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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started