How to replace constant on compiled executable?

Just starting out? Need help? Post your questions and find answers here.
stmdbe2019
User
User
Posts: 89
Joined: Mon Aug 31, 2009 2:11 pm

How to replace constant on compiled executable?

Post by stmdbe2019 »

I have PureBasic compiled executable which has following variable.

Code: Select all

Global URL_POST$ = "https://www.myserver.com/stream/userid=1"
after running the application for 5 minute how to replace the value of URL_POST$ or remove URL_POST$ on the executable permanently? Its only for one time use executable.

Scenario:

1 - AGENT1 call center over phone with CLIENT1 random
2 - CLIENT1 over phone need the service from AGENT1 so he execute the stream tool for 5 minute
3 - after 5 minute CLIENT1 and AGENT1 is disconnected/session is over. CLIENT1 restarted the executable second time
4 - second time CLIENT1 should not be able to reach to the URL "https://www.myserver.com/stream/userid=1"
5 - AGENT1 is connected with CLIENT2 (same procedure follows)

Is there a way to remove the URL on the compiled executable of CLIENT1?
-----
Registered PureBasic Coder.
User avatar
Kukulkan
Addict
Addict
Posts: 1348
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: How to replace constant on compiled executable?

Post by Kukulkan »

Hi Shamun,

I know this is not what you asked for, but you should consider using a ticket system instead. In your case, you have to re-compile new executables all the time. Including code signature (to let it work with AV scanners) and the need for a Windows Webserver because the PB compiler needs Windows to compile a Windows executable. Sound like a nightmare to me...

Why don't you deliver the same executable all the time? It may simply ask the user to enter a token number. So your executable is using this token for some URL like https://www.myserver.com/stream/token=R24T981H. Of course, the token is only valid for a limited time and this has to be handled server side. This also is much more secure. Ant this is much more easy than compiling new executables all the time. Just my 2 cents...
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: How to replace constant on compiled executable?

Post by nco2k »

modifying the executable is easy. but this question and some of your other questions sound pretty shady. if you are offering some sort of service, then you shouldnt care about the executable itself. you could simply block out the user (when needed) from your end. but this sounds like you are only trying to cover your tracks or whatever.

that being said, i fully agree with kukulkan. if you are not doing anything shady, use a method that doesnt resemble ransomware.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: How to replace constant on compiled executable?

Post by Fig »

Last time i tried auto-modifiable code, it worked only on x86 hardware architecture. On x64 it seams not to be allowed by design.
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: How to replace constant on compiled executable?

Post by walbus »

I use something similar to replace a hash in an exe.
This assigns the file to a defined user
The way is:
Create a fixed string, the string beginns as sample so:
"Search_me___:"+"Space (50)
Then you can search in the exe and replace the spaces with a URL
With necessary rights or feasibility you have to see for yourself
The file is searched from the back to the front
In terms of implementation, it is not very difficult
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: How to replace constant on compiled executable?

Post by Dude »

nco2k wrote:modifying the executable is easy
And pointless. The user can just copy the original exe and run the copy each time. So there's no point Shamun doing what he's asking, as it won't achieve any security.
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: How to replace constant on compiled executable?

Post by walbus »

I use it for QUICK-AES-256 (QAES)
You can choose a password that will be converted to SHA3 hash.
This hash is internal used as an additional key
This change can also be reversed.
But if the hash is changed in the exe, nobody in this world with a different QAES version can your encrypted data brute force
This is ultimate protection for encrypted data in the cloud :o
You can also remove the hash after encrypting.
It is then no longer possible to decrypt something without setting this hash before.
Many years ago, software was personalized with it, without a personalized and valid hash, the software was not executable.
stmdbe2019
User
User
Posts: 89
Joined: Mon Aug 31, 2009 2:11 pm

Re: How to replace constant on compiled executable?

Post by stmdbe2019 »

Thanks for the feedback. According to the project requirement i cant ask for a token (which would have made my life easier). What i understood is that we cant do it. In such case i will remove the executable after 5 minute from the disk, so that i have less risk that CLIENT1 can re-execute it while CLIENT2 is connected with AGENT1.

PureBasic server does following:

1. Midnight compile .exe for each AGENT1 till 200 for OSX, Windows.
2. Compiled .exe's are autmatically code signed

3. When CLEINT1 till CLIENT500 request support they get the static compiled .exe
4. after running the .exe in CLIENTxx desktop it kills itself within the predefined constant duration.
-----
Registered PureBasic Coder.
User avatar
Kukulkan
Addict
Addict
Posts: 1348
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: How to replace constant on compiled executable?

Post by Kukulkan »

Maybe you can block the clients IP server-side after 5 minutes? Much more secure. I do not believe in self deletion or modification. This is not working if your clients are having some basic IT skills. They can simply make a copy before the first execution of the downloaded file.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: How to replace constant on compiled executable?

Post by Dude »

shamun wrote:i will remove the executable after 5 minute from the disk
And that will stop a copy of the executable, how?
fabulouspaul
User
User
Posts: 34
Joined: Sun Nov 23, 2014 1:18 pm

Re: How to replace constant on compiled executable?

Post by fabulouspaul »

Why not using a registry-entry that marks the URL on the client-system as "used"?

Of course a user with serious computer-skills can change that, but it is not too obvious.
stmdbe2019
User
User
Posts: 89
Joined: Mon Aug 31, 2009 2:11 pm

Re: How to replace constant on compiled executable?

Post by stmdbe2019 »

1 - IP cant be blocked (because behind the same subnet of public IP, there can be other users such as in office floor1 has 10 PC, floor2 has 20 PC, all of them has same public IP)
2 - Removing is also not 100% but at-least its safe that CLIENT1 after first session cant not quickly re-execute and create the flood

EXE that CLIENT1 download is only for one time use on one time Download (assuming AGENT1 and CLIENT1 were connected and only then CLIENT1 is expected to be allowed to execute it). Depending on use case, CLIENT1 can reconnect with AGENT1 and again re-download the similar EXE and it has to work. The point is CLIENT1 can at any point of time again connect with AGENT1 to download a EXE. On-download that EXE has to work. But all previous EXE's should never, ever work.


3. Maybe registry code was good, but still same CLIENT1 when re-download next time EXE from AGENT1 then the EXE will again read "used" and it will fail.
Last edited by stmdbe2019 on Thu Dec 14, 2017 8:24 am, edited 1 time in total.
-----
Registered PureBasic Coder.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: How to replace constant on compiled executable?

Post by Dude »

Shamun, you're not listening to me. Protecting the executable is POINTLESS. Protecting it WON'T stop them running it more than once.
stmdbe2019
User
User
Posts: 89
Joined: Mon Aug 31, 2009 2:11 pm

Re: How to replace constant on compiled executable?

Post by stmdbe2019 »

@Dude. I am trying to make following which i believe solves my problem.

1. EXE on execute. WRITE "USED" on that EXE
2. EXE on second time execute READ "USED" on its own "EXE"

if found "USED" exit if not let it run (flood or copy no problem in such case, that solves my problem)
-----
Registered PureBasic Coder.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: How to replace constant on compiled executable?

Post by Dude »

But here's why it won't work:

1. Person copies EXE as EXE2.
2. EXE2 on execute. WRITE "USED" on that EXE2.
3. Person deletes EXE2.
4. Person goes to step 1.

Result: "USED" is never found in EXE2, so person gets to run EXE2 forever. Classic software piracy. ;)
Post Reply