AutoIt脚本的反编译和代码格式化问题分析(lua脚本反编译工具手机版)新鲜出炉

随心笔谈12个月前发布 admin
82 0


#!/usr/bin/env python2.7
#-*- coding: utf-8 -*-

_AU3=’;https://www.jb51.net/article/sample.au3′;
_AU3_OUT=’;https://www.jb51.net/article/format.au3′;
_INDENT=’; ‘; * 4

def au3formater(line, indent):
line=line.strip().lower()

next_indent=indent
if (line.startswith(‘;end’;) or
line.startswith(‘;until’;) or
line in (‘;next’;, ‘;wend’;)):
indent -=1
next_indent -=1
elif line.startswith(‘;if’;) and line.endswith(‘;then’;):
next_indent +=1
elif (line.startswith(‘;func’;) or
line.startswith(‘;for’;) or
line.startswith(‘;select’;) or
line.startswith(‘;switch’;) or
line.startswith(‘;while’;) or
line==’;do’;):
next_indent +=1
elif line.startswith(‘;else’;) or line.startswith(‘;case’;):
indent -=1
new_line=_INDENT * indent + line

return new_line, next_indent

def main():
with open(_AU3, ‘;r’;) as fp:
with open(_AU3_OUT, ‘;w’;) as fpw:
indent=0
line=fp.readline()
while line:
new_line, indent=au3formater(line, indent)
fpw.write(‘;%s\n’; % new_line)
line=fp.readline()

if __name__==’;__main__’;:
main()

© 版权声明

相关文章