Esempio n. 1
0
if (not args.level) or args.level[0] < min_version:
    level = min_version
else:
    level = args.level[0]

dex_file = open(dexpath, 'w')
dex_file.write(a.get_dex())
dex_file.close()

smali_jar = os.path.join(working_dir, "smali", "smali.jar")
baksmali_jar = os.path.join(working_dir, "smali", "baksmali.jar")
cert_path = os.path.join(working_dir, "config", "apkil.cert")

call(args=['java', '-jar', baksmali_jar, '-b', '-o', smalidir, dexpath])
s = smali.SmaliTree(level, smalidir)

s = mo.inject(s, level)
s.save(new_smalidir)

call(args=[
    'java', '-jar', smali_jar, '-a',
    str(level), '-o', new_dexpath, new_smalidir
])

new_dex = open(new_dexpath).read()
a.new_zip(filename=new_apk,
          deleted_files="(META-INF/.)",
          new_files={"classes.dex": new_dex})
apk.sign_apk(new_apk, cert_path, "apkil", "apkilapkil")
print "NEW APK: %s" % new_apk
Esempio n. 2
0
SMALI_DIR = "examples/APKILTests"
APK = "examples/LeCha_v1.09.apk"
DEX = "examples/LeCha_v1.09.dex"
SMALI_DIR = "examples/LeCha_v1.09"

NEW_OUT = "examples/new"
NEW_DEX = "examples/classes.dex"
NEW_APK = "examples/new.apk"

a = apk.APK(APK)
dex_file = open(DEX, 'w')
dex_file.write(a.get_dex())
dex_file.close()

call(args=['baksmali', '-b', '-o', SMALI_DIR, DEX])
s = smali.SmaliTree(SMALI_DIR)

api_list = []
perms = a.get_permissions()
for p in perms:
    print p
    if API_BY_PERMISSION.has_key(p):
        for ml in API_BY_PERMISSION[p].values():
            api_list.extend(ml)

mo = monitor.APIMonitor(api_list)
s = mo.inject(s)
s.save(NEW_OUT)

call(args=['smali', '-a', '7', '-o', NEW_DEX, NEW_OUT])
Esempio n. 3
0
SMALI_DIR = "examples/APKILTests"

NEW_OUT = "examples/new"
NEW_DEX = "examples/classes.dex"
NEW_APK = "examples/new.apk"

a = apk.APK(APK)
min_version = int(a.get_min_sdk_version())
target_version = int(a.get_target_sdk_version())

dex_file = open(DEX, 'w')
dex_file.write(a.get_dex())
dex_file.close()

call(args=['java', '-jar', 'smali/baksmali.jar', '-b', '-o', SMALI_DIR, DEX])
s = smali.SmaliTree(min_version, SMALI_DIR)

db_path = os.path.join(working_dir, "androidlib")

API_LIST = [ \
"Landroid/net/Uri;->parse(Ljava/lang/String;)", \
"Landroid/content/Intent;-><init>(Ljava/lang/String;)", \
"Landroid/content/ContextWrapper;->openFileOutput(Ljava/lang/String;I)", \
"Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)", \
"Lapkil/tests/APKIL;->openFileInput(Ljava/lang/String;)",
"Ljava/io/BufferedReader;->readLine()Ljava/lang/String;", \
"Landroid/telephony/SmsManager;->sendTextMessage(\
Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;\
Landroid/app/PendingIntent;Landroid/app/PendingIntent;)"                                                        , \
"Landroid/content/pm/PackageManager;->getInstalledApplications(I)",
            ]
Esempio n. 4
0
#j = monitor.JavaType("[[Landroid/adf/arae;")
#print j.get_java_desc()
#sys.exit(0)

APK = "examples/DroidBoxTests.apk"
DEX = "examples/DroidBoxTests.dex"
SMALI_DIR = "examples/DroidBoxTests_smali"

a = apk.APK(APK)
dex_file = open(DEX, 'w')
dex_file.write(a.get_dex())
dex_file.close()

call(args=['baksmali', '-b', '-o', SMALI_DIR, DEX])
s = smali.SmaliTree(SMALI_DIR)

NEW_OUT = "examples/new"
NEW_DEX = "examples/classes.dex"
NEW_APK = "examples/new.apk"

# sys.exit(0)

API_LIST = [ "Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V", \
"Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Integer;)V", \
"Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V", \
"Ldroidbox/tests/DroidBoxTests;->openFileOutput(Ljava/lang/String;I)Ljava/io/FileOutputStream;",
\
"Ljava/io/OutputStreamWriter;->write(Ljava/lang/String;)V", \
#"Ldroidbox/tests/DroidBoxTests;->openFileInput(Ljava/lang/String;)Ljava/io/FileInputStream;",
\