+ Reply to Thread
Showing results 1 to 11 of 11

Thread: [Java] JNI Hacking Interface

  1. #1
    F7 F1EF Senior Member
    Retired Staff Member

    Crusader
    bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me's Avatar
    Join Date
    Jun 2004
    Location
    Torreón, Coah. México
    Posts
    3,316
    Blog Entries
    1

    Default [Java] JNI Hacking Interface

    Well, yeah I found my code. Please keep in mind that I just did it for that workshop and it's far from perfect, maybe I'll update this as a Java iNHALE template.

    You have the basic stuff, OpenProcess finds a window either by ClassName or WindowName and returns the processHandle to you.

    Refer to the MSDN WriteProcessMemory documentation for information on the return values of this function. Additionally you should only write n bytes where n%2 == 0. The same goes for ReadProcessMemory you should only read n bytes where n%2 == 0. I may or may not improve this interface in the future, mainly because the use of chars was a nasty fix and I had little time to implement this. (chars are unsigned in Java) :p

    Main.java
    Code:
    /**
     * [descripción]
     * Creado el 2/11/2005 @ 11:47:58 AM
     *
     * @author 
     * @version %I%, %G%
     */
    public class Main {
    
        public static void main(String[] args) {
        
            System.out.println();
    
            Process process = new Process(null, "MSN Messenger");
    
            // WriteProcessMemory
            if ( process.getpHandle() != 0 ) {
                System.out.println("MSN Messenger encontrado!");
                process.WriteProcessMemory(0x5070ED, new char[] {0x77EB});
            }
            else {
                System.out.println("Error: MSN Messenger no econtrado!.");
            }
        }
    Process.java
    Code:
    /**
     * [descripción]
     * Creado el 31/10/2005 @ 09:46:47 PM
     *
     * @author 
     * @version %I%, %G%
     */
    public class Process {
        private int pHandle;
        private static String NULL = "";
    
        private native int OpenProcess(String lpClassName, String lpWindowName);
        private native int WriteProcessMemory(int pHandle, int lpBaseAddress, char[] lpBuffer);
        private native char[] ReadProcessMemory(int pHandle, int lpBaseAddress, int nSize);
    
        static {
            System.loadLibrary("SandBox");
        }
    
        public Process() {
        }
    
        public Process(int pHandle) {
            this.pHandle = pHandle;
        }
    
        public Process(String lpClassName, String lpWindowName) {
            this.pHandle = OpenProcess(lpClassName == null ? NULL : lpClassName, lpWindowName == null ? NULL : lpWindowName);
        }
    
        public int getpHandle() {
            return pHandle;
        }
    
        public void setpHandle(int pHandle) {
            this.pHandle = pHandle;
        }
    
        public void setpHandle(String lpClassName, String lpWindowName) {
            this.pHandle = OpenProcess(lpClassName == null ? NULL : lpClassName, lpWindowName == null ? NULL : lpWindowName);
        }
    
        public int WriteProcessMemory(int lpBaseAddress, char[] lpBuffer) {
            return WriteProcessMemory(pHandle, lpBaseAddress, lpBuffer);
        }
    
        public char[] ReadProcessMemory(int lpBaseAddress, int nSize) {
            return ReadProcessMemory(pHandle, lpBaseAddress, nSize);
        }
    }
    SandBox.DLL
    Last edited by bulk_4me : 07-11-2007 at 03:16 PM

  2. #2
    kds
    kds 15 0FF11|\|3
    MENOS EL OSO Senior Member
    Moderator

    Saint
    kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds's Avatar
    Join Date
    Sep 2004
    Location
    Chicago
    Posts
    6,765

    Default

    Ah, if only I could remember back to last school year when I was working with Java JNI. Good job bulk.
    i swear this tea is at a real good temperature right now

  3. #3
    F7 F1EF Senior Member
    Retired Staff Member

    Crusader
    bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me's Avatar
    Join Date
    Jun 2004
    Location
    Torreón, Coah. México
    Posts
    3,316
    Blog Entries
    1

    Default

    You mentioned something about a joystick interface.

  4. #4

    Advocate
    arpsmack is a jewel in the rough arpsmack's Avatar
    Join Date
    Feb 2005
    Posts
    326

    Default

    /me gives mad props to bulk

    Enjoy the props, they are extra mad.

  5. #5
    kds
    kds 15 0FF11|\|3
    MENOS EL OSO Senior Member
    Moderator

    Saint
    kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds has a reputation beyond repute kds's Avatar
    Join Date
    Sep 2004
    Location
    Chicago
    Posts
    6,765

    Default

    Quote Originally Posted by bulk_4me View Post
    You mentioned something about a joystick interface.
    Yeah, we were using JNI to interact with the serial port and joystick.
    i swear this tea is at a real good temperature right now

  6. #6

    Zealot
    Pwnd is a jewel in the rough Pwnd's Avatar
    Join Date
    Jun 2005
    Location
    import java.util.*;
    Posts
    788

    Default

    Oo, please do improve. Dude, I'll try and help. Thing is, I don't know anything about process modifying/hacking/whatever. I've been going along with Java though. I'm not to bad at that :D I'm very unfamiliar with JNI though, for now.

  7. #7
    Mortal JavaFreak is on a distinguished road
    Join Date
    Feb 2007
    Posts
    1

    Default

    I'm also trying to hack with java using the win32 api. The JNI is cumbursome and requires a steep learning curve, which is what java is NOT about. Though one day I want to be able to work with JNI inside out, let me offer a slightly easier approach. Use jawin, a java/win32 interop project. Google it or go to their homepage at http://jawinproject.sourceforge.net/. I have not done much with it yet as I have to concern myself with other matters that are more important to my job (Like higher level stuff that people who use java only cares about). Remember, Sun designed java to be platform independent and relatively easy to use, JNI breaks both paradigm so support for it is not widely available. I honestly wish Sun would implement a wrapper package (maybe something like javax.win32 and each sub package each has DLL as a static library), it would definitely make hacking in java a lot easier. I'm very interested in this topic, if you guys discover more about JNI and hacking please post it here

  8. #8

    Deviant
    Totte_ch is on a distinguished road Totte_ch's Avatar
    Join Date
    May 2007
    Location
    Sweden
    Posts
    134

    Default

    I'm intressted of this...
    ...but the link is broken!
    Please insert a new link, send the dll-file to me or message me

  9. #9
    F7 F1EF Senior Member
    Retired Staff Member

    Crusader
    bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me's Avatar
    Join Date
    Jun 2004
    Location
    Torreón, Coah. México
    Posts
    3,316
    Blog Entries
    1

    Default

    I restored the file. Try again.

  10. #10

    Deviant
    Totte_ch is on a distinguished road Totte_ch's Avatar
    Join Date
    May 2007
    Location
    Sweden
    Posts
    134

    Default Next step

    Thank you

    Do you know how to hack Brood War? I understand that I must use WriteProcessMemory, but how??
    What means lpBaseAddress and what means with lpBuffer??
    Code:
    public int WriteProcessMemory(int lpBaseAddress, char[] lpBuffer)
    Thanks for help
    Last edited by Totte_ch : 07-13-2007 at 09:47 AM

  11. #11
    F7 F1EF Senior Member
    Retired Staff Member

    Crusader
    bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me has much to be proud of bulk_4me's Avatar
    Join Date
    Jun 2004
    Location
    Torreón, Coah. México
    Posts
    3,316
    Blog Entries
    1

    Default

    Address is target address when you want to start writing data, lpBuffer is an array of bytes you want to write to that address this example will not work with Broodwar unless you patch it to enable OpenProcess.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Basic VB Hacking Tutorial - Hacking PQ
    By LCSBSSRHXXX in forum Hacking Tutorials
    Replies: 9
    Last Post: 01-14-2010, 11:56 PM
  2. [C++] iTunes COM Interface Troubles
    By Dyndrilliac in forum Software Development
    Replies: 3
    Last Post: 11-11-2008, 12:19 AM
  3. Petition to become Mod of Hacking Section
    By MiCrOz in forum Website Feedback
    Replies: 41
    Last Post: 11-17-2005, 01:52 AM
  4. Hacking 101
    By Fish Beans in forum Hacking Tutorials
    Replies: 0
    Last Post: 07-29-2004, 01:00 AM

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts