ASP decryption, restore CHRW, CHR Encoding file Method _ Application Skills

Source: Internet
Author: User
Tags chr eval readfile

How to decode ChrW content after the parameters of an ASP function are encrypted by CHRW encoding. The following decoding function, originally very simple, uses the ChrW string in the regular fetch content, then eval dynamically executes obtains the CHRW string to obtain the content, then executes the substitution. Note Reference to the source code inside the comments, note that the source code saved as a VBS file after the implementation, if it is an ASP file, you need to modify the CreateObject to Server.CreateObject.

function ReadFile (FN) ' reads the contents of the encoded file set Fso=createobject ("Scripting.FileSystemObject") set TS=FSO. OpenTextFile (fn,1,false,-2) ' Note the last argument here, and if you have a Unicode encoding, modify-2 (System default encoding) to-1 (Unicode encoding). 0 is an ASCII readfile=ts. ReadAll Ts.close Set ts=nothing set fso=nothing End Function function Decodechrw (s) ' Decodes CHRW encoded content set rx=new REGEXP Rx. Global=true Rx. Ignorecase=true Rx. Pattern= "Chrw\s*\ (\s*\d+\s*\) (\s*&\s*chrw\s*\ (\s*\d+\s*\)) *" Decodes ChrW string set Mc=rx. Execute (s) for each m in MC S=replace (S, M.value, "" "" &eval (m.value) & "" "") Next Rx. Pattern= "Chr\s*\ (\s*\d+\s*\) (\s*&\s*chr\s*\ (\s*\d+\s*\)) *" ' Hurry CHR string set Mc=rx. Execute (s) for each m in MC S=replace (S, M.value, "" "" &eval (m.value) & "" "") Next decodechrw=s End Function fu Nction decodechrwfile (FN) ' decodes the content containing the CHRW encoded file S=readfile (FN) S=DECODECHRW (s) ' writes the decoded content back to the file set Fso=createobject (" Scripting.FileSystemObject ") Set TS=FSO. OpenTextFile (replace (FN, ".", "_decode."), 2,true,-2) ' Write the decoded content to the file with the original filename replaced with _decode, if FN is encode.txt, then the decoded file is encOde_decode.txt ts.write s Ts.close set ts=nothing set fso=nothing End Function Decodechrwfile ("Encode.txt") ' pay attention to modify here CHR
 W Encrypted file name and path, if the content is submitted by the client
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.