栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Java登录网站

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Java登录网站

<form action="login.php?do=login" method="post"     onsubmit="md5hash(vb_login_password, vb_login_md5password,         vb_login_md5password_utf, 0)">
  • 在提交页面之前,请对密码进行编码(

    onsubmit
    )。您应该在代码中执行相同的操作。

  • action
    属性的值与您的代码(
    https://accounts.google.com...
    )不匹配。您应该将发布请求发送到
    login.php?do=login

还有很多隐藏字段:

<input type="hidden" name="s"     value="b804473163cb55dce0d43f9f7c41197a" /><input type="hidden" name="securitytoken"     value="0dcd78b4c1a376232b62126e7ad568e0d1213f95" /><input type="hidden" name="do" value="login" /><input type="hidden" name="vb_login_md5password" /><input type="hidden" name="vb_login_md5password_utf" />

您也应该发送这些参数。

通常,安装HttpFox Firefox附加组件来检查post参数的请求比解码javascript 容易。

我的浏览器发送了以下发布参数(用HttpFox捕获,密码为

pass1
):

vb_login_username: user1vb_login_password:s: 5d8bd41a83318e683de9c55a38534407securitytoken: 0dcd78b4c1a376232b62126e7ad568e0d1213f95do: loginvb_login_md5password: a722c63db8ec8625af6cf71cb8c2d939vb_login_md5password_utf: a722c63db8ec8625af6cf71cb8c2d939

编辑

以下对我有用,我可以在打印的html代码中获得 “谢谢您登录” 消息:

final HttpClient client = new DefaultHttpClient();final HttpPost post = new HttpPost(        "http://www.xtratime.org/forum/login.php?do=login");try {    final List<NamevaluePair> namevaluePairs =         new ArrayList<NamevaluePair>(1);    namevaluePairs.add(new BasicNamevaluePair("vb_login_username", "my user"));    namevaluePairs.add(new BasicNamevaluePair("vb_login_password", ""));    namevaluePairs.add(new BasicNamevaluePair("s", ""));    namevaluePairs.add(new BasicNamevaluePair("securitytoken", "inspected with httpfox, like f48d01..."));    namevaluePairs.add(new BasicNamevaluePair("do", "login"));    namevaluePairs.add(new BasicNamevaluePair("vb_login_md5password", "inspected with httpfox, like 8e6ae1..."));    namevaluePairs.add(new BasicNamevaluePair( "vb_login_md5password_utf", "inspected with httpfox, like 8e6ae1..."));    post.setEntity(new UrlEnpredFormEntity(namevaluePairs));    final HttpResponse response = client.execute(post);    final BufferedReader rd = new BufferedReader(new InputStreamReader( response.getEntity().getContent()));    String line = "";    while ((line = rd.readLine()) != null) {        System.out.println(line);    }} catch (final IOException e) {    e.printStackTrace();}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/410360.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号