|
1 | | -local parent_command = "common" |
2 | | -local function bof_path(bof_name, arch) |
3 | | - return "common/bof/" .. bof_name .. "." .. arch .. ".o" |
4 | | -end |
5 | | -local function command_register(command_name, command_function, help_string, ttp) |
6 | | - command(parent_command .. ":" .. command_name, command_function, |
7 | | - help_string, ttp) |
8 | | -end |
9 | | - |
10 | | --- netUserAdd |
11 | | - |
12 | | -local function run_netuseradd_bof(cmd) |
13 | | - local username = cmd:Flags():GetString("username") |
14 | | - local password = cmd:Flags():GetString("password") |
15 | | - if username == "" then error("username is required") end |
16 | | - if password == "" then error("password is required") end |
17 | | - local pack_args = bof_pack("ZZ", username, password) |
18 | | - local session = active() |
19 | | - local arch = session.Os.Arch |
20 | | - if not isadmin(session) then |
21 | | - error("You need to be an admin to run this command") |
22 | | - end |
23 | | - local bof_file = bof_path("NetUserAdd", arch) |
24 | | - return bof(session, script_resource(bof_file), pack_args, true) |
25 | | -end |
26 | | - |
27 | | -local netuseradd_bof_command = command("common:netuseradd_bof", |
28 | | - run_netuseradd_bof, |
29 | | - "netuseradd_by_bof <username> <password>", |
30 | | - "") |
31 | | -netuseradd_bof_command:Flags():String("username", "", "the username to add") |
32 | | -netuseradd_bof_command:Flags():String("password", "", "the password to set") |
33 | | - |
34 | | --- curl |
35 | | -local function parse_curl_bof(args) |
36 | | - local size = #args |
37 | | - if size < 1 then error(">=1 arguments are allowed") end |
38 | | - local host = args[1] |
39 | | - local port = "80" |
40 | | - local method = "GET" |
41 | | - local header = "Accept: */*" |
42 | | - local userAgent = |
43 | | - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" |
44 | | - local body = "" |
45 | | - |
46 | | - if size >= 2 then port = args[2] end |
47 | | - local valid_methods = { |
48 | | - GET = true, |
49 | | - POST = true, |
50 | | - PUT = true, |
51 | | - PATCH = true, |
52 | | - DELETE = true |
53 | | - } |
54 | | - if size >= 3 then |
55 | | - method = args[3] |
56 | | - if not valid_methods[method] then |
57 | | - error("HTTP method " .. method .. " isn't valid.") |
58 | | - end |
59 | | - end |
60 | | - local output = 1 |
61 | | - if args[4] == "--disable-output" then output = 0 end |
62 | | - proxy = 1 |
63 | | - if args[4] == "--noproxy" then proxy = 0 end |
64 | | - if size >= 5 then userAgent = args[5] end |
65 | | - if size >= 6 then header = args[6] end |
66 | | - if size >= 7 then body = args[7] end |
67 | | - return bof_pack("zizizzzi", host, port, method, output, userAgent, header, |
68 | | - body, proxy) |
69 | | -end |
70 | | - |
71 | | -local function run_curl_bof(args) |
72 | | - args = parse_curl_bof(args) |
73 | | - local session = active() |
74 | | - local arch = session.Os.Arch |
75 | | - local bof_file = bof_path("curl", arch) |
76 | | - return bof(session, script_resource(bof_file), args, true) |
77 | | -end |
78 | | -command_register("curl_bof", run_curl_bof, |
79 | | - "curl <host> [port] [method] [--show|--noproxy] [userAgent] [header] [body]", |
80 | | - "") |
81 | | --- readfile |
82 | | - |
83 | | -local function run_readfile_bof(args) |
84 | | - if args[1] == nil then error(">=1 arguments are allowed") end |
85 | | - local file_path = args[1] |
86 | | - local packed_args = bof_pack("z", file_path) |
87 | | - local session = active() |
88 | | - local arch = session.Os.Arch |
89 | | - local bof_file = bof_path("readfile", arch) |
90 | | - return bof(session, script_resource(bof_file), packed_args, true) |
91 | | -end |
92 | | -command_register("readfile_bof", run_readfile_bof, "readfile_bof <file_path>", |
93 | | - "") |
94 | | - |
95 | | --- kill_defender |
96 | | -local function parse_kill_defender_bof(args) |
97 | | - local size = #args |
98 | | - if size < 1 then error(">=1 arguments are allowed") end |
99 | | - local action = args[1] |
100 | | - if action == "kill" or action == "check" then |
101 | | - local username = session.Os.Username |
102 | | - end |
103 | | - return bof_pack("z", args[1]) |
104 | | -end |
105 | | -local function run_kill_defender_bof(args) |
106 | | - local session = active() |
107 | | - local arch = session.Os.Arch |
108 | | - local bof_file = bof_path("kill_defender", arch) |
109 | | - return bof(session, script_resource(bof_file), args, true) |
110 | | -end |
111 | | -command_register("kill_defender_bof", run_kill_defender_bof, |
112 | | - "kill_defender_bof <action>", "") |
113 | | --- clipboard |
114 | | -local function run_clipboard_bof(args) |
115 | | - local session = active() |
116 | | - local arch = session.Os.Arch |
117 | | - local bof_file = bof_path("clipboard", arch) |
118 | | - return bof(session, script_resource(bof_file), args, true) |
119 | | -end |
120 | | --- dump clipboard |
121 | | -local function run_dump_clipboard(args) |
122 | | - local session = active() |
123 | | - local arch = session.Os.Arch |
124 | | - local bof_file = bof_path("dump_clipboard", arch) |
125 | | - return bof(session, script_resource(bof_file), args, true) |
126 | | -end |
127 | | -command_register("dump_clipboard_bof", run_dump_clipboard, "dump_clipboard_bof", |
128 | | - "") |
129 | | --- wifidump |
130 | | -local function parse_wifidump_bof(args) |
131 | | - local size = #args |
132 | | - if size < 1 then error(">=1 arguments are allowed") end |
133 | | - print(args[1]) |
134 | | - local interface = args[1] |
135 | | - return bof_pack("Z", interface) |
136 | | -end |
137 | | -local function run_wifidump_bof(args) |
138 | | - args = parse_wifidump_bof(args) |
139 | | - local session = active() |
140 | | - local arch = session.Os.Arch |
141 | | - local bof_file = bof_path("wifidump", arch) |
142 | | - return bof(session, script_resource(bof_file), args, true) |
143 | | -end |
144 | | -command_register("wifidump_bof", run_wifidump_bof, "wifidump_bof <profilename>", |
145 | | - "") |
146 | | - |
147 | | --- wifienum |
148 | | -local function run_wifienum_bof(args) |
149 | | - if #args > 0 then error("no arguments are allowed") end |
150 | | - local session = active() |
151 | | - local arch = session.Os.Arch |
152 | | - local bof_file = bof_path("wifienum", arch) |
153 | | - return bof(session, script_resource(bof_file), args, true) |
154 | | -end |
155 | | -command_register("wifienum_bof", run_wifienum_bof, "wifienum_bof", "") |
156 | | - |
157 | | --- memory info |
158 | | -local function run_read_memory_bof() |
159 | | - local session = active() |
160 | | - local arch = session.Os.Arch |
161 | | - local bof_file = bof_path("memory", arch) |
162 | | - return bof(session, script_resource(bof_file), {}, true) |
163 | | -end |
164 | | -command_register("meminfo_bof", run_read_memory_bof, "meminfo_bof", "") |
165 | | - |
166 | | --- memory reader |
167 | | --- Usage : memreader <target-pid> <pattern> <output-size> |
168 | | -local function parse_memory_reader_bof(args) |
169 | | - local size = #args |
170 | | - if size < 2 then error(">=2 arguments are allowed") end |
171 | | - local target_pid = args[1] |
172 | | - local pattern = args[2] |
173 | | - local output_size = 10 |
174 | | - if size == 3 then output_size = args[3] end |
175 | | - return bof_pack("izi", target_pid, pattern, output_size) |
176 | | -end |
177 | | - |
178 | | -local function run_memory_reader_bof(args) |
179 | | - args = parse_memory_reader_bof(args) |
180 | | - local session = active() |
181 | | - local arch = session.Os.Arch |
182 | | - local bof_file = bof_path("memreader", arch) |
183 | | - return bof(session, script_resource(bof_file), args, true) |
184 | | -end |
185 | | -command_register("mem_reader_bof", run_memory_reader_bof, |
186 | | - "common mem_reader_bof <target-pid> <pattern> <output-size>", |
187 | | - "") |
188 | | - |
189 | | --- regdump |
190 | | -local function run_regdump_bof(args) |
191 | | - local session = active() |
192 | | - if not isadmin(session) then |
193 | | - error("You need to be an admin to run this command") |
194 | | - end |
195 | | - local location = args[1] or "" |
196 | | - local packed_args = bof_pack("z", location) |
197 | | - |
198 | | - local arch = session.Os.Arch |
199 | | - local bof_file = bof_path("regdump", arch) |
200 | | - return bof(session, script_resource(bof_file), packed_args, true) |
201 | | -end |
202 | | -command_register("regdump_bof", run_regdump_bof, "regdump_bof <location>", "") |
203 | | - |
204 | | --- screenshot |
205 | | -local function run_screenshot(args) |
206 | | - local filename |
207 | | - if #args == 1 then |
208 | | - filename = args[1] |
209 | | - else |
210 | | - filename = "screenshot.jpg" |
211 | | - end |
212 | | - local packed_args = bof_pack("z", filename) |
213 | | - local session = active() |
214 | | - local arch = session.Os.Arch |
215 | | - local bof_file = bof_path("screenshot", arch) |
216 | | - local result = bof(session, script_resource(bof_file), packed_args, true) |
217 | | - return result |
218 | | -end |
219 | | -command_register("screenshot_bof", run_screenshot, |
220 | | - "Command: situational screenshot <filename>", "T1113") |
221 | | - |
222 | | ---- common sharp |
| 1 | +--- common sharp |
223 | 2 | local function run_SharpWebServer(args) |
224 | 3 | local session = active() |
225 | 4 | local arch = session.Os.Arch |
|
0 commit comments