Stripping Hex code from a plain text file in Python

0

I have a regshot text file that I am trying to clean up and move the necessary data into a new text file. I have a program that prints the registry entries that were changed and moved, but I can not remove the data after the colon which moves into hex data.

Code:

import re
import sys

#This allows you to specify the text file
#in commandline start of program.
with open(sys.argv[1], 'r') as f:
    for i in xrange(7):
        f.next()
    for line in f:
        #process(line)
        if ':' in line:
            #Remove unneeded hex data
            re.sub("\W+", "", line),
        #Print every line with \ on new file
        if '\\' in line:
            with open("completed.txt", "w") as f1:
                f1.write(line)
f.close
f1.close

Data sample:

HKU\S-1-5-21-230830461-2995936100-1910591732-1107\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\Subscriptions\280810\UpdateDrivenByExpiration: 0x00000001
HKU\S-1-5-21-230830461-2995936100-1910591732-1107\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\Subscriptions\280810\UpdateDrivenByExpiration: 0x00000000
HKU\S-1-5-21-230830461-2995936100-1910591732-1107\Software\Microsoft\Windows\CurrentVersion\Search\JumplistData\E7CF176E110C211B:  D6 1E 9E B8 B3 B7 D3 01
HKU\S-1-5-21-230830461-2995936100-1910591732-1107\Software\Microsoft\Windows\CurrentVersion\Search\JumplistData\E7CF176E110C211B:  08 64 2B 00 B4 B7 D3 01
python
plaintext
asked on Stack Overflow Mar 21, 2018 by theworstTM • edited Mar 21, 2018 by wwii

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0