index.html
<a href="http://adtuu-server.com/login/login.php?auth_username=admin&auth_password=admin123">Login</a> admincp.php
<?php
$username = $_POST['auth_username'];
$password = $_POST['auth_password']; if ($username == 'admin' && $password == 'admin123') {
echo 'ok';
} else {
echo 'error.';
} login.php
<?php
if (isset($_GET['auth_username']) && isset($_GET['auth_password'])) { $user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)"; $header = array (
"Host:www.adtuu-server.com",
"Referer: http://www.adtuu-server.com/login/login.php",
); $data = array(
'auth_username' => $_GET['auth_username'],
'auth_password' => $_GET['auth_password']
); $url = 'http://www.adtuu-server.com/login/admincp.php'; $curl = curl_init (); // 启动一个CURL会话
curl_setopt ( $curl, CURLOPT_URL, $url ); // 要访问的地址
curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, 0 ); // 对认证证书来源的检查
// curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, 1 ); // 从证书中检查SSL加密算法是否存在
curl_setopt ( $curl, CURLOPT_USERAGENT, $user_agent ); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); //设置头信息的地方
@curl_setopt ( $curl, CURLOPT_FOLLOWLOCATION, 1 ); // 使用自动跳转
// curl_setopt ( $curl, CURLOPT_HTTPGET, 1 ); // 发送一个常规的GET请求
curl_setopt ( $curl, CURLOPT_POST, 1 ); // 发送一个常规的Post请求
curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data ); // Post提交的数据包 // curl_setopt ( $curl, CURLOPT_COOKIE, $cookie); // 直接发送cookie内容
// curl_setopt($curl,CURLOPT_COOKIEFILE, $cookieFile); //发送Cookie文件
curl_setopt ( $curl, CURLOPT_TIMEOUT, 120 ); // 设置超时限制防止死循环
curl_setopt ( $curl, CURLOPT_HEADER, 0 ); // 不显示返回的Header区域内容
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 ); // 获取的信息以文件流的形式返回 $res = curl_exec ( $curl ); // 执行操作 if (curl_errno ( $curl )) {
die('失败:Errno' . curl_error ( $curl ));
} curl_close ( $curl ); // 关闭CURL会话 // header('Location:http://www.adtuu-server.com/login/admincp.php');
echo $res;
exit;
}
?> <form action="http://www.adtuu-server.com/login/admincp.php" method="post">
<input type="text" name="auth_username" /><br />
<input type="password" name="auth_password" value="" /><br />
<input type="submit" value="Login" /><br />
</form>

  

CURL模拟登陆的更多相关文章

  1. PHP 之 CURL 模拟登陆并获取数据

    1.CURL模拟登陆的流程和步骤 2.tempnam 创建一个临时文件 3.使用CURL模拟登陆到PHP100论坛 <?php $cookie_file = tempnam('./temp',' ...

  2. php 的curl 模拟登陆

    做一个类似这样的web 应用. 1,解决掉验证码 其实这是正方的一个小bug,当我们进入登陆界面时,浏览器会去请求服务器,服务器会生成一个验证码图片.如果我们不去请求这个图片,那么正方后台也不会生成相 ...

  3. 【转】PHP 之 CURL 模拟登陆并获取数据

    1.CURL模拟登陆的流程和步骤2.tempnam 创建一个临时文件3.使用CURL模拟登陆到PHP100论坛 <?php$cookie_file = tempnam('./temp','coo ...

  4. PHP curl 模拟登陆

    一个比较好的类: $cookie_file=tempnam("C:/users","tmp");生成以以tmp为前缀的文件. <?php define ( ...

  5. Shell 利用 curl 模拟登陆

    -b 参数 指定使用cookie文件 -c是往cookie文件中写cookie -d 是指定此次登录所需的参数,通过httpfox查看 -L 指定页面自动跳转 #curl -c ck.txt --us ...

  6. php curl模拟登陆抓取数据

    http://www.cnblogs.com/zengguowang/p/6814474.html

  7. php模拟登陆的两种实现方法分析

    php模拟登陆的实现方法分析 本文实例分析了php模拟登陆的实现方法.分享给大家供大家参考.具体分析如下: php模拟登陆的实现方法,这里分别列举两种方法实现模拟登陆人人网.具体实例代码如下: 1)使 ...

  8. 以正方教务系统为例,用php模拟登陆抓取课表、空教室

    课程格子和超级课程表这两个应用,想必大学生都很熟悉,使用自己的学号和教务系统的密码,就可以将自己的课表导入,随时随地都可以在手机上查看. 其实稍微了解一点php的话,我们也可以做一个类似这样的web ...

  9. curl模拟自动登陆&采集网页数据

    <!DOCTYPE> <html> <head> <meta http-equiv="Content-Type" content=&quo ...

随机推荐

  1. LeetCode: Reverse Words in a String:Evaluate Reverse Polish Notation

    LeetCode: Reverse Words in a String:Evaluate Reverse Polish Notation Evaluate the value of an arithm ...

  2. 使用phpExcel向mysql数据库导入excel

    使用phpExcel向mysql数据库导入excel from:http://blog.163.com/dustye_l/blog/static/172439513201242491016834/ 使 ...

  3. 详解SQL Server连接(内连接、外连接、交叉连接)

    在查询多个表时,我们经常会用“连接查询”.连接是关系数据库模型的主要特点,也是它区别于其它类型数据库管理系统的一个标志. 什么是连接查询呢? 概念:根据两个表或多个表的列之间的关系,从这些表中查询数据 ...

  4. AngularJS - 插件,module注入

    Index.html <body> <div ng-app="myApp"> <div ng-controller="firstContro ...

  5. php编程中容易忽略的地方

    一:fopen ( string $filename , string $mode [, bool $use_include_path = false [, resource $context ]] ...

  6. String StringBuilder以及StringBuffer

    例一:[看了威哥视频,下面更好理解] package sunjava; public class String_test { public static void main(String[] args ...

  7. 浅谈xss攻击

    近期学习过程中提到xss攻击的问题,便想要了解一下,总结如下: XSS攻击:跨站脚本攻击(Cross Site Scripting),为不和层叠样式表(Cascading Style Sheets, ...

  8. Android进阶笔记05:View、SurfaceView 和GLSurfaceView 的关系和区别

    1.  Android游戏当中主要的除了控制类外就是显示类View.SurfaceView是从View基类中派生出来的显示类.android游戏开发中常用的三种视图是:    (1) view.Sur ...

  9. Org-mode 任务添加提醒

    org-mode中的约会日程有提醒功能,这样设置就行: ;; ;;; 提醒 ;; (require 'appt) ;; (appt-activate t);启用约会提醒 ;; (setq appt-d ...

  10. jQuery扩展工具方法

    共享学习Jquery源码的一些东西 jQuery.extend({   expando  :  生成唯一JQ字符串(内部) noConflict()  :  防止冲突 ---------------- ...