views:

81

answers:

2

For an obfuscation program I am writing in Java, I need to find a way to get a value at a specific address. For example, in a program I opened in a hex editor, at the address 0000001F is the hex value "00". Furthermore, is it possible to write to a specific memory address? For example writing to 0000001F and changing it from "00" to for example, "FF"

+1  A: 

To answer your first question, you can open a file as a binary stream and read whatever you want from it. That won't do much in the way of the classloader, but if you have a custom classloader that manipulates the file and converts it at runtime into a class that is valid and loaded by the JVM, that is certainly theoretically possible. I would wonder what the point is, though, as the classloader itself would not be obfuscated in this manner.

To answer your second question, no you cannot write directly to a memory address with Java. You could call a function via JNI which could do so (outside of the JVM memory allocation).

It sounds to me like you are using the wrong language for what you want to do.

Yishai
+1  A: 

You are using the wrong language. C or C++ would be better choices because you can easily call operating system libraries (on most systems) and attempt to access the memory at a particular location.

Most POSIX-compliant operating systems implement mmap which allows you to map memory at a particular location in the current processes address space.

thesuperbigfrog