Python Forum
Changing Text in an .exe File
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Text in an .exe File
#1
Hi there,

I have a Program called SafelySurf V1.2, the Program is great it partially works, but it is quite old, so some of the Paths are wrong. The Program deletes temporary Internet Files, Internet Explorer History, Url Cache etc. But the Program was designed for Windows XP
And I have Windows 7 X64, so it doesn't delete the Files, as the Paths are wrong. One Path I would like to change would is :-

ASCII "C:\Windows\Temporary Internet Files\"

Which needs changing to :- ASCII "C:\Users\Edward\AppData\Local\Microsoft\Windows\Temporary Internet Files" and there are others that need changing. Is there a way, I can list those Paths and change them, to what they need changing to with Python ? How can I get Python to scan through the .exe File, looking for the paths that need changing ?

And if so could someone, show me some examples, or point me to some, that I could look at.

Any help would be appreciated

Regards

Eddie Winch
Reply
#2
You could create a dictionary with the keys as the current path and the values as the new path, step through each line of the file, check for the key, if it matches write the value to a new file, else write the existing line.
Reply
#3
Hi Yoriz,

Thanks for your reply, are there examples of that, that I could look at, on this Forum ?
Reply
#4
test.txt
Output:
stuff more stuff ASCII "C:\Windows\Temporary Internet Files\" other stuff
paths = {r'ASCII "C:\Windows\Temporary Internet Files\"':
         r'ASCII "C:\Users\Edward\AppData\Local\Microsoft\Windows\Temporary Internet Files\"'}

with open('test.txt', 'r') as infile, open('testout.txt', 'w') as outfile:
    for stuff in infile:
        stuff = stuff.strip()
        line = paths.get(stuff, stuff)
        outfile.write(f'{line}\n')
testout.txt
Output:
stuff more stuff ASCII "C:\Users\Edward\AppData\Local\Microsoft\Windows\Temporary Internet Files\" other stuff
Reply
#5
Thanks for that example Yoriz, How would I get the Code, to scan through the .exe File in Question ?
Reply
#6
you cant do that to an exe file, its a compiled file, just write the whole thing in python, it can delete files.
Reply
#7
Hi Yoriz,

I tried to use decompilers, i.e Programs like OllyDbg and IDA etc, to alter the Directory Paths, in the .exe File, it was a commercial Program, not made by me. But changing some paths, messed up the names of the other Paths, they would be partially overwritten. I am not sure of a way around this ?
Reply
#8
Hi Yoriz,

So is there no way of modifying the .exe File, i.e. changing the directory paths ? That is all I want to change, in the .exe File.
Reply
#9
When this thread started i mistakenly thought you was altering a text file that the exe referenced.
Do a google search 'how to alter an exe file'
Reply
#10
Thanks Yoriz, for your reply's, I will do that now.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020