Asp. NET Basic Learning (brute force password)

Source: Internet
Author: User

First write a login procedure:

//Ashx End<%@ WebHandler language="C #"class="addcalation"%>usingSystem;usingsystem.web; Public classAddcalation:ihttphandler { Public voidProcessRequest (HttpContext context) {context. Response.ContentType="text/html"; stringIspostback=context. request["Isback"]; stringUsername = context. request["username"]; stringPassword = context. request["Password"]; if(IsPostBack = ="Yes")        {            if(Username = ="Admin"&& Password = ="2314") {context. Response.Write ("Landing Success"); }            Else{context. Response.Write ("Login Failed"); }                    }        Else{username=string.            Empty; Password=string.        Empty; }        stringPath = context. Server.MapPath ("addcalation.html"); stringContent =System.IO.File.ReadAllText (path); Content=content. Replace ("@user", username); Content= content. Replace ("@pass", password); Context.    Response.Write (content); }      Public BOOLisreusable {Get {            return false; }    }}//HTML Side<! DOCTYPE html>"http://www.w3.org/1999/xhtml">"addcalation.ashx"> <input type="Hidden"Value="Yes"Name="Isback"/> <label for="User"> User name </label> <input type="text"Id="User"Value="@user"Name="username"/> <br/> <label for="Pass"> Password </label> <input type="Password"Id="Pass"Value="@pass"Name="Password"/> <br/><input type="Submit"Value="Login"/></form></body>

Then write a C # console program to brute force

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Net;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 9 namespacePasswordbreakTen { One     class Program A     { -         Static voidMain (string[] args) -         { theWebClient WC =NewWebClient (); -Wc. Encoding =Encoding.UTF8; -             strings=""; -              for(inti =0; I < the; i++) +             { -s = WC. Downloadstring ("http://localhost:41566/AddCalation.ashx?isback=yes&username=admin&password="+i); +                 if(S.contains ("Landing Success")) A{Console.WriteLine (i); Break; } at             } - Console.WriteLine (); - Console.Write (s); - Console.readkey (); -         } -     } in}

Try to hack the password in your login code by looping through the password in turn

Therefore, the security of the login port is very important.

Asp. NET Basic Learning (brute force password)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.