Stores simple states in exe

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Stores simple states in exe

Post by Kwai chang caine »

Yeeeess !!! never heard spoken of this way :shock:

Furthermore the second link have a code more at the zero level of KCC (Only several lines) :mrgreen:
I try this example soon

Today you are my miracle bearer 8)

Image

Thanks a lot
ImageThe happiness is a road...
Not a destination
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: Stores simple states in exe

Post by firace »

Haha, enjoy :)

Just one thing to be aware of: ADS is a property of the NTFS file system, so the information is lost if you copy the file to another drive (or if you zip it).
normeus
Enthusiast
Enthusiast
Posts: 470
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: Stores simple states in exe

Post by normeus »

KCC,
your simpler solution is better:

#FILE_ATTRIBUTE_TEMPORARY = 256

The system will not delete this file.
You will be safe changing this FLAG
It is used when you are creating documents so that the system will know you are going to delete this file so it has an option to save to cache.
since you are not creating the file then the system will just ignore #FILE_ATTRIBUTE_TEMPORARY.

The only problem I see is that, some backup and replication programs will not copy files marked as temp.


Thank you.
Norm
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Stores simple states in exe

Post by Mijikai »

Run shellcode in another application to override the stateflag once ur application closes.
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Stores simple states in exe

Post by RSBasic »

firace wrote:Just one thing to be aware of: ADS is a property of the NTFS file system, so the information is lost if you copy the file to another drive (or if you zip it).
+1 :!: :!: :!:
Image
Image
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Stores simple states in exe

Post by HanPBF »

Normally an exe is not allowed to be changed as malicious software could do so and that's prevented.

A file storing the state beside the exe is the only way or writing in the registry of the user.

To have one file for start, maybe UPX exe packer could help (https://upx.github.io/).
Pack all files together; when started, config file gets unzipped.

Surprisingly that an exe can not store a state in a sandboxed area...
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Stores simple states in exe

Post by RSBasic »

HanPBF wrote:To have one file for start, maybe UPX exe packer could help (https://upx.github.io/).
But be careful: Some antivirus programs sound the alarm.
Image
Image
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Stores simple states in exe

Post by HanPBF »

It's all hacking...

http://ro.ecu.edu.au/cgi/viewcontent.cg ... ontext=adf
http://edn.embarcadero.com/article/27979

Even an assembler integration to change a flag should be seen once by an antivirus or OS.
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Stores simple states in exe

Post by RSBasic »

Yes, therefore it is better to save the file with the state in the current program directory or temp folder or AppData.
Image
Image
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Stores simple states in exe

Post by Kwai chang caine »

First, one thousand of thanks at all, for your interest to my problem :shock: 8)
Firace wrote:Just one thing to be aware of: ADS is a property of the NTFS file system, so the information is lost if you copy the file to another drive (or if you zip it).
I suppose you talk about a drive in FAT32 ? or even if the drive is in NTFS ?
It's sure i think my tips is not the most secure of the world :lol:
But except the case name, it's the more simple i have found :wink:
So your way is when even very interesting, at less for learning 8)
Normeus wrote:It is used when you are creating documents so that the system will know you are going to delete this file so it has an option to save to cache.
since you are not creating the file then the system will just ignore #FILE_ATTRIBUTE_TEMPORARY.
Happy to read your advice about my choice :D
There surely another flag or another simple old function forgotten, or simply not really knowing by everybody, who can be deturned for do something completely different that the first and original function
Anyway, it's the main activity of the hacker to search this style of functions, forgotten of all :wink:
Normeus wrote:The only problem I see is that, some backup and replication programs will not copy files marked as temp.
It's good to know that, before throwing his pc in the trash, because he decided not to backup our programs anymore :lol: :lol:
Mijikai wrote:Run shellcode in another application to override the stateflag once ur application closes.
I don't know really what is Shellcode :oops:
You mean, like a batch ? i have do one time this style of way, when i close the exe, i write a batch in tempfolder, with inside the rename of the exe, and after the batch can delete itself 8)
But i don't know it's possible to poke an exe with a script :shock:
HanPBF wrote:Normally an exe is not allowed to be changed as malicious software could do so and that's prevented.
A file storing the state beside the exe is the only way or writing in the registry of the user.
Yes you have right, an EXE is not an ACCESS file :wink:
I understand perfectly what you say, and it's normal, when we see the engineering of hacker for put something just at the place where nobody thinking :shock:
But my request is not for store DATAS, it's all the cool members of this thread who talk about DATAS, me i just ask for store one bit, 0/1, or better 0/255, and i don't think even Kevin Mitnick before the better hacker of the world
Image
can be create malicious thing wit one value 0/255..
Finally i hope :oops: :lol: because the legend say he so much strong the judge not allow him to have even a simple calculator when he is condamned :shock: :lol:

So your two links is very interesting, i don't understand all, but it's more easy to understand how the PE works 8)
Now, i'm not sure that even the ASM can writing in the EXE when it works, because it's surely windows who not allow this behaviour no ??
HanPBF wrote:To have one file for start, maybe UPX exe packer could help (https://upx.github.io/).
Interesting new way, even if use it for just a txt file with 0 or 1 inside, it's a little bit, use an elephant for carry your stylus for your smartphone :wink: :lol:

Image

It's always good to know for sandboxed area... 8)
RSBasic wrote:But be careful: Some antivirus programs sound the alarm.
Yes you have right, it's also a thing to consider :wink:
ImageThe happiness is a road...
Not a destination
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Stores simple states in exe

Post by Mijikai »

Kwai chang caine wrote:I don't know really what is Shellcode :oops:
You mean, like a batch ? i have do one time this style of way, when i close the exe, i write a batch in tempfolder, with inside the rename of the exe, and after the batch can delete itself 8)
But i don't know it's possible to poke an exe with a script :shock:
Shellcode is basically code that can run by itself anywhere in memory.
The only problem in this case is that we cant run it in the same addresspace as the executable.

However using the registry/ ads / another file are all good (and more sane) solutions.
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Stores simple states in exe

Post by Mijikai »

HanPBF wrote:Normally an exe is not allowed to be changed as malicious software could do so and that's prevented.
...
Afaik - patching itself is normal practise :?:
Last edited by Mijikai on Fri Apr 06, 2018 5:37 pm, edited 1 time in total.
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: Stores simple states in exe

Post by walbus »

It's like eating soup with a shoehorn
You can, it's going more or less well
But it leaves a bad taste
For the above purpose simple unprofessionall, sorry KCC
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Stores simple states in exe

Post by Michael Vogel »

KCC - I did a small snippet for you, 'cause you're one of the really good characters here... :wink:

You need to compile the code to kcc.exe - Daisy will copy this exe to the temporary directory and start it to allow Donald to set the file date, return to the main porgram and delete all temporary files again.

Code: Select all

#Q=#DOUBLEQUOTE$
#KccExe="kcc.exe"
#KccCmd="kcc.cmd"

Procedure Daisy(value)

	Protected temp.s
	Protected original.s
	Protected new.s

	original=ProgramFilename()
	temp=GetTemporaryDirectory()

	If CopyFile(original,temp+#KccExe)
		RunProgram(temp+#KccExe,"! "+Str(value)+" "+#Q+original+#Q,temp)
		End
	Else
		MessageRequester("Daisy",": (")
	EndIf

EndProcedure
Procedure Donald(value,original.s)

	Protected temp.s
	temp=GetTemporaryDirectory()
	
	If Left(ProgramFilename(),Len(temp))=temp
		SetCurrentDirectory(temp)
		SetFileDate(original,#PB_Date_Modified,Date(2000,1,1,0,0,value))
		If CreateFile(0,#KccCmd)
			WriteStringN(0,"@del "+#Q+#KccExe+#Q)
			WriteStringN(0,"@del "+#Q+#KccCmd+#Q)
			CloseFile(0)
			WinExec_("cmd.exe /c "+#KccCmd,#SW_HIDE)
			RunProgram(original)
			End
		EndIf
	EndIf

	MessageRequester("Donald",": (")

EndProcedure

If CountProgramParameters()=3
	If ProgramParameter(0)="!"
		Donald(Val(ProgramParameter(1)),ProgramParameter(2))
	EndIf
	
Else
	value=GetFileDate(ProgramFilename(),#PB_Date_Modified)
	If Year(value)>2000
		value=0
	Else
		value=value%60
	EndIf

	If MessageRequester("Main - "+GetPathPart(ProgramFilename()),"Value: "+Str(value),#PB_MessageRequester_YesNo)=#PB_MessageRequester_Yes
		Debug "!"
		Daisy(value+1)
	Else
		End
	EndIf
EndIf
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Stores simple states in exe

Post by Kwai chang caine »

Thanks Michael for your disney code 8) :lol:

@Walbus
Never mind, you know the words "kcc" and "professionnal" are rarely in the same sentence :wink: :lol:
ImageThe happiness is a road...
Not a destination
Post Reply