Self Virus Check / Exec Alteration

Share your advanced PureBasic knowledge/code with the community.
Joris
Addict
Addict
Posts: 890
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Self Virus Check / Exec Alteration

Post by Joris »

BarryG wrote:That's what ProgramFilename() is for. You don't need to know where the user puts your exe. It gets the exe's path and filename at runtime.
Well, if I put that text file in the Linker and try to create executable, I get the message :
POLINK Fatal Error : File not found 'szFullPath.s=ProgramFilename()'.
So, what am I doing wrong then ?

Thanks.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: Self Virus Check / Exec Alteration

Post by kvitaliy »

Joris wrote: Well, if I put that text file in the Linker and try to create executable, I get the message :
POLINK Fatal Error : File not found 'szFullPath.s=ProgramFilename()'.
So, what am I doing wrong then ?

Thanks.
The text file must contain 1 line:
/RELEASE

And you must embed this code into your program on PureBasic:

Code: Select all

szFullPath.s=ProgramFilename()
dwFileChecksum.l = 0: dwRealChecksum.l = 0
sz.s = "Hello" ; replace at least 1 character in EXE
MapFileAndCheckSum_(@szFullPath, @dwFileChecksum, @dwRealChecksum)
If dwFileChecksum<>dwRealChecksum
 
 MessageRequester(sz, "the checksum is Not correct = " + Str(dwFileChecksum) +" R="+  dwRealChecksum)
Else
   MessageRequester(sz,  "the checksum is correct= " + Str(dwFileChecksum) +" R="+  dwRealChecksum) 
EndIf
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Self Virus Check / Exec Alteration

Post by J. Baker »

As Paul pointed out in another post (different topic), a "=" or "<>" can easily be changed in a hex editor, etc. This should help a bit but nothing is 100%. Replace "@b" with "@c" for a different result.

Code: Select all

szFullPath.s = ProgramFilename()

dwFileChecksum.l = 0
dwRealChecksum.l = 0

sz.s = "Hello" ; replace at least 1 character in EXE

MapFileAndCheckSum_(@szFullPath, @dwFileChecksum, @dwRealChecksum)

a.s = Str(dwFileChecksum)
b.s = Str(dwRealChecksum)
c.s = "hello"

If CompareMemoryString(@a,@b) ; dwFileChecksum <> dwRealChecksum
  MessageRequester(sz, "the checksum is Not correct = " + Str(dwFileChecksum) + " R=" + dwRealChecksum)
Else
  MessageRequester(sz,  "the checksum is correct= " + Str(dwFileChecksum) + " R=" + dwRealChecksum) 
EndIf
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: Self Virus Check / Exec Alteration

Post by kvitaliy »

J. Baker wrote:As Paul pointed out in another post (different topic), a "=" or "<>" can easily be changed in a hex editor, etc.
The virus will not use hex editor, and will not change "=" to "<>" :lol:
A hacker will crack any code if needed.
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Self Virus Check / Exec Alteration

Post by J. Baker »

LOL! Nope. If a virus uses a hex editor, I think that would be called an A.I. Just thought I would post it anyway. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Self Virus Check / Exec Alteration

Post by Saki »

J. Baker wrote:Saki, fill free to post. ;)
The QAES File Crypter addon for the Universal Crypter has a 256 bit AES and SHA3 based protection function.
You find at the bottom of the code.

This is primarily needed to check encrypted files for changes or damages.
Or to protect documents, files or images without encrypted content.
It is equally effective on encrypted and unencrypted files and cannot be manipulated.
It is very fast and can be added, checked or removed in a fraction of a second for common files.

Code: Select all

For very fast batch processing :
Debug "###### File protection without encrypt a file ###"
      SaveImage(CreateImage(#PB_Any, 10, 10), path_0$, #PB_ImagePlugin_JPEG)
Debug QAES_smart_file_coder(1, window_ID, progressbar_ID, path_0$, key$, "", 10) ; Protect a file
Debug QAES_smart_file_coder(3, window_ID, progressbar_ID, path_0$, key$, "", 10) ; Check the file protection - Also for encrypted files
Debug QAES_smart_file_coder(2, window_ID, progressbar_ID, path_0$, key$, "", 10) ; Remove the file protection

#### File protection without encrypt a file ###
ALLok ##16QF - File protected  ! - File hash ==>851039acf9350805f70315b74df68e20e155bc9de0259baff9e5719e1906b665
ALLok ##11QF - File integrity succesfully checked ! - Used counter =>10 - File hash ==>851039acf9350805f70315b74df68e20e155bc9de0259baff9e5719e1906b665
ALLok ##15QF - File unprotected  ! - Used counter =>10 - File hash ==>851039acf9350805f70315b74df68e20e155bc9de0259baff9e5719e1906b665
viewtopic.php?f=12&t=75943

It has included a complete tool for simplest using :
Image
地球上の平和
Post Reply