Sunday, January 23, 2011

Javascript decoding using Python Interpreter

I keep forgetting the module to decode % encoded javascript obfuscation using python, so here it is:
$ python

>>> import urllib
>>> s = '%33%76%31%4C%20%6A%73%63%72%69%70%74%21'
>>> urllib.unquote(s)
'3v1L jscript!'

Remove html tags: two sed one liners

1. Quick and easy one liner to remove any html tags from file blah:
cat blah | sed 's/<[^>]*>//g'

2. Remove html tags and format jscript just enough to read file blah:
cat blah | sed 's/<[^>]*>//g' | sed 's/;[^\n]/;\n/g' | sed 's/{/{\n/g'| sed 's/{\s*[^\n]/\n{/g'

note that these only work if the html tag is not broken onto two lines.