zoukankan      html  css  js  c++  java
  • 12306的动态验证码变成静态

    本以为这次12306的动态验证码很厉害,什么刷票软件都不行了,看了以后发现并不是很复杂,估计不出两日刷票软件又会卷土重来,开来要一个验证码很难遏制这些刷票软了。

    这次换的动态验证码采用的是GIF格式在客户端输出,至于要拿到这个gif文件然后把动态图的各张图片拼凑起来就能得到完整的静态验证码,接下来就是识别静态验证码的事情了。

    比如这张动态验证码

    他的静态效果就是

    下面是随手写的代码,有点混乱

                Image imgGif = Image.FromFile(Application.StartupPath + @"getPassCodeNew.gif");
                FrameDimension ImgFrmDim = new FrameDimension(imgGif.FrameDimensionsList[0]);
                System.Drawing.Bitmap bp = new Bitmap(imgGif.Size.Width, imgGif.Size.Height);
                int nFrameCount = imgGif.GetFrameCount(ImgFrmDim);
                for (int i = 0; i < nFrameCount; i++)
                {
                    imgGif.SelectActiveFrame(ImgFrmDim, i);
                    System.Drawing.Bitmap nbp = new Bitmap(imgGif);
                    Color dd = nbp.GetPixel(1, 1);
                    if (i == 0)
                    {
                        for (int x = 0; x < nbp.Width; x++)
                        {
                            for (int y = 0; y < nbp.Height; y++)
                            {
                                bp.SetPixel(x, y, dd);
                            }
                        }
                    }
                    for (int x = 0; x < nbp.Width; x++)
                    {
                        for (int y = 0; y < nbp.Height; y++)
                        {
                            Color c = nbp.GetPixel(x, y);
                            if (c == dd) continue;
                            bp.SetPixel(x, y, c);
                        }
                    }
                }
                bp.Save(Application.StartupPath + @"Frame.jpg", ImageFormat.Bmp);
    

      

  • 相关阅读:
    PCM简介
    微波炉炖蛋
    python的命令行参数处理
    耳机标准
    SELinux杂谈
    Linux ssh服务器配置
    Centos 7安装nginx
    WPF TextBox属性IsReadOnlyCaretVisible
    [WPF打印]WPF 文档元素(Run TextBlock Paragraph)的文字对齐方式
    [SQLite3]connection string的连接池参数引发的错误
  • 原文地址:https://www.cnblogs.com/CR-Soft/p/3503520.html
Copyright © 2011-2022 走看看