简体   繁体   中英

Prevent program from being debugged

I was reading on the internet about how it is always possible to decompile mostly everything. will adding this method make it harder for a hacker to decompile a program:

void PreventProgramFromBeingDebuged()
{
     Task.Factory.StartNew(()=>{

         while(true){
             var a = DateTime.Now;
             Thread.Sleep(10);
             var b = DateTime.Now;

             // if difference in time is greater than 1 second it means the program has stopped executing

             if( (b-a).TotalSeconds > 1)
               // then make appliction crash or make it behave the way it is not suppose to
         }      
     });
}

That method is kind of obvious but you can have two threads being synchronized by a semaphore making the same code harder to understand. Having a method like that will make the life harder for a hacker? Or does a hacker does not have to debug a program in order to decompile it?

Decompiling can be done without running the code. In fact, can decompile, take this code out, recompile.

What your code actually does is cause your program to crash if the users system comes under heavy load (running low on memory or other resources). Instead of preventing debugging, you are introducing a nasty Heisenbug .

Often when you attempt to block someone from reverse engineering your code, you are setting yourself up for problems down the road from actual customers.

Edit : Your program is also likely to crash whenever the users computer automatically syncs its clock with a time source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM