是否足以通过渗透测试?

时间:2018-05-09 02:55:01

标签: android proguard android-proguard penetration-testing

对于我们的Android移动应用程序,我们必须选择一个混淆工具,以便我们的应用程序将通过渗透测试用例。 Proguard是否足够相同,或者我们应该使用Dexguard?

2 个答案:

答案 0 :(得分:1)

模糊不足以通过渗透测试

正确的渗透测试将分析应用程序的静态和运行时行为,因此只有通过模糊处理才能完全覆盖运行时行为

但是也只考虑你将要经历的静态分析远非安全

我将为您提供一个实用的简单示例,因为您建议的两个工具之间的差异已在另一个答案中报告

假设您有一个原始的未经模糊处理的MainActivity由:

给出
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //...

    // lines for adding the shortcut in the home screen
    appPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    isAppInstalled = appPreferences.getBoolean("isAppInstalled", false);

    if(isAppInstalled == false)
        addShortcut();

其中:

private void addShortcut() {
    //Adding shortcut

    // ...

    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    // ...

    SharedPreferences.Editor editor = appPreferences.edit();
    editor.putBoolean("isAppInstalled", true);
    editor.commit();
}

这些是由ProGuard混淆并通过online Java decompiler

获取的共同部分

decompiled_obfuscated_onCreate()

enter image description here

结论:

1)正如您所看到的 - 尽管进行了模糊处理 - 您处于一个攻击者可以轻松修改代码流的位置[例如,将if (!this.f2293p)转换为if (this.f2293p)]并轻松了解您在修改应用中的值时必须做些什么,尽管模糊不清。在这种情况下,这是一个简单的愚蠢" isAppInstalled"偏好,但当然它可能是更敏感的东西,如:

public boolean appIsPurchased(){
    return settings.getBoolean(keyPurchase,false);
}

PS存储未加密的共享首选项[特别是如果包含敏感数据]是一种非常糟糕的做法,这只是一个示例目的的快速示例。在有根设备中,检索此文件只等于浏览到系统文件夹并搜索xml文件

2)此外,这种纯粹的混淆不会隐藏任何硬编码的东西。我们已经看到了:

editor.putBoolean("isAppInstalled", true);

转变为:

this.f2293p = this.f2292o.getBoolean("isAppInstalled", false);

另一个简单的例子可以是:

if (barcode.equals("123456")) {
    return "Hat";
}
if (barcode.equals("234567")) {
    return "Jumper";
}
if (barcode.equals("345678")) {
    return "Pants";
}
return "Troubles detecting the new item";

成为混淆之后:

return str.equals("123456") ? "Hat" : str.equals("234567") ? "Jumper" : str.equals("345678") ? "Pants" : "Troubles detecting the new item";

这些字符串对于那些打破纯粹混淆应用程序的人来说是一种厚颜无耻的提示。例如,任何人都可以使用您的端点字符串

所以你需要一个像DexGuard或其他商业解决方案这样的工具能够产生比简单混淆更复杂的东西

这是ProGuard +第三方安全工具最终结果的一个示例[我没有DexGuard,我使用另一个保护是通过拖动原始未受保护的原因自动应用保护的APK]

这是新的onCreate()方法:

protected void onCreate(Bundle bundle) {
    //...
    this.f1859o = PreferenceManager.getDefaultSharedPreferences(this);
    this.f1860p = this.f1859o.getBoolean(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~"), false);
    if (!this.f1860p) {
        m3099j();
    }
}

虽然这是硬编码字符串的第二个例子,但是黑客视图已经完全隐藏了:

public String m3101a(String str) {
    PrintStream printStream = System.out;
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("}}"));
    stringBuilder.append(str);
    String stringBuilder2 = stringBuilder.toString();
    return str.equals(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("}|")) ? k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("}s") : str.equals(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("}r")) ? k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~{") : str.equals(k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~z")) ? k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~y") : k09kcah9u6scvhh4ab059fbmtq.itg7jcg3c4din73t0cib8n7eau("~x");
}

这是通过渗透测试所需的保护程度

最后 - 作为一项额外的安全措施 - 这种专业工具还可以检测受保护的"不可读的"代码并在检测到对受保护版本的篡改操作时停止应用程序执行。而且,与简单[但美观]的ProGuard不同,实现对仿真器,root设备和其他潜在危险场景的检测

请注意代码是如何通过这些步骤加强的。任何人都不会被黑客攻击100%安全。你的工作只是尽可能地让它变得困难,那就是

答案 1 :(得分:0)

ProGuard是Java字节码的通用优化器。 DexGuard是一款专门用于保护Android应用程序的工具。

ProGuard提供针对静态分析的基本保护。 DexGuard可保护应用程序免受静态和动态分析的影响。

ProGuard提供最小的混淆。 DexGuard采用多层加密和混淆。

ProGuard专注于字节码。 DexGuard处理应用程序的所有组件。

来源:DexGuard vs. ProGuard