Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import os
import sys
if len(sys.argv) < 2:
print('usage: python3', sys.argv[0], ' /path/to/file_smali')
exit(2)
path = sys.argv[1]
if not os.path.exists(path):
print(path, 'not existing')
exit(2)
if not os.path.isfile(path):
print(path, 'is not a smali file')
exit(2)
with open(path, 'r') as f:
data = f.read()
if not data.startswith('.class'):
print(path, 'is not a smali file')
exit(2)
lines = data.split('\n')
def get_class(line: str, index=0):
try:
index = start = line.index('L', index) + 1
index = line.index(';', index)
return line[start:index].replace('/', '.'), index
except:
return None, 0
ret = []
for line in lines:
clazz, index = get_class(line)
while clazz is not None:
ret.append(clazz)
clazz, index = get_class(line, index)
ret = list(dict.fromkeys(ret))
print(ret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.