Android逆向-python写一个.class分析辅助脚本
# 0x00 前言
##1.起因
使用二进制文件进行分析的时候,不知道cp_info的结束部分在哪,虽然有一个javap程序,但是还是很不友好,所以做了一个python脚本来进行辅助分析。
##2.说明
在之前只是粗糙的过了一遍python的基本语言,但是在应用方面还是很少,所以这次通过编写class文件的辅助脚本,对命令行脚本使用进行了学习,还有对缩进等,还有对python语句不同的使用方法的练习。最后,学习语言的最好方式就是做东西,这样理解就会方便的很多。
# 0x01 主函数
##1.程序结构图

##2.程序main函数
```
def main(argv):
inputfile=''
outputfile=''
try:
opts,args=getopt.getopt(argv,"hm:i:o:v:V:c:C:a:")
except getopt.GetoptError:
print "This is bad!"
print "You can enter -h for help."
sys.exit()
for opt,arg in opts:
if opt=='-h':
help()
sys.exit()
elif opt in ("-v"):
minor_version(arg)
elif opt in ("-V"):
major_version(arg)
elif opt in ("-m"):
moshu(arg)
elif opt in ("-c"):
constant_pool_count(arg)
elif opt in ("-C"):
cp_info(arg)
elif opt in ("-a"):
access_flags(arg)
zhuzhu()
if __name__=="__main__":
main(sys.argv)
```
##3.程序说明:
首先调用了一个zhuzhu()函数,来进行logo的载入。
```
def zhuzhu():
print '---------------------------'
print '| class analysis 1.0 |'
print '| -------love zhuzhu |'
print '| HAI_ZHU |'
print '---------------------------'
```
然后通过import sys,getopt
main(sys.argv) 载入命令行。
# 0x02
测试使用文件 first.class
## 1.python class.py -h
难点:对格式进行调整即可。

## 2.python class.py -v first.class

## 3.python class.py -V first.class

## 4.python class.py -c first.class

## 5.python class.py -C first.class

## 6.python class.py -a first.class

##源程序分享:链接:https://pan.baidu.com/s/1mj4UIG4 密码:k4vv 冥界3大法王 发表于 2018-1-15 19:06
@BubblePig
这效果怎么做到的?
用markdown写的,用了``的效果 @BubblePig
这效果怎么做到的? 冥界3大法王 发表于 2018-1-15 19:06
@BubblePig
这效果怎么做到的?
MD编辑器,toc添加目录 哈哈哈谢谢楼主分享{:1_921:} 看不太懂啊哈哈哈哈 python用的很6{:1_921:}{:1_921:}{:1_921:} 看不太懂啊哈哈哈哈 太厉害了啊~~~~~ 先收藏,再学习,谢谢楼主分享
页:
[1]
2