capacitor-dex-editor 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorDexEditor'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '14.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapacitorDexEditor",
6
+ platforms: [.iOS(.v14)],
7
+ products: [
8
+ .library(
9
+ name: "CapacitorDexEditor",
10
+ targets: ["DexEditorPluginPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "DexEditorPluginPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/DexEditorPluginPlugin"),
23
+ .testTarget(
24
+ name: "DexEditorPluginPluginTests",
25
+ dependencies: ["DexEditorPluginPlugin"],
26
+ path: "ios/Tests/DexEditorPluginPluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # capacitor-dex-editor
2
+
3
+ A powerful Capacitor plugin for editing DEX files in APK packages. Similar to MT Manager's DEX editor functionality.
4
+
5
+ ## Features
6
+
7
+ - **DEX Operations**: Load, save, modify DEX files
8
+ - **Class Management**: Get, add, remove, rename classes
9
+ - **Method Editing**: View/modify Smali code, add/remove methods
10
+ - **Field Operations**: Get, add, remove fields
11
+ - **Smali Conversion**: Class ↔ Smali bidirectional conversion
12
+ - **Search**: Search strings, code, methods, fields
13
+ - **APK Operations**: Open, extract, repack, sign APK files
14
+ - **Utilities**: Fix DEX, merge DEX, split DEX
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install capacitor-dex-editor
20
+ npx cap sync
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```typescript
26
+ import { DexEditorPlugin } from 'capacitor-dex-editor';
27
+
28
+ // 1. Open APK
29
+ const { data: apk } = await DexEditorPlugin.execute({
30
+ action: 'openApk',
31
+ params: { apkPath: '/sdcard/test.apk' }
32
+ });
33
+
34
+ // 2. Load DEX
35
+ const { data: dex } = await DexEditorPlugin.execute({
36
+ action: 'loadDex',
37
+ params: { path: apk.dexFiles[0] }
38
+ });
39
+
40
+ // 3. Get all classes
41
+ const { data: classes } = await DexEditorPlugin.execute({
42
+ action: 'getClasses',
43
+ params: { sessionId: dex.sessionId }
44
+ });
45
+
46
+ // 4. Modify method (change return value to true)
47
+ await DexEditorPlugin.execute({
48
+ action: 'setMethodSmali',
49
+ params: {
50
+ sessionId: dex.sessionId,
51
+ className: 'Lcom/example/App;',
52
+ methodName: 'isVip',
53
+ methodSignature: '()Z',
54
+ smaliCode: `.method public isVip()Z
55
+ .registers 1
56
+ const/4 v0, 0x1
57
+ return v0
58
+ .end method`
59
+ }
60
+ });
61
+
62
+ // 5. Save DEX
63
+ await DexEditorPlugin.execute({
64
+ action: 'saveDex',
65
+ params: { sessionId: dex.sessionId, outputPath: apk.dexFiles[0] }
66
+ });
67
+
68
+ // 6. Repack APK
69
+ await DexEditorPlugin.execute({
70
+ action: 'repackApk',
71
+ params: { sessionId: apk.sessionId, outputPath: '/sdcard/modified.apk' }
72
+ });
73
+
74
+ // 7. Sign APK
75
+ await DexEditorPlugin.execute({
76
+ action: 'signApkWithTestKey',
77
+ params: { apkPath: '/sdcard/modified.apk', outputPath: '/sdcard/signed.apk' }
78
+ });
79
+ ```
80
+
81
+ ## Supported Actions
82
+
83
+ ### DEX File Operations
84
+ | Action | Description |
85
+ |--------|-------------|
86
+ | `loadDex` | Load DEX file |
87
+ | `saveDex` | Save modified DEX |
88
+ | `closeDex` | Close DEX session |
89
+ | `getDexInfo` | Get DEX file info |
90
+
91
+ ### Class Operations
92
+ | Action | Description |
93
+ |--------|-------------|
94
+ | `getClasses` | Get all classes |
95
+ | `getClassInfo` | Get class details |
96
+ | `addClass` | Add new class |
97
+ | `removeClass` | Remove class |
98
+ | `renameClass` | Rename class |
99
+
100
+ ### Method Operations
101
+ | Action | Description |
102
+ |--------|-------------|
103
+ | `getMethods` | Get all methods of a class |
104
+ | `getMethodInfo` | Get method details |
105
+ | `getMethodSmali` | Get method Smali code |
106
+ | `setMethodSmali` | Modify method Smali code |
107
+ | `addMethod` | Add new method |
108
+ | `removeMethod` | Remove method |
109
+
110
+ ### Field Operations
111
+ | Action | Description |
112
+ |--------|-------------|
113
+ | `getFields` | Get all fields of a class |
114
+ | `getFieldInfo` | Get field details |
115
+ | `addField` | Add new field |
116
+ | `removeField` | Remove field |
117
+
118
+ ### Smali Operations
119
+ | Action | Description |
120
+ |--------|-------------|
121
+ | `classToSmali` | Convert class to Smali |
122
+ | `smaliToClass` | Compile Smali to class |
123
+ | `disassemble` | Disassemble entire DEX |
124
+ | `assemble` | Assemble Smali directory to DEX |
125
+
126
+ ### Search Operations
127
+ | Action | Description |
128
+ |--------|-------------|
129
+ | `searchString` | Search strings (regex supported) |
130
+ | `searchCode` | Search in code |
131
+ | `searchMethod` | Search method names |
132
+ | `searchField` | Search field names |
133
+
134
+ ### APK Operations
135
+ | Action | Description |
136
+ |--------|-------------|
137
+ | `openApk` | Open and extract APK |
138
+ | `closeApk` | Close APK session |
139
+ | `getApkInfo` | Get APK info |
140
+ | `listApkContents` | List APK contents |
141
+ | `extractFile` | Extract file from APK |
142
+ | `replaceFile` | Replace file in APK |
143
+ | `addFile` | Add file to APK |
144
+ | `deleteFile` | Delete file from APK |
145
+ | `repackApk` | Repack APK |
146
+ | `signApk` | Sign APK with custom key |
147
+ | `signApkWithTestKey` | Sign APK with test key |
148
+ | `getApkSignature` | Get APK signature info |
149
+
150
+ ### Utility Operations
151
+ | Action | Description |
152
+ |--------|-------------|
153
+ | `fixDex` | Fix corrupted DEX |
154
+ | `mergeDex` | Merge multiple DEX files |
155
+ | `splitDex` | Split DEX by class count |
156
+ | `getStrings` | Get string pool |
157
+ | `modifyString` | Batch replace strings |
158
+
159
+ ## Requirements
160
+
161
+ - Android only (iOS not supported)
162
+ - Capacitor 7.0+
163
+ - Android API 23+
164
+
165
+ ## License
166
+
167
+ MIT
168
+
169
+ ## API
170
+
171
+ <docgen-index>
172
+
173
+ * [`execute(...)`](#execute)
174
+ * [Interfaces](#interfaces)
175
+ * [Type Aliases](#type-aliases)
176
+
177
+ </docgen-index>
178
+
179
+ <docgen-api>
180
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
181
+
182
+ DEX编辑器插件 - 通用执行器接口
183
+ 通过 action 参数调用 dexlib2 的全部功能
184
+
185
+ ### execute(...)
186
+
187
+ ```typescript
188
+ execute(options: DexExecuteOptions) => Promise<DexExecuteResult>
189
+ ```
190
+
191
+ 通用执行器 - 调用任意 dexlib2 功能
192
+
193
+ | Param | Type |
194
+ | ------------- | --------------------------------------------------------------- |
195
+ | **`options`** | <code><a href="#dexexecuteoptions">DexExecuteOptions</a></code> |
196
+
197
+ **Returns:** <code>Promise&lt;<a href="#dexexecuteresult">DexExecuteResult</a>&gt;</code>
198
+
199
+ --------------------
200
+
201
+
202
+ ### Interfaces
203
+
204
+
205
+ #### DexExecuteResult
206
+
207
+ | Prop | Type |
208
+ | ------------- | -------------------- |
209
+ | **`success`** | <code>boolean</code> |
210
+ | **`data`** | <code>any</code> |
211
+ | **`error`** | <code>string</code> |
212
+
213
+
214
+ #### DexExecuteOptions
215
+
216
+ | Prop | Type |
217
+ | ------------ | ------------------------------------------------------------ |
218
+ | **`action`** | <code><a href="#dexaction">DexAction</a></code> |
219
+ | **`params`** | <code><a href="#record">Record</a>&lt;string, any&gt;</code> |
220
+
221
+
222
+ ### Type Aliases
223
+
224
+
225
+ #### DexAction
226
+
227
+ 支持的操作类型
228
+
229
+ <code>'loadDex' | 'saveDex' | 'closeDex' | 'getDexInfo' | 'getClasses' | 'getClassInfo' | 'addClass' | 'removeClass' | 'renameClass' | 'getMethods' | 'getMethodInfo' | 'getMethodSmali' | 'setMethodSmali' | 'addMethod' | 'removeMethod' | 'getFields' | 'getFieldInfo' | 'addField' | 'removeField' | 'classToSmali' | 'smaliToClass' | 'disassemble' | 'assemble' | 'searchString' | 'searchCode' | 'searchMethod' | 'searchField' | 'fixDex' | 'mergeDex' | 'splitDex' | 'getStrings' | 'modifyString' | 'openApk' | 'closeApk' | 'getApkInfo' | 'listApkContents' | 'extractFile' | 'replaceFile' | 'addFile' | 'deleteFile' | 'repackApk' | 'signApk' | 'signApkWithTestKey' | 'getApkSignature' | 'getSessionDexFiles'</code>
230
+
231
+
232
+ #### Record
233
+
234
+ Construct a type with a set of properties K of type T
235
+
236
+ <code>{
237
  [P in K]: T;
1
238
  }</code>
239
+
240
+ </docgen-api>
@@ -0,0 +1,67 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.7.2'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "com.aetherlink.dexeditor"
22
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_21
41
+ targetCompatibility JavaVersion.VERSION_21
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+
56
+ // dexlib2 & smali - DEX文件编辑核心库
57
+ implementation 'com.android.tools.smali:smali-dexlib2:3.0.3'
58
+ implementation 'com.android.tools.smali:smali:3.0.3'
59
+ implementation 'com.android.tools.smali:smali-baksmali:3.0.3'
60
+
61
+ // Gson - JSON序列化
62
+ implementation 'com.google.code.gson:gson:2.10.1'
63
+
64
+ testImplementation "junit:junit:$junitVersion"
65
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
66
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
67
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>