curl模拟登陆

1446人浏览 / 0人评论

一、先填写一个错误的账号密码进行登录

然后就可以看到我输入错的密码:

我们需要这条请求链接

当我们点击登录按钮的时候,浏览器就会POST请求

http://zabbix02.cdstm.cn/index.phpname=zxcasd&password=546544654&autologin=1&enter=Sign+in

二、服务器上测试

先curl获取cookie

[root@openvpn curl]# curl -X GET -c cookie -b cookie http://zabbix02.cdstm.cn/index.php
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="Author" content="Zabbix SIA" />
        <title>zabbix42: Zabbix</title>
        <link rel="icon" href="favicon.ico">
        <link rel="apple-touch-icon-precomposed" sizes="76x76" href="img/apple-touch-icon-76x76-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="120x120" href="img/apple-touch-icon-120x120-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="img/apple-touch-icon-152x152-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="180x180" href="img/apple-touch-icon-180x180-precomposed.png">
        <link rel="icon" sizes="192x192" href="img/touch-icon-192x192.png">
        <meta name="csrf-token" content=""/>
        <meta name="msapplication-TileImage" content="img/ms-tile-144x144.png">
        <meta name="msapplication-TileColor" content="#d40000">
        <meta name="msapplication-config" content="none"/>
<link rel="stylesheet" type="text/css" href="styles/blue-theme.css" />
<style type="text/css">.na-bg, .na-bg input[type="radio"]:checked + label, .na-bg:before, .flh-na-bg, .status-na-bg { background-color: #97AAB3 }
.info-bg, .info-bg input[type="radio"]:checked + label, .info-bg:before, .flh-info-bg, .status-info-bg { background-color: #7499FF }
.warning-bg, .warning-bg input[type="radio"]:checked + label, .warning-bg:before, .flh-warning-bg, .status-warning-bg { background-color: #FFC859。。。。

。。。。。。。。。。。。

。。。。。。

 

查看网址源代码是一样的

 三、直接登录

-L 是跟随跳转

[root@openvpn curl]# curl -X POST -L -c cookie -b cookie -d "name=Admin&password=4565664&autologin=1&enter=Sign+in" http://zabbix.cdstm.cn/index.php

登录成功

----

 

全部评论