Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions