Sending Packets

02/07/2013 12:36 Interest07#346
Quote:
Originally Posted by belobrk View Post
So, can anyone please translate the main subject here? I ain't no programmer or anything related but I'd still like to know how would I make a good use of this 35 pages o info. It'd be much appreciated :D
This information is for programmers I'm afraid :)

The way your game communicates with the server is by sending 'packets' of information (for example moving to some place, using a skill, talking to an NPC). The server also sends packets back to your game telling you what is happening around you (other players moving, using skills, mobs that are around etcetera). In order to make an effective bot, you want your game to perform actions without you having to click or press any buttons. What this thread describes is how to send packets pretending to be the game once you've located that function within the game's code.

Because bandwidth is limited, packets are condensed into as few bytes of information as possible:
One number indicating the type of packet (e.g. doing a buying an item = 21), then additional numbers for any other information necessary for performing that action (item id, quantity, etc). In order to use the send packet function, you first have to figure out what number of packet describes which action, and what parameters (additional numbers) are needed for that action.

This thread basically discusses a big amount of different actions and their corresponding packet ids and parameters.

edit: also, since the packets sent from the server and back are encrypted, this function isn't actually the function that's responsible for sending the packets, but more for encrypting them first and then sending.
02/08/2013 02:13 hkr1#347
I need a bit of help is anyone is up for it.

I'm trying to read the inventory to an array but I'm doing something wrong.

I'm guessing I'm not reading from the right place and finding offsets is not really my strong side.

Fyi I did not write the BuildInventoryArray function (most of it anyways), found it on a prophet modified bot and I'm trying to make it work with my client (scanning inventory, opening packs and dropping "crap" items for a private server).

Using what Interest07 posted it was easy to send packets to open packs and dropping items but I'd have to know their current position in inventory and that is where I'm lost.

Anyways, here is the code:

PHP Code:
#RequireAdmin
#include <File.au3>
#include <NomadMemory.au3>

Global $APP_BASE_ADDRESS 0x00B4EF34

Global $PROCESS_ID ProcessExists('elementclient.exe')
Global 
$PROCESS_INFORMATION _MemoryOpen($PROCESS_ID)
Global 
$CHAR_DATA_BASE _MemoryRead(_MemoryRead($APP_BASE_ADDRESS$PROCESS_INFORMATION) + 0x34 $PROCESS_INFORMATION)

Global 
$OFFSET_INVENTORYID 8
Global $OFFSET_INVENTORYSTACKAMOUNT 16
Global $OFFSET_INVENTORYMAXSTACKAMOUNT 20
Global $OFFSET_INVENTORYDESCRIPTION 64

BuildInventoryArray
()

Func BuildInventoryArray()
    
Local $array[1][7], $pointer$inventory_base$counter$inventorysize
    $inventorysize 
_MemoryRead(_MemoryRead($CHAR_DATA_BASE 0xD20$PROCESS_INFORMATION) + 0x14$PROCESS_INFORMATION) ;0xCA4
    $pointer 
_MemoryRead(_MemoryRead($CHAR_DATA_BASE 0xD20$PROCESS_INFORMATION) + 0xC$PROCESS_INFORMATION) ;0xCA4
    
For $i=0 To $inventorysize 1
        $inventory_base 
_MemoryRead($pointer $i 0x4$PROCESS_INFORMATION)
        
ReDim $array[$i 1][7]
        
$array[$i][0] = _MemoryRead($inventory_base$PROCESS_INFORMATION) ;ID
        $array
[$i][1] = _MemoryRead($inventory_base $OFFSET_INVENTORYID$PROCESS_INFORMATION) ;ID
        $array
[$i][2] = _MemoryRead($inventory_base $OFFSET_INVENTORYSTACKAMOUNT$PROCESS_INFORMATION) ;Stack Amount
        $array
[$i][3] = _MemoryRead($inventory_base $OFFSET_INVENTORYMAXSTACKAMOUNT$PROCESS_INFORMATION) ;MAX Stack Amount
        
;$array[$i][4] = _MemoryRead($inventory_base $OFFSET_INVENTORYSELLPRICE$PROCESS_INFORMATION) ;Sell Price
        
;$array[$i][5] = _MemoryRead($inventory_base $OFFSET_INVENTORYBUYPRICE$PROCESS_INFORMATION) ;Buy Price
        $array
[$i][6] = _MemoryRead(_MemoryRead($inventory_base $OFFSET_INVENTORYDESCRIPTION$PROCESS_INFORMATION), $PROCESS_INFORMATION'wchar[30]') ;Name
    Next
    Local $sFile 
= @ScriptDir "\Test.txt"
    
_FileWriteFromArray($sFile$array)
EndFunc 
I'd appreciate any help..
02/08/2013 05:37 Murmuring#348
Quote:
Originally Posted by hkr1 View Post
but I'd have to know their current position in inventory and that is where I'm lost.
sit back, take some time, look again at the code you posted and try to understand the function first before you use it...

im sure the most who read your question and look on the code make this -> [Only registered and activated users can see links. Click Here To Register...]
02/08/2013 11:01 hkr1#349
Quote:
Originally Posted by Murmuring View Post
sit back, take some time, look again at the code you posted and try to understand the function first before you use it...

im sure the most who read your question and look on the code make this -> [Only registered and activated users can see links. Click Here To Register...]
Got it to work ;)
02/14/2013 18:27 belobrk#350
Quote:
Originally Posted by Interest07 View Post
This information is for programmers I'm afraid :)

The way your game communicates with the server is by sending 'packets' of information (for example moving to some place, using a skill, talking to an NPC). The server also sends packets back to your game telling you what is happening around you (other players moving, using skills, mobs that are around etcetera). In order to make an effective bot, you want your game to perform actions without you having to click or press any buttons. What this thread describes is how to send packets pretending to be the game once you've located that function within the game's code.

Because bandwidth is limited, packets are condensed into as few bytes of information as possible:
One number indicating the type of packet (e.g. doing a buying an item = 21), then additional numbers for any other information necessary for performing that action (item id, quantity, etc). In order to use the send packet function, you first have to figure out what number of packet describes which action, and what parameters (additional numbers) are needed for that action.

This thread basically discusses a big amount of different actions and their corresponding packet ids and parameters.

edit: also, since the packets sent from the server and back are encrypted, this function isn't actually the function that's responsible for sending the packets, but more for encrypting them first and then sending.
You could have stopped at your first line but you kept going and I'm thankful for that. Thanks a bunch. Cleared a lot of things up.
02/20/2013 22:48 ntldr32#351
[Only registered and activated users can see links. Click Here To Register...]
How to select one of that option,
i tryd to use function handInQuest after interact with the npc, but somehow i alwasy fail with that function, anyone can help?
i also want to know, why my image above not showed XD,...
03/11/2013 07:30 jollyjoker0305#352
Quote:
Originally Posted by ntldr32 View Post
[Only registered and activated users can see links. Click Here To Register...]
How to select one of that option,
i tryd to use function handInQuest after interact with the npc, but somehow i alwasy fail with that function, anyone can help?
i also want to know, why my image above not showed XD,...
To accept and hand in this quest :

[Only registered and activated users can see links. Click Here To Register...]

Code:
acceptQuest(24877, $pid)
Sleep(1000)
handInQuest(24877, 0, $pid)
That will trade your Nirvana Talisman to Mysterious Chip x10 (0 mean first option)

or handInQuest(24877, 1, $pid) will trade your Nirvana Talisman to Mirage Celestone x5


About your image problem, u should check your client, maybe file models.pck

Quote:
Originally Posted by nashua100 View Post
so..it means ...i cant send packet over 0x80 with (sendpacket function) as the usual i use ?
if cannot...how i write it......can You tell me ...Swoosh....Txs before
If i were you,i would send 3 buy packet to buy 3 item, don't have to send one big packet to buy 3 item :p
05/29/2013 23:46 PopingIt#353
Hello Do you have a script like that ? [Only registered and activated users can see links. Click Here To Register...]
07/08/2013 18:20 missnaya#354
this is my first time doing a bot EVER! so can someone just give me a push on it. i downloaded the program and downloaded autoit but thats it. i would greatly appreciate it
07/08/2013 23:52 dumbfck#355
Quote:
Originally Posted by missnaya View Post
this is my first time doing a bot EVER! so can someone just give me a push on it. i downloaded the program and downloaded autoit but thats it. i would greatly appreciate it
This thread is not actually a bot although it's about something that many bots use these days.
If you're just starting with bots, you're better off using one straight out of the box - I see you've already found Murmuring's prophet bot thread. That thread is kind of aimed at those who already know how to use it, so for basic info on setting it up, you'd probably want to take a look at one of the older threads.
Having not actually used the bot, I'm gonna guess that [Only registered and activated users can see links. Click Here To Register...] for tutorials etc.
If anyone has a better link, please jump in :)

Or if you're after a commercial (subscription) bot that's much kinder on your system resources, give [Only registered and activated users can see links. Click Here To Register...] a go.
07/09/2013 03:10 missnaya#356
ok thx i will start from the bottom, im obsessed with pw now so i got time to learn
07/25/2013 21:54 ntldr32#357
hi, i download the packetsender and memfunction class and compiled both of that class into .Net Dll Library, and then i use it with VB.net.
All function look good, all working until i try to call skill with "useSkill" function, i got mesg "Invalid Skill" in game,
im sure that the skill id is correct, but everytime i try to use that function, the result is always same :/. I do something like this on my code
______________
PHP Code:
    Public Shared Sub killTarget(ByVal targetID As IntegerByVal skillArray As List(Of Integer))
        
sendPacket.select(targetID)
        For 
As Integer 0 To skillArray.Count 1
            
If skillArray(i) = 0 Then
                sendPacket
.regularAttack(0)
            
End If
            If 
skill.isCooldown(skillArray(i)) = False And skillArray(i) <> 0 Then
                sendPacket
.useSkill(skillArray(i), targetID)
            
End If
        
Next
    End Sub 
______________
i also try to call it manual by directly passd the id of skill and target, but still get "Invalid Skill" msg in game., can you tell me what to be fix? do i need to edit the packet sender, and recompile it?
07/26/2013 00:49 dumbfck#358
If you're getting the invalid skill message, that would suggest the injection function is working fine but your values aren't. Are you mixing decimal and hex?
Try putting a
Code:
Console.Write(skillArray(i).ToString("X"))
to see what actual value you have at that point - Or set a breakpoint.
Also, check your target ID is valid and also in the correct format.

Alternatively, try using hardcoded values. Have you tried using non-target skills, e.g., spark?
07/26/2013 01:34 ntldr32#359
Quote:
Originally Posted by dumbfck View Post
If you're getting the invalid skill message, that would suggest the injection function is working fine but your values aren't. Are you mixing decimal and hex?
Try putting a
Code:
Console.Write(skillArray(i).ToString("X"))
to see what actual value you have at that point - Or set a breakpoint.
Also, check your target ID is valid and also in the correct format.

Alternatively, try using hardcoded values. Have you tried using non-target skills, e.g., spark?
i used all value as decimal, since the packetSender.cs req integer value as parameter.
i had try to call skill directly, eg
Code:
    Sub tes()
        Dim rBaseAddrs As Integer = 12633740
        Dim psAddres As Integer = 7177216
        Dim pHandle As IntPtr
        Try
            For Each proc As Process In Process.GetProcessesByName("elementclient")
                pHandle = pwi_lib.MemFunctions.OpenProcess(proc.Id)
            Next
        Catch ex As Exception
            Exit Sub
        End Try
        Dim sendPacket As New pwi_lib.PacketSender(pHandle)
        sendPacket.REAL_BASE_ADDRESS = rBaseAddrs
        sendPacket.SEND_PACKET_ADDRESS = psAddres
        sendPacket.select(-2092956593) 'select Demonic Souling, work'        
        sendPacket.useSkill(1352, -2092956593) 'try to kill it with Battousai, not work'
        sendPacket.useSkill(1714, 0) 'cast seeker Celestial Eruption, its work'
    End Sub
im sure tha 1352 is the ID for seeker skill Battousai, and -2092956593 is the ID for one of some Demonic Souling, in demonic world. when i call sendPacket.select(-2092956593), the carachter lock that mobs, so i dont think its wrong,. but not sure also, bcos when i use prophet bot to see the id of same monster, the result is differnt 2202010703 is the id of that mob i got from prophet bot, i also try to use that target id from prophet bot, but VS show error when i passed that number(maybe out of integer range).
07/26/2013 02:01 dumbfck#360
Those two numbers are effectively the same. -2092956593 = FFFFFFFF8340044F which if it was a 64 bit number would make a difference as it's the signed equivalent, but as a 32 bit DWORD is the same as 2202010703 = 8340044F.
You're better off working in hex by the way as it's much less confusing in the long run. I still can't understand how people can work in decimal with machine code for the vast majority of stuff lol.

I don't use VB for this sort of thing because it's not really ideal, so I can't test it as I don't have any projects I can throw it into. Unless you want to PM me your project or something and I can maybe have a look tomorrow (it's late here now!)
It's the sort of thing I'd probably want breakpoint in VS and Olly to track down the fault.
Also, I haven't done packet stuff for a really long time, so perhaps the packet structure has changed since the code you're using was posted.
I have detailed how you can analyse what stuff is being sent in packets [Only registered and activated users can see links. Click Here To Register...]

There are other utilities and stuff that people have posted for analysing packets
but I've not really used them so I don't know how they work or if they still work. If you're interested in that, take a look at the packet section on the [Only registered and activated users can see links. Click Here To Register...]

Hopefully something here will be of use to you lol.