Met Spammer problem

03/03/2011 18:08 shitboi#1
I am trying to add a met spammer to my proxy, but somehow it always dc's me from the server, and non of the packets that proxy has sent to server got recognized (mets/gears count no change)

This is what i did.

ProxyTimer:
on first itemUsage packet sent by client, i obtained a clientTimerBase, at the same time, i obtained a systemTimerBase. Whenever i need a current ClientTimer, I'll simply do a clientTimerBase+CurrentSystemTime-systemTimerBase.

Gear list: which ever gears in inventory that have static IDs that fall in range of gears, and have a location value of 0.

Met list: items with static id of met/met tear.

Algo start:
-If met count = zero, go to end.
-else Cycle through gearlist
-formulate TC upgrade packets on one met per gear basis
-send packet to server
end.

my codes for building a tc upgrade packet
Code:
         * Build a tc item upgrade packet
         * @param itemid : Unique ID of packet
         * @param metid : Unique ID of meteor
         * @param timer : timer when upgrade is performed - timer step up (3000000) will be perform in this method.
         * @return : an upgrade packet.
         */
        public static byte[] ItemUpgradeInTC(int itemid, int metid, int timer){
            COPacketWriter pw = new COPacketWriter();
            pw.write(Utility.Int16ToBytes(0x50));
            pw.write(Utility.Int16ToBytes(0x3F1));
            pw.write(Utility.Int32ToBytes(itemid));
            pw.write(Utility.Int32ToBytes(metid));
            pw.write(Utility.Int32ToBytes(0x14));   //usage
            pw.write(Utility.Int32ToBytes(timer+3000000));
            pw.write(new byte[60]);    //60 zeros
            pw.write(clientStamp);
            return pw.getBytes();
        }
What could be the problems causing this?
03/03/2011 18:23 IAmHawtness#2
I don't really understand your whole timer system, it looks wrong to me. I'm not sure a wrong timestamp in the useitem packet would disconnect you though.
The only thing I can guess is wrong is that something is wrong with your write method.
Other than that, the way you're creating the packet looks right
03/03/2011 18:35 shitboi#3
I saw in most of the C# codes around that ppl simply use environment tick count. But i can't really find such a thing in java. All i get is System.currentTimeMillis() and System.nanoTime().

So, i thought that by obtaining a time base + a time difference should do a trick.

Can you point out what part of the write feels wrong? The writing is done by adding a block of bytes to the end of what is already in COPacketWriter, which is initially none. The Utility conversion is heavily used throughout my entire proxy too. Maybe not so much of num2bytes conversion. I'll verify it though. Will check this thread in 1-2 hours time. Gotta get some meds for cold. Sneeeeze

Just to elaborate a bit on the proxytimer thing.

if packet is from client and is a itemusage packet and my timerbase is zero then
-obtain timer from this itemusage packet.
-set proxytimerbase = System.currentTimeMillis();



whenever i need to use timer, i'll do
- currentTimer = timerbase + System.currentTimeMillis() - proxytimerbase
03/03/2011 20:35 IAmHawtness#4
Quote:
Originally Posted by shitboi View Post
I saw in most of the C# codes around that ppl simply use environment tick count. But i can't really find such a thing in java. All i get is System.currentTimeMillis() and System.nanoTime().

So, i thought that by obtaining a time base + a time difference should do a trick.

Can you point out what part of the write feels wrong? The writing is done by adding a block of bytes to the end of what is already in COPacketWriter, which is initially none. The Utility conversion is heavily used throughout my entire proxy too. Maybe not so much of num2bytes conversion. I'll verify it though. Will check this thread in 1-2 hours time. Gotta get some meds for cold. Sneeeeze

Just to elaborate a bit on the proxytimer thing.

if packet is from client and is a itemusage packet and my timerbase is zero then
-obtain timer from this itemusage packet.
-set proxytimerbase = System.currentTimeMillis();



whenever i need to use timer, i'll do
- currentTimer = timerbase + System.currentTimeMillis() - proxytimerbase
System.currentTimeMillis() is the same as Environment.TickCount :p.
I'm just not sure if your write(byte[]) method is correct, could you perhaps convert the pw.getBytes to a text string so it shows as "50 00 F1 03 xx xx xx xx xx xx" etc.? Perhaps then you'll be able to see what's wrong
03/03/2011 22:21 shitboi#5
Quote:
Originally Posted by IAmHawtness View Post
System.currentTimeMillis() is the same as Environment.TickCount :p.
I'm just not sure if your write(byte[]) method is correct, could you perhaps convert the pw.getBytes to a text string so it shows as "50 00 F1 03 xx xx xx xx xx xx" etc.? Perhaps then you'll be able to see what's wrong
the System.currentTimeMillis() actually returns a long number that is few times the digits of what i see in the timer field in the the itemusage packets. What i do see if that both the co_timer and system timer increments at the same rate.

i definitely can over write the timer field in the packet with my system timer, but doesn't that mean i need to overwrite the timer field in any packet that contains a timer field? I am trying to avoid that.

Alright, this is an output of what i get when i check on my different timers.
Code:
Waiting ... 
Waiting ... 
DH exchange complete.
Client time base :21161659        Proxy time base :1299186607937
Client Time Diff:10470        Proxy Timer Diff:10531
Client Time Diff:20489        Proxy Timer Diff:20547
Client Time Diff:30557        Proxy Timer Diff:30609
Client Time Diff:40589        Proxy Timer Diff:40641
Client Time Diff:50627        Proxy Timer Diff:50688
Client Time Diff:60659        Proxy Timer Diff:60719
Client Time Diff:70676        Proxy Timer Diff:70734
Client Time Diff:80679        Proxy Timer Diff:80734
Following are the codes that actually prints the about results.
Code:
case 1009:
                    PacketTypes.ItemUsage usage = new PacketTypes.ItemUsage(p);
                    if (packetSource == CLIENT) {
                        if (usage.usageType != 27) {
                            System.out.println(usage.toString());
                            Utility.printHexPacket(p);
                        }
                        //------------------------------------------------------------------------
                        //sets proxy timer on first invocation of item usage packet.
                        //to update proxy timer, perform System.currentTimeMillis - proxy_time_base + timer
                        //------------------------------------------------------------------------
                        if (this.timer == 0) {
                            this.timer = usage.timer;
                            this.proxy_time_base = System.currentTimeMillis();
                            System.out.println("Client time base" + this.timer + "\tProxy time base :" + this.proxy_time_base);
                        }
                        System.out.println("Client Time Diff:" + (usage.timer - this.timer) + "\tProxy Timer Diff:" + (System.currentTimeMillis() - this.proxy_time_base));
                        if (usage.usageType == 37) {
                            System.out.println("Throwing away "+usage.itemID);
                            this.items.remove(usage.itemID);
                        }
                    }
                    break;
Here is an original packet from perform met upgrade in TC
in this case item location contains met UID.
Looking at the timer ... i have a feeling that it was stepped up. If it wasn't meant to be this way.. then i must be doing something wrong with my local timers.
Code:
Client Time Diff:411789        Proxy Timer Diff:411797
Client Time Diff:421793        Proxy Timer Diff:421844
Size=80 ,Type=1009, ItemID=1053324710, ItemLocation=1053324733, UsageType=20, timer=24730295
50 0 F1 3 A6 75 C8 3E BD 75 C8 3E 14 0 0 0 B7 5A 79 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 51 43 6C 69 65 6E 74 
Client Time Diff:3568636        Proxy Timer Diff:426891
Here is a proxy constructed tc met upgrade packet - which causes dc.
Code:
Client Time Diff:612624        Proxy Timer Diff:612688
Client Time Diff:622624        Proxy Timer Diff:622688
Client Time Diff:632646        Proxy Timer Diff:632703
Met spam started
You have 9 gears, and 2 mets.
Upgrade packet Built: length = 88, timer =21801940
50 0 F1 3 AD 75 C8 3E BC 75 C8 3E 14 0 0 0 94 72 7A 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 51 43 6C 69 65 6E 74

EDIT:
above output come from the same session...
I know it is a bit weird that why the proxy generated packet is attempting to use the same met as the previous manual upgrade, well, you can see from my codes that i only removed an item from my itemlist if it is dropped. Didn't account for other ways an item can be consumed/traded/sold and what not. However this is definitely not the main cause as i have edited my codes and tested; Still dc's

I have a feeling that problem lies with my timestamp.