Page 2 of 4

Re: Any thoughts on security

Posted: Sat Dec 09, 2023 6:18 am
by AUGE_OHR
hi Franco,

you can not change Byte in "Header" of File but you can add something "at End" of File
this might be identify as Attack by Antivirus when "infect" a File by add CODE
---
you can not delete a File which is running.
use a *.BAT File for that CODE which you have post as xBase Syntax

Re: Any thoughts on security

Posted: Sat Dec 09, 2023 11:01 am
by edk

Code: Select all

if file('winlog1.ese')
	copy file winlog1.ese to winlog1.exe                          //This works
	msgbox('You Must Restart Program After Entering the Following')               //This works
	Do While .Not. hb_FileDelete('winlog1.ese')                                          
	     Do events
	End Do
	execute file('winlog1.exe') 
	Do While .Not. hb_FileDelete( 'winlog1.exe')   
	      Do events
	End Do
	cancel
	return
endif	                                             

Re: Any thoughts on security

Posted: Sat Dec 09, 2023 5:51 pm
by franco
Thanks Edward, this completely makes sense.
Jimmy try this it works so we could basically send a program to a client that only works only 1 time by erasing it after use inside another program.

Code: Select all

#include <hmg.ch>
local msn := '', memvar

memvar := memoread('winlog1.ese')                                // any hmg .exe program
*msgbox(substr(memvar,79,1))
memowrit('winlog1.ese', substr(memvar,1,78)+substr(memvar,80,len(memvar)-78))   // This takes out the T
copy file winlog1.ese to winlog1.exe                             // changes extention
execute file('winlog1.exe')                                           //Will not run
*msgbox()
memvar := memoread('winlog1.exe')
memowrit('winlog1.exe',subst(memvar,1,78)+'T'+substr(memvar,79,len(memvar)-78))             // This replaces the T
memowrit('winlog1.ese',subst(memvar,1,78)+'T'+substr(memvar,79,len(memvar)-78))
execute file('winlog1.exe')                                    //Then it works
*msgbox()
RETURN
Anyone, give it a try with any hmg program.

Re: Any thoughts on security

Posted: Sat Dec 09, 2023 10:40 pm
by franco
Had to adjust previous post.

Code: Select all

#include <hmg.ch>
local memvar
memvar := memoread('winlog1.ese')                                // any hmg .exe program
*msgbox(substr(memvar,79,1))
memowrit('winlog1.ese', substr(memvar,1,78)+substr(memvar,80,len(memvar)-78))          // This takes out the T from exe file
copy file winlog1.ese to winlog1.exe
          execute file('winlog1.exe')      //Will not run
*msgbox()
memvar := memoread('winlog1.exe')
memowrit('winlog1.exe',subst(memvar,1,78)+'T'+substr(memvar,79,len(memvar)-78))             // This replaces the T
memowrit('winlog1.ese',subst(memvar,1,78)+'T'+substr(memvar,79,len(memvar)-78))
	execute file('winlog1.exe')     //Then it works
*msgbox()
RETURN

Re: Any thoughts on security

Posted: Sun Dec 31, 2023 6:09 pm
by franco
Does anyone know how to stop a program from running from inside another program.
If I execute a program exe2 from inside program exe1 I would like to stop exe1 from running from exe2 so I can modify it or delete it
as EDK subjects above.
If I can do this I have figured a pretty sure way of creating an secure program.
Thanks in advance Franco

Re: Any thoughts on security

Posted: Wed Jan 03, 2024 1:20 am
by franco
Have figured out, before deleting as EDK above.
I run the table making exe program from inside main exe program. After tables are made I can write to program while running.
memowrit('winlog1.exe',"winlog")

Code: Select all

                                                      // from inside main exe program
if file('winlog1.ese')                         // These files create the tables for main exe program
	copy file winlog1.ese to winlog1.exe                          //This works
	msgbox('You Must Restart Program After Entering the Following')               //This works
        memowrit('winlog1.ese',"winlog1")
	Do While .Not. hb_FileDelete('winlog1.ese')                                          
	     Do events
	End Do
	execute file('winlog1.exe') 
        memowrit('winlog1.exe',"winlog1")           
	Do While .Not. hb_FileDelete( 'winlog1.exe')   
	      Do events
	End Do                                                             // Now if someone finds the winlog programs they will never work again
                                                                               // We do not need them the tables are created.
	cancel
        return
endif

Re: Any thoughts on security

Posted: Mon Jun 10, 2024 10:34 pm
by franco
Hi All,
Still trying to make this better.
If I could close a program from running from another program I would have this figured to perfection.
Open exe1. Run exe2 from inside exe1. close exe1 from inside exe2.
Then I can put the exe1`s new serial number into it with memwrite

Re: Any thoughts on security

Posted: Tue Jun 11, 2024 12:44 pm
by edk
Check out the process ID based solution:
exe1 and exe2.zip
(2.1 KiB) Downloaded 35 times

Re: Any thoughts on security

Posted: Tue Jun 11, 2024 4:46 pm
by franco
Thanks EDK, I tried building demos but get HMG_UPPER errors when I try to run exe2 from exe1. Nothing seems to happen when I run exe2 to kill exe 1.

Re: Any thoughts on security

Posted: Tue Jun 11, 2024 9:10 pm
by edk
Which version of HMG are you compiling exe1.prg and exe2.prg?
I tested on versions 3.4.4 and 3.6 and it works for me. :?
Post what you have in edit boxes exe1 and exe2.
Exe2 will only be able to kill exe1 if exe2 is started from exe1.