iwebsec靶场 文件包含漏洞通关笔记7-php://input伪协议

发布于:2023-09-15 ⋅ 阅读:(130) ⋅ 点赞:(0)

目录

前言

1.php://input伪协议原理

2.php://input伪协议使用条件

3.file_get_contents()函数

第07关 php://input伪协议

1.打开靶场

2.源码分析

3.伪协议渗透

(1)构造post信息

(2)渗透


前言

1.php://input伪协议原理

​php://input可以访问请求的原始数据的只读流,将post请求的数据当作php代码执行,如果存在文件包含漏洞,可将php://input作为文件名传入,同时在post中注入设置想要注入的代码,php执行时就会将post的内容作为php代码执行。


2.php://input伪协议使用条件

使用条件:
1.allow_url_fopen: on
2.allow_url_include:on

3.file_get_contents()函数

在利用文件包含漏洞的时候经常会碰到file_get_contents()函数,这个函数的作用是把整个文件读入一个字符串中

第07关 php://input伪协议

1.打开靶场

http://iwebsec.com:81/fi/07.php

 

2.源码分析

<?php

  require_once('../header.php');
  ?>
<html>
	<head>
		<title>php://input伪协议</title>
	</head>
	<h2>php://input伪协议</h2>
		<div class="alert alert-success">
			<p>/07.php?filename=php://input </p>
		</div>
	<body>
	
<?php
    echo file_get_contents("php://input");
	
?>

 如下所示关键源码中有file_get_contents函数,参数是"php://input", 通常file_get_content函数是结合代码审计做一些渗透。

<?php
    echo file_get_contents("php://input");
?>

这时候只要将参数通过post传入到服务器即可。

3.伪协议渗透

(1)构造post信息

I am a hacker!

(2)渗透

如下所示,通过传入参数I am a hacker!使用file_get_content将内容输出到页面

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到