MCPcopy Create free account
hub / github.com/d78ui98/APKDeepLens / AutoApkScanner

Class AutoApkScanner

APKDeepLens.py:187–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185
186
187class AutoApkScanner(object):
188
189 def __init__(self):
190 pass
191
192 def create_dir_to_extract(self, apk_file, extracted_path=None):
193 """
194 Creating a folder to extract apk source code
195 """
196 extracted_source_path = os.path.join(
197 os.path.dirname(os.path.abspath(__file__)), "app_source", apk_file
198 )
199
200 resources_path = os.path.join(extracted_source_path, "resources")
201 sources_path = os.path.join(extracted_source_path, "sources")
202
203 if (
204 os.path.exists(extracted_source_path)
205 and os.path.isdir(extracted_source_path)
206 and os.path.exists(resources_path)
207 and os.path.isdir(resources_path)
208 and os.path.exists(sources_path)
209 and os.path.isdir(sources_path)
210 ):
211 util.mod_log(
212 "[+] Source code for apk - {} Already extracted. Skipping this step.".format(
213 apk_file
214 ),
215 util.OKCYAN,
216 )
217 return {"result": 0, "path": extracted_source_path}
218 else:
219 os.makedirs(extracted_source_path, exist_ok=True)
220 util.mod_log(
221 "[+] Creating new directory for extracting apk : "
222 + extracted_source_path,
223 util.OKCYAN,
224 )
225 return {"result": 1, "path": extracted_source_path}
226
227 def extract_source_code(self, apk_file, target_dir):
228 """
229 Extracting source code with JADX
230 """
231 util.mod_log("[+] Extracting the source code to: " + target_dir, util.OKCYAN)
232
233 def is_running_in_docker():
234 return os.path.exists('/.dockerenv') or (
235 os.path.isfile('/proc/1/cgroup') and 'docker' in open('/proc/1/cgroup').read()
236 )
237
238 is_windows = os.name == "nt"
239 in_docker = is_running_in_docker()
240
241 jadx_executable = "jadx.bat" if is_windows else "jadx"
242
243 if in_docker:
244 jadx_path = "/app/static_tools/jadx/bin/jadx"

Callers 1

APKDeepLens.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected