Prevent Hex Editing!

i even somewhat hard coded the word

Me.Text = "BLAH"

If Me.Text <> Chr(66) & Chr(76) & Chr(65) & Chr(72) Then 'That all means BLAH in character form
Call MsgBox("This program has been altered from it's original content and will now close!", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "BLAH ERROR")
End
End If


i downloaded hex workshop, edited BLAH to something like MAIL, and it still works. but if i have the workspace open and before i debug it, if i manually change it to MAIL in the "Me.Text = " part, then the message box will pop up stating so.

what am i doing wrong, logically, to make it not work outside of the actual workspace



Answer this question

Prevent Hex Editing!

  • samreedha

    Are you just trying to secure a single field or variable A checksum would be easy for that. (And also avoids any compiler issues...)
  • Tony_C

    Yes, or look up the current executing program and run a checksum of it.

    myprog = application.ExecutablePath

    Then use a streamreader and create a checksum by reading all the bytes. The simplest checksum would just be the sum of all the bytes. This wouldn't detect changes like swapping the order of two bytes though, so most checksum actually use a combination of methods to arrive at a number (or numbers). Another way to make it harder to spoof a simple byte-order swap would be to read in blocks of bytes and treat them as a large value. (Read 4 bytes, and call it a 32-bit integer) Exclusive ORing (XOR) is also a popular method. Just do a few googles on checksums.

    The trickiest part of using checksums is figuring out how to put the value to check into your program! (Adding it in would actually change the checksum of your program!) You can get around this problem by storing the checksum in an external file, and comparing it to the computed checksum. If you're paranoid, hide the checksum by disguising it with other data. (A version number, part of a graphic image, etc...)

    Some older Anti-virus programs might look aslant at a program checking itself :)


  • RookieDBA

    thats really too much work for any small-type program.  for a bigger type program (maybe from a corporation or worth lot's of money) then yea thats worth it.

    i might go with dotfuscator, or does anyone else have any coding related ideas so i dont really have to try dotfuscator

    oh yea it looks like i wont try dotfuscator, considering its $1,000+

    any other ideas


  • qfel

    The best way to secure your code is to use an application encryptor/obsfucator...

    MS recommeds DOTFUSCATOR

    http://www.preemptive.com/products/dotfuscator/index.html

    "Microsoft's choice for code protection and obfuscation. For enterprise protection, Microsoft uses Dotfuscator Professional to obfuscate their .NET code. And when Microsoft sought a .NET obfuscator to introduce developers to obfuscation, they chose a lite version of our .NET obfuscator for use in Visual Studio. "



  • AlBriggs

    its just trying to prevent someone from hex editing the program name to something else and claim they made it. and if it's hex edited to something other than what i intended it to be, it will pop up a message box and end the program.

    i dont see how a field or variable has anything to do with Me.Text


  • Philippe A.

    the only way i can see how that if statement can be called continuously, is put it in a timer.

    and im editing the finished (compiled) program


  • Michael Sync

    Sounds good in theory...

    A few things to look at:

    1) Is that IF statement still getting called after you made the change

    2) Take a second look at the file you are editing... are you editing your compiled program in the bin folder The Form.vb file

    Some other possibilities: Maybe the compiler is optimizing, and replacing both strings with a pointer to the same thing. (Smart compiler, recognizing both forms as the same thing!) You could try tricking it with something like

    Dim x as integer

    x=5

    If Me.Text <> Chr(x + 61) & Chr(76) & Chr(65) & Chr(72) Then


  • MrSkinnman

    ok timer didn't work for the compiled program, but works in the actual workspace....i really don't get it.


  • zetto

    I suppose what you looking for is a cheap tool to obfuscate your code.

    http://www.dotnetspider.com/ToolPages/ObfuscationTools.aspx

    Shows a couple of tools which are free and may achieve what you want (i haven't used them but this may be what your looking for)

    It seems as though you saying protecting your code is too much work for small type programs but for yet thats what your trying to do.


  • Prevent Hex Editing!