常用命令行commands

一些常用的基础命令

mac wechat

1
2
3
直接使用命令行: 
nohup /Applications/WeChat.app/Contents/MacOS/WeChat > /tmp/wechat.txt 2>&1 &

class2jar

1
2
3
4
5
6
1. jar -cvf result.jar classPath 生成jar包

2. jar umf MANIFEST.MF hello.jar 更新清单,可以指定入口类,生成可执行jar包
Manifest-Version: 1.0
Main-Class: xxxx.class

jar2dex

1
dx --dex --output result.dex source.jar 

zip,unzip

1
2
3
zip -q -r *.jar ./dir
unzip source -d ./dir

zipalign apk对齐

1
2
3
4
zipalign -v -p 4 source.apk aligned.apk

4字节 也就是32位对齐

apksigner 签名

1
2
3
4
5
6
7
8
9
10
apksigner sign --ks [xx.keystore] --ks-key-alias [证书名] --ks-pass pass:[xx] --out sign.apk unsign.apk


--ks //jks签名证书路径
--ks-key-alias 你的alias 名字    //生成jks时指定的alias
--ks-pass pass:你的密码 //KeyStore密码
--out output.apk //输出路径
input.apk //被签名的apk


1
2
3
4
5
6
7
8
9
10
11
java -jar apksigner_30.0.2.jar sign -verbose --ks game8u.keystore --v1-signing-enabled true --v2-signing-enabled false  --v3-signing-enabled false --v4-signing-enabled false --ks-key-alias game8u --ks-pass pass:admin0A --key-pass pass:admin0A --out  7944_sign.apk 7944_unsign.apk

--ks 签名文件位置
--v1-signing-enabled true|false
--v2-signing-enabled true|false
--v3-signing-enabled true|false
--v4-signing-enabled true|false
--ks-key-alias 签名别名
--ks-pass pass: 签名文件密码
--key-pass pass:签名别名密码
--out 输出文件

apkTools

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
	Decoding
The decode option can be invoked either from d or decode like shown below.

$ apktool d foo.jar
# decodes foo.jar to foo.jar.out folder

$ apktool decode foo.jar
# decodes foo.jar to foo.jar.out folder

$ apktool d bar.apk
# decodes bar.apk to bar folder

$ apktool decode bar.apk
# decodes bar.apk to bar folder

$ apktool d bar.apk -o baz
# decodes bar.apk to baz folder


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
	Building
The build option can be invoked either from b or build like shown below

$ apktool b foo.jar.out
# builds foo.jar.out folder into foo.jar.out/dist/foo.jar file

$ apktool build foo.jar.out
# builds foo.jar.out folder into foo.jar.out/dist/foo.jar file

$ apktool b bar
# builds bar folder into bar/dist/bar.apk file

$ apktool b .
# builds current directory into ./dist

$ apktool b bar -o new_bar.apk
# builds bar folder into new_bar.apk

$ apktool b bar.apk
# WRONG: brut.androlib.AndrolibException: brut.directory.PathNotExist: apktool.yml
# Must use folder, not apk/jar file


dex & smali

1
2
3
4
5
dex2mali
java -jar baksmali-2.5.2.jar d classes.dex -o tmp

smali2dex
java -jar smali-2.5.2.jar a tmp -o tmp.dex

反编译实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

把apk文件反编译
java -jar apktool.jar d *.apk

jar转为dex
dx --dex --output *.dex classes.jar

反编译 dex
java -jar baksmali.jar d *.dex -o /dir

替换文件以后 把 app-debug 回编译为 apk
java -jar apktool.jar b /dir -o unsign.apk

签名:
apksigner sign --ks *.keystore --ks-key-alias [alias] --ks-pass pass:[admin] --out sign.apk unsign.apk

python

1
2
3
4
5
6
7
windows : py2exe ,

mac : py2app :
py2applet   --make-setup xxx.py  
修改setup文件,写入要执行的py源文件
python setup.py py2app -A 生成可执行文件

adb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//遍历设备安装package
adb shell pm list package

//安装包base.apk
adb shell pm path [pkgName]

//将移动设备中的文件传送到PC上
adb pull 移动设备路径 PC路径

//将PC中的文件传送到移动设备端
adb push PC路径 移动设备路径
adb push PC路径 /sdcard/

启动app
adb shell am start -D -S -W [pkg]/[mainActivity]

获取app pid
adb shell ps | grep [pkg]

端口转发
adb forward tcp:5005 jdwp:3013