免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2844 | 回复: 3
打印 上一主题 下一主题

帮帮忙解决一下网站自动登陆的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-19 21:25 |只看该作者 |倒序浏览
请各位帮忙看看下面这段代码哪有问题,我不怎么试,打开aa.html页面都是说输入的用户名、密码错误!  我已经看了好几天了但
就是找不到问题原因

use LWP 5.64;
  use URI;
  use CGI qw(:standard);
  use HTTP::Cookies;
  use strict;

open (ABC,">E:/aa.html");
my $ua = LWP::UserAgent->new;  
my   $cookie_jar = HTTP::Cookies->new;

my $header = HTTP::Headers->new(
      Date         => 'Sat, 19 Jul 2008 20:38:00 GMT',
      Content_Type => 'text/html; charset=UTF-8',
      Content_Base => 'http://192.168.240.105:8080/pebble/');
my $loginurl='http://192.168.240.105:8080/pebble/j_security_check';
my $loginconten="j_username=dianqiang.yang&j_password=780602,.";
my $request = HTTP::Request->new(POST=>$loginurl,$header,$loginconten);
$cookie_jar->add_cookie_header($request);  

my $response = $ua->request($request);
$cookie_jar->extract_cookies($response);
print ABC $response->content;
close (ABC)


---------------------网站登陆界面的源代码------------------------------------













<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="http://192.168.240.105:8080/pebble/" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>服务系统日志 - Login</title>
    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://192.168.240.105:8080/pebble/rss.xml" />
    <link rel="alternate" type="application/rdf+xml" title="RDF" href="http://192.168.240.105:8080/pebble/rdf.xml" />
    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://192.168.240.105:8080/pebble/atom.xml" />

   
      
        <style>
        body {
  font-family: Lucida Grande, Verdana, Tahoma, Arial, Helvetica, sans-serif;
  font-size: 11px;
  background : darkgray;
  color : black;
  text-align: left;
  border-top: solid black 1px;
  border-right: solid black 1px;
  border-bottom: solid black 1px;
  border-left: solid black 1px;
  margin: 16px;
}
blockquote {
  border-left: solid silver 4px;
  padding-left: 8px;
}
.small {
  font-size: 11px;
}
.header {
  background : #4169AA;
  color: white;
  font-weight: bold;
  padding: 8px;
  background-image: url(common/images/header.jpg);
  background-position: top;
  background-repeat: repeat-x;
  position: relative;
}
.header a:link, .header a:visited, .header a:active {
  color : white;
}
.search {
  float: right;
  position: relative;
  text-align: right;
}
.headerLinks, .footerLinks {
  float: right;
  position: relative;
  width: 50%;
  text-align: right;
}
.headerLinks a:link, .headerLinks a:visited, .headerLinks a:active,
.footerLinks a:link, .footerLinks a:visited, .footerLinks a:active {
  color : white;
}
#categories {
  padding-left: 0px;
  padding-right: 0px;
  padding-top: 0px;
  padding-bottom: 0px;
  color : white;
  font-weight: bold;
}
.category a:link, .category a:visited, .category a:active {
  padding-top: 1px;
  padding-bottom: 1px;
  padding-left: 2px;
  padding-right: 2px;
  color : white;
}
.category {
}
.category a:hover, .selectedCategory {
  color: #4169AA;
  background: white;
  text-decoration: none;
  padding-top: 1px;
  padding-bottom: 1px;
  padding-left: 2px;
  padding-right: 2px;
}
.tags {
  border: solid #F0F0F0 1px;
  margin: 16px;
  padding: 4px;
  background: #F8F8F8;
  font-weight: normal;
}
.tags a:link, .tags a:visited, .tags a:active {
  color : gray;
  font-weight: normal;
}
.photo {
  padding-top: 0px;
  padding-right: 0px;
  padding-bottom: 0px;
  padding-left: 0px;
  border-top: solid black 1px;
  border-right: solid black 1px;
  border-bottom: solid black 1px;
  border-left: solid black 1px;
  text-align: center;
}
.codeSample {
  font-family: Courier, sans-serif;
  border-top: solid #F0F0F0 1px;
  border-right: solid #F0F0F0 1px;
  border-bottom: solid #F0F0F0 1px;
  border-left: solid #F0F0F0 1px;
  text-align: left;
  background: #F8F8F8;
  margin-left: 32px;
  margin-right: 32px;
  padding: 16px;
  overflow: auto;
}
a:link, a:visited, a:active {
  color: #4169AA;
  text-decoration: none;
  font-weight: bold;
}
a:hover {
  text-decoration: underline;
}
.content {
  background : white;
  padding-top: 16px;
  padding-right: 8px;
  padding-bottom: 8px;
  padding-left: 8px;
  margin-right: 220px;
}
.bodyContent {
  background : white;
}
.sidebar {
  text-align: center;
  float: right;
  position: relative;
  width: 200px;
  padding-left: 8px;
  padding-top: 8px;
  padding-right: 8px;
  padding-bottom: 32px;
}
.footer {
  background: #4169AA;
  color: white;
  font-weight: bold;
  padding: 8px;
  clear: both;
  background-image: url(common/images/footer.jpg);
  background-position: bottom;
  background-repeat: repeat-x;
}
.footer a:link, .footer a:visited, .footer a:active {
  color : white;
}
.blogName, .blogName a:link, .blogName a:visited, .blogName a:active {
  font-size: 24px;
  font-weight: bold;
}
.blogDescription {
  font-weight: none;
  padding-bottom: 32px;
}
.linearNavigationLinks {
  text-align: center;
  padding-bottom: 8px;
  position: relative;
}
.calendar {
  text-align: center;
}
.calendarDayHeader {
  font-weight: bold;
  text-align: right;
}
.calendarDay {
  text-align: right;
  border: solid white 1px;
}
.calendarDayWithEntries {
  text-align: right;
  border: solid #F0F0F0 1px;
}
.calendarDayWithEntries a:link, .calendarDayWithEntries a:visited, .calendarDayWithEntries a:active {
  border: solid white 0px;
}
.calendarToday, .calendarToday a:link, .calendarToday a:visited, .calendarToday a:active {
  background : #4169AA;
  color: white;
  font-weight: bold;
  text-align: right;
}
.help, .help a:link, .help a:visited, .help a:active {
  color: gray;
  font-weight: bold;
  text-align: right;
}
.validationError {
  color: #B20D1C;
}

.blogEntry, .item {
  text-align: left;
  border-top: dotted silver 1px;
  padding-top: 8px;
  padding-left: 8px;
  padding-right: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  position: relative;
}
.comment, .trackback {
  padding: 8px;
}

.blogEntryHeader, .blogEntryHeader a:link, .blogEntryHeader a:visited, .blogEntryHeader a:active {
  color: black;
  font-weight: bold;
  position: relative;
}
.itemHeader, .itemHeader a:link, .itemHeader a:visited, .itemHeader a:active {
  color: black;
  font-size: 16px;
  font-weight: bold;
  position: relative;
}
.commentHeader, .commentHeader a:link, .commentHeader a:visited, .commentHeader a:active, .trackbackHeader,
.trackbackHeader a:link, .trackbackHeader a:visited, .trackbackHeader a:active {
  font-weight: bold;
  color: black;
}

.blogEntryTitle, .blogEntryTitle a:link, .blogEntryTitle a:visited, .blogEntryTitle a:active {
  color: black;
  font-size: 16px;
  font-weight: bold;
}
.blogEntrySubtitle, .blogEntrySubtitle a:link, .blogEntrySubtitle a:visited, .blogEntrySubtitle a:active {
  color: black;
  font-weight: bold;
}
.blogEntryBody, .itemBody {
  padding-top: 16px;
  padding-bottom: 16px;
  line-height: 1.5;
}
.itemBodyEven {
  background: #F4F4F4;
}
.itemBodyOdd {
  background: white;
}
.commentBody, .trackbackBody {
  padding-top: 8px;
  padding-bottom: 8px;
  line-height: 1.5;
}

.blogEntryLinks, .itemLinks, .commentLinks, .trackbackLinks {
  float: right;
  position: relative;
  color: gray;
  font-weight: bold;
  text-align: right;
  font-size: 11px;
}

.blogEntryLinks a:link, .blogEntryLinks a:visited, .blogEntryLinks a:active,
.itemLinks a:link, .itemLinks a:visited, .itemLinks a:active,
.commentLinks a:link, .commentLinks a:visited, .commentLinks a:active,
.trackbackLinks a:link, .trackbackLinks a:visited, .trackbackLinks a:active {
  color: gray;
  font-weight: normal;
  font-size: 11px;
}

.blogEntryMetadata, .blogEntryMetadata a:link, .blogEntryMetadata a:visited, .blogEntryMetadata a:active,
.itemMetadata, .itemMetadata a:link, .itemMetadata a:visited, .itemMetadata a:active,
.commentMetadata, .commentMetadata a:link, .commentMetadata a:visited, .commentMetadata a:active,
.trackbackMetadata, .trackbackMetadata a:link, .trackbackMetadata a:visited, .trackbackMetadata a:active {
  color: gray;
  font-weight: normal;
}

.floatRight {
  float: right;
  position: relative;
}

.approved {
}
.pending {
  border-left: solid #FF9900 4px;
}
.rejected {
  border-left: solid red 4px;
}
thead {
  background : white;
  color: black;
  font-weight: bold;
  padding: 8px;
}
thead a:link, thead a:visited, thead a:active {
}
.tagCloud {
  line-height: 40px;
}
.tagCloud1 {
  font-size: 10px;
}
.tagCloud2 {
  font-size: 12px;
}
.tagCloud3 {
  font-size: 14px;
}
.tagCloud4 {
  font-size: 16px;
}
.tagCloud5 {
  font-size: 18px;
}
.tagCloud6 {
  font-size: 20px;
}
.tagCloud7 {
  font-size: 22px;
}
.tagCloud8 {
  font-size: 24px;
}
.tagCloud9 {
  font-size: 26px;
}
.tagCloud10 {
  font-size: 28px;
}

        </style>
      
      
   

   
    <script type="text/javascript">
    function openWindow(url, windowName, width, height) {
  popup = window.open(url, windowName, 'width='+width+',height='+height+',toolbar=0,resizable=1,scrollbars=1,menubar=0,status=1');
  popup.focus();
}

function confirmRemove(url) {
  if (confirm("Are you sure?")) {
    window.location = url;
  }
}

function populateFilename(fromField, toField) {
  var indexOfSlash = fromField.value.lastIndexOf("/");
  if (indexOfSlash < 0) {
    indexOfSlash= fromField.value.lastIndexOf("\\");
  }
  if (indexOfSlash < 0) {
    indexOfSlash = 0;
  }

  toField.value = fromField.value.substring(indexOfSlash+1, fromField.value.length);
}

function checkAll(checkboxes) {
  for (i = 0; i < checkboxes.length; i++) {
    checkboxes.checked = true;
  }
}

function uncheckAll(checkboxes) {
  for (i = 0; i < checkboxes.length; i++) {
    checkboxes.checked = false;
  }
}

    </script>
   
  </head>

  <body>
    <div class="bodyContent">



<div class="header">
  <div class="search">
    <form method="post" action="search.action" accept-charset="UTF-8">
    <table cellpadding="4" cellspacing="0">
      <tr>
        <td align="right">
          <a href="today.html">Today</a> |
          <a href="rss.xml">RSS</a> |
          <a href="rdf.xml">RDF</a> |
          <a href="atom.xml">Atom</a>
        </td>
      </tr>
      <tr>
        <td valign="top" align="right">
          <input type="text" name="query" />&nbsp;<input type="submit" value="Search" />
        </td>
      </tr>
    </table>
    </form>
  </div>
  <div class="blogName">
    <a href="http://192.168.240.105:8080/pebble/">服务系统日志</a>
  </div>
  <div class="blogDescription">
    服务系统日志
  </div>

  <br />

  <div class="small">
    &nbsp;
  </div>
</div>

<div class="sidebar">
  <div class="calendar"><table width="100%"><tr><td colspan="7" align="center"><b><a href="http://192.168.240.105:8080/pebble/2008/07.html">July 2008</a></b></td></tr><tr><td class="calendarDayHeader" width="14%">Mon</td><td class="calendarDayHeader" width="14%">Tue</td><td class="calendarDayHeader" width="14%">Wed</td><td class="calendarDayHeader" width="14%">Thu</td><td class="calendarDayHeader" width="14%">Fri</td><td class="calendarDayHeader" width="14%">Sat</td><td class="calendarDayHeader">Sun</td></tr><tr><td class="calendarDay">&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/01.html">1</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/02.html">2</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/03.html">3</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/04.html">4</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/05.html">5</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/06.html">6</a>&nbsp;</td></tr><tr><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/07.html">7</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/08.html">8</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/09.html">9</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/10.html">10</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/11.html">11</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/12.html">12</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/13.html">13</a>&nbsp;</td></tr><tr><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/14.html">14</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/15.html">15</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/16.html">16</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/17.html">17</a>&nbsp;</td><td class="calendarDayWithEntries">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/18.html">18</a>&nbsp;</td><td class="calendarToday">&nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/19.html">19</a>&nbsp;</td><td class="calendarDay">&nbsp;20&nbsp;</td></tr><tr><td class="calendarDay">&nbsp;21&nbsp;</td><td class="calendarDay">&nbsp;22&nbsp;</td><td class="calendarDay">&nbsp;23&nbsp;</td><td class="calendarDay">&nbsp;24&nbsp;</td><td class="calendarDay">&nbsp;25&nbsp;</td><td class="calendarDay">&nbsp;26&nbsp;</td><td class="calendarDay">&nbsp;27&nbsp;</td></tr><tr><td class="calendarDay">&nbsp;28&nbsp;</td><td class="calendarDay">&nbsp;29&nbsp;</td><td class="calendarDay">&nbsp;30&nbsp;</td><td class="calendarDay">&nbsp;31&nbsp;</td><td class="calendarDay">&nbsp;</td><td class="calendarDay">&nbsp;</td><td class="calendarDay">&nbsp;</td></tr><tr><td colspan="7" align="center"><a href="http://192.168.240.105:8080/pebble/2008/06.html">Jun</a>&nbsp; | &nbsp;<a href="http://192.168.240.105:8080/pebble/2008/07/19.html">Today</a>&nbsp; | &nbsp;Aug</td></tr></table></div>
</div>

<div class="content">
  







  
  


<div class="item">

  <div class="itemHeader">
    Login
  </div>

  <div class="itemBody">
   
      An incorrect username/password was entered - please try again.
      <br /><br />
   

    <form name="loginForm" method="post" action="j_security_check">
    <input type="hidden" name="j_uri" value="http://192.168.240.105:8080/pebble/" />
    <table>
      <tr>
        <td align="left"><b>Username</b></td>
        <td align="left"><input type="text" name="j_username" /></td>
      </tr>
      <tr>
        <td align="left"><b>Password</b></td>
        <td align="left"><input type="password" name="j_password" /></td>
      </tr>
      <tr>
        <td colspan="2" align="right">
          <input type="submit" value="Login" />
        </td>
      </tr>
    </table>
    </form>
  </div>

</div>

<script type="text/javascript">
window.onload = function()
{
  document.loginForm.j_username.focus()
}
</script>

</div>

<div class="footer">
  <span class="footerLinks">
    Powered by <a href="http://pebble.sourceforge.net"><b>Pebble </b></a>
    [
      
        <a href="login.secureaction">Login</a>
      
      
    ]
  </span>
  <span>
    Content &copy; Various
  </span>
</div>

    </div>
  </body>
</html>

论坛徽章:
0
2 [报告]
发表于 2008-07-20 16:13 |只看该作者
这么长代码。。。
为啥不说说具体思路呢

论坛徽章:
0
3 [报告]
发表于 2008-07-21 09:25 |只看该作者
1、先登陆网站http://192.168.240.105:8080/pebble/j_security_check,自动输入用户名及密码;
2、实现登陆后找到对应连接并把系统的log日志放在对应页面的form中;
3、完成;

放上来的代码只停留在第一步,我双击此脚本生成的aa.html文件,打开的页面总是提示用户名及密码错误

论坛徽章:
0
4 [报告]
发表于 2008-07-23 11:19 |只看该作者
咋没人帮着看看呀,急死我了!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP