默认
发表评论 3
想开发IM:买成品怕坑?租第3方怕贵?找开源自已撸?尽量别走弯路了... 找站长给点建议
网站验证码破解实战研究(一)
阅读(26391) | 评论(3 收藏2 淘帖 2
验证码原图: 网站验证码破解实战研究(一)_QQ截图20151130143437.jpg
这种验证码是最简单的,只需要简单的几步就能完成破解



package com.xuanyao.server.imgcode;

import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;

public class AsiaImageCodeParse {

        private  int useXstart = 6;
        private  int useYstart = 5;
        private  int useXover = 15;
        private  int useYover = 39;
        
        private  StringBuffer codebuffer = new StringBuffer();
        private  StringBuffer one = new StringBuffer();
        private  StringBuffer two = new StringBuffer();
        private  StringBuffer three = new StringBuffer();
        private  StringBuffer four = new StringBuffer();
        
        private  final String er = "00111100011001101100001100000011000001100000110000011000001100000110000011111111";//2
        private  final String san="01111100110001100000001100000110000111000000011000000011000000111100011001111100";//3
        private  final String si="00000110000011100001111000110110011001101100011011111111000001100000011000000110";//4
        private  final String wu="11111110110000001100000011011100111001100000001100000011110000110110011000111100";//5
        private  final String liu="00111100011001101100001011000000110111001110011011000011110000110110011000111100";//6
        private  final String qi="11111111000000110000001100000110000011000001100000110000011000001100000011000000";//7
        private  final String ba="00111100011001101100001101100110001111000110011011000011110000110110011000111100";//8
        private  final String jiu="00111100011001101100001111000011011001110011101100000011010000110110011000111100";//9
        
        private  final Map<String, Integer> codemap = new HashMap<String, Integer>();
        
        {
                codemap.put(er, 2);
                codemap.put(san, 3);
                codemap.put(si, 4);
                codemap.put(wu, 5);
                codemap.put(liu, 6);
                codemap.put(qi, 7);
                codemap.put(ba, 8);
                codemap.put(jiu, 9);
        }
        
        //将图片解析成1,0编码的字符串
        public  String PaseByte(BufferedImage img){
                for(int i=0;i<20;i++){
                        for(int j=0;j<50;j++){
                                //16777216
                                //2565928
                                if((j>=useYstart&&j<=useYover)&&(i>=useXstart&&i<=useXover))
                                if(img.getRGB(j, i)==-2565928){
                                        codebuffer.append("0");
                                }else{
                                        codebuffer.append("1");
                                }
                        }
                        codebuffer.append(",");
                }
                return SplitByte(codebuffer);
        }
        //将字符串拆分为4个单独的1,0编码
        public  String SplitByte(StringBuffer codebuffer){
                for(String s:codebuffer.toString().split(",")){
                        if(s.length()==35){
                                one.append(s.substring(0, 8));
                                two.append(s.substring(9, 17));
                                three.append(s.substring(18, 26));
                                four.append(s.substring(27, 35));
                        }
                }
                return GetCode();
        }
        
        public  String GetCode(){
                return  codemap.get(one.toString())+""+
                                codemap.get(two.toString())+""+
                                codemap.get(three.toString())+""+
                                codemap.get(four.toString());
        }
        
}

即时通讯网 - 即时通讯开发者社区! 来源: - 即时通讯开发者社区!

上一篇:[已解决] 将demo导入myeclipse,但不知怎么发布成可执行jar下一篇:JAVA Swing 仿微信PC界面实现(内含源码)
推荐方案
评论 3
很好~~~学到了~~~
这方面的资料不多,支持原创。
引用:JackJiang 发表于 2015-11-30 15:23
这方面的资料不多,支持原创。

12306的变态  验证码  给它破了吧
打赏楼主 ×
使用微信打赏! 使用支付宝打赏!

返回顶部