当前位置:网站首页>网络安全——Cookie注入
网络安全——Cookie注入
2022-07-24 13:32:00 【Beluga】
综合渗透测试-Cookie注入
第一步,打开网络拓扑,启动实验虚拟机,分别查看虚拟机IP地址:
Kali Linux

Windows 7

第二步,使用Kali Linux访问sqli-lab第20关的页面:
http://172.16.1.200(靶机IP地址)/sqli-labs/Less-20/

第三步,右键页面-选择Inspect Element with Firebug

第四步,切换至Cookies选项卡-Cookies-Create Cookie

第五步,创建一个用户名的Cookie,名称为uname,值为admin,将Path修改为“/”

第六步,关闭窗口,并重新刷新页面

第七步,刷新页面后,发现Cookie已经被显示

通过上图我们可以发现,我们将Cookie中的uname用户名设为admin,网页通过SQL语句查询出该用户的密码是admin。既然uname被引用并查询了SQL,那么通过修改Cookie中uname的值,我们或许可以进行SQL注入攻击。
第八步,再次重复上述步骤,右键uname-edit,修改用户名的值

第九步,爆出行数:
1)将uname的值修改:
admin' order by 4--+

2)刷新页面,提示第四行不存在

3)将值中的“4”改为“3”,即以第三列排序,以此判断第三列是否存在

4)刷新页面,页面正常,证明数据库共有三列

第十步,爆出当前数据库的名称:
1)修改uname的值:
-admin' union select 1,2,database()--+

2)刷新页面,得到当前的数据库名为security

第十一步,进入第21关,访问地址:
http://172.16.1.200/sqli-labs/Less-21

第十二步,21关卡也同样是Cookie注入。刚刚我们测试过的uname仍然生效,但页面最下方显示错误

出现该错误,我们首先要考虑的是编码问题。由于上个关卡测试没有问题,所以不是编码问题。那么很有可能是uname的值被加密了,最有可能的就是可以被还原的base64加密。
切换至Windows 7靶机,查看网站源码,验证base64加密的过程
C:\AppServ\www\sqli-labs\Less-22\index.php

在源代码中,通过base64_encode方法将用户名(username字段)进行了base64的加密。
第十三步,先将现在uname的值提取出来,将其base64加密后再写入到Cookie当中:
1)右键uname-edit,复制Value中的值

2)打开终端,使用命令将当前语句进行base64加密
echo -n "-admin' union select 1,2,database()--+" | base64

3)将加密后的值粘贴回去

4)刷新页面,页面成功解析了我们base64加密后的值,但报出错误

这表示我们的“--+”注释符号失去了作用。
5)更换注入语句,重新编码:
echo -n "-admin') union select 1,2,database()#" | base64

6)写入Cookie

7)刷新页面,获得当前数据库名

第十四步,访问第22关卡:
http://172.16.1.200/sqli-labs/Less-22

第十五步,本关卡仍为Cookie注入,我们在上一关的Cookie依然保留,首先看到,我们当前的Cookie是没有返回任何结果的

第十六步,切换至Windows 7靶机,查看该页面的源代码,找到原因:
C:\AppServ\www\sqli-labs\Less-22\index.php

22关卡的SQL语句不再使用单引号进行包含,变成了双引号。
第十七步,修改刚刚的注入语句,使用双引号代替单引号,再去掉括号:
1)生成新的uname值:
echo -n "-admin\" union select 1,2,database()#" | base64

2)写入到Cookie

3)刷新页面,注入成功

实验结束,关闭虚拟机。
边栏推荐
- Handler learning
- Activity start (launchactivity/startactivity)_ (1)_ WMS of flow chart
- Question 10: find numbers in an array with rows and columns in order
- Sort method -- bubble sort (use an array to sort a string of numbers from large to small or from small to large)
- The use of two-dimensional array (including the definition of two-dimensional array, the declaration and initialization of two-dimensional array (dynamic initialization, static initialization), common
- 深入浅出边缘云 | 2. 架构
- 基于社会媒体数据增强的交通态势感知研究及进展
- 浅谈Node Embedding
- Outdoor billboards cannot be hung up if you want! Guangzhou urban management department strengthens the safety management of outdoor advertising
- 关于如何提升TTL(UART)通信抗干扰——心得
猜你喜欢
![[acm/ two points] two points clear entry-level explanation](/img/87/e4d58b7530bfc381ec07d7c76e90a1.png)
[acm/ two points] two points clear entry-level explanation

From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"

HCIP第十三天

Outdoor billboards cannot be hung up if you want! Guangzhou urban management department strengthens the safety management of outdoor advertising

Finclip's "applet export app" function has been updated again by the company

Representation and basic application of regular expressions

Knowledge sharing | sharing some methods to improve the level of enterprise document management

LeadTools 22 kit LeadTools super set

vscode配置用户代码片段(包括删除方法)

ESP32ADC
随机推荐
FinClip 「小程序导出 App 」功能又双叒叕更新了
论文笔记:Swin-Unet: Unet-like Pure Transformer for MedicalImage Segmentation
登临科技联合创始人王平:创新+自研“双核”驱动,GPU+赋能AI落地生根|量子位·视点分享回顾...
The use of two-dimensional array (including the definition of two-dimensional array, the declaration and initialization of two-dimensional array (dynamic initialization, static initialization), common
Realize a JS lottery?
Outdoor billboards cannot be hung up if you want! Guangzhou urban management department strengthens the safety management of outdoor advertising
Easycvr platform security scanning prompt go pprof debugging information leakage solution
SSM hospital inpatient management system
Detailed explanation of odoo JS DoAction
Interview question 01.02. determine whether it is character rearrangement
Redis(13)----浅谈Redis的主从复制
基于ABP实现DDD--实体创建和更新
汉字风格迁移篇---用于汉字多字体生成的多样性正则化StarGAN
Recommended idling tools | comprehensive comparison of 10 spatial transcriptome deconvolution tools
Introduction to single chip microcomputer
关于如何提升TTL(UART)通信抗干扰——心得
Windivert: capture and modify packages
Selenium environment configuration and eight elements positioning
Copy of array and array address value
Introduction to encryption technology