开发者

How to decode this in C#

i have this in a page source code

<script type="text/javascript">document.write(unescape(escapeall('%$3c%!6f%N62%A6a%H65%#63%]74%L20%P74%T79%]70%F65%A3d%B22%S61%L70%B70%L6c%B69%N63%O61%M74%U69%]6f%-6e%T2f%E78%V2d%Y73%$68%A6f%O63%A6b%@77%J61%L76%J65%M2d%K66%D6c%@61%A73%H68%*22%X20%K63%Q6c%#61%*73%K73%N3d%R22%U70%]6c%?61%T79%B65%!72%-5f%-73%{69%-7a%Y65%Y22%S20%D73%Z74%-79%P6c%N65%D3d%K22%J68%S65%W69%O67%?68%D74%O3a%N33%N30%X34%@70%R78%P22%W20%B64%X61%B74%I61%@3d%+22%A68%.74%T74%X70%$3a%B2f%}2f%T73%C74%@61%@74%R69%?63%Q2e%E61%A6b%U2e%Q66%C62%~63%]64%I6e%C2e%I6e%.65%A74%X2f%F72%I73%M72%B63%?2e%I70%V68%}70%?2f%.7a%K34%N4f%!47%Q35%J2f%K68%*61%V73%@68%Y2f%H37%?71%B6b%V62%B73%K33%I6e%[62%K2e%[73%B77%I66%V22%W3e%A3c%*70%B61%J72%J61%G6d%F20%L6e%Y61%E6d%*65%R3d%A22%B66%X6c%~61%X73%?68%I76%D61%~72%P73%P22%-20%}76%E61%E6c%.75%T65%D3d%A22%.26%O76%U69%-64%{65%N6f%D5f%[73%W72%F63%A3d%V68%[74%$74%Q70%[3a%H2f%A2f%@76%$69%[64%D65%#6f%+2e%W61%C6b%.2e%O66%V61%@63%-65%#62%V6f%+6f%V6b%M2e%Q63%?6f%U6d%W2f%+63%W66%~73%A2d%{61%L6b%Y2d%O61%P73%T68%J32%Y2f%A34%+32%G30%T32%~38%Q2f%C36%$36%X34%U2f%E31%]31%L36%#35%L34%U39%+39%*35%C38%W33%Z39%F37%*32%E38%W34%Y5f%#31%X38%+33%T30%Q32%E2e%+6d%S70%.34%Y26%.76%O69%[64%R65%G6f%~5f%P74%G69%S74%~6c%~65%K3d%!56%-69%[64%D26%K76%.3d%W31%$33%~33%{37%-22%}20%N2f%+3e%K3c%P70%@61%K72%#61%Y6d%V20%~6e%Y61%E6d%A65%{3d%G22%K61%[6c%M6c%$6f%N77%$6e%J65%R74%@77%W6f%M72%*6b%O69%J6e%!67%O22%I20%?76%W61%?6c%T75%!65%B3d%T22%-69%A6e%E74%B65%+72%}6e%L61%~6c%Q22%L20%M2f%!3e%#3c%K70%L61%]72%[61%P6d%F20%G6e%A61%+6d%M65%C3d%V22%J61%Y6c%O6c%U6f%#77%{66%M75%$6c%!6c%N73%J63%Z72%E65%L65%-6e%~22%U20%W76%}61%W6c%$75%K65%Q3d%J22%N74%V72%Y75%T65%]22%A20%~2f%W3e%T3c%@70%V61%D72%R61%H6d%@20%[6e%A61%]6d%~65%T3d%E22%~6d%~6f%T76%P69%N65%}22%}20%S76%Z61%H6c%~75%.65%S3d%K22%L68%M74%E74%G70%+3a%Z2f%?2f%H73%X74%R61%K74%I69%Q63%C2e%}61%E6b%T2e%W66%S62%U63%I64%J6e%#2e%T6e%J65%M74%R2f%]72%Y73%W72%*63%D2e%J70%Z68%+70%~2f%T7a%U34%$4f%.47%U35%J2f%V68%-61%S73%F68%[2f%S37%L71%R6b%V62%I73%U33%E6e%R62%-2e%F73%[77%C66%[22%A20%{2f%U3e%H3c%S2f%S6f%]62%A6a%M65%N63%B74%}3e')));</script>

and i want to decode it, in C#, and i don't know how, can somebody help me?

this is it the page source to

function escapeall(str){

return str.replace(/([A-Z\~\!\@\#\$\*\{\}\[\]\-\+\.\?\<\>])/g,''); }

so this is the code but it's not working

string todecode = "%C3c%Q6f%F62%A6a%!65%~63%M74%K20%L74%Y79%J70%#65%N3d%P22%V61%T70%@70%F6c%S69%+63%J61%?74%#69%O6f%@6e%O2f%@78%F2d%{73%.68%H6f%[63%V6b%Y77%D61%$76%Y65%P2d%*66%G6c%Z61%Z73%K68%@22%[20%M63%]6c%T61%A73%#73%-3d%Q22%B70%Y6c%S61%A79%V65%*72%}5f%L73%K69%G7a%K65%G22%?20%M64%K61%L74%@61%[3d%-22%K68%F74%K74%{70%H3a%+2f%G2f%.77%W77%N77%Y2e%Q64%T61%?69%.6c%+79%V6d%*6f%{74%B69%H6f%H6e%E2e%W63%$6f%E6d%O2f%V73%X77%A66%-2f%}76%{69%@64%E65%W6f%*2f%D78%E65%K35%X67%W6a%[72%Q5f%Y67%R69%S61%{6e%I74%$31%V37%T2d%.32%{5f%*73%!68%K6f%[72%F74%I66%K69%{6c%{6d%]73%I22%$3e%S3c%{70%V61%Q72%$61%B6d%!20%?6e%$61%A6d%P65%[3d%B22%]66%G6c%K61%H73%T68%S76%B61%Z72%K73%]22%J20%F76%.61%C6c%+75%H65%+3d%{22%T61%X64%-64%H69%Y74%A69%M6f%@6e%J61%O6c%F49%K6e%J66%R6f%U73%X3d%[30%@22%*20%A2f%P3e%$3c%K70%@61%X72%Z61%-6d%$20%+6e%+61%~6d%N65%R3d%K22%Y61%I6c%E6c%T6f%!77%V6e%I65%[74%U77%R6f%P72%J6b%E69%N6e%#67%+22%I20%X76%P61%F6c%Z75%Y65%S3d%W22%S69%!6e%C74%K65%P72%F6e%Z61%K6c%W22%X20%-2f%.3e%S3c%Q70%R61%-72%U61%Y6d%E20%K6e%O61%B6d%J65%~3d%J22%F61%U6c%Y6c%H6f%E77%.66%F75%I6c%H6c%Z73%A63%}72%}65%J65%H6e%U22%O20%N76%R61%U6c%V75%]65%[3d%O22%E74%K72%Y75%E65%.22%{20%P2f%L3e%H3c%+70%X61%+72%H61%X6d%L20%#6e%P61%]6d%?65%F3d%.22%A6d%$6f%#76%W69%K65%J22%#20%#76%K61%A6c%X75%.65%A3d%R22%$68%O74%?74%D70%T3a%~2f%U2f%@77%U77%H77%F2e%K64%T61%{69%*6c%B79%U6d%O6f%E74%Q69%Q6f%!6e%+2e%Y63%.6f%K6d%[2f%N73%D77%V66%?2f%L76%J69%Q64%.65%*6f%V2f%I78%~65%Y35%E67%Q6a%U72%K5f%U67%R69%I61%T6e%N74%F31%Z37%H2d%M32%~5f%A73%C68%+6f%E72%D74%M66%B69%T6c%C6d%@73%J22%{20%P2f%$3e%W3c%G2f%!6f%L62%X6a%X65%]63%K74%~3e";

        string replaced = Regex.Replace(todecode, @"([A-Z\~!\@#\$*{}[]-+.\?\<>])/g", "");

        st开发者_运维问答ring data = Uri.UnescapeDataString(replaced);

        textBoxPrint.Text += data + "";

Thanks iande and OneSHOT, now it's working...


Just use Uri.UnescapeDataString() on the string.

It appears that Uri.Unescpe, which was my first suggestion, is obsolete, so the static UnescaptDataString() should be used instead.


You probably got it already.

Every second character in the group is inserted for obfuscation.

%$3c%!6f%N62
 ^   ^   ^

The following regular expression removes all characters inserted for obfuscation replace(/([A-Z\~!\@#\$*{}[]-+.\?\<>])/g,''); }

Once you remove the second character using the above regex you can use answer from @Oded Uri.UnescapeDataString()

The result should be:

<object type="application/x-shockwave-flash" class="player_size" style="height:304px" data="http://static.ak.fbcdn.net/rsrc.php/z4OG5/hash/7qkbs3nb.swf"><param name="flashvars" value="&video_src=http://video.ak.facebook.com/cfs-ak-ash2/42028/664/116549958397284_18302.mp4&video_title=Vid&v=1337" /><param name="allownetworking" value="internal" /><param name="allowfullscreen" value="true" /><param name="movie" value="http://static.ak.fbcdn.net/rsrc.php/z4OG5/hash/7qkbs3nb.swf" /></object>

Here is the code:

        string todecode = "%C3c%Q6f%F62%A6a%!65%~63%M74%K20%L74%Y79%J70%#65%N3d%P22%V61%T70%@70%F6c%S69%+63%J61%?74%#69%O6f%@6e%O2f%@78%F2d%{73%.68%H6f%[63%V6b%Y77%D61%$76%Y65%P2d%*66%G6c%Z61%Z73%K68%@22%[20%M63%]6c%T61%A73%#73%-3d%Q22%B70%Y6c%S61%A79%V65%*72%}5f%L73%K69%G7a%K65%G22%?20%M64%K61%L74%@61%[3d%-22%K68%F74%K74%{70%H3a%+2f%G2f%.77%W77%N77%Y2e%Q64%T61%?69%.6c%+79%V6d%*6f%{74%B69%H6f%H6e%E2e%W63%$6f%E6d%O2f%V73%X77%A66%-2f%}76%{69%@64%E65%W6f%*2f%D78%E65%K35%X67%W6a%[72%Q5f%Y67%R69%S61%{6e%I74%$31%V37%T2d%.32%{5f%*73%!68%K6f%[72%F74%I66%K69%{6c%{6d%]73%I22%$3e%S3c%{70%V61%Q72%$61%B6d%!20%?6e%$61%A6d%P65%[3d%B22%]66%G6c%K61%H73%T68%S76%B61%Z72%K73%]22%J20%F76%.61%C6c%+75%H65%+3d%{22%T61%X64%-64%H69%Y74%A69%M6f%@6e%J61%O6c%F49%K6e%J66%R6f%U73%X3d%[30%@22%*20%A2f%P3e%$3c%K70%@61%X72%Z61%-6d%$20%+6e%+61%~6d%N65%R3d%K22%Y61%I6c%E6c%T6f%!77%V6e%I65%[74%U77%R6f%P72%J6b%E69%N6e%#67%+22%I20%X76%P61%F6c%Z75%Y65%S3d%W22%S69%!6e%C74%K65%P72%F6e%Z61%K6c%W22%X20%-2f%.3e%S3c%Q70%R61%-72%U61%Y6d%E20%K6e%O61%B6d%J65%~3d%J22%F61%U6c%Y6c%H6f%E77%.66%F75%I6c%H6c%Z73%A63%}72%}65%J65%H6e%U22%O20%N76%R61%U6c%V75%]65%[3d%O22%E74%K72%Y75%E65%.22%{20%P2f%L3e%H3c%+70%X61%+72%H61%X6d%L20%#6e%P61%]6d%?65%F3d%.22%A6d%$6f%#76%W69%K65%J22%#20%#76%K61%A6c%X75%.65%A3d%R22%$68%O74%?74%D70%T3a%~2f%U2f%@77%U77%H77%F2e%K64%T61%{69%*6c%B79%U6d%O6f%E74%Q69%Q6f%!6e%+2e%Y63%.6f%K6d%[2f%N73%D77%V66%?2f%L76%J69%Q64%.65%*6f%V2f%I78%~65%Y35%E67%Q6a%U72%K5f%U67%R69%I61%T6e%N74%F31%Z37%H2d%M32%~5f%A73%C68%+6f%E72%D74%M66%B69%T6c%C6d%@73%J22%{20%P2f%$3e%W3c%G2f%!6f%L62%X6a%X65%]63%K74%~3e";
        string replaced = Regex.Replace(todecode, @"([A-Z\~\!\@\#\$\*\{\}\[\]\-\+\.\?\<\>])", "");            
        string data = Uri.UnescapeDataString(replaced);
        textBoxPrint.Text += data + "";

But please note that the regex is quite dangerous because it handles this specific case of obfuscation. If you use any uppercase in your hexadecimal encoding the application will crash on the decode.


This should work for you

string todecode = "%C3c%Q6f%F62%A6a%!65%~63%M74%K20%L74%Y79%J70%#65%N3d%P22%V61%T70%@70%F6c%S69%+63%J61%?74%#69%O6f%@6e%O2f%@78%F2d%{73%.68%H6f%[63%V6b%Y77%D61%$76%Y65%P2d%*66%G6c%Z61%Z73%K68%@22%[20%M63%]6c%T61%A73%#73%-3d%Q22%B70%Y6c%S61%A79%V65%*72%}5f%L73%K69%G7a%K65%G22%?20%M64%K61%L74%@61%[3d%-22%K68%F74%K74%{70%H3a%+2f%G2f%.77%W77%N77%Y2e%Q64%T61%?69%.6c%+79%V6d%*6f%{74%B69%H6f%H6e%E2e%W63%$6f%E6d%O2f%V73%X77%A66%-2f%}76%{69%@64%E65%W6f%*2f%D78%E65%K35%X67%W6a%[72%Q5f%Y67%R69%S61%{6e%I74%$31%V37%T2d%.32%{5f%*73%!68%K6f%[72%F74%I66%K69%{6c%{6d%]73%I22%$3e%S3c%{70%V61%Q72%$61%B6d%!20%?6e%$61%A6d%P65%[3d%B22%]66%G6c%K61%H73%T68%S76%B61%Z72%K73%]22%J20%F76%.61%C6c%+75%H65%+3d%{22%T61%X64%-64%H69%Y74%A69%M6f%@6e%J61%O6c%F49%K6e%J66%R6f%U73%X3d%[30%@22%*20%A2f%P3e%$3c%K70%@61%X72%Z61%-6d%$20%+6e%+61%~6d%N65%R3d%K22%Y61%I6c%E6c%T6f%!77%V6e%I65%[74%U77%R6f%P72%J6b%E69%N6e%#67%+22%I20%X76%P61%F6c%Z75%Y65%S3d%W22%S69%!6e%C74%K65%P72%F6e%Z61%K6c%W22%X20%-2f%.3e%S3c%Q70%R61%-72%U61%Y6d%E20%K6e%O61%B6d%J65%~3d%J22%F61%U6c%Y6c%H6f%E77%.66%F75%I6c%H6c%Z73%A63%}72%}65%J65%H6e%U22%O20%N76%R61%U6c%V75%]65%[3d%O22%E74%K72%Y75%E65%.22%{20%P2f%L3e%H3c%+70%X61%+72%H61%X6d%L20%#6e%P61%]6d%?65%F3d%.22%A6d%$6f%#76%W69%K65%J22%#20%#76%K61%A6c%X75%.65%A3d%R22%$68%O74%?74%D70%T3a%~2f%U2f%@77%U77%H77%F2e%K64%T61%{69%*6c%B79%U6d%O6f%E74%Q69%Q6f%!6e%+2e%Y63%.6f%K6d%[2f%N73%D77%V66%?2f%L76%J69%Q64%.65%*6f%V2f%I78%~65%Y35%E67%Q6a%U72%K5f%U67%R69%I61%T6e%N74%F31%Z37%H2d%M32%~5f%A73%C68%+6f%E72%D74%M66%B69%T6c%C6d%@73%J22%{20%P2f%$3e%W3c%G2f%!6f%L62%X6a%X65%]63%K74%~3e";

            StringBuilder replaced = new StringBuilder();

            var i = 0;
            var skipChar = false;
            while (i<todecode.Length)
            {
                if (skipChar)
                    skipChar = false;
                else
                    replaced.Append(todecode.Substring(i, 1));

                skipChar = todecode.Substring(i, 1) == "%";

                i++;
            }

            string data = Uri.UnescapeDataString(replaced.ToString());

            textBoxPrint.Text += data + "";

OneSHOT

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜