网络渗透作业

server/2025/2/27 7:00:04/

第一题:使用Xpath对Order by 语句进行布尔盲注

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ORDER BY-Error-Numeric</title>
</head><body bgcolor="#000000">
<div style=" margin-top:70px;color:#FFF; font-size:23px; text-align:center">Welcome&nbsp;&nbsp;&nbsp;<font color="#FF0000"> Dhakkan </font><br>
<font size="3" color="#FFFF00"><?php
include("../sql-connections/sql-connect.php");
$id=$_GET['sort'];	
if(isset($id)){//logging the connection parameters to a file for analysis.$fp=fopen('result.txt','a');fwrite($fp,'SORT:'.$id."\n");fclose($fp);$sql = "SELECT * FROM users ORDER BY $id";$result = mysql_query($sql);if ($result){?><center><font color= "#00FF00" size="4"><table   border=1'><tr><th>&nbsp;ID&nbsp;</th><th>&nbsp;USERNAME&nbsp;  </th><th>&nbsp;PASSWORD&nbsp;  </th></tr></font></font><?phpwhile ($row = mysql_fetch_assoc($result)){echo '<font color= "#00FF11" size="3">';		echo "<tr>";echo "<td>".$row['id']."</td>";echo "<td>".$row['username']."</td>";echo "<td>".$row['password']."</td>";echo "</tr>";echo "</font>";}	echo "</table>";}else{echo '<font color= "#FFFF00">';print_r(mysql_error());echo "</font>";  }}	else{echo "Please input parameter as SORT with numeric value<br><br><br><br>";echo "<br><br><br>";echo '<img src="../images/Less-46.jpg" /><br>';echo "Lesson Concept and code Idea by <b>D4rk</b>";}
?></font> </div></br></br></br></center> 
</body>
</html>

若要在 XPath 中执行布尔盲注,你首先需要识别网页中的 sort 参数,它通常包含在 URL 中,以下是Python 示例代码,演示如何通过抓取该网页和分析 URL 中的 sort 参数

import requests
from lxml import htmlurl = "http://example.com/your_page.php?sort=1"  # 攻击URL
response = requests.get(url)
tree = html.fromstring(response.text)# 假设你想查看URL中的sort参数
print("URL:", response.url)  # 打印最终请求的URL# 提取网页内容
page_content = tree.xpath('//div[@style=" margin-top:70px;color:#FFF; font-size:23px; text-align:center"]//text()')
print("网页内容:", page_content)

假设 sort 参数直接插入到 ORDER BY 子句中,可尝试不同的值,验证页面内容的变化,例如

sort=1 AND 1=1(总是为真,通常不会改变输出)

sort=1 AND 1=2(总是为假,通常导致页面没有显示任何内容)

第二题:information_schema被过滤了该如何绕过

1. 使用其他数据库表

  • mysql数据库mysql数据库包含一些系统表,可以提供类似的信息。例如,mysql.dbmysql.tables_privmysql.columns_priv等。
  • performance_schema:如果启用了performance_schema,可以通过它访问某些元数据(如表、列、索引等)。
  • sys数据库:如果你的MySQL版本支持sys数据库,它可以提供比information_schema更简化的查询接口。

2. 字典表或文件系统

  • 直接读取文件系统上的数据库文件和配置文件。如果数据库服务器的文件系统允许访问某些特定的文件,可能能够直接查看表结构或敏感数据。
  • 如果数据库存在数据字典表,它们可能会存储有关数据库结构的其他信息。

3. 使用动态查询

  • 动态SQL:某些情况下,你可以利用动态SQL来间接查询系统表。例如,构造存储过程或使用EXECUTE来绕过过滤。

4. 使用漏洞

  • 如果过滤是由特定的漏洞引起的,可能会通过利用已知漏洞绕过限制。比如,在SQL注入攻击中,如果能通过特殊字符绕过过滤,就能访问information_schema

第三题:对seacmsv9实现联合查询注入管理员密码

<?php
session_start();
require_once("../../include/common.php");
$id = (isset($gid) && is_numeric($gid)) ? $gid : 0;
$page = (isset($page) && is_numeric($page)) ? $page : 1;
$type = (isset($type) && is_numeric($type)) ? $type : 1;
$pCount = 0;
$jsoncachefile = sea_DATA."/cache/review/$type/$id.js";
//缓存第一页的评论
if($page<2)
{if(file_exists($jsoncachefile)){$json=LoadFile($jsoncachefile);die($json);}
}
$h = ReadData($id,$page);
$rlist = array();
if($page<2)
{createTextFile($h,$jsoncachefile);
}
die($h);	function ReadData($id,$page)
{global $type,$pCount,$rlist;$ret = array("","",$page,0,10,$type,$id);if($id>0){$ret[0] = Readmlist($id,$page,$ret[4]);$ret[3] = $pCount;$x = implode(',',$rlist);if(!empty($x)){$ret[1] = Readrlist($x,1,10000);}}	$readData = FormatJson($ret);return $readData;
}function Readmlist($id,$page,$size)
{global $dsql,$type,$pCount,$rlist;$ml=array();if($id>0){$sqlCount = "SELECT count(*) as dd FROM sea_comment WHERE m_type=$type AND v_id=$id ORDER BY id DESC";$rs = $dsql ->GetOne($sqlCount);$pCount = ceil($rs['dd']/$size);$sql = "SELECT id,uid,username,dtime,reply,msg,agree,anti,pic,vote,ischeck FROM sea_comment WHERE m_type=$type AND v_id=$id ORDER BY id DESC limit ".($page-1)*$size.",$size ";$dsql->setQuery($sql);$dsql->Execute('commentmlist');while($row=$dsql->GetArray('commentmlist')){$row['reply'].=ReadReplyID($id,$row['reply'],$rlist);$ml[]="{\"cmid\":".$row['id'].",\"uid\":".$row['uid'].",\"tmp\":\"\",\"nick\":\"".$row['username']."\",\"face\":\"\",\"star\":\"\",\"anony\":".(empty($row['username'])?1:0).",\"from\":\"".$row['username']."\",\"time\":\"".date("Y/n/j H:i:s",$row['dtime'])."\",\"reply\":\"".$row['reply']."\",\"content\":\"".$row['msg']."\",\"agree\":".$row['agree'].",\"aginst\":".$row['anti'].",\"pic\":\"".$row['pic']."\",\"vote\":\"".$row['vote']."\",\"allow\":\"".(empty($row['anti'])?0:1)."\",\"check\":\"".$row['ischeck']."\"}";}}$readmlist=join($ml,",");return $readmlist;
}function Readrlist($ids,$page,$size)
{global $dsql,$type;$rl=array();$sql = "SELECT id,uid,username,dtime,reply,msg,agree,anti,pic,vote,ischeck FROM sea_comment WHERE m_type=$type AND id in ($ids) ORDER BY id DESC";$dsql->setQuery($sql);$dsql->Execute('commentrlist');while($row=$dsql->GetArray('commentrlist')){$rl[]="\"".$row['id']."\":{\"uid\":".$row['uid'].",\"tmp\":\"\",\"nick\":\"".$row['username']."\",\"face\":\"\",\"star\":\"\",\"anony\":".(empty($row['username'])?1:0).",\"from\":\"".$row['username']."\",\"time\":\"".$row['dtime']."\",\"reply\":\"".$row['reply']."\",\"content\":\"".$row['msg']."\",\"agree\":".$row['agree'].",\"aginst\":".$row['anti'].",\"pic\":\"".$row['pic']."\",\"vote\":\"".$row['vote']."\",\"allow\":\"".(empty($row['anti'])?0:1)."\",\"check\":\"".$row['ischeck']."\"}";}$readrlist=join($rl,",");return $readrlist;
}function ReadReplyID($gid,$cmid,&$rlist)
{global $dsql;if($cmid>0){if(!in_array($cmid,$rlist))$rlist[]=$cmid;$row = $dsql->GetOne("SELECT reply FROM sea_comment WHERE id=$cmid limit 0,1");if(is_array($row)){$ReplyID = ",".$row['reply'].ReadReplyID($gid,$row['reply'],$rlist);}else{$ReplyID = "";}}else{$ReplyID = "";}return $ReplyID;
}function FormatJson($json)
{$x = "{\"mlist\":[%0%],\"rlist\":{%1%},\"page\":{\"page\":%2%,\"count\":%3%,\"size\":%4%,\"type\":%5%,\"id\":%6%}}";for($i=6;$i>=0;$i--){$x=str_replace("%".$i."%",$json[$i],$x);}$formatJson = jsonescape($x);return $formatJson;
}function jsonescape($txt)
{$jsonescape=str_replace(chr(13),"",str_replace(chr(10),"",json_decode(str_replace("%u","\u",json_encode("".$txt)))));return $jsonescape;
}

存在漏洞的位置

$sqlCount = "SELECT count(*) as dd FROM sea_comment WHERE m_type=$type AND v_id=$id ORDER BY id DESC";


$rs = $dsql->GetOne($sqlCount);


$sql = "SELECT id,uid,username,dtime,reply,msg,agree,anti,pic,vote,ischeck FROM sea_comment WHERE m_type=$type AND v_id=$id ORDER BY id DESC limit ".($page-1)*$size.",$size ";
 

可将$type参数更改为一个恶意的SQL注入,进行联合查询

UNION SELECT null, null, null, null, null, null, null, null, null, username, password FROM admin_table --+


http://www.ppmy.cn/server/170964.html

相关文章

Unity Shader 学习13:屏幕后处理 - 使用高斯模糊的Bloom辉光效果

目录 一、基本的后处理流程 - 以将画面转化为灰度图为例 1. C#调用shader 2. Shader实现效果 二、Bloom辉光效果 1. 主要变量 2. Shader效果 &#xff08;1&#xff09;提取较亮区域 - pass1 &#xff08;2&#xff09;高斯模糊 - pass2&3 &#xff08;3&#xff…

每日一题——LRU缓存机制的C语言实现详解

LRU缓存机制的C语言实现详解 参考1. 数据结构设计双向链表节点哈希表节点哈希表LRU缓存结构 2. 初始化哈希表和双向链表哈希函数初始化哈希表初始化双向链表创建LRU缓存 3. 更新双向链表4. 实现Get操作5. 实现Put操作更新节点值删除最久未使用节点插入或更新节点 6. 释放缓存释…

内容中台的企业CMS架构是什么?

企业CMS模块化架构 现代企业内容管理系统的核心在于模块化架构设计&#xff0c;通过解耦内容生产、存储、发布等环节构建灵活的技术栈。动态/静态发布引擎整合技术使系统既能处理实时更新的产品文档&#xff0c;也能生成高并发的营销落地页&#xff0c;配合版本控制机制确保内…

20.<Spring图书管理系统①(登录+添加图书)>

PS&#xff1a;关于接口定义 接口定义&#xff0c;通常由服务器提供方来定义。 1.路径&#xff1a;自己定义 2.参数&#xff1a;根据需求考虑&#xff0c;我们这个接口功能完成需要哪些信息。 3.返回结果&#xff1a;考虑我们能为对方提供什么。站在对方角度考虑。 我们使用到的…

JAVA面试常见题_基础部分_springboot面试题

问题一 什么是 Spring Boot&#xff1f; 多年来&#xff0c;随着新功能的增加&#xff0c;spring 变得越来越复杂。只需访问 https://spring.io/projects 页面&#xff0c;我们就会看到可以在我们的应用程序中使用的所有 Spring 项目的不同功能。如果必须启动一个新的 Sprin…

C++ STL(二)deque

目录 deque&#xff08;双端队列&#xff09; 内存结构 验证地址不连续 使用详解 构造函数 元素访问 容量操作 修改 迭代器 迭代器失效 code实例 实现一个简单的deque deque&#xff08;双端队列&#xff09; std::deque&#xff08;双端队列&#xff09;是 C 标准…

word中对插入的图片修改背景色

关于对word中插入的图片修改背景色的问题&#xff0c;网上查了好多都无效&#xff0c;可能是由于word版本的问题&#xff0c;本人word版本为2019版&#xff0c;亲测有效的修改图片背景色为透明的小技巧&#xff1a; 选中图片-设置图片格式-最右面图标&#xff0c;选择图片校正…

JavaEE 编写Java程序,实现简单的echo程序(网络编程TCP实践练习)

Java TCP 客户端/服务器开发深度解析 一、客户端代码全注释 public class TcpClient {private Socket socket null; // TCP通信核心对象// 构造函数&#xff1a;建立TCP连接public TcpClient(String ip, int port) throws IOException {// 创建Socket时会自动进行三次握手s…