2. time.Sleep() 2/2

#AVEvasion #Golang #maldev #malwaredevelopment #sleep

As mentioned previously some AV sandbox will speed up execution of sleep functions to identify if any malicious action occurs without timing out.

A simple way to detect if the sleep function actually slept for 10 seconds is to get the time before and after the sleep function and calculate the difference.

An example of the exact code is provided by the golang package.

	fmt.Println("[+] Sleeping for 10 Seconds")
	t0 := time.Now()
	time.Sleep(10 * time.Second)
	t1 := time.Now()
	diff := t1.Sub(t0)
	fmt.Println("[+] Woke Up ... Execution Continues")

	fmt.Printf("[+] The call took %v to run.\n", diff)
	if diff.Seconds() < 10 {
		log.Fatalln("[FATAL] Execution faster than 10 seconds")
	}
  • In line 5 we calculate the difference of the time before and after the sleep function.

  • In line 9 we check if that's less than 10 seconds we terminate execution

Complete Code

Last updated

Was this helpful?