验证码问题

hrbwgs1111 2009-08-26 04:44:41
程序需要做一个模拟提交form的功能去访问另一个网站,在登录的form里发现了
<input type="hidden" name="verifyCodeKey" value="$verifyCodeKey" />
试过直接提交$verifyCodeKey无法打开另一个网站,另一个网站使用java做的,而且在登录页的脚本里没有发现jquery
请问我需要如何才能正确的取到$verifyCodeKey值
...全文
767 38 打赏 收藏 转发到动态 举报
写回复
用AI写文章
38 条回复
切换为时间正序
请发表友善的回复…
发表回复
hrbwgs1111 2009-08-27
  • 打赏
  • 举报
回复
谢谢大家的热心回复,先把要做成自动登录的网址发出来,高手有空帮忙看一下
http://221.238.6.120:8070/insms/dealer/en/loginin.do
uncleson88 2009-08-27
  • 打赏
  • 举报
回复
1.服务端可能屏蔽了外部提交
2.验证码有加密吗?
uncleson88 2009-08-27
  • 打赏
  • 举报
回复
1.服务端可能屏蔽了外部提交
2.验证码有加密吗?
hrbwgs1111 2009-08-27
  • 打赏
  • 举报
回复
carlhhhhcarl 2009-08-27
  • 打赏
  • 举报
回复
我也想看看
xupeihuagudulei 2009-08-26
  • 打赏
  • 举报
回复
帮UP
staticuser 2009-08-26
  • 打赏
  • 举报
回复
帮顶。。


[img=http://pic.nipic.com/2008-05-12/2008512155311339_2.jpg]情人节快乐[/img]
****************************************************************
今天回帖带祝福,七夕情人节快乐~^_^
****************************************************************
Tomzzu 2009-08-26
  • 打赏
  • 举报
回复
只能帮顶了
XGJ889 2009-08-26
  • 打赏
  • 举报
回复
zhangzhanchengwo 2009-08-26
  • 打赏
  • 举报
回复
不清楚。。。。
guyehanxinlei 2009-08-26
  • 打赏
  • 举报
回复
[Quote=引用 25 楼 wangchaozhong 的回复:]
XML code<?xml version="1.0" encoding="UTF-8"?><web-appxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-a¡­
[/Quote]

这是JAVA的吧》
lsd123 2009-08-26
  • 打赏
  • 举报
回复
.
超维电脑科技 2009-08-26
  • 打赏
  • 举报
回复

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Example</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>GetPic</display-name>
<servlet-name>GetPic</servlet-name>
<servlet-class>GetPic</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GetPic</servlet-name>
<url-pattern>/GetPic</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>Login</display-name>
<servlet-name>Login</servlet-name>
<servlet-class>Login</servlet-class>
<init-param>
<param-name>userName</param-name>
<param-value>guest</param-value>
</init-param>
<init-param>
<param-name>userPwd</param-name>
<param-value>123456</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping>
<filter>
<display-name>ValidLogin</display-name>
<filter-name>ValidLogin</filter-name>
<filter-class>ValidLogin</filter-class>
</filter>
<filter-mapping>
<filter-name>ValidLogin</filter-name>
<url-pattern>/admin/*</url-pattern>
</filter-mapping>
</web-app>
超维电脑科技 2009-08-26
  • 打赏
  • 举报
回复



import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
* Servlet Filter implementation class ValidLogin
*/
public class ValidLogin implements Filter {

/**
* Default constructor.
*/
public ValidLogin() {
// TODO Auto-generated constructor stub
}

/**
* @see Filter#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub
}

/**
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
// place your code here
HttpServletRequest hsr=(HttpServletRequest)request;
HttpSession session=hsr.getSession();
if(session.getAttribute("UserName")!=null)
{
// pass the request along the filter chain
chain.doFilter(request, response);
}
else
{
HttpServletResponse hresponse=(HttpServletResponse)request;
hresponse.sendRedirect("../index.jsp");
}
}

/**
* @see Filter#init(FilterConfig)
*/
public void init(FilterConfig fConfig) throws ServletException {
// TODO Auto-generated method stub
}

}
超维电脑科技 2009-08-26
  • 打赏
  • 举报
回复



import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
* Servlet implementation class Login
*/
public class Login extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public Login() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request,response);
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String userName=request.getParameter("loginName");
String userPwd=request.getParameter("loginPwd");
String userCode=request.getParameter("loginCode");

ServletConfig sc= this.getServletConfig();
String saveUserName=sc.getInitParameter("userName");
String saveUserPwd=sc.getInitParameter("userPwd");
HttpSession session=request.getSession();
String saveUserCode=session.getAttribute("validCode").toString();

if(userName.equals(saveUserName)&& userPwd.equals(saveUserPwd)&& userCode.equals(saveUserCode))
{
session.setAttribute("UserName", userName);
response.sendRedirect("./admin/index.jsp");
}
else
{
response.sendRedirect("./index.jsp");
}
}

}

showjim 2009-08-26
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 hrbwgs1111 的回复:]
引用 16 楼 sbwwkmyd 的回复:
引用 3 楼 hrbwgs1111 的回复:
    <td align="right">验证码 </td>
    <td> <input name="verifyCode" type="text" AUTOCOMPLETE="off" class="login_codetext" size="4" maxlength="4" />
                    <img src="/insms/getImgVerify2" width="60" height="28" align="absmiddle" /> </td>
    <input type="hidden" name="verifyCodeKey" value="$verifyCodeKey" />


如果没有js干预的话,这个值应该不用改的,可能是对方服务端屏蔽了外部提交.


对方没有屏蔽外部提交,我用外网可以登录到他的系统里
[/Quote]
不是外网的问题,应该是来源页面地址或者Cookie的问题或者其它问题
超维电脑科技 2009-08-26
  • 打赏
  • 举报
回复


import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Random;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
* Servlet implementation class GetPic
*/
public class GetPic extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public GetPic() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("image/jpeg");
BufferedImage image=new BufferedImage(60,30,BufferedImage.TYPE_INT_RGB);
Graphics g=(Graphics)image.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, 120, 80);
String validCode=funGetRandNum();
HttpSession session=request.getSession();
session.setAttribute("validCode", validCode);
g.setColor(Color.RED);
g.setFont(new Font("黑体",24,20));
g.drawString(validCode, 10, 20);
ServletOutputStream out=response.getOutputStream();
try{
ImageIO.write(image, "jpg", out);
}catch(IOException ex){}
}

private String funGetRandNum()
{
String source="1234567890abcdefghiklmvysz";
String retStr="";
Random rnd=new Random();
for(int i=0;i<4;i++)
{
int k=Math.abs(rnd.nextInt());
k=k%source.length();
retStr=retStr+source.charAt(k);

}

return retStr;

}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request,response);
}

}

超维电脑科技 2009-08-26
  • 打赏
  • 举报
回复
[code=JSP]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登入</title>
</head>
<body>
<form action="Login" method="post">
<table align="center">
<tr><td>登陆名称:</td><td><input type="text" name="loginName"></td></tr>
<tr><td>登陆密码:</td><td><input type="password" name="loginPwd"></td></tr>
<tr><td>验 证 码:</td><td><input type="text" name="loginCode"><img src="GetPic" border="1"></td></tr>
<tr><td coispan="2" align="center"><input type="submit" name="btnLogin"value="登入"><input type="reset" name="btnCancel"value="取消"></td></tr>
</table>
</form>
</body>
</html>
[/code]
polarissky 2009-08-26
  • 打赏
  • 举报
回复
JavaScript 传值 http://www.hack97.com/article/ruqin/979.html
加载更多回复(18)

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧