Decrypt ASP source code

Source: Internet
Author: User

Download the ASP source code from the Internet with great enthusiasm. once a file is opened, tianshu-like encryption code is displayed. it's depressing. I found the decryption method on the Internet. I had to open, copy, paste, decrypt, copy, and paste a file one by one, save ...... if an ASP program has hundreds of files ???
There is a solution .. Copy codeThe Code is as follows: <% @ Language = "JavaScript" %>
<%
/*
* --------------- Decode. asp -----------------
* Function: traverses all files in a directory and encrypts. asp files.
* Decryption and writing to the source file.
* Instance: decrypts a single file
* Response. Write (DncodeFile (Server. MapPath ("conn. asp ")));
* Instance: decrypts all files in the directory.
* DncodeFolderFiles (Server. MapPath ("xml "))
* Author: wanghr100 (Baby gray bean. net)
* Update:
* --------------- Decode. asp -----------------
*/
Function DncodeFile (sFilePath)
{
/*
* ------------- DncodeFile (sFilePath )-----------------
* DncodeFile (sFilePath)
* Function: open the file sFilePath, Encode decryption, and rewrite the file.
* Parameter: sFilePath, string, and file path.
* Return value: sFilePath, file path.
* Instance: Response. Write (DncodeFile (Server. MapPath ("conn. asp ")));
* Author: wanghr100 (Baby gray bean. net)
* Update:
* ------------- DncodeFile (sFilePath )-----------------
*/
Var ForReading = 1, ForWriting = 2, ForAppending = 8;
Var fso = Server. CreateObject ("Scripting. FileSystemObject ");
Var f = fso. OpenTextFile (sFilePath, ForReading, true );
SFileText = f. ReadAll ();
F. Close ();
SDncodeText = strdec (sFileText)
Var f = fso. OpenTextFile (sFilePath, ForWriting, true );
F. Write (sDncodeText );
F. Close ();
// Return sDncodeText;
Return sFilePath;
}

Function GetFilesPath (sFolderPath)
{
/*
* --------------- GetFilesPath (sFolderPath )-----------------
* GetFilesPath (sFolderPath)
* Function: traverses all files in the sFolderPath directory, returns an array, and stores the file path.
* Parameter: sFolderPath, String, absolute directory path.
* Instance: Response. Write (GetFilesPath (Server. MapPath ("xml ")))
* Update:
* Author: wanghr100 (Baby gray bean. net)
* --------------- GetFilesPath (sFolderPath )-----------------
*/
Var sFilePath = new Array ();
Var fso = Server. CreateObject ("Scripting. FileSystemObject ");
Var oFolder = fso. GetFolder (sFolderPath );
Var oSubFolders = oFolder. SubFolders;
Var oFiles = oFolder. Files;
Icount = oFiles. Count;

Var enmFiles = new Enumerator (oFiles );
For (;! EnmFiles. atEnd (); enmFiles. moveNext ())
{
SFilePath [sFilePath. length] = enmFiles. item (). Path
}

Var enmFolders = new Enumerator (oSubFolders );
For (;! EnmFolders. atEnd (); enmFolders. moveNext ())
{
/* The Old array is multi-dimensional .*/
// SFilePath [sFilePath. length] = GetFilesPath (enmFolders. item (). Path );
/* Add only one-dimensional array */
SFilePath = sFilePath. concat (GetFilesPath (enmFolders. item (). Path ));
}

Return sFilePath;

}

Function GetFileType (sFileName)
{
/*
* --------------- GetFileType (sFileName )-----------------
* GetFileType (sFileName)
* Function: Obtain the file type of sFileName through the suffix.
* Parameter: sFileName, String, file name.
* Instance: Response. Write (GetFileType ("decode. asp "))
* Update:
* Author: wanghr100 (Baby gray bean. net)
* --------------- GetFileType (sFileName )-----------------
*/
SFileName = String (sFileName );
Return sFileName. split (".") [sFileName. split ("."). length-1];
}

/* Start Decryption Implementation: Li brilliant Start */
Function screncode (s, l)
{Enc = new ActiveXObject ("Scripting. Encoder ");
Return enc. EncodeScriptFile ("." + l, s, 0, l + "success ");
}

Var STATE_COPY_INPUT = 100
Var state_readlen= 101
Var STATE_DECODE = 102
Var STATE_UNESCAPE = 103

Var pick_encoding = new Array (
1, 2, 0, 1, 2, 0, 2, 0, 0, 2, 0, 2, 1, 0, 2, 0,
1, 0, 2, 0, 1, 1, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2,
1, 1, 0, 2, 0, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 2,
1, 0, 2, 0, 1, 1, 2, 0, 0, 1, 1, 2, 0, 1, 0, 2
)

Var rawData = new Array (
0x64, 0x37, 0x69, 0x50, 0x7E, 0x2C, 0x22, 0x5A, 0x65, 0x4A, 0x45, 0x72,
0x61, 0x3A, 0x5B, 0x5E, 0x79,0x66, 0x5D, 0x59,0x75, 0x5B, 0x27, 0x4C,
0x45, 0x60, 0x76, 0x62, 0x2A, 0x65, 0x4D, 0x43,
0x5F, 0x51,0x33, 0x7E, 0x53,0x42, 0x4F, 0x52,0x20, 0x52,0x20, 0x63,
0x7A, 0x26, 0x4A, 0x21,0x54, 0x5A, 0x46,0x71,0x38, 0x20, 0x2B, 0x79,
0x26,0x66,0x32, 0x63, 0x2A, 0x57, 0x2A, 0x58, 0x6C, 0x76, 0x7F, 0x2B,
0x47, 0x7B, 0x46, 0x25, 0x30,0x52, 0x2C, 0x31, 0x4F, 0x29, 0x6C, 0x3D,
0x69,0x49,0x70, 0x3F, 0x3F, 0x3F, 0x27,0x78, 0x7B, 0x3F, 0x3F, 0x3F,
0x67, 0x5F, 0x51, 0x3F, 0x3F, 0x3F, 0x62,0x29, 0x7A, 0x41,0x24, 0x7E,
0x5A, 0x2F, 0x3B, 0x66,0x39,0x47, 0x32, 0x33,0x41, 0x73, 0x6F, 0x77,
0x4D, 0x56, 0x75, 0x5F, 0x26, 0x39,0x78,
0x7C, 0x46, 0x6E, 0x53, 0x4A, 0x64, 0x48, 0x5C, 0x74, 0x31,0x48, 0x67,
0x72,0x36, 0x7D, 0x6E, 0x4B, 0x68, 0x70, 0x7D, 0x35, 0x49, 0x5D, 0x22,
0x3F, 0x6A, 0x55, 0x4B, 0x50, 0x3A, 0x6A, 0x69,0x60, 0x2E, 0x23, 0x6A,
0x7F, 0x09,0x71, 0x28,0x70, 0x6F, 0x35,0x65,0x49, 0x7D, 0x74, 0x5C,
0x24, 0x2C, 0x5D, 0x2D, 0x77,0x27, 0x54,0x44,0x59, 0x37, 0x3F, 0x25,
0x7B, 0x6D, 0x7C, 0x3D, 0x7C, 0x23, 0x6C, 0x43, 0x6D, 0x34,0x38,0x28,
0x6D, 0x5E, 0x31, 0x4E, 0x5B, 0x39, 0x2B, 0x6E, 0x7F, 0x30,0x57,0x36,
0x6F, 0x4C, 0x54, 0x34,0x34, 0x6B, 0x62, 0x4C, 0x25, 0x4E,
0x33,0x56,0x30, 0x56,0x73, 0x5E, 0x3A, 0x68,0x73, 0x78,0x55,0x09,
0x57,0x47, 0x4B, 0x77,0x32, 0x61, 0x3B, 0x35, 0x24, 0x44, 0x2E, 0x4D,
0x2F, 0x64, 0x6B, 0x59, 0x4F, 0x44, 0x45, 0x3B, 0x21, 0x5C, 0x2D, 0x37,
0 x, 0 x, 0x53, 0 x, 0 x, 0x58, 0x58, 0x7A, 0x48, 0x79,0x22, 0x2E,
0x09,0x60,0x50, 0x75, 0x6B, 0x2D, 0x38, 0x4E, 0x29, 0x55, 0x3D, 0x3F
)

Var transformed = new Array ()
For (var I = 0; I <3; I ++) transformed [I] = new Array ()
For (var I = 31; I <= 126; I ++) for (var j = 0; j <3; j ++) transformed [j] [rawData [(i-31) * 3 + j] = (I = 31 )? 9: I

Var digits = new Array ()
For (var I = 0; I <26; I ++)
{
Digits ["A". charCodeAt (0) + I] = I
Digits ["a". charCodeAt (0) + I] = I + 26
}
For (var I = 0; I <10; I ++) digits ["0". charCodeAt (0) + I] = I + 52
Digits [0x2b] = 62
Digits [0x2f] = 63

Function unescape (char)
{
Var escapes = "#&! * $"
Var escaped = "\ r \ n <> @"

If (char. charCodeAt (0)> 126) return char
If (escapes. indexOf (char )! =-1) return escaped. substr (escapes. indexOf (char), 1)
Return "? "
}

Function decodeBase64 (string)
{
Var val = 0
Val + = (digits [string. substr (0, 1). charCodeAt (0)] <2)
Val + = (digits [string. substr (1,1). charCodeAt (0)]> 4)
Val + = (digits [string. substr (1,1). charCodeAt (0)] & 0xf) <12
Val + = (digits [string. substr (2, 1). charCodeAt (0)]> 2) <8)
Val + = (digits [string. substr (2, 1). charCodeAt (0)] & 0x3) <22)
Val + = (digits [string. substr (3,1). charCodeAt (0)] <16)
Return val
}

Function strdec (encodingString)
{

Var marker = "#@~ ^"
Var stringIndex = 0
Var scriptIndex =-1
Var unEncodingIndex = 0
Var char = null
Var encodingLength = unEncodinglength = 0
Var state = STATE_COPY_INPUT
Var unEncodingString = ""
Var re, arr

While (state)
{
Switch (state)
{
Case (STATE_COPY_INPUT ):
ScriptIndex = encodingString. indexOf (marker, stringIndex)
If (scriptIndex! =-1)
{
UnEncodingString + = encodingString. substring (stringIndex, scriptIndex)
ScriptIndex + = marker. length
State = STATE_READLEN
}
Else
{
StringIndex = 0? 0: stringIndex
UnEncodingString + = encodingString. substr (stringIndex, encodingString. length)
State = 0
}
Break

Case (STATE_READLEN ):
EncodingLength = encodingString. substr (scriptIndex, 6)
UnEncodinglength = decodeBase64 (encodingLength)
ScriptIndex + = (6 + "=". length)
State = STATE_DECODE
Break

Case (STATE_DECODE ):
If (! UnEncodinglength)
{
StringIndex = scriptIndex + "DQgAAA = ^ #~ @ ". Length
UnEncodingIndex = 0
State = STATE_COPY_INPUT
Break
}
Char = encodingString. substr (scriptIndex, 1)
If (char = "@") state = STATE_UNESCAPE
Else
{
If (char. charCodeAt (0) <0xFF)
{
UnEncodingString + = String. fromCharCode (transformed [pick_encoding [unEncodingIndex % 64] [char. charCodeAt (0)])
UnEncodingIndex ++
}
Else
{
UnEncodingString + = char
}
ScriptIndex ++
UnEncodinglength --
Break
}

Case STATE_UNESCAPE:
UnEncodingString + = unescape (encodingString. substr (++ scriptIndex, 1 ))
ScriptIndex ++; unEncodinglength-= 2
UnEncodingIndex ++
State = STATE_DECODE
Break
}
}

Re = new RegExp ("(JScript | VBscript). encode", "gmi ")
While (arr = re.exe c (unEncodingString) unEncodingString = RegExp. leftContext + RegExp. $1 + RegExp. rightContext
Return unEncodingString
}
/* End Decryption Implementation: Li brilliant End */
Function DncodeFolderFiles (sFolderPath)
{
/*
* ------------- DncodeFolderFiles (sFolderPath )-----------------
* DncodeFolderFiles (sFolderPath)
* Function: traverses all files in the sFolderPath directory and encrypts. asp files.
* Decryption and writing to the source file.
* Instance: DncodeFolderFiles (Server. MapPath ("xml "));
* Author: wanghr100 (Baby gray bean. net)
* Update:
* ------------- DncodeFolderFiles (sFolderPath )-----------------
*/
Var arrFiles = GetFilesPath (sFolderPath)
For (var I = 0; I <arrFiles. length; I ++)
{
If (GetFileType (arrFiles [I]) = "asp ")
{
Response. Write (DncodeFile (arrFiles [I])
Response. Write ("OK. <br> ")
}
}
}

// Retrieve all files in the xml directory. decrypt.
DncodeFolderFiles (Server. MapPath ("list "))
// Obtain t. asp. decryption.
// Response. Write (DncodeFile (Server. MapPath ("t. asp ")))
%>

Related Article

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.