JS Development Dictionary Probes user name or password tool

Source: Internet
Author: User
Tags define array continue exception handling integer interface net time interval
Js

Developing dictionaries using JavaScript to probe user names or password tools

Article Author: Zhangkai (Xiao Qi)
Author website:http://www.xiaoqi.net
Author Forum:http://www.tdqy.com
qq:22336848 53353866

Example Demo
Package download

It is better to give a person a fish than to give it to him. This article focuses on the development of the author's ideas and procedures to achieve the goal is to let you understand a program development process and the program function of the implementation of the principle, not just to provide you with such a tool. I hope that the friends who have read this article will be rewarded and share with me the fun of writing programs with JavaScript.
To make it easier for everyone to understand, this program in the implementation process, a concise use of a variety of JavaScript technology, and at each step, there are detailed annotations, even if you are a novice Web application development, you can easily understand this article, and believe that this article will help you in the future development of Web applications.

Core Technology :

    • XMLHTTP fetch data JavaScript to text data processing
    • JavaScript log-group read (two methods)
    • XMLHTTP to take Chinese value garbled conversion
       

Main function :

    • Web site available User name probes
    • Use user name dictionary Bulk Explorer name
    • User name password brute force crack

features :

    • Using AJAX technology, no refresh operation, rendering results can be loaded into the local dictionary file or network dictionary files from the background dynamic language dependence, b/S mode C/s interface, pure JavaScript writing function code, perfect operation in all IE kernel browser real-time display detection results, detection progress, The success results are separated from the failure results to support pause detection and continue probing
    • Code simple only 1 k
    • Multi-threaded probes are supported to set buffer time

Development Idea and principle :

First, the basic detection

    • Use XMLHTTP to send probe data to the detected page address
    • To judge the return value of a XMLHTTP
    • Renders the result of the judgment as an append to the page

Second, batch detection

    • Load a dictionary file with XMLHTTP
    • Use JavaScript to separate dictionary files into newline characters (\ r \ n) and convert them to arrays
    • Sends data to the probe address in a dictionary array sequence and judges the return data

Third, the function strengthens

    • Get the size of the dictionary array (that is, the number of times to probe), return to the user to add the number of probes, presented to the user's current probe progress set detection process, that is: Each probe how many data before returning to the user a result
    • Set the buffer time, that is, set the probe time interval to prevent the browser in the large amount of data to stop the response
    • Probe pause or continue probing

Iv. Background of development

A few days ago, want to register a short and meaningful user name in Baidu Space, found that many of their favorite user names are occupied, and a manual user name detection is too troublesome.
Because I am a person who likes to use the techniques I have mastered to solve problems (or difficulties), so I wrote this program.
In order to make it more convenient to use, but also in order to make it more practical, I also in its versatility to do some strengthening.
Like what:
You can detect most sites that do not require a CAPTCHA to detect whether the user name is occupied.
You can probe the passwords of some Web site users.
Can detect a number of Web site users password retrieval problem.
You can bulk submit specified data to a Web server

At first I used ASP script to implement, but the ASP program can only run on the Web server to support ASP, not directly in the browser to execute, not so convenient to use, so I wrote this JavaScript version of the program.

V. The process of implementation

1. Create XMLHttpRequest objects using Try-catch exception handling

Try to create a XMLHttpRequest object in IE browser
var xmlhttp = null;
Try
{
XMLHTTP = new ActiveXObject ("MSXML2. XMLHTTP ");
}
catch (E)
{
Try
{
XMLHTTP = new ActiveXObject ("Microsoft.XMLHTTP");
}
catch (e) {
Alert ("Your browser cannot create a XMLHttpRequest object, you cannot use this program!");
}
}
Attempt to create a XMLHttpRequest object end in IE browser

/*
Zhangkai Note: msxml2.xmlhttp and Microsoft.XMLHTTP are Microsoft's XMLHTTP controls, but different versions.
If the security level of IE is not too high, Microsoft's XMLHTTP control can obtain data across domains.
Because the Mozilla Firefox browser's XMLHttpRequest () cannot fetch data across domains, we do not have to create XMLHTTP objects XMLHttpRequest () methods.
*/

2, the return of the Chinese code processing

Processing of the returned Chinese encoding
function rec_html (Html)
{
var rec=new activexobject ("ADODB"). RecordSet ");
Rec.Fields.Append ("DDD", 201, 1);
Rec.open ();
Rec.addnew ();
Rec (0). AppendChunk (Html);
Rec.update ();
Return Rec (0). Value;
Rec.close ();
}
End of returned Chinese encoding processing

3, check the basis of the determination of the need for Chinese code processing

if (Err.value.replace (/[^\w]/g, '). length=0)
If you replace any non word and number characters with a positive, if the value is greater than 0, it means that the judgment may contain Chinese or other characters in the basis of the code conversion.
{
html=xmlhttp.responsetext;//not converted
}
Else
{
Html=rec_html (xmlhttp.responsebody);//Conversion
}

4, the detection, the results of the judgement and output

The start probe parameter is the current value to probe
function Geturl (ID)
{
try{
Xmlhttp.open ("Get", url.value+id,false)//Define data transfer method, URL of Service Web page (probe address + probe value), whether synchronous execution
Xmlhttp.onreadystatechange = function () {//xmlhttp trigger Event

if (xmlhttp.readystate==4)//xmlhttp object state if completed
{
if (xmlhttp.status==200)//If the server returns a status code of 200 (successful)
{

Judging the conversion of the result in Chinese encoding
if (Err.value.replace (/[^\w]/g, '). length=0)
/* Note on conversion judgment:
For example: "Zhangkai". Replace (/[^\w]/g, ""). Length returns results 3
"Zhangkai 22336848". Replace (/[^\w]/g, '). Length return result 3
"xiaoqi22336848". Replace (/[^\w]/g, '). Length returns results 0
"Xiao Qi 22336848". Replace (/[^\w]/g, '). Length returns results 2
The function of replace (/[^\w]/g, ') is to erase both the English and the digits in the string.
*/

{
html=xmlhttp.responsetext;//not converted
}
Else
{
Html=rec_html (xmlhttp.responsebody);//Conversion
}
The end of the conversion judgment of the Chinese encoding of the result


Distinguish between available and unavailable values based on your judgment!
if (Html.indexof (err.value,0) <0)
{
x_1.innerhtml=x_1.innerhtml+ "<nobr>" +id;//output available values
}
Else
{
x_2.innerhtml=x_2.innerhtml+ "<nobr>" +id;//output unavailable value
}
Distinguish between available and unavailable values based on your judgment!
}
}
}
Xmlhttp.send ();
}
catch (E)
{
x_2.innerhtml=x_2.innerhtml+ "<nobr>" +id+ "Timeout!"; /output exception or timeout value.
}
}
Start probe end

5, load the dictionary file, and define the content as an array

Load the local dictionary file and define the content as an array
function Kaishi () {
Filefullpath=dic_url.value;
Xmlhttp.open ("Get", filefullpath,false);//Load Dictionary file method
Xmlhttp.send ();

Html=rec_html (xmlhttp.responsebody)//Chinese code conversion
Dic=html.split (' \ r \ n ');//Convert the loaded dictionary contents to an array in line breaks
sl.value=dic.length;//tells the user how many times to probe (array size)

Xunhuan ()///Start loop probe after successful loading.
}
Load the local dictionary file and define the content as an array end

6. Cyclic detection

Cyclic detection
function Xunhuan ()
{
Bar=parseint (Jd.value);//Convert a progress value to an integer
if (bar<sl.value)//To determine whether the probe is finished
{
For (I=0;i<parseint (jc.value); i++) {//Set probe thread
Geturl (Dic[bar+i]);//to probe from the value of the array
}

Jd.value=bar+parseint (Jc.value)//cumulative probe progress and present progress to the user
SetTimeout ("Xunhuan ()", parseint (hc.value*1000))//Repeat cycle detection based on buffer time
}
else//returns the result of the probe completion to the user if the progress is not less than the number of times to probe.
{
Alert ("Probe complete!");
}
}
Loop probe End

7. For ease of use, add a pause function

Pause Probe function
function Pause (obj)
{
if (obj.value== ' paused ')
{
obj.temp=hc.value;//memory of the original buffer time.
hc.value=5000;//sets the buffer time to 5,000 seconds, and the value can be modified by itself.
Obj.value= ' Continue '/Change button display status
}
Else
{
hc.value=obj.temp;//extracts the original buffer time.
Obj.value= ' pause '/change button display status
Kaishi ()//Continue probing
}
}
Pause probe Function End

8. Perform error verification before starting probe

function ck ()//single value probe validation check
{
if (url.value.length<5) {alert (' Please enter the address to be probed! '); return};
if (id_one.value.length<1) {alert (' Please enter the value to probe! '); return};
Geturl (Id_one.value)
}

function Ck1 ()//batch value detection verification check
{
if (url.value.length<5) {alert ("Please enter the address to probe!"); Return
if (err.value.length<1) {alert ("Please enter an unavailable tag!"); Return
if (dic_url.value.length<5) {alert ("Please select dictionary file first!"); Return
jd.value=0;
Kaishi ()
}

9. Program Interface

<body>
<p>
Program Author: Zhangkai qq:22336848 Development Date: August 2006 <br>
Website: <a href= "Http://www.xiaoqi.net" >http://www.xiaoqi.net</a>
Program package download Address: <a href= "Http://www.xiaoqi.net/zuopin/js_user.rar" >http://www.xiaoqi.net/
zuopin/
Js_user.rar</a>
</p>
<fieldset >
<legend> Detection Settings </legend>
<table border= "1" width= "100%" bordercolorlight= "#E6E6E6" cellspacing= "0" bordercolordark= "#D4D0C8" >
<tr>
<td> Probe Address </td>
<td>
<input type= "text" id= "url" size= "value=" "></td>
</tr>
<tr>
<td> Failure Inclusion Mark </td>
<td><input type= "text" id= "err" size= "value=" "></td>
</tr>
<tr>
<td> test a single value </td>
<td><input type= "text" id= "Id_one" size= ">"
<input type= "button" value= "Probe" > </td>
</tr>
<tr>
<td> Select dictionary file </td>
<td><input type= "File" Name= "Dic_url" size= ">"
<input type= "button" value= "Start" >
<input type= "button" value= "Pause" temp= "" >
<input type= "button" value= "Clear available Results" >
<input type= "button" value= "Clear unavailable result" >
</td>
</tr>
<tr>
<td> Advanced Parameters </td>
<td>
Each probe: <input type= "text" id= "JC" value= "1" size= "3" >
Buffer time: <input type= "text" id= "HC" value= "0.1" size= "3" > Sec
Progress: <input type= "text" id= "JD" value= "0" size= ">"
Probe Quantity: <input type= "text" id= "SL" size= ">"
</td>
</tr>
</table>
</fieldset>

<fieldset>
<legend> Available Values:</legend>
<div style= "Height:100px;width:100%;overflow:auto;" ><span id= "X_1" ></span></div></fieldset>

<fieldset>
<legend> Unavailable Value:</legend>
<div style= "Height:100px;width:100%;overflow:auto;" ><span id= "X_2" ></span></div>
</fieldset>

</body>

vi. reference materials :

1. Handling Exceptions with try-catch-finally

The structure can be used by the user to handle code that might occur and, if an exception occurs, caught by catch and processed with the following syntax:

try{
The code to execute
}
catch (e) {
Code to handle exceptions
}
finally{
Code that executes regardless of whether the exception occurs
}

Through the exception handling, can avoid the program to stop running, thus has the certain self-healing ability.
In AJAX development, a typical application of exception handling is to create a XMLHttpRequest object, different browsers to create it is not the same way, in order to enable the code to run across browsers, you can use the exception, one method is not, and then use another method until no exception, for example:

<script language= "JavaScript" type= "Text/javascript" >
<!--
var xmlhttp;
try{
Try to create a XMLHttpRequest object in IE browser
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}catch (e) {
try{
Try common XMLHttpRequest objects in a non-ie browser way
Xmlhttp=new XMLHttpRequest ();
}catch (e) {}
}
-->
</script>

2, Append method

Append method
Appends an object to the collection. If the collection is Fields, you can first create a new Field object and then append it to the collection.
Grammar
Collection. Append Object
Fields. Append Name, Type, DefinedSize, Attrib
Parameters
Collection the collection object.
Fields Fields collection.
Object variable that represents the object you want to append.
The name string, the names of the new Field objects, which must not have the same name as any other object in the fields.
Type DataTypeEnum, whose default value is Adempty. The data type of the new field.
DefinedSize optional, long integer indicating the defined size, in characters or bytes, of the new field. The default value for this parameter is derived from type (the default type is Adempty and the default DefinedSize unspecified).
Attrib Optional, FieldAttributeEnum, whose default value is Adflddefault. Specifies the properties of the new field. If the value is not specified, the field will contain a property originating from Type.

3, XMLHttpRequest Object properties

onReadyStateChange
Event handlers for events that occur each time the state changes
ReadyState
Object state Value:
0 = uninitialized (uninitialized)
1 = loading (loading)
2 = loading complete (loaded)
3 = interaction (interactive)
4 = complete (complete)
ResponseText
The string form of the data returned from the server process
Responsexml
DOM-compliant document data objects returned from the server process
Status
Numeric code returned from the server, such as 404 (not Found) or 200 (ready)
StatusText
String information for accompanying status codes



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.