How to programmatically detect VB.NET obfuscation? -
i using confuserex obfuscate program before release, want program show warning if being run without obfuscation. reduce chance of non obfuscated executable being shipped. @ runtime want function returns true/false depending if obfuscation has been applied.
i can see 2 ways of doing it.
if obfuscation process use part of release build , therefore release build has embedded instructions obfuscation part, that.
appvalidator.validate()
the validation validate release version or if not, application run allowed users (dev. team instance).
i added way validate commandline calling myapp.exe validate
however. not validated obfuscation per see, validates application in release mode.
your obfuscator, if embedded release build, should fails if cannot obfuscate release version or premise validation not good.
public class appvalidator #if debug private shared readonly isdebugversion boolean = true #else private shared readonly isdebugversion boolean = false #end if private shared readonly isvaliduser boolean = validatedevuser() ''' <summary> ''' validate user authorized run program ''' </summary> ''' <returns></returns> private shared function validatedevuser() boolean try ' custom validation determine if used in dev. environment such 'as validating username , domain name or checking agains dev. registry key catch ex exception return false end try return true end function public shared function validate() boolean dim args = environment.getcommandlineargs dim consolevalidate boolean = args.count = 2 andalso string.compare(args(1), "validate") = 0 if isdebugversion if consolevalidate console.writeline(not isdebugversion) application.current.shutdown() return false end if if not validatedevuser() messagebox.show("access denied") application.current.shutdown() return false end if end if return true end function end class
the first solution best if can sure build fails if release version produced , obfuscator steps fails.
if cannot sure of that, can maybe take @ obfuscation checker, red-gate, free , has command-line , seek in direct approach.
Comments
Post a Comment