• Welcome to Valhalla Legends Archive.
 

[Java] 0x50 Complications

Started by Spilled, October 09, 2005, 11:30 PM

Previous topic - Next topic

Spilled

Hi, in my first attempt to make a bot in java, i have ran into a problem. When i recieve 0x50, extracting the data from it has been harder then i thought and am seeking your help.

In VB i did this like so:

             Hashing.ServerToken = Val("&H" & Connection.StrToHex(StrReverse(Mid(strData, 9, 4))))
             Hashing.Hash = Mid(strData, 38, Len(strData) - 2)
             Hashing.MpqName = CStr(Mid(Mid(strData, InStr(1, strData, "IX86ver"), Len(strData)), 1, 12))


Is there an easier way then writing a reverse function and a strtohex function? What about the Val and the CStr? Any tips would be appreciated because I am kinda lost in this problem.

Spilled[DW]

Joe[x86]

Uh, you're probably going to want to use a debuffer.

http://www.javaop.com/javaop2/src/javaop2_pub/src/util/BNetPacket.java
http://www.javaop.com/javaop2/src/javaop2_pub/src/util/Buffer.java

LoginType = packet.RemoveDWORD();
ServerToken = packet.RemoveDWORD();
UDPValue = packet.RemoveDWORD();
MPQFiletime = packet.RemoveQWORD();
MPQName = packet.RemoveNTString();
ValueString = packet.RemoveNTString();
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

UserLoser.

Quote

Val("&H" & Connection.StrToHex(StrReverse(Mid(strData, 9, 4))))


wtf.  Do us all and your computer a favor by using memcpy/CopyMemory

Joe[x86]

Oh god, didn't even notice that was a DWORD. =p
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Dynobird

#4
Well, you could make a class for receiving 0x50, and have methods that return the bytes/words/dwords that you want to get from it because those methods will know the offset and length ints for your byte array.

Or you could have a generic packet debuffer class in which you give it a Packet or a byte array and call methods that take a given offset. You wouldn't need a length because you could have separate methods for getWord, getDword etc. and they will know the lengths.

~~

String to hex is simply...
String strToHex = new String();
byte strbytes[] = strToHex.getBytes();
the method returns a byte array

Conversion in Java isn't that hard, you should look at the api's
http://java.sun.com/j2se/1.5.0/docs/api/ search for String and you'll see the getBytes() method there.

Perhaps you should read a book on Java or OOP b/c its very different than VB.

Spilled

Yea, i am currently reading a book on Java because we are taking it at my college. But anyways off that subject How would i load the checkrevision.dll library? would i use System.loadLibrary("CheckRevision.dll") ? And if this is how, how come i cant use the functions inside it? I try to but its not letting me.


static
{
System.loadLibrary("CheckRevision.dll");
}


Also is this how i would load the hashes? Thanks in advance!

Dynobird

I don't know that much about the C family, but as I see it you're trying use the functions of .dll's in the Java file? Well, I don't know much about that. The weird thing about the System.loadLibrary() call is that it doesn't return anything. So I guess that it does the functions of the .dll itself... but you said you wanted to use the functions of the dll yourself inside your java class?

Here's another idea, you can make an .exe that does it for you, perhaps a VB .exe if you wish, b/c its easy to run exe's through Java. You use sun's Runtime class to do it.

Example:

Runtime cmd = Runtime.getRuntime();        // I don't think you can instantiate Runtime any other way, it's probably protected
cmd.exec("start DoCheckRevision.exe");


Hope that helps.

Spilled


Kp

Why're you loading a DLL?  That's inherently non-portable, which negates the primary benefit of writing this in Java.  Besides which, if that's the Blizzard CheckRevision DLL, it won't work for you anyway.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Joe[x86]

#9
Using a DLL in Java is possible, I think, but rather messy and totally distroys Java's main advantage, its cross-platformness. You can do it if you want, but I suggest recreating checkrevision in Java.

EDIT -
WAR3 Stuff
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Spilled

#10
Quote from: Joe on October 11, 2005, 06:59 PM
Using a DLL in Java is possible, I think, but rather messy and totally distroys Java's main advantage, its cross-platformness. You can do it if you want, but I suggest recreating checkrevision in Java.

EDIT -
WAR3 Stuff

What variable does this CheckRevision return? The CheckSum or the Version ID?, and how would i get the other stuff that i need? Including the exeinfo and anything else i need? Please no flaming I have never worked with doing CheckRevision in any other language then VB, which is already provided by the dll and im eager to learn how to do it in Java. All help is appreciated!

Hdx

Crev() return the checksum.
I will post info on how to get the exeinfo when i get home. And I'm not sure how to get the EXEVer automatically in java so I'm interested in this to.
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Spilled

ahh i c, Thanks again Hdx. Get back as soon as possible. :)

Hdx

#13
/** Compiles BNET Exe Info of a given game set
* @return Exe Info String
* @param files - file list
* */
    private static String getExeInfo(String[] files)
    {
        //return "starcraft.exe 03/28/03 04:21:56 1064960";

        File f = new File(files[0]);
       
        // Set up a calendar to point at the last modified time
        Calendar c = Calendar.getInstance();
        c.setTime(new Date(f.lastModified()));
       
        StringBuffer exeInfo = new StringBuffer();
       
        // Write to the exeInfo buffer
        exeInfo.append(f.getName()).append(" ");
       
        // date
        exeInfo.append(PadString.padNumber(c.get(Calendar.MONTH), 2)).append("/");
        exeInfo.append(PadString.padNumber(c.get(Calendar.DAY_OF_MONTH), 2)).append("/");
        exeInfo.append(PadString.padNumber((c.get(Calendar.YEAR) % 100), 2)).append(" ");
       
        // time
        exeInfo.append(PadString.padNumber(c.get(Calendar.HOUR_OF_DAY), 2)).append(":");
        exeInfo.append(PadString.padNumber(c.get(Calendar.MINUTE), 2)).append(":");
        exeInfo.append(PadString.padNumber(c.get(Calendar.SECOND), 2)).append(" ");
       
        // size
        exeInfo.append(f.length());
       
        return exeInfo.toString();
    }

Code was writtin by iago, It's part of many open source programs so He shouldn't have a problem with you using it. you need his PadString class. It jsut makes life easier >.<
Also as for the ExeVer I beleave you can set it to null due to Macs not having the proper functions to get it.
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Spilled

o, nice nice Thanks HdX and Thanks iago i  hope you dont mind ;)

Hrmm now what about the Bnetauth class and the hash class? Anyone mind helping me with those functions? Thanks in advance!