News:

So the widespread use of emojis these days kinda makes forum smileys pointless, yeah?

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Lance

#1
General Programming / [JAVA] Datagram Hook
June 25, 2010, 09:35:46 PM
I want to receive the outgoing UDP datagrams from a C++ program, and spoof the sender address of incoming datagrams; nothing more and nothing less. Is this possible with Java, or is the language too limited?

I am using Fedora by the way.

Thanks :)

EDIT: The C++ program is open source so I have full access to it's API.

EDIT 2: Fixed some bad wording.
#2
Some machines on my network are sending datagrams to me and I am trying to reply to them, but I am not sure how to code a datagram listener. The code below works (well, it receives the datagrams), but when I try to get the InetAddress it originated from, it is either null or my own InetAddress (I suppose it varies by what I try, but I always get one of those two results). How can I get the correct InetAddress to reply with another datagram?


setSocket(new DatagramSocket(1234)); // Just a setter for a DatagramSocket instance.

...

byte[] raw = new byte[256];
DatagramPacket datagram = new DatagramPacket(raw, raw.length);
getSocket() // Just a getter for a DatagramSocket instance.
          .receive(datagram);

...

datagram.getInetAddress(); // Either null or my InetAddress


Thanks :)
#3
General Programming / [JAVA] Packet Joins
June 21, 2010, 12:37:55 AM
Joe brought something interesting up in the JavaOp section:
Quote from: JoeBecause all the packet plugins are loaded by the core, not by the Battle.net plugin, so they'd be getting the raw socket data instead of packets. The only issue with that is that Battle.net is known to send packets in pieces or several packets in one clump, so there'd have to be a non-protocol-agnostic packet thread to pick these apart for parsing, not to mention it's not a good idea to trust TCP connections to have packets split perfectly, even if it's known to in the past.

I am currently working on a program with a (non-bnet) protocol, but have run into this issue. In particular, I have 13000 bytes of data split over a few packets. This is the code I am currently using:

public void run() {
while(true) {
try {
Packet buf = new Packet(); //Packet is just a small extension of iago's Buffer class, similar to BNetPacket in some ways.
int size = new Buffer(PacketTools.getInputStreamBytes(in, 4)).removeDword(); //This reads 4 bytes (packet size) into a new Buffer and converts them into an int
buf.addBytes(PacketTools.getInputStreamBytes(in, size)); //Read "size" number of bytes from the InputStream and add them to the buffer
// Do stuff
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}


How can I change this so I can read multiple packets into that single Packet instance (buf)?

Thanks :)
#4
General Programming / :<
April 03, 2010, 06:14:19 PM
:<
#5
When a shaman joins the channel, I get this:

[TIME] WARNING: Error processing event: java.lang.NullPointerException

and events are no longer received from that shaman! If I make the bot leave the clan channel and come back, it does not see the shaman in the channel.

After throwing in a .prinstackTrace() in BnetEventProcess, and running eclipse debug, I got this:

java.lang.NullPointerException
at com.javaop.users.Statstring.getClient(Statstring.java:33)
at com.javaop.SwingGui.JavaOpPanel.userFlags(Unknown Source)
at com.javaop.pluginmanagers.PluginRegistration.userFlags(PluginRegistration.java:538)
at com.javaop.bot.BotCore.userFlags(BotCore.java:487)
at com.javaop.BnetEventProcess.PluginMain.processEvent(PluginMain.java:249)
at com.javaop.BnetEventProcess.PluginMain.access$1(PluginMain.java:220)
at com.javaop.BnetEventProcess.PluginMain$Callback.run(PluginMain.java:208)
at java.util.TimerThread.mainLoop(Timer.java:534)
at java.util.TimerThread.run(Timer.java:484)


This has been a problem for a while, starting around 2.1.1 if I remember right.

EDIT: It looks like "String[] tokens" is not being set by com.javaop.users.Statstring because the statstring passed to the constructor is null.
#6
JavaOp Board / StayConnected Problem
February 24, 2010, 09:33:41 PM
If I try to connect to Battle.Net with a bad password and StayConnected enabled, StayConnected will detect the password failure socket disconnect and repeatedly attempt to reconnect me with the bad password, using up my login attempts and eventually getting the bot a temporary ban. How can this be fixed?

Thanks :)
#7
JavaOp Board / Modularization
February 24, 2010, 09:25:43 PM
I am posting in this thread classes that I think should be moved from the core to plugins so JavaOp is more modular.

I think Battle.net should have its own plugin (named Bnet, possibly making BnetLogin and BnetEventProcess parts of the plugin) to hold the protocol-specific classes. Of course there are plugins that use these classes from the core, but there is nothing wrong with having more than one project on the build path right? :P

com.javaop.util
BnetEvent > Bnet
BnetPacket > Bnet
BnlsPacket > Bnet
Profile > Bnet

com.javaop.users
Statstring > Bnet
War3Statstring > Bnet

com.javaop.constants
PacketConstants > Bnet (This is heavily based on the Bnet protocol :P)

com.javaop.bot
PacketThread > Bnet (This class is horribly dependant on the Bnet protocol and needs to be modularized somehow)

Once those are moved, adding IRC functionality and such will be a breeze ;D
#8
JavaOp Board / Plugin Packages
February 17, 2010, 11:07:30 PM
The Simple Event Processor, Command, and Channel List plugins are useless without the Battle.net Login one, so why have four plugin files instead of one? The 4-file dilemma is what led me to making this suggestion to create a package-type plugin system. The Simple Event Processor and Channel List plugins have no packages and one class! Surely, the overhead that comes with loading them is not worth it.

One jar (Bnet.jar) would contain the src/plugins package:
-src.plugins.Main (this is not a folder, but a class to retrieve a list of plugins, provide access to PublicExposedFunctions, provide activate(), deactivate(), and load(); and provide an interface to extend)
-src.plugins.LoginProcessor (Formerly BNetLogin.jar)
-src.plugins.SimpleEventProcessor
-src.plugins.Commands
-src.plugins.Channel List

Also, parts of the product could still be disabled individually (like Commands).

This will most likely require a massive rewriting of the bot, but it is just an idea anyway... for now :)

Thanks for reading! :)
#9
JavaOp Board / CD-Key Exception
February 03, 2010, 10:38:09 PM
Just updated to 2.1.2 (with the new BNetLogin.jar), tried to connect (W3XP) and got the following error:


CRITICAL: [BNET] Caught exception while validating CD-Keys: exceptions.LoginException: CDKey is not 24 characters!


Thanks for the help :)
#10
Botdev / [JAVA, W3XP, W3GS] Host Counter Decoding
December 06, 2009, 01:22:29 AM
Quote from: http://forum.valhallalegends.com/index.php?topic=14994.0
DotA.For.Rest:
(char[8])3130303030303030 |text formated hexadecimal Hosting Counter (upper case)

After I get those 8 bytes, how would I go about converting them into a host counter/4-length byte array that I can send back to the host (e.g. new byte[] { 1, 0, 0, 0 })?

I have tried converting the byte array to a string, then using String.getBytes with the default, ascii, and utf-8 encodings. None of them work! :(

Thanks :)
#11
Botdev / [WAR3, W3XP] Packet before W3GS_REQJOIN
November 30, 2009, 12:10:22 PM
How do I get battle.net to give me the IP and game port for the host of a specified private game name? I have looked everywhere for the packet and can't find it.

Thanks  :)
#12
Botdev / Information on W3GS data
November 29, 2009, 11:46:51 PM
I am trying to figure out how to decode a buffer. In the thread in the quote below, the posters seem to decode the buffer somehow. How are they decoding the buffer? (which in the first code block seems to be enc1_raw)

Thanks :)

Quote from: http://forum.valhallalegends.com/index.php?topic=14994.msg152623#msg152623
i have some comments on the gameInfo packet.
about the encoded part.
i am very certain, as i stated in the other thread, that the encoded part starts after the 0x00 after the gamename. why?
1) in replays it starts there
2) some values tagged unknown by you do vanish...

example:

i let my encoded data start with 01034907... not with 997d01...

static const char enc1_raw[] =
{
0x01,0x03,0x49,0x07,0x01,0x01,0x7d,0x01,
0x99,0x7d,0x01,0xa3,0xdf,0x1d,0x43,0x4d,0x8b,0x61,
0x71,0x73,0x5d,0x29,0x35,0x29,0xcd,0x4d,0x6f,0x73,
0x75,0x55,0x65,0x6d,0xe9,0x71,0x6d,0x65,0x2f,0x77,
0x33,0x6d,0x89,0x01,0x47,0x6f,0x73,0x2f,0x53,0x65,
0x03,0x73,0x75,0x01,0x01
};

if we decode that, we get

02 48 06 00 00 7c 00 7c
.  H  .  .  .  |  .  |  
00 a3 df 1c 42 4d 61 70
.  .  .  .  B  M  a  p  
73 5c 28 34 29 4c 6f 73
s  \  (  4  )  L  o  s  
74 54 65 6d 70 6c 65 2e
t  T  e  m  p  l  e  .  
77 33 6d 00 46 6f 72 2e
w  3  m  .  F  o  r  .  
52 65 73 74 00 00
r  e  s  t

...
#13
JavaOp Support Archive / Using local hashes
November 29, 2009, 08:58:43 AM
How can I use local hashing? When I try to connect using local hashing, I get this:


...
[08:51:19.328] NOTICE: [BNET] Server successfully authenticated -- it's Blizzard's
[08:51:19.547] INFO: [BNET] Client token: ...
[08:51:19.585] INFO: [BNET] Version Hash: ...
[08:51:19.600] INFO: [BNET] Checksum: ...
[08:51:19.601] INFO: [BNET] CDKey owner: ...
[08:51:19.604] NOTICE: [BNET] CDKey and Version check sent.
[08:51:19.625] exceptions.InvalidVersion: [BNET] Invalid game version
[08:51:19.631] Login.getLogin(Login.java:180)
[08:51:19.632] PluginMain.processedPacket(PluginMain.java:328)
[08:51:19.633] pluginmanagers.PluginRegistration.processedIncomingPacket(PluginRegistration.java:722)
[08:51:19.634] bot.PacketThread.run(PacketThread.java:178)


I have the hashes in the .hashes folder and are up to date (from a live client).
The CDKeys are valid.
Using JavaOp 2.1.1.

BNetLogin->game is set to W3XP (which works when I use BNLS servers). If I try to use "Warcraft III: TFT" from the dropdown, I get:

[08:56:31.400] NOTICE: Bot 'PrivateBot' has been started.
[08:56:32.243] DEBUG: Entering disconnect()
[08:56:32.245] DEBUG: Entering connect()
[08:56:32.254] ALERT: [BNET] Unable to connect due to exception: exceptions.InvalidVersion: Game not found - warcraft iii: tft


I have googled around and looked in the archive but have found no solutions that don't involve BNLS (which I would like to avoid).
#14
JavaOp Support Archive / JavaOP and Java ME
September 14, 2008, 03:23:17 PM
Is there a way to run JavaOP on a mobile edition of Java such as the Java installed on the Motorola Razr v3?
#15
[14:19:37.728] java.net.SocketException: Connection reset
[14:19:37.744] java.net.SocketInputStream.read(Unknown Source)
[14:19:37.790] java.net.SocketInputStream.read(Unknown Source)
[14:19:37.790] bot.PacketThread.run(PacketThread.java:139)
[14:19:57.712] WARNING: Keepalive failed to send: java.net.SocketException: Socket closed


I'm trying to make a plugin to reconnect my bot after it is disconnected like it was above. When I create PluginMain, what do I need to implement so I may have a method availiable to catch it. Furthermore, what method is it? :p

Thanks.
#16
JavaOp Support Archive / Garbage Collector
August 04, 2008, 04:43:39 PM
I am looking for a way to make my huge JavaOP2 plugin (and JavaOP2 overall, without modifying source) more efficient. I do not know exactly how the Garbage Collector works and when to invoke it. Can someone shed some light on this for me? Thanks.
#17
General Programming / Get Checksum of W3X map
July 28, 2008, 11:54:26 AM
How can I do it? I've already figured out how to get the mapsize and crc32.
#18
I have JavaOP2 receive packets (non-battle.net ones). I am currently modifying the core to meet my needs.

This works:

byte []packet = new byte[127];
                   input.read(packet);

but I have to specify the size which is completely inaccurate and it throws off my data by adding lots of 0x00's. I need a solution to this problem ;(

The traditional

int len1 = (input.read() & 0x000000FF);
                   int len2 = (input.read() & 0x000000FF) << 8;

int length = len1 | len2;

byte []packet = new byte[length];

for(int i = 0; i < packet.length; i++)
                       packet[i] = (byte)input.read();

results in my incoming packets not processing for some reason.

Ron said something about looping through each byte but I am still pretty new to java :p

Thanks :)
#19
How can I listen to a socket opened by another program? Let's say I just logged on BNET with JavaOP2 and I received the ENTERCHAT packet. I want to view the contents of that packet in my program x3
#20
I have JavaOP2 loaded into eclipse.
I would like to change the packets that are sent to the server when a successful connection is made (I don't want 0x01) (Experimenting with some stuff -- and this will not be connecting to a BATTLE.NET server) and change how JavaOP2 responds to what the server sends. But I'm interested more in the sending part :P.

In what package can I find the classes to change this stuff? Thanks