解密 HtmlShip 加密的 html 文件
- #! /usr/bin/python
- #coding=gb2312
- import sys
- import webbrowser, os
- if len(sys.argv) < 2:
- print 'usage: UnHtmlShip.py encodehtml\n'
- print '运行后将弹出IE,点击允许activex\n'
- print "将在程序目录下生成 UnHtmlShip.htm"
- sys.exit(1)
- pypath = os.path.abspath(os.path.dirname(sys.argv[0]))
- pypath = pypath.replace('\\', '\\\\')
- decodeHtmlpath = pypath + '\\\\UnHtmlShip.htm'
- # 插入主要起作用的代码
- add = """;var fso, ts;
- fso = new ActiveXObject("Scripting.FileSystemObject"); """ + \
- """ts = fso.OpenTextFile(""" + '"' + decodeHtmlpath + '"' + """, 8, true); """ + \
- """ts.WriteLine(w);
- ts.Close();"""
- # 获得文件大小,单位字节
- filesize = os.path.getsize(sys.argv[1])
- substring = r',document.write(w);'
- func = lambda(x): x.replace(substring, add)
- try:
- f = open(sys.argv[1], 'rb')
- lines = f.readlines(filesize)
- newlines = [func(x) for x in lines]
- f = open(sys.argv[1], 'wb')
- f.writelines(newlines)
- f.close()
- webbrowser.open(sys.argv[1])
- except:
- print 'error occur'
- sys.exit(0)
2条评论 ▼