How to make 1.exe extract main.exe and execute main.exe?

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 make 1.exe extract main.exe and execute main.exe?

Post by stmdbe2019 »

I have a main.exe which need to have argument like following to execute.

Code: Select all

C:\win\>main.exe www.client1.com licenseID1
osx$ ./main www.client1.com licenseID1
Is there anyway to make another 1.exe which holds main.exe. And when 1.exe is executed it extract the main.exe from it and pass the arguments?
-----
Registered PureBasic Coder.
Bitblazer
Enthusiast
Enthusiast
Posts: 730
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: How to make 1.exe extract main.exe and execute main.exe?

Post by Bitblazer »

shamun wrote:I have a main.exe which need to have argument like following to execute.

Code: Select all

C:\win\>main.exe www.client1.com licenseID1
osx$ ./main www.client1.com licenseID1
Is there anyway to make another 1.exe which holds main.exe. And when 1.exe is executed it extract the main.exe from it and pass the arguments?
Include the main.exe (for example into a datasection), then write the included second exe to ${tmp}/main.exe and execute it with the passed arguments. Keywords are WriteData, DataSection, IncludeBinary, RunProgram and ExamineEnvironmentVariables. The Problem is that some trojans try the same and therefore antivirus software might pick that up - either due to behaviour (disguising a hidden executable/payload) or by disallowing execution from ${TMP} completely.

So this might create more problems than you want longterm. I wont go into a technical explanation of how this could be avoided on a public forum.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to make 1.exe extract main.exe and execute main.exe?

Post by IdeasVacuum »

Windows 10 itself will intercept the executable. Why would you need to do this anyway?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: How to make 1.exe extract main.exe and execute main.exe?

Post by walbus »

Bitplazer wrote:The Problem is that some trojans try the same...
Maybe you should explain exactly why you want to do that !
The construction of such things hurt PB
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: How to make 1.exe extract main.exe and execute main.exe?

Post by Dude »

As mentioned, running exes from %TEMP% will probably get your app flagged by anti-virus apps, but lots of legit products do exactly that from %TEMP% anyway, so it's hard to say for sure. Is there any reason your app can't just have the other exe in the same folder as the main app, and run it from there? Or just extract and run it from there, instead of %TEMP%.
stmdbe2019
User
User
Posts: 89
Joined: Mon Aug 31, 2009 2:11 pm

Re: How to make 1.exe extract main.exe and execute main.exe?

Post by stmdbe2019 »

Automatically at midnight PB compiler in server (Windows, OSX) compiles executable file per client (in database lets say i have 500 client, 500 times compiles, and it creates 500 .exe files) where clients are unlimited.

To minimise that logic, i wanted to make main.exe and use a wrapper 1.exe. Where 1.exe will be only released per client which will have small footprint and main.exe wont be compiled anymore which is large in size and code complex involved.

FYI.

- AGENT1 in call center is connected with a client over telephone (PSTN/ISDN/VOIP)
- CLIENT ask and grant the AGENT1. Can you see my desktop, what am i doing wrong?
- AGENT1 says sure, go to our: https://www.government.site.gov/AGENT1

- AGENT1 shared link has a PureBasic midnight compiled .exe and .dmg file available
- CLIENT execute that link and open the PureBasic compiled executable file

- AGENT1 now see the screen of CLIENT. PureBasic compiled execute file exit after 15 seconds and kills itself

- Session ends

(My project goal is: i need to minimise that above process with 1.exe holding main.exe inside 1.exe)
-----
Registered PureBasic Coder.
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: How to make 1.exe extract main.exe and execute main.exe?

Post by Mijikai »

Why not just rewrite 'main.exe' and add some basic configuration (file) capabilities ?
Or just have uniq request links for each client...
stmdbe2019
User
User
Posts: 89
Joined: Mon Aug 31, 2009 2:11 pm

Re: How to make 1.exe extract main.exe and execute main.exe?

Post by stmdbe2019 »

What do you mean by unique request URL?

- Suppose i have 500 rows, i make 500 .exe in server (disk space reserved)? Currently i am doing this because i had no choice
- Or you mean get argument via URL and then compile main.exe (one time only and distribute it, instead of keeping it 500 times) ?
-----
Registered PureBasic Coder.
stmdbe2019
User
User
Posts: 89
Joined: Mon Aug 31, 2009 2:11 pm

Re: How to make 1.exe extract main.exe and execute main.exe?

Post by stmdbe2019 »

-----
Registered PureBasic Coder.
Post Reply