如何从RAM存储器中存储和加载类?

提尔兹

今天,一个朋友问我是否可以反转jar文件,就像我们可以使用IDA反转可执行文件一样。

答案显然是“是”,但是由于我很好奇,我需要尝试。

免费的IDA不允许我反编译JAR文件,但是我终于找到了CFR和JD。

因此,我创建了一个crackMe.jar,要求我们提供密码,然后解密2个DLL并读取其输出。

第一个DLL的输出是一个类文件,该类文件检查密码是否正确,第二个DLL的输出也是一个类文件,此处用于擦除两个输出-目的是使破解者无法读取它们。

但是这个crackMe仍然太容易破解了……破解者只需修改crackMe.jar的Main.class,保留DLL的输出,然后修改tmp.class并删除tmp $ del.class。

我认为可以制作另一个DLL来检查Main.class是否已被修改...但是我们可以轻松地对其进行破解。

这就是为什么我需要第一次知道是否可以在RAM内存中存储文件的原因。

为什么在使用CFR时Java中的源代码是可读的?我们有没有一种方法可以加密该类并以十六进制执行它,而无需使用外部程序对其进行解密?

即使我们在Java中没有指针,也可以在内存中提取某些内容并保持对它的访问吗?(在C ++中可能吗?)-我已经找到了这个主题:https : //unix.stackexchange.com/questions/59300/how-to-place-store-a-file-in-memory-on-linux

我们可以管理内存的访问权限吗?因此,如果以管理员身份启动程序,CPU是否可以将控件保留在内存的一部分上,仅允许程序而非用户读取?- https://en.wikipedia.org/wiki/Protection_ring

crackMe.jar的源代码:

public class Main
{
    public static void main(String[] args) throws Exception
    {
        if (new java.io.File(fct("yju!ibq+hifpx")).exists() || new java.io.File(fct("yju+hifpx")).exists())
        {
            new java.io.File(fct("i^y^3aqi")).delete();
            new java.io.File(fct("i^y^d/3aqi")).delete();
            javax.swing.JOptionPane.showMessageDialog(null, fct("Zkf_qb%qttsjo|onqjyju+hifpxto%qrm)aji3`q^xp"));
        }
        String str = javax.swing.JOptionPane.showInputDialog(fct("Jkybw~lzo%mfpxttoi7"));
        byte[] keyBytes = fct("o^{^").getBytes();
        javax.crypto.spec.SecretKeySpec secretKeySpec = new javax.crypto.spec.SecretKeySpec(keyBytes, fct("Gittkfxe"));
        javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(fct("Gittkfxe"));
        cipher.init(javax.crypto.Cipher.DECRYPT_MODE, secretKeySpec);
        java.io.File fileTmp1 = new java.io.File(fct("yju!ibq+hifpx"));
        java.io.BufferedInputStream bufferedInputStream = new java.io.BufferedInputStream(new java.io.FileInputStream(fct("i^y^d/3aqi")));
        javax.crypto.CipherOutputStream cipherOutputStream = new javax.crypto.CipherOutputStream(new java.io.BufferedOutputStream(new java.io.FileOutputStream(fileTmp1)), cipher);
        int i;
        if (str != null && str != "")
        {
            do
            {
                i = bufferedInputStream.read();
                if (i != -1)
                    cipherOutputStream.write(i);
            }while (i != -1);
        }
        bufferedInputStream.close();
        cipherOutputStream.close();
        java.io.File fileTmp2 = new java.io.File(fct("yju+hifpx"));
        bufferedInputStream = new java.io.BufferedInputStream(new java.io.FileInputStream(fct("i^y^3aqi")));
        cipherOutputStream = new javax.crypto.CipherOutputStream(new java.io.BufferedOutputStream(new java.io.FileOutputStream(fileTmp2)), cipher);
        if (str != null && str != "")
        {
            do
            {
                i = bufferedInputStream.read();
                if (i != -1)
                    cipherOutputStream.write(i);
            }while (i != -1);
        }
        bufferedInputStream.close();
        cipherOutputStream.close();
        Runtime.getRuntime().exec(fct("o^{^%qrm%") + str);
        Thread.sleep(200);
        fileTmp1.delete();
        fileTmp2.delete();
    }

    private static String fct(String str)
    {
        char[] strC = str.toCharArray();
        for (int i = 0, j = str.length(); i < j; i++)
        {
            if (i % 2 == 0)
                strC[i] -= 5;
            else
                strC[i] += 3;
        }
        return String.valueOf(strC);
    }
}

tmp.class和tmp $ del.class的源代码

它们不在crackMe.jar中,而是位于名称为data.dll和data_2.dll的同一文件夹中。

此源代码已加密。

class tmp
{
    private static String str1, str2 = "Iivfv1$Nvfr^$:Ho\\}%", str3 = "EGq\"", str4 = "W\\xltwkeix\\h%";
    private static boolean bool;

    protected static void setBool(boolean b)
    {
        bool = b;
    }

    protected static boolean getBool()
    {
        return bool;
    }

    public static void main(String[] args)
    {
        new tmp(true, args[0]);
    }

    private static void fct1(int index)
    {
        if (index == 0)
            javax.swing.JOptionPane.showMessageDialog(null, fct5(str2));
    }

    private static void fct2(int index)
    {
        if (index == 0)
            javax.swing.JOptionPane.showMessageDialog(null, fct5(str4));
    }

    private static void fct3(int index)
    {
        new del().start();
        if (index == 0 && getBool())
        {
            fct1(0);
        }
        else if (index == 1 && !getBool())
        {
            fct2(0);
        }
    }

    private static boolean fct4()
    {
        return !bool&&!(fct5(str3).equals(str1));
    }

    private static String fct5(String str)
    {
        char[] strC = str.toCharArray();
        for (int i = 0, j = str.length(); i < j; i++)
        {
            if (i % 2 == 0)
                strC[i] -= 4;
            else
                strC[i] += 9;
        }
        return String.valueOf(strC);
    }

    protected tmp(boolean bool, String arg)
    {
        str1 = arg;
        setBool(false);
        if (fct4())
        {
            setBool(true);
            fct3(0);
        }
        else
        {
            fct3(1);
        }
    }

    static class del extends Thread
    {
        public void run()
        {
            try
            {
                Thread.sleep(50);
                byte[] keyBytes = "erase".getBytes();
                javax.crypto.spec.SecretKeySpec secretKeySpec = new javax.crypto.spec.SecretKeySpec(keyBytes, "Blowfish");
                javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("Blowfish");
                cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, secretKeySpec);
                java.io.BufferedInputStream bufferedInputStream = new java.io.BufferedInputStream(new java.io.FileInputStream("tmp.class"));
                javax.crypto.CipherOutputStream cipherOutputStream = new javax.crypto.CipherOutputStream(new java.io.BufferedOutputStream(new java.io.FileOutputStream("tmp.class")), cipher);
                int i;
                do
                {
                    i = bufferedInputStream.read();
                    if (i != -1)
                        cipherOutputStream.write(i);
                }while (i != -1);
                bufferedInputStream.close();
                cipherOutputStream.close();
                bufferedInputStream = new java.io.BufferedInputStream(new java.io.FileInputStream("tmp$del.class"));
                cipherOutputStream = new javax.crypto.CipherOutputStream(new java.io.BufferedOutputStream(new java.io.FileOutputStream("tmp$del.class")), cipher);
                do
                {
                    i = bufferedInputStream.read();
                    if (i != -1)
                        cipherOutputStream.write(i);
                }while (i != -1);
                bufferedInputStream.close();
                cipherOutputStream.close();
            }
            catch (Exception e)
            {

            }
        }
    }
}

我用来创建DLL文件的加密器的源代码

该程序永远不会离开我的计算机,因此破解者无法读取它。

我们仅将其用于将tmp.class和tmp $ del.class加密为data.dll和data_2.dll。

public class encrypt
{
    public static void main(String[] args) throws Exception
    {
        byte[] keyBytes = "java".getBytes();
        javax.crypto.spec.SecretKeySpec secretKeySpec = new javax.crypto.spec.SecretKeySpec(keyBytes, "Blowfish");
        javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("Blowfish");
        cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, secretKeySpec);

        java.io.BufferedInputStream bufferedInputStream = new java.io.BufferedInputStream(new java.io.FileInputStream("tmp.class"));
        javax.crypto.CipherOutputStream cipherOutputStream = new javax.crypto.CipherOutputStream(new java.io.BufferedOutputStream(new java.io.FileOutputStream("data.dll")), cipher);
        int i;
        do
        {
            i = bufferedInputStream.read();
            if (i != -1)
                cipherOutputStream.write(i);
        }while (i != -1);
        bufferedInputStream.close();
        cipherOutputStream.close();

        bufferedInputStream = new java.io.BufferedInputStream(new java.io.FileInputStream("tmp$del.class"));
        cipherOutputStream = new javax.crypto.CipherOutputStream(new java.io.BufferedOutputStream(new java.io.FileOutputStream("data_2.dll")), cipher);
        do
        {
            i = bufferedInputStream.read();
            if (i != -1)
                cipherOutputStream.write(i);
        }while (i != -1);
        bufferedInputStream.close();
        cipherOutputStream.close();

        System.exit(0);
    }
}
斯蒂芬·C

是的,可以从内存资源中加载类。您需要编写一个自定义的类加载器来执行此操作,但是该类加载器可以将字节码加载到中,byte[]并调用(protecteddefineClass方法之一。

但是,我不确定这将为您带来什么:

  • 如果您试图在计算机上运行代码时保护它,则不需要这样做。只需停止饼干进入您的机器即可。(但是,如果您无法做到这一点,那将会很麻烦;请参阅下文。)

  • 如果您想在饼干的计算机上运行代码时保护它,那么这将无济于事。破解者所需要做的就是启动调试器,在byte[]准备好调用的解密字节码的位置设置一个断点defineClass

无论您做什么,如果破解者“拥有”执行平台,他们就可以掌握在其上运行的应用程序的密码。(并且同样适用于任何本机代码库。)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

RAM存储器中的数据布局如何?

来自分类Dev

使用 MIF 文件 VHDL 预加载 RAM 存储器

来自分类Dev

无法在M预览中从外部存储器加载图像

来自分类Dev

外部功能如何使用设备存储器中的变量?

来自分类Dev

如何从Android的内部存储器中删除文件?

来自分类Dev

在引导加载程序中向/从存储器存储/读取功能指针符号地址

来自分类Dev

如何将存储器中的mp3数据加载到Swift中的AVAudioPCMBuffer中?

来自分类Dev

如何改进我的 StringArray 存储和加载?

来自分类Dev

9.2R在RAM存储器中是什么意思?

来自分类Dev

堆栈存储器如何组织?

来自分类Dev

C存储器地址中的If语句

来自分类Dev

C存储器地址中的If语句

来自分类Dev

添加RAM后更改交换存储器的大小?

来自分类Dev

fCK(RAM存储器速度)代表什么?

来自分类Dev

存储器时序和RAM是什么意思?

来自分类Dev

如何上传存储在内部存储器文件中的所有图像

来自分类Dev

如何上传存储在内部存储器文件中的所有图像

来自分类Dev

单击后如何将图像存储在内部存储器中?

来自分类Dev

快速将字典存储在永久存储器中

来自分类Dev

显示存储在内部存储器中的图像

来自分类Dev

读取存储在存储器或内存中的文件

来自分类Dev

将表大部分或部分加载到工作存储器中以进行查询

来自分类Dev

将引导加载程序放在FLASH存储器的底部

来自分类Dev

如何在python中的文件中存储和加载列表,同时保留其元素类型

来自分类Dev

如何使用HDF5存储和加载Python词典

来自分类Dev

如何使用 Open Layers 下载、存储和加载图块?

来自分类Dev

如何获取其他程序存储器的地址,然后在我的程序中读取它

来自分类Dev

如何在ARM ELF文件中查找功能存储器映射?

来自分类Dev

如何在特定的存储器地址中读取和写入1个字节?

Related 相关文章

  1. 1

    RAM存储器中的数据布局如何?

  2. 2

    使用 MIF 文件 VHDL 预加载 RAM 存储器

  3. 3

    无法在M预览中从外部存储器加载图像

  4. 4

    外部功能如何使用设备存储器中的变量?

  5. 5

    如何从Android的内部存储器中删除文件?

  6. 6

    在引导加载程序中向/从存储器存储/读取功能指针符号地址

  7. 7

    如何将存储器中的mp3数据加载到Swift中的AVAudioPCMBuffer中?

  8. 8

    如何改进我的 StringArray 存储和加载?

  9. 9

    9.2R在RAM存储器中是什么意思?

  10. 10

    堆栈存储器如何组织?

  11. 11

    C存储器地址中的If语句

  12. 12

    C存储器地址中的If语句

  13. 13

    添加RAM后更改交换存储器的大小?

  14. 14

    fCK(RAM存储器速度)代表什么?

  15. 15

    存储器时序和RAM是什么意思?

  16. 16

    如何上传存储在内部存储器文件中的所有图像

  17. 17

    如何上传存储在内部存储器文件中的所有图像

  18. 18

    单击后如何将图像存储在内部存储器中?

  19. 19

    快速将字典存储在永久存储器中

  20. 20

    显示存储在内部存储器中的图像

  21. 21

    读取存储在存储器或内存中的文件

  22. 22

    将表大部分或部分加载到工作存储器中以进行查询

  23. 23

    将引导加载程序放在FLASH存储器的底部

  24. 24

    如何在python中的文件中存储和加载列表,同时保留其元素类型

  25. 25

    如何使用HDF5存储和加载Python词典

  26. 26

    如何使用 Open Layers 下载、存储和加载图块?

  27. 27

    如何获取其他程序存储器的地址,然后在我的程序中读取它

  28. 28

    如何在ARM ELF文件中查找功能存储器映射?

  29. 29

    如何在特定的存储器地址中读取和写入1个字节?

热门标签

归档