mirror of
https://github.com/lukaszraczylo/go-obfuscation.git
synced 2026-10-14 05:48:22 +00:00
.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package antidebug
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
var signalTrapDetected bool
|
||||
|
||||
func checkSignalTrap() bool {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGTRAP)
|
||||
|
||||
signalTrapDetected = false
|
||||
go func() {
|
||||
select {
|
||||
case <-ch:
|
||||
signalTrapDetected = true
|
||||
case <-time.After(200 * time.Millisecond):
|
||||
}
|
||||
}()
|
||||
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
||||
syscall.Kill(syscall.Getpid(), syscall.SIGTRAP)
|
||||
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
signal.Stop(ch)
|
||||
|
||||
// If the handler received the signal, no debugger intercepted it.
|
||||
// If signalTrapDetected is false, a debugger caught the SIGTRAP.
|
||||
return !signalTrapDetected
|
||||
}
|
||||
Reference in New Issue
Block a user