Php 如何通过操纵当前页面向某些网页发送POST请求?

Php 如何通过操纵当前页面向某些网页发送POST请求?,php,security,http,post,header,Php,Security,Http,Post,Header,我想设置诸如post变量名和值等标题,并发送和期望响应。 这也是一个安全问题,假设我想发送一个表单变量,其变量为action=“delete”和userid=100,并且假设我找到了一个接受ajax请求的文件。您可以使用它。查查 您可以发送数据POST/GET方法、上载文件、SSL支持、cookie支持、ftp支持以及更多信息(是您的朋友!) 假设您在example.org/process.php上注意到一个表单正在发布到的端点。您可以使用curl从命令行轻松定制您自己的定制请求 $ curl

我想设置诸如post变量名和值等标题,并发送和期望响应。 这也是一个安全问题,假设我想发送一个表单变量,其变量为action=“delete”和userid=100,并且假设我找到了一个接受ajax请求的文件。

您可以使用它。查查

您可以发送数据POST/GET方法、上载文件、SSL支持、cookie支持、ftp支持以及更多信息(是您的朋友!)

假设您在
example.org/process.php
上注意到一个表单正在发布到的端点。您可以使用
curl
从命令行轻松定制您自己的定制请求

$ curl -X POST --data "action=delete&userid=100" example.org/process.php
--data
-D
标志允许您像HTML表单一样传递任意POST数据。您还可以同样轻松地设置HTTP请求头:

$ curl --header "User-Agent: Mosaic" example.org/process.php
您可以确切地看到
-v
(详细)标志发生了什么。对于上面的第一个示例,输出为:

* About to connect() to example.org port 80 (#0)
*   Trying 192.0.43.10... connected
* Connected to example.org (192.0.43.10) port 80 (#0)
> POST /process.php HTTP/1.1
> User-Agent: curl/7.21.6 (x86_64-apple-darwin10.5.0) libcurl/7.21.6 OpenSSL/1.0.0d zlib/1.2.5 libidn/1.22
> Host: example.org
> Accept: */*
> Content-Length: 24
> Content-Type: application/x-www-form-urlencoded
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Found
< Location: http://www.iana.org/domains/example/
< Server: BigIP
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 0
< 
* Connection #0 to host example.org left intact
* Closing connection #0
*即将()连接到example.org端口80(#0)
*正在尝试192.0.43.10。。。有联系的
*已连接到example.org(192.0.43.10)端口80(#0)
>POST/process.php HTTP/1.1
>用户代理:curl/7.21.6(x86_64-apple-darwin10.5.0)libcurl/7.21.6 OpenSSL/1.0.0d zlib/1.2.5 libidn/1.22
>主持人:example.org
>接受:*/*
>内容长度:24
>内容类型:application/x-www-form-urlencoded
> 
*HTTP 1.0,假设在正文之后关闭
找到

如果您使用的是包含Mac OS X的*NIX操作系统,您可能已经有了
curl
,只需打开一个shell即可。如果您使用Ruby,我强烈建议您使用该语言的一组绑定。大多数PHP安装都支持curl,尽管界面非常糟糕。文档在。

您可能还想看看史努比()

它是一个PHP类,设计用作web浏览器,具有许多有用的功能,如模拟HTTP请求、操作表单数据等