How can I uncode data from javascript?

A discussion of how to use EasyPatterns, EasyPattern Helper and using the EasyPattern library.

Moderator: DataMystic Support

kageua
Posts: 2
Joined: Tue Feb 09, 2010 11:29 pm

How can I uncode data from javascript?

Postby kageua » Tue Feb 09, 2010 11:41 pm

While mining html files I found that browser shows data normal, but in source html file it`s coded!
So I get only data like this:
<script language="JavaScript">WriteSmiles('79D711D64D901D111C99E64F221D501D46E411A101C511','','');</script>
<script language="JavaScript">WriteSmiles('711A411E64E79D121E46D701C501F511B111A111F601','','');</script>
<script language="JavaScript">WriteSmiles('711A411D64F801D501B79A901A46D79A601A011C79D611C59A79A701A401C511A111F701D501A011','','');</script>

As I understood this code is created to uncode the data when browser shows it to me

Code: Select all

<script languauge="JavaScript">
<!--
function WriteSmiles(smile,t,c)
{
  var m=document; var s=':otl'+'iam'+'\"=f'+'erh a<';
  var a=';'; for (i=0;i<smile.length;i++) if (smile.charAt(i)>'9') a=a+'#&;'; else a=a+smile.charAt(i); a=a+'#&';
  for (i=s.length-1;i>=0;i--) m.write(s.charAt(i));
  for (i=a.length-1;i>=0;i--) m.write(a.charAt(i)); if (c!='') m.write('?su'+'bj'+'ect='+c); m.write('\">');
  if (t=='') { for (i=a.length-1;i>=0;i--) m.write(a.charAt(i)); } else m.write(t); m.write('</'+'a>');
}
//-->
</script>


But, how can I get this data in TextPipe Pro or maybe download via Offline Browser whis data already uncoded?
Big thanks in advance for all your suggestions!

User avatar
DataMystic Support
Site Admin
Posts: 2154
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: How can I uncode data from javascript?

Postby DataMystic Support » Wed Feb 10, 2010 10:37 am

Pretty easy actually.

Use a perl search/replace with this pattern:

Code: Select all

  <script language="JavaScript">WriteSmiles\('(.*)','',''\);</script>

and set the replace field to

Code: Select all

$1


Then add a Filters\Convert\Hex encoding\decode from Hex as a subfilter.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

kageua
Posts: 2
Joined: Tue Feb 09, 2010 11:29 pm

Re: How can I uncode data from javascript?

Postby kageua » Wed Feb 10, 2010 8:41 pm

Thanks a lot, I got string by this method, but Hex encoding/decoding is not the proper way to encode this string

For example as I understood this string
<script language="JavaScript">WriteSmiles('79B711E64B901C111C99A64C221F501A46D411E101B511','','');</script>
in browser encoded to
<a href="mailto:ser@iz.com.ua">ser@iz.com.ua</a>

But with hex encode/decode I have
37394237313145363442393031433131314339394136344332323146353031413436443431314531303142353131
or
y·жKђ™¦L"PFФбµ


Can I put this algoritm to TextPipe Pro without changing, and get needed string in out?

Code: Select all

<script languauge="JavaScript">
<!--
function WriteSmiles(smile,t,c)
{
  var m=document; var s=':otl'+'iam'+'\"=f'+'erh a<';
  var a=';'; for (i=0;i<smile.length;i++) if (smile.charAt(i)>'9') a=a+'#&;'; else a=a+smile.charAt(i); a=a+'#&';
  for (i=s.length-1;i>=0;i--) m.write(s.charAt(i));
  for (i=a.length-1;i>=0;i--) m.write(a.charAt(i)); if (c!='') m.write('?su'+'bj'+'ect='+c); m.write('\">');
  if (t=='') { for (i=a.length-1;i>=0;i--) m.write(a.charAt(i)); } else m.write(t); m.write('</'+'a>');
}
//-->


There is the problem, that I don`t know nor JScript, nor VBScript

User avatar
DataMystic Support
Site Admin
Posts: 2154
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: How can I uncode data from javascript?

Postby DataMystic Support » Thu Feb 11, 2010 7:41 am

Ah I see, it's more complicated than I thought.

There is a distinct possibility that you can, using the Scripting filter, and a JScript script, combined with the JScript 'eval' function.

It would only work for this website - if the WriteSmiles function changed, you would need to rewrite it.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “EasyPatterns Support”

Who is online

Users browsing this forum: No registered users and 2 guests