找回密码
 立即注册

QQ登录

只需一步,快速开始

1401软件论坛总版规【新人必看】如何正确发布收费帖子加入vip系统学习仅需498元免费获得1401软件安全论坛vip开通本站VIP会员请联系QQ 564853771
论坛纪念优盘Beyond EXE超强加密器V1.61401论坛破解工具包 2017-9-12[破解班vip]入门篇[破解班vip]基础篇
[破解班vip]脱壳篇[破解班vip]实战篇[破解班vip]网络验证篇[破解班vip]零基础HOOK教程[破解班vip]零基础易语言入门
[破解班vip]零基础c语言入门[破解班vip]零基础Delphi编程入门[破解班vip]寒假培训课程共7课[破解班vip]破解提高篇[破解班vip]易语言培训课程
[破解班vip]核心技术培训篇[破解班vip]pe格式与pe操作[破解班vip]2022全新封包-山寨-爆破全系列[原创课程]c++单文档框架课程[逆向班vip]汇编语句与反汇编基础
[逆向班vip]全自动扫雷辅助[逆向班vip]手机模拟按键[逆向班vip]植物大战僵尸辅助广告位招租...付费破解软件 +Q 564853771
查看: 3352|回复: 0

逆向360加固等dex被隐藏的APK

[复制链接]
  • TA的每日心情

    2023-5-7 22:27
  • 签到天数: 340 天

    [LV.8]以坛为家I

    343

    主题

    454

    回帖

    2098

    积分

    武林新贵

    UID
    7
    元宝
    232
    威望
    815
    贡献
    64
    信誉值
    0
    精华
    10
    在线时间
    189 小时
    注册时间
    2014-1-16
    最后登录
    2023-5-7
    违规
    0
    积分
    2098

    优秀版主热心会员金点子奖突出贡献最佳新人活跃会员宣传达人吾爱富翁论坛元老管理团队已有小成灌水之王

    发表于 2015-3-11 14:08:26 | 显示全部楼层 |阅读模式
    Ȧ
    1. 1.static void Main(string[] args)
    2. 2.        {
    3. 3.        REBEGIN:
    4. 4.            Console.WriteLine("请输入gcore出来的文件路径:");
    5. 5.
    6. 6.            string filepath = Console.ReadLine();
    7. 7.
    8. 8.            if (!File.Exists(filepath))
    9. 9.            {
    10. 10.                Console.WriteLine("指定的文件不存在,请输入正确的文件路径\r\n");
    11. 11.                goto REBEGIN;
    12. 12.            }
    13. 13.
    14. 14.            new DirectoryInfo(filepath + ".dex").Create();
    15. 15.
    16. 16.            FileStream fs = new FileStream(filepath, FileMode.Open);
    17. 17.            long flen = fs.Length;
    18. 18.            BinaryReader br = new BinaryReader(fs);
    19. 19.
    20. 20.            byte[] bs = br.ReadBytes((int)flen);
    21. 21.
    22. 22.            fs.Close();
    23. 23.
    24. 24.            int bsl = bs.Length;
    25. 25.
    26. 26.
    27. 27.            for (int i = 0; i < bsl - 100; i++)
    28. 28.            {
    29. 29.                if (bs == 'd' && bs[i + 1] == 'e' && bs[i + 2] == 'x' && bs[i + 3] == 10 && bs[i + 4] == '0' && bs[i + 5] == '3' && bs[i + 6] == '5')
    30. 30.                {
    31. 31.                    string a1 = bs[i + 35].ToString("x2");
    32. 32.                    string a2 = bs[i + 34].ToString("x2");
    33. 33.                    string a3 = bs[i + 33].ToString("x2");
    34. 34.                    string a4 = bs[i + 32].ToString("x2");
    35. 35.
    36. 36.                    string hexlen = a1 + a2 + a3 + a4;
    37. 37.                    int dexlength = Int32.Parse(hexlen, System.Globalization.NumberStyles.HexNumber);
    38. 38.
    39. 39.                    byte[] dex_tmp = new byte[dexlength];
    40. 40.
    41. 41.                    int h = 0;
    42. 42.                    for (int j = i; j < (i + dexlength); j++)
    43. 43.                    {
    44. 44.                        dex_tmp[h++] = bs[j];
    45. 45.                    }
    46. 46.
    47. 47.                    File.WriteAllBytes(filepath + ".dex\" + i + ".dex", dex_tmp);
    48. 48.
    49. 49.
    50. 50.                }
    51. 51.            }
    52. 52.
    53. 53.            Console.WriteLine("所有的DEX文件已经输出到文件夹" + filepath + ".dex\");
    54. 54.
    55. 55.            while (true)
    56. 56.            {
    57. 57.                Console.Read();
    58. 58.            }
    59. 59.
    60. 60.
    61. 61.        }


    复制代码

    如果遇到apk中的lib文件夹中是这样的

    基本没有dex文件可以反编译,这中的dex文件一般都是加密混淆压缩后放在so中啦。
    但是软件要想运行就需要解出dex字节码然后加载到手机内存中,这样就可以在软件运行过程中把dex提取出来再使用相应的软件反编译成smail啦,接着就是转成java。
    好啦,第一次发帖子,以下就是干货。

    首先下载附件中的
    gdb.7z.001.rar (2.00 MB)   
    gdb.7z.002.rar (1.21 MB)
    把这两个文件的后缀名去掉使用7zip解压出来二进制文件gdb (大约13MB)
    打开安卓虚拟机,把需要逆向的加壳软件安装的虚拟机中,然后启动APK。

    1、使用ADB把gdb push到手机中
    adb push /home/down/gdb /data/local/tmp/gdb

    2、找到需要逆向的apk对应linux的进程pid
    adb 中执行
    adb shell
    top
    会显示手机中全部的进程,然后找到进程名字为apk包名的pid (在此假设pid为 482)

    3、赋予gdb权限(依次执行以下命令)
    adb shell
    su
    cd /data/local/tmp/
    chmod 777 gdb

    4、dump进程482的内存
    ./gdb --pid 482
    此时进入了gdb模式
    这个时候输入 gcore 会dump到当前目录 /data/local/tmp/core.482
    把这个core.482的文件放到安装了.net 3.5 的电脑上(win7默认是可以得)
    比如放到以下位置
    D:\core.482

    5、下载附件中的 DumpAllDEX.7z 解压出文件 DumpAllDEX.exe
    运行





    就会把所有的dex文件提取到D:\core.482.dex 文件夹中。

    6、逐个反编译提取出来的dex文件,直到找到你要逆向的软件dex。这个时候就可以开开心心的转成java看源码啦。

    DumpAllDEX.exe 为C#写的,源码如下:
    代码:
    复制代码
    1.static void Main(string[] args)
    2.        {
    3.        REBEGIN:
    4.            Console.WriteLine("请输入gcore出来的文件路径:");
    5.
    6.            string filepath = Console.ReadLine();
    7.
    8.            if (!File.Exists(filepath))
    9.            {
    10.                Console.WriteLine("指定的文件不存在,请输入正确的文件路径\r\n");
    11.                goto REBEGIN;
    12.            }
    13.
    14.            new DirectoryInfo(filepath + ".dex").Create();
    15.
    16.            FileStream fs = new FileStream(filepath, FileMode.Open);
    17.            long flen = fs.Length;
    18.            BinaryReader br = new BinaryReader(fs);
    19.
    20.            byte[] bs = br.ReadBytes((int)flen);
    21.
    22.            fs.Close();
    23.
    24.            int bsl = bs.Length;
    25.
    26.
    27.            for (int i = 0; i < bsl - 100; i++)
    28.            {
    29.                if (bs == 'd' && bs[i + 1] == 'e' && bs[i + 2] == 'x' && bs[i + 3] == 10 && bs[i + 4] == '0' && bs[i + 5] == '3' && bs[i + 6] == '5')
    30.                {
    31.                    string a1 = bs[i + 35].ToString("x2");
    32.                    string a2 = bs[i + 34].ToString("x2");
    33.                    string a3 = bs[i + 33].ToString("x2");
    34.                    string a4 = bs[i + 32].ToString("x2");
    35.
    36.                    string hexlen = a1 + a2 + a3 + a4;
    37.                    int dexlength = Int32.Parse(hexlen, System.Globalization.NumberStyles.HexNumber);
    38.
    39.                    byte[] dex_tmp = new byte[dexlength];
    40.
    41.                    int h = 0;
    42.                    for (int j = i; j < (i + dexlength); j++)
    43.                    {
    44.                        dex_tmp[h++] = bs[j];
    45.                    }
    46.
    47.                    File.WriteAllBytes(filepath + ".dex\\" + i + ".dex", dex_tmp);
    48.
    49.
    50.                }
    51.            }
    52.
    53.            Console.WriteLine("所有的DEX文件已经输出到文件夹" + filepath + ".dex\\");
    54.
    55.            while (true)
    56.            {
    57.                Console.Read();
    58.            }
    59.
    60.
    61.        }


    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|1401软件安全 ( ICP备16034480号 )

    GMT+8, 2024-5-2 16:58 , Processed in 0.133775 second(s), 25 queries , Gzip On.

    Powered by Discuz! X3.5

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表