demo實現腳本下載
安裝工具
1
|
需要python3,apktool.jar,apktool |
1.用apktool進行反編譯
1
|
cmd = 'apktool d -f ' + apkpath + ' -o ' + outpath |
2.修改需要配置的參數值
說明:如果是androidmanifest.xml,注意在 parse 前 一定要設置namespace, 不然就會出現 ns0:name錯誤, 而不是預期的 android:name,設置namespace的方法 et.register_namespace('android', "http://schemas.android.com/apk/res/android")
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
curpath = (apktoolpath + '/ihdrm202103161405apk/' ) tree = et.parse(curpath + 'androidmanifest.xml' ) #打開xml root = tree.getroot() #找到manifest的根文件 print (root.tag) #我們輸出一下就知道root目錄就是manifest目錄 print (root.attrib) #輸出一下root目錄的成員 #獲取package versionname = root.get( 'package' ) #修改 root. set ( 'package' , 'com.youxi.jiayou' ) #獲取application目錄 application = root.find( 'application' ) #遍歷所有meta-data for item in application. iter ( 'meta-data' ): name = item.attrib.get(space + 'name' ) value = item.attrib.get(space + 'value' ) |
3.修改應用名字
1
2
3
4
5
6
7
|
def appnamechang(): print ( '--------修改應用名字完成--------' ) tree = read_xml(in_path) text_nodes = get_node_by_keyvalue(find_nodes(tree, "string" ), { "name" : "app_name" }) change_node_text(text_nodes, "霸道傳奇" ) # write_xml(tree, "./strings的絕對路徑.xml") write_xml(tree,apktoolpath + "/ihdrm202103161405apk/res/values/strings.xml" ) |
4.修改icon圖標
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
source_path = (apktoolpath + '/icon' ) target_path = (apktoolpath + '/ihdrm202103161405apk/res' ) def copy_search_file(): print ( '--------修改icon成功--------' ) '''將一個目錄下的全部文件和目錄,完整地<拷貝并覆蓋>到另一個目錄''' # source_path 源目錄 # target_path 目標目錄 if not (os.path.isdir(source_path) and os.path.isdir(target_path)): return for a in os.walk(source_path): # #創建目錄 for d in a[ 1 ]: dir_path = os.path.join(a[ 0 ].replace(source_path,target_path),d) if not os.path.isdir(dir_path): os.makedirs(dir_path) #拷貝文件 for p in a[ 2 ]: dep_path = os.path.join(a[ 0 ],p) arr_path = os.path.join(a[ 0 ].replace(source_path,target_path),p) shutil.copy(dep_path,arr_path) |
5.刪除簽名回編譯
1
|
cmd = 'apktool b -f ' + outpath |
6.創建證書
1
2
3
4
|
def createzu(): cmd = 'keytool -genkey -alias jayoux.keystore -keyalg rsa -validity 20000 -keystore jayoux.keystore' print ( '-------- 創建證書--------' ) os.system(cmd) |
到此這篇關于使用python反編譯apk簽名出包的文章就介紹到這了,更多相關python反編譯apk內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!
原文鏈接:https://blog.csdn.net/zmjwf521/article/details/114885390