Skip to content

Commit 2ba72cb

Browse files
authored
Add files via upload
BIG UPDATE / ENJOY BLOCKS WHERE YOU CAN MODIFY WHAT TO DO. BETTER ERROR HANDLING CONTROLABLE VERSION
1 parent b0bcdb9 commit 2ba72cb

File tree

17 files changed

+245
-192
lines changed

17 files changed

+245
-192
lines changed

AntiDebug/CheckBlacklistedWindowsNames/CheckBlacklistedWindowsNames.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package blacklistcheck
1+
package CheckBlacklistedWindowsNames
22

33
import (
4-
"fmt"
4+
"log"
55
"syscall"
66
"unsafe"
77
)
@@ -52,7 +52,7 @@ func enumWindowsProc(hwnd syscall.Handle, lParam uintptr) uintptr {
5252
// Check if the window title contains any blacklisted strings
5353
for _, blacklisted := range blacklistedWindows {
5454
if contains(wt, blacklisted) {
55-
fmt.Printf("Detected blacklisted window: %s\n", wt)
55+
log.Printf("Detected blacklisted window: %s\n", wt)
5656
// If a blacklisted window is found, terminate the associated process
5757
proc, _, _ := pop.Call(syscall.PROCESS_TERMINATE, 0, uintptr(pid))
5858
if proc != 0 {
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
package InternetCheck
22

33
import (
4-
"fmt"
5-
"net"
6-
"os"
4+
"log"
5+
"net"
6+
"errors"
77
)
88

9-
func CheckConnection() {
10-
_, err := net.Dial("tcp", "google.com:80")
11-
if err == nil {
12-
fmt.Println("Debug Check: [!] Internet connection is active.")
13-
} else {
14-
fmt.Println("Debug Check: INTERNET CONNECTION CHECK FAILED!")
15-
os.Exit(-1)
16-
}
17-
}
9+
func CheckConnection() (bool, error) {
10+
conn, err := net.Dial("tcp", "google.com:80")
11+
if err != nil {
12+
err = errors.New("error checking internet connection: " + err.Error())
13+
log.Printf("[DEBUG] Error checking internet connection: %v", err)
14+
return false, err
15+
}
16+
defer func() {
17+
if cerr := conn.Close(); cerr != nil {
18+
log.Printf("[DEBUG] Error closing connection: %v", cerr)
19+
}
20+
}()
21+
22+
return true, nil
23+
}
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
package IsDebuggerPresent
22

33
import (
4-
"os"
5-
"syscall"
4+
"syscall"
65
)
76

87
var (
9-
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
10-
isDebugger = kernel32DLL.NewProc("IsDebuggerPresent")
8+
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
9+
isDebugger = kernel32DLL.NewProc("IsDebuggerPresent")
1110
)
1211

1312
// IsDebuggerPresent1 checks if a debugger is present.
1413
func IsDebuggerPresent1() bool {
15-
flag, _, _ := isDebugger.Call()
16-
return flag != 0
14+
flag, _, _ := isDebugger.Call()
15+
return flag != 0
1716
}
1817

19-
// CheckAndPrint checks if a debugger is present and prints a message.
20-
func IsDebuggerPresent() {
21-
if IsDebuggerPresent1() {
22-
println("Debug check: IsDebuggerPresent is present.")
23-
os.Exit(-1)
24-
} else {
25-
println("Debug check: IsDebuggerPresent is not present.")
26-
}
18+
// IsDebuggerPresent checks if a debugger is present and logs the result.
19+
func IsDebuggerPresent() bool {
20+
if IsDebuggerPresent1() {
21+
return true
22+
} else {
23+
return false
24+
}
2725
}

AntiDebug/KillBadProcesses/KillBadProcesses.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package processkiller
1+
package KillBadProcesses
22

33
import (
44
"os/exec"
Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package parentantidebug
1+
package ParentAntiDebug
22

33
import (
4-
"fmt"
4+
"log"
55
"os"
66
"path/filepath"
77
"syscall"
88
"unsafe"
9+
910
"golang.org/x/sys/windows"
1011
)
1112

@@ -23,42 +24,69 @@ type ProcessInfo struct {
2324
}
2425

2526
// NtQueryProc queries process information
26-
func NtQueryProc(handle syscall.Handle, class uint32, info *ProcessInfo, length uint32) {
27-
syscall.Syscall6(ntquery.Addr(), 5, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(length), 0, 0)
27+
func NtQueryProc(handle syscall.Handle, class uint32, info *ProcessInfo, length uint32) error {
28+
r1, _, err := syscall.Syscall6(ntquery.Addr(), 5, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(length), 0, 0)
29+
if err != 0 {
30+
log.Printf("NtQueryInformationProcess failed: %v", err)
31+
return err
32+
}
33+
if r1 != 0 {
34+
log.Printf("NtQueryInformationProcess failed: unexpected return value: %v", r1)
35+
return err
36+
}
37+
return nil
2838
}
2939

3040
// QueryImageName retrieves the full image name of the process
31-
func QueryImageName(handle syscall.Handle, flags uint32, nameBuffer []uint16, size *uint32) {
32-
windows.QueryFullProcessImageName(windows.Handle(handle), flags, &nameBuffer[0], size)
41+
func QueryImageName(handle syscall.Handle, flags uint32, nameBuffer []uint16, size *uint32) error {
42+
err := windows.QueryFullProcessImageName(windows.Handle(handle), flags, &nameBuffer[0], size)
43+
if err != nil {
44+
log.Printf("QueryFullProcessImageName failed: %v", err)
45+
return err
46+
}
47+
return nil
3348
}
3449

3550
// CurrentProcName returns the name of the current executable
36-
func CurrentProcName() string {
37-
exePath, _ := os.Executable()
38-
return filepath.Base(exePath)
51+
func CurrentProcName() (string, error) {
52+
exePath, err := os.Executable()
53+
if err != nil {
54+
log.Printf("os.Executable failed: %v", err)
55+
return "", err
56+
}
57+
return filepath.Base(exePath), nil
3958
}
4059

41-
// ParentAntiDebug checks the parent process and exits if it's not explorer.exe or cmd.exe
42-
func ParentAntiDebug() {
60+
// ParentAntiDebug checks the parent process if it's explorer.exe or cmd.exe
61+
func ParentAntiDebug() bool {
4362
const ProcInfo = 0
4463
var p ProcessInfo
45-
NtQueryProc(syscall.Handle(windows.CurrentProcess()), ProcInfo, &p, uint32(unsafe.Sizeof(p)))
64+
if err := NtQueryProc(syscall.Handle(windows.CurrentProcess()), ProcInfo, &p, uint32(unsafe.Sizeof(p))); err != nil {
65+
log.Printf("Error querying process information: %v", err)
66+
return false
67+
}
4668
par := int32(p.InheritedFromPID)
4769
if par == 0 {
48-
return
70+
return false
71+
}
72+
handle, err := syscall.OpenProcess(syscall.PROCESS_QUERY_INFORMATION, false, uint32(par))
73+
if err != nil {
74+
log.Printf("Error opening process handle: %v", err)
75+
return false
4976
}
50-
handle, _ := syscall.OpenProcess(syscall.PROCESS_QUERY_INFORMATION, false, uint32(par))
5177
defer syscall.CloseHandle(handle)
78+
5279
buff13 := make([]uint16, windows.MAX_PATH)
5380
size := uint32(len(buff13))
54-
QueryImageName(handle, 0, buff13, &size)
55-
pa1231 := syscall.UTF16ToString(buff13[:size])
56-
parname := filepath.Base(pa1231)
81+
if err := QueryImageName(handle, 0, buff13, &size); err != nil {
82+
log.Printf("Error querying image name: %v", err)
83+
return false
84+
}
85+
parname := filepath.Base(syscall.UTF16ToString(buff13[:size]))
5786

5887
if parname != "explorer.exe" && parname != "cmd.exe" {
59-
fmt.Printf("Debug Check: Parent process (%s) is not in the whitelist\n", parname)
60-
os.Exit(-1)
88+
return true
6189
} else {
62-
fmt.Printf("Debug Check: Parent process (%s) is in the whitelist\n", parname)
90+
return false
6391
}
6492
}
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
package remotedebuggercheck
1+
package RemoteDebugger
22

33
import (
4-
"fmt"
5-
"os"
64
"syscall"
75
"unsafe"
86
)
97

108
var (
11-
mk32 = syscall.NewLazyDLL("kernel32.dll")
12-
crdp = mk32.NewProc("CheckRemoteDebuggerPresent")
9+
mk32 = syscall.NewLazyDLL("kernel32.dll")
10+
crdp = mk32.NewProc("CheckRemoteDebuggerPresent")
1311
)
1412

1513
// RemoteDebugger checks for the presence of a remote debugger.
16-
func RemoteDebugger() {
14+
func RemoteDebugger() (bool, error) {
1715
var isremdebpres bool
18-
crdp.Call(^uintptr(0), uintptr(unsafe.Pointer(&isremdebpres)))
16+
r1, _, err := crdp.Call(^uintptr(0), uintptr(unsafe.Pointer(&isremdebpres)))
17+
if r1 == 0 {
18+
return false, nil
19+
}
20+
if err != nil {
21+
return false, err
22+
}
23+
1924
if isremdebpres {
20-
fmt.Println("Debug check: Remote debugger detected.")
21-
os.Exit(-1)
25+
return true, nil
2226
} else {
23-
fmt.Println("Debug check: Remote debugger is not present.")
27+
return false, nil
2428
}
2529
}
Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
// runningprocesses.go
2-
package runningprocesses
1+
package RunningProcesses
32

43
import (
5-
"fmt"
6-
"os"
7-
"syscall"
8-
"unsafe"
4+
"log"
5+
"syscall"
6+
"unsafe"
97
)
108

119
var (
12-
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
13-
pep = kernel32DLL.NewProc("K32EnumProcesses")
10+
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
11+
enumProcesses = kernel32DLL.NewProc("K32EnumProcesses")
1412
)
1513

1614
// GetRunningProcessesCount returns the number of currently running processes.
17-
func GetRunningProcessesCount() int {
18-
var ids [1024]uint32
19-
var needed uint32
20-
pep.Call(uintptr(unsafe.Pointer(&ids)), uintptr(len(ids)), uintptr(unsafe.Pointer(&needed)))
21-
return int(needed / 4)
15+
func GetRunningProcessesCount() (int, error) {
16+
var ids [1024]uint32
17+
var needed uint32
18+
r1, _, err := enumProcesses.Call(uintptr(unsafe.Pointer(&ids)), uintptr(len(ids)), uintptr(unsafe.Pointer(&needed)))
19+
if r1 == 0 {
20+
log.Printf("K32EnumProcesses failed: %v", err)
21+
return 0, nil
22+
}
23+
return int(needed / 4), nil
2224
}
2325

2426
// CheckRunningProcessesCount checks if the number of currently running processes is less than a specified count.
25-
func CheckRunningProcessesCount(count int) {
26-
processesCount := GetRunningProcessesCount()
27-
//fmt.Printf("Number of running processes: %d\n", processesCount)
28-
if processesCount < count {
29-
fmt.Println("Number of running processes is less than the specified count. Exiting.")
30-
os.Exit(-1)
31-
}
32-
fmt.Println("Debug Check: Number of running processes is greater than or equal to the specified count. Continuing.")
27+
func CheckRunningProcessesCount(count int) (bool, error) {
28+
processesCount, err := GetRunningProcessesCount()
29+
if err != nil {
30+
return false, err
31+
}
32+
33+
if processesCount < count {
34+
return true, nil
35+
}
36+
return false, nil
3337
}

AntiDebug/UserAntiAntiDebug/HooksDetection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package userantiantidebug
1+
package HooksDetection
22

33
import (
4-
"fmt"
4+
"log"
55
"syscall"
66
"unsafe"
77
)
@@ -144,5 +144,5 @@ func DetectHooksOnCommonWinAPIFunctions(moduleName string, functions []string) b
144144
}
145145

146146
func AntiAntiDebug() {
147-
fmt.Println("Detecting Hooks on Common WinAPI Functions by checking for Bad Instructions on Functions Addresses (Most Effective on x64): ", DetectHooksOnCommonWinAPIFunctions("", nil))
147+
log.Println("Detecting Hooks on Common WinAPI Functions by checking for Bad Instructions on Functions Addresses (Most Effective on x64): ", DetectHooksOnCommonWinAPIFunctions("", nil))
148148
}

AntiDebug/pcuptime/pcuptime.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
// pcuptime.go
21
package pcuptime
32

43
import (
5-
"fmt"
6-
"os"
74
"syscall"
85
)
96

@@ -12,19 +9,25 @@ var (
129
getTickCount = kernel32DLL.NewProc("GetTickCount")
1310
)
1411

15-
// GetUptimeInSeconds returns the system uptime in seconds, predefined one is 1200 which is 20mins.
16-
func GetUptimeInSeconds() int {
17-
uptime, _, _ := getTickCount.Call()
18-
return int(uptime / 1000)
12+
// GetUptimeInSeconds returns the system uptime in seconds.
13+
func GetUptimeInSeconds() (int, error) {
14+
uptime, _, err := getTickCount.Call()
15+
if err != nil && err.Error() != "The operation completed successfully." {
16+
return 0, err
17+
}
18+
return int(uptime / 1000), nil
1919
}
2020

21-
// CheckUptime checks if the system uptime is less than a specified duration in seconds and prints a message.
22-
func CheckUptime(durationInSeconds int) {
23-
uptime := GetUptimeInSeconds()
21+
// CheckUptime checks if the system uptime is less than a specified duration in seconds.
22+
func CheckUptime(durationInSeconds int) (bool, error) {
23+
uptime, err := GetUptimeInSeconds()
24+
if err != nil {
25+
return false, err
26+
}
27+
2428
if uptime < durationInSeconds {
25-
fmt.Println("Debug Check: System uptime is less than the specified duration.")
26-
os.Exit(-1)
29+
return true, nil
2730
} else {
28-
fmt.Println("Debug Check: System uptime is greater than or equal to the specified duration.")
31+
return false, nil
2932
}
3033
}

0 commit comments

Comments
 (0)