开发者

Understanding obfuscated JavaScript source code

Im a begginer in Android programming and google has redirected me countless times to this useful website. Here is my problem :

Using java.io I managed to mimic a HTTP POST request as such :

From Source Code :

<div id="box1"><form method="post" action="/index2.php" name="form" id="form" class="form" onsubmit="return quickly();">
<div id="textbox"><textarea rows="30" cols="50" name="BOX1" class="textbox"></textarea></div>
<div id="textbox2"><input onfocus="this.value=''" type="text" name="BOX2" class="mobilia" value=""/></div>

 My Java Code :

 String data = URLEncoder.encode("BOX1", "UTF-8") + "=" + URLEncoder.encode(string1, "UTF-8");
        data += "&" + URLEncoder.encode("BOX2", "UTF-8") + "=" + URLEncoder.encode(string2, "UTF-8");

URL url = new URL("http://www.slidesms.com/sendsms2.php");
        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(data); ... 

And this used to work like magic! Except that the website got updated and now the same position of the source code as before became as such :

div id="textbox"><Script Language='Javascript'> 
<!--
document.write(unescape('%3C%69%6E%70%75%74%20%6F%6E%66%6F%63%75%73%3D%22%74%68%69%73%2E%76%61%6C%75%65%3D%27%27%22%20%74%79%70%65%3D%22%74%65%78%74%22%20%6E%61%6D%65%3D%22%69%65%6E%6F%22%20%63%6C%61%73%73%3D%22%6D%6F%62%69%6C%65%32%22%20%76%61%6C%75%65%3D%22%43%6E%74%72%79%20%43%6F%64%65%20%26%20%4D%6F%62%69%6C%65%20%4E%6F%2E%22%20%2F%3E'));
//-->
</Script></div>

I have no experience whatsoever with Javascript, could someone even put me back on the right track ? I dont even know where to start looking, I used to mimic the POST开发者_JAVA技巧 method, now I cant understand the source code anymore. Any help would be extremely appreciated :)


That javascript writes the <input> element out to the page, in place of the script tag.

See http://jsfiddle.net/4Vj9B/

But why it does this, I honestly have no idea. It seems whatever code you have that is generating those form elements wants to generate it via obfuscated javascript. Likely due to a very strange setting/preference/configuration somewhere.

The reason this is usually done is to obfuscate email addresses in mailto links to make it harder for spiders to harvest emails. But in this case, using javascript to insert a form elements makes very little sense, and what ever chunk is "helping" you by doing needs a swift kick in the nuts.


System.out.println(URLDecoder.decode("%3C%69%6E%70%75%74%20%6F%6E%66%6F%63%75%73%3D%22%74%68%69%73%2E%76%61%6C%75%65%3D%27%27%22%20%74%79%70%65%3D%22%74%65%78%74%22%20%6E%61%6D%65%3D%22%69%65%6E%6F%22%20%63%6C%61%73%73%3D%22%6D%6F%62%69%6C%65%32%22%20%76%61%6C%75%65%3D%22%43%6E%74%72%79%20%43%6F%64%65%20%26%20%4D%6F%62%69%6C%65%20%4E%6F%2E%22%20%2F%3E", "UTF-8"));

gives you

<input onfocus="this.value=''" type="text" name="ieno" class="mobile2" value="Cntry Code & Mobile No." />
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜