Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the hard-coded database password of a Delphi program that I can't recompile? [closed]

I have a Delphi application that I cannot recompile.

In the process of moving the database to a new SQL Server version, I want to change the database password so it's no longer blank. The problem is that the application has the database credentials embedded in the .exe.

Is there any way that I can change the password?

Server name and database name are configurable.

like image 834
e4rthdog Avatar asked Jul 09 '15 09:07

e4rthdog


2 Answers

If the connection string was saved in the TADOConnection component in design mode, Your best choice is to use Resource editor such as Resource Hacker.

The forms or data modules DFM are found in the RCData section. just change the connection string and use "Compile script". This will save your changes back to the EXE file without the worry of corrupting the EXE.

I assume your EXE is not packed (PE packer) or digitally signed.

enter image description here

like image 131
kobik Avatar answered Sep 20 '22 13:09

kobik


Below is a screenshot of part of a D7 .Exe of mine showing the relevant part of its Ado ConnectionString.

I used an antique file viewer (from the example apps accompanying an old TurboPower library) to take the screenshot. I just loaded the file into it, entered "persist" as the search string and skipped a couple of TPersistent instances to locate it.

Of course, you could use any old hex file-editor to do similar and change it, provided the .Exe isn't compressed or protected against tampering by checksums, etc.

You'll probably need to experiment a bit, & compare with another app which has a non-blank password so that you can come up with some new credentials that'll fit into the space available in the .Exe's disk image.

enter image description here

like image 44
MartynA Avatar answered Sep 19 '22 13:09

MartynA