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