python wmiexec_impacket远程命令执行记录

本文记录了使用impacket的wmiexec模块进行远程命令执行的过程,包括如何处理445端口被防火墙过滤的问题。通过`-nooutput`参数可以避免依赖445端口并减少回显。同时,文章提到了UAC(用户账户控制)对横向移动的影响,特别是在工作组和域环境中的不同表现,并指出在非RID 500的本地管理员账户下需要调整注册表设置以绕过Access is Denied错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值