impacket远程命令执行记录
在横向移动的时候常常会遇到目标445端口被防火墙过滤的情况,那么我们就需要通过其他端口进行横向移动。
之前对impacket中远程命令执行的帮助文件看的不是很透彻,导致掉坑里。
wmiexec&dcomexec
正常我们使用wmiexec、dcomexec的时候,命令会这样写,会回显执行结果。这时wmiexec、dcomexec会使用135、445端口,但如果目标445端口被防火墙过滤就会导致远程命令执行失败。
1python wmiexec.py administrator@172.16.102.135 "whoami"
后续发现有一个参数叫-nooutput就可以解决这样的情况,这时wmiexec、dcomexec仅仅会使用135端口,但是不会有回显。有些时候很有必要把debug打开。
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
31Impacket v0.9.14-dev - Copyright 2002-2015 Core Security Technologies
usage: wmiexec.py [-h] [-share SHARE] [-nooutput] [-debug]
[-hashes LMHASH:NTHASH] [-no-pass] [-k] [-aesKey hex key]
target [command [command ...]]
Executes a semi-interactive shell using Windows Management Instrumentation.
positional arguments:
target [[domain/]username[:password]@]
command command to execute at the target. If empty it will
launch a semi-interactive shell
optional arguments:
-h, --help show this help message and exit
-share SHARE share where the output will be grabbed from (default
ADMIN$)
-nooutput whether or not to print the output (no SMB connection
created)
-debug Turn DEBUG output ON
authentication:
-hashes LMHASH:NTHASH
NTLM hashes, format is LMHASH:NTHASH
-no-pass don't ask for password (useful for -k)
-k Use Kerberos authentication. Grabs credentials from
ccache file (KRB5CCNAME) based on target parameters.
If valid credentials cannot be found, it will use the
ones specified in the command line
-aesKey hex key AES key to use for Kerberos Authentication (128 or 256
bits)
感觉这张图总结的很好,喜欢了😍
UAC
在横向移动的时候我们也常常会遇到UAC的问题,rpc_s_access_denied是我们不愿意看到的。
主要分为两种情况:工作组、域
工作组:
对于任何非RID 500的本地管理员(Administrator)连接到WIndows Vista+的计算机,无论是采用WMI、PSexec还是其他方法,使用的令牌都是”已经过滤过的”(即中等令牌)。当使用上述命令进行链接的时候会显示Access is Denied。
在工作组的情况,我们需要使用RID 500的Administrator才可以成功。如果想要在非RID 500的账户测试,需要更改一下注册表。
1HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy
域:
我记得在域的环境下,貌似远程UAC是不一样的,具体的忘记了,后续补一下。
Respect