Proxy Help: Dropping an Item

08/14/2010 03:57 Santa#1
Alright, so i have decided to mess around with a proxy and try to make myself an autominer. I have gotten as far as to dropping the items. I am not sure what the problem with it is, weather its the packet structure or the Item ids itself.

EDIT: Totally forgot to mention its for a 5065 binary server.

This is in my PacketHandler, everytime i pick something up, or mine an ore i Add the item to a dictionary, then i check to see if There are more than 19 items, if their are i call my drop method(Obviously).
PHP Code:
C.MyChar.Inventory.Add(I.UIDI);
                                if (
C.MyChar.BotOn == true)
                                {
                                    if (
C.MyChar.Inventory.Count >= 20)
                                        
C.MyChar.Drop(IC.MyChar);
                                }
                                break;
                            } 
I created an arraylist containing all the ID that i would like to drop.
PHP Code:
        public static ArrayList OresToDrop = new ArrayList() 
        { 
            (
uint)1072010, (uint)1072011, (uint)1072012, (uint)1072013, (uint)1072014,
            (
uint)1072015, (uint)1072016, (uint)1072017, (uint)1072018, (uint)1072019,
            (
uint)1072020, (uint)1072021, (uint)1072022, (uint)1072023, (uint)1072024,
            (
uint)1072025, (uint)1072026, (uint)1072027, (uint)1072028, (uint)1072029,
            (
uint)1072040, (uint)1072041, (uint)1072042, (uint)1072043, (uint)1072044
            (
uint)1072045, (uint)1072046, (uint)1072047, (uint)1072048, (uint)1072049 
        
}; 
Then i loop through every value in the dictionary. If any of them are contained in the list, it sends the drop packet.

PHP Code:
public void Drop(Struct.ItemInfo DMyCharacter C)
        {
            foreach (
KeyValuePair<uintStruct.ItemInfoItem in C.Inventory)
            {
                if (
OresToDrop.Contains(Item.Value))
                {
                    
MyClient.SendToServer(Packets.DropItem(DC).Get);
                    
Thread.Sleep(1000);
                }
            }            
        } 
And this is my packet, its a lil sketchy, i have NO idea if it correct.
PHP Code:
public static COPacket DropItem(Struct.ItemInfo IMyCharacter Char)
        {
            
Random Rand = new Random();
            
byte[] Packet = new byte[28];
            
COPacket P = new COPacket(Packet);
            
P.WriteInt16((ushort)(Packet.Length -8));
            
P.WriteInt16((ushort)(1009));
            
P.WriteInt32(I.UID);
            
P.WriteInt16((ushort)(Char.Loc.Rand.Next(4) + Rand.Next(4)));
            
P.WriteInt16((ushort)(Char.Loc.Rand.Next(4) + Rand.Next(4)));
            
P.WriteInt32(3);
            
P.WriteInt32((uint)Environment.TickCount);
            
P.WriteString("TQServer");
            return 
P;
        } 
Any help would be appreciated, i have been going at this all day.
08/14/2010 05:15 gabrola#2
I'm on my phone now so I have no access to the correct packet structure right now; however, I noticed a couple of stuff.
OresToDrop.Contains(Item.Value)
Item.Value is the ItemInfo struct instance however you should be checking for item IDs so it should be something like OresToDrop.Contains(Item.Value.ID)
I'm not sure if it's called ID but it's NOT UID.
Second, DropItem(D, C) should be DropItem(Item.Value, C)
Third, in the packet struct replace TQServer with TQClient.
Also you should remove the "- R a n d . N e x t ( 4 ) + R a n d . N e x t ( 4 )" part.
I also noticed the packet structure you have is off a private server because of the random part, probably it's wrong anyway. I'll send the correct struct tomorrow.
08/14/2010 05:22 Santa#3
Quote:
Originally Posted by gabrola View Post
I'm on my phone now so I have no access to the correct packet structure right now; however, I noticed a couple of stuff.
OresToDrop.Contains(Item.Value)
Item.Value is the ItemInfo struct instance however you should be checking for item IDs so it should be something like OresToDrop.Contains(Item.Value.ID)
I'm not sure if it's called ID but it's NOT UID.
Second, DropItem(D, C) should be DropItem(Item.Value, C)
Third, in the packet struct replace TQServer with TQClient.
Also you should remove the "- R a n d . N e x t ( 4 ) + R a n d . N e x t ( 4 )" part.
I also noticed the packet structure you have is off a private server because of the random part, probably it's wrong anyway. I'll send the correct struct tomorrow.
Thanks so much. Yes that would be great if you could help me when you get access to your PC. I will try some of the things you mentioned, thanks.

Edit- Still not having any luck.
08/14/2010 08:26 Huseby#4
#Moved
08/15/2010 03:20 Santa#5
I have been recording the id of the same item that i am dropping and picking up and i noticed that sometimes it will be WAY different like its 18072342 and after, say 4 times, it will be like 342765.
This is the way I'm reading the values
PHP Code:
PacketReader PR = new PacketReader(Data4);
I.UID PR.ReadUInt32();
I.ItemID PR.ReadUInt32(); 
I realized that i had the length wrong on my packet so i added the 4 bytes, but it didn't make a difference. So i decided to dump the packet being sent from my command and also the packet(on the same item) being sent from the client seconds later. I noticed that the timestamp was WAYY different (unless i did this wrong).

Could this be why my packet isn't working?

Here is both of the packets without the Auth stamp on the end.

Sent via Cmd
PHP Code:
18 00 f1 03 e1 61 29 0b 71 00 A0 00 03 00 00 00 8f 93 83 01 00 00 00 00     Timestamp->25400207 
Sent via client
PHP Code:
18 00 f1 03 e1 61 29 0b 71 00 A0 00 03 00 00 00 40 b5 cd 01 00 00 00 00   Timestamp->1946944 
08/15/2010 04:23 © Haydz#6
They don't actually send the Item ID, just the Unique ID.

The ID field is used as a union for the coordinates.

I can't explain how your timestamps are madly different, I think I discovered the same thing, soon as I added coordinates though, dropping started to work.
08/15/2010 04:53 Santa#7
Quote:
Originally Posted by © Haydz View Post
They don't actually send the Item ID, just the Unique ID.

The ID field is used as a union for the coordinates.

I can't explain how your timestamps are madly different, I think I discovered the same thing, soon as I added coordinates though, dropping started to work.
They do send the Item ID, unless its just a VERY weird coincidence where it just so happens to be the same as the ItemID every time.

I'm assuming the server would reject the packet if since the time stamps are soo different? Could that be why its not working? Any way to fix how the problem? I'm trying the jump packet to see if the time stamps are corrected on there.

EDIT:

Here are the results of my Jump packet stamp test.

Sent via Command
PHP Code:
18 00 f2 03 7e 48 f8 01 e2 28 4e 00 a3 00 71 00 a3 00 72 00 00 00 85 00  Timestamp ->33048702 
Sent via Client
PHP Code:
18 00 f2 03 f8 34 00 00 e2 28 4e 00 a3 00 71 00 a3 00 72 00 00 00 85 00   TimeStamp ->13560 
I'm going to restart my PC and see what happens.

Here are the results after i restarted my PC.

Sent via Command
PHP Code:
18 00 f2 03 ca a1 02 00 e2 28 4e 00 a3 00 71 00 a3 00 72 00 00 00 85 00  Timestamp ->172490 
Sent via Client
PHP Code:
18 00 f2 03 6a 04 00 00 e2 28 4e 00 a3 00 71 00 a3 00 72 00 00 00 85 00  Timestamp ->1130 
08/15/2010 05:37 © Haydz#8
Quote:
Originally Posted by StarBucks View Post
They do send the Item ID, unless its just a VERY weird coincidence where it just so happens to be the same as the ItemID every time.
Quote:
Originally Posted by StarBucks
I have been recording the id of the same item that i am dropping and picking up and i noticed that sometimes it will be WAY different like its 18072342 and after, say 4 times, it will be like 342765.
Why say that then? It's just a VERY weird coincidence that I can drop item's yet you can't?
They don't check timestamps on an item drop either.

Jeez, you try to help someone here, you get it thrown back in your face.
08/15/2010 06:01 gabrola#9
The UID stays the same cause it's the same item. You should also try using the native timeGetTime instead of TickCount.
08/15/2010 06:35 Santa#10
Quote:
Originally Posted by gabrola View Post
The UID stays the same cause it's the same item. You should also try using the native timeGetTime instead of TickCount.
I know that the UID stay the same, it must be the packet im receiving must be messed up.

I tried native timeGettime and still no luck. Same outcome.

This is making me mad, i pretty much can't do anything because of this problem.
08/15/2010 06:39 Ian*#11
well looks like you just have the wrong type to be honest. In the logged packets you have it's 0x3F2, in your structure (1009) is 0x3F1.

Also timestamps are checked (now anyways) haydz, not sure if they have to be accurate but if ya dont send one earned yourself a free trip to botjail.

so try type 1010, (not what it is right now but yeah.) currently Item info is 3f0 3f1 is drop.

May have been 3f2 back when your pserver was made.

Edit: sorry i thought your second post with packets logged was a drop packet lol.
Ill look again and see if i find anything
08/15/2010 06:45 Santa#12
Quote:
Originally Posted by Ian* View Post
well looks like you just have the wrong type to be honest. In the logged packets you have it's 0x3F2, in your structure (1009) is 0x3F1.

Also timestamps are checked (now anyways) haydz, not sure if they have to be accurate but if ya dont send one earned yourself a free trip to botjail.

so try type 1010, (not what it is right now but yeah.) currently Item info is 3f0 3f1 is drop.

May have been 3f2 back when your pserver was made.
I have the correct packet type, I decided to try messing with the General packet for jump just to see if the timestamp was actually the reason, it was.

Do you have anyway that i could fix the problem with my timestamp?
08/15/2010 11:27 tanelipe#13
PHP Code:
[StructLayout(LayoutKind.Explicit)]
    public 
struct DwordUnion
    
{
        [
FieldOffset(0)]
        public 
uint Value;
        [
FieldOffset(0)]
        public 
ushort Low;
        [
FieldOffset(2)]
        public 
ushort High;
    }
    [
StructLayout(LayoutKind.Sequential)]
    public 
unsafe struct ItemUsagePacket
    
{

        public 
Header Header;
        public 
uint UID;
        public 
DwordUnion dwParam;
        public 
ItemPacketSub ID;
        public 
uint TimeStamp;
        public 
uint dwExtraInfo;
        public 
fixed sbyte TQPadding[8];
        public static 
ItemUsagePacket Create()
        {
            
ItemUsagePacket Packet = new ItemUsagePacket
            
{
                
Header = new Header
                
{
                    
Size 24,
                    
Type 1009
                
},
                
TimeStamp = (uint)Environment.TickCount
            
};
            
PacketBuilder.EncodePadding(Packet.TQPadding"TQClient");
            return 
Packet;
        }
        public static 
ItemUsagePacket Drop(uint UID)
        {
            
ItemUsagePacket Packet Create();
            
Packet.UID UID;
            
Packet.ID ItemPacketSub.DropItem;

            return 
Packet;
        }
    }


 if (
IsOre(Item.ID))
                    {
                        if (!
IsGold(Item.ID))
                        {
                            
ItemUsagePacket Drop ItemUsagePacket.Drop(Item.UID);
                            for (
int j 0<= 8j++)
                            {
                                if (
Client.Inventory.ContainsKey(Item.UID) == false)
                                    break;
                                
int[] _DELTA_X = { 0, -1, -1, -10111};
                                
int[] _DELTA_Y = { 110, -1, -1, -101};
                                
Drop.dwParam.Low = (ushort)(Client.Entity._DELTA_Y[j]);
                                
Drop.dwParam.High = (ushort)(Client.Entity._DELTA_X[j]);
                                
Client.Send(&DropDrop.Header.SizeSendMode.Server);
                                
Thread.Sleep(400);
                            }
                        } 
Seems to work just peachy for me. I'm not sure what is the problem in your code.

EDIT: I noticed the first post, you're writing "TQServer" at the end when it should be "TQClient" because you're sending it to server, perhaps this is the reason it's not working?
08/15/2010 19:18 Santa#14
Ok, these packets are IDENTICAL except the timestamp(of course). Yet the one im sending from the proxy doesn't work. Can anyone explain to me why this doesn't work? Do i need to send something to the client?

PHP Code:
FROM CLIENT
18 00 f1 03 a4 19 2f 0b 72 00 a2 00 03 00 00 00 63 c6 69 00 00 00 00 00 54 51 43 6c 69 65 6e 74

FROM COMMAND
:  

18 00 f1 03 a4 19 2f 0b 72 00 a2 00 03 00 00 00 83 63 33 00 00 00 00 00 54 51 43 6c 69 65 6e 74 
And This packet gave me those results
PHP Code:
        public static COPacket DropItem(Struct.ItemInfo Iuint Xuint Y)
        {
            
Random Rand = new Random();
            
byte[] Packet = new byte[0x20];
            
COPacket P = new COPacket(Packet);
            
P.WriteInt16((ushort)(Packet.Length 8));
            
P.WriteInt16((ushort)(0x3F1));
            
P.WriteInt32(I.UID);
            
P.WriteInt16((ushort)X);
            
P.WriteInt16((ushort)Y);
            
P.WriteInt32(0x03);
            
P.WriteInt32((uint)Environment.TickCount);
            
P.Move(4);
            
P.WriteString("TQClient");
            return 
P;
        } 
EDIT: So, apparently my X and Y cords were backwards so it freakin works now. Now I gotta see if i can get the jump packet to work. I'm freakin stupid.
08/15/2010 21:37 IAmHawtness#15
Since when does the "DropItem" packet contain coordinates?