PHP's file_get_contents and CURL functions

PHP下载远程内容:file_get_contents与CURL函数概览
本文总结了使用PHP的file_get_contents函数和CURL函数下载远程内容(如网页、XML文件、图片等)的相关技巧。包括设置用户代理、处理HTTP基本认证、使用CURL发送用户名和密码、配置CURL存储cookie、提交表单、设置HTTP referer、以及在使用MAMP遇到HTTPS访问问题时的解决方案。

PHP's file_get_contents and CURL functions

转载:http://www.electrictoolbox.com/php-file-get-contents-curl/

This is a summary of the posts I've written about PHP's file_get_contents functions when used to download remote content (e.g. webpages, XML files, images etc) and the CURL functions which are used to do the same thing.

PHP Manual Pages

As always, don't forget to read the manual pages from the PHP manual; they don't always cover everything that well and are sometimes lacking in examples but always make a good starting point when wanting to know how a particular function works. The user submitted comments are often useful too.

file_get_contents() posts

CURL


我在参加ctf新生赛,这是一道web题目,叫做ez??upload 给了一个网站http://160.30.231.222:33360/ 源代码是<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title>Upload</title> <style> body { font-family: Arial, sans-serif; background-color: #f2f2f2; } .container { max-width: 400px; margin: 0 auto; padding: 20px; background-color: #fff; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } .form-group { margin-bottom: 20px; } .form-group label { display: block; font-weight: bold; margin-bottom: 5px; } .form-group input[type="file"] { padding: 10px; border: 1px solid #ccc; border-radius: 5px; background-color: #fff; } .form-group input[type="submit"] { padding: 10px 20px; background-color: #4CAF50; color: #fff; border: none; border-radius: 5px; cursor: pointer; } .form-group input[type="submit"]:hover { background-color: #45a049; } </style> </head> <body> <div class="container"> <h2>文件上传</h2> <form action="index.php" method="POST" enctype="multipart/form-data"> <div class="form-group"> <label for="file">选择文件</label> <input type="file" name="file" id="file" /> </div> <div class="form-group"> <input type="submit" value="上传" /> </div> </form> </div> </body> </html> <!-- class.php --> Hacker? 把网站后缀加上/class.php得到<?php error_reporting(0); highlight_file(__FILE__); class hacker{ public $cmd; public $a; public function __destruct(){ if('hahaha' === preg_replace('/;+/','hahaha',preg_replace('/[A-Za-z_\(\)]+/','',$this->cmd))){ eval($this->cmd.'hahaha!'); } else { echo 'nonono'; } } } if(isset($_POST['file'])) { if(preg_match('/^phar:\/\//i',$_POST['file'])) { die("nonono"); } file_get_contents($_POST['file']); } ?> 我该怎么做才能找到flag,一步一步详细来讲,我是纯新手注意我是纯新手!
10-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值