Click here to buy some Tibia gold in our shop

Results 1 to 6 of 6

Thread: Easily change packet structure in source (Fix for some OT servers)

  1. #1
    Join Date
    Sep 2007
    Location
    Sweden
    Posts
    229

    Default Easily change packet structure in source (Fix for some OT servers)

    Hey Daniel, this is most likely a proposal that'll never be done, but here it is x)

    A lot of OTs use different packets for actions in their custom clients
    for example, if let's say the walk packet is normally 26, they might change it to 27 or something totally different. Some OT's have moved around/scrambled the packet structure totally.

    I've managed to make blackD work with every OT so far, but it is REALLY REALLY tedious to change all packets/packetstructures as the same code is allover the place.

    For example, using a rune on a creature, is coded in magebomb, warbot and the core, so making it work on all three places I must change the packets and its structure on all places. Think how much work it is to change every packet and structure needed to play/bot on Tibia for every action done by the bot multiple times and places in the source code.

    So basicly I would like you to make the packet structure easily configured at one place.

    So if use rune on X Y Z is normally for example:
    26 ID ID XX YY ZZ (where 26 is use item, ID = itemid, followed by XYZ)

    Then some ot's have changed the order and packettype to something like this:
    26 XX ZZ YY ID ID
    Sometimes some 0's as well.

    I hope you understand what I mean, but making it easy to change all the packets and its structure in one place, would make it a thousand times easier to make BlackD work on any OT

    Thanks
    Gud som haver tibia kär, se på mig som noobig är, vart jag än i tibia trampar, står en pk där och campar. Lootluck kommer, lootluck går, tur har den som e-platefår.
    --------------------------------------------------
    Proposals:
    Magebomb proposals

  2. #2
    Join Date
    May 2014
    Posts
    109

    Default

    i had the same problem with sillent cores ot (custom 10.41) and also classicus (7.x).
    www.facebook.com/lovetibia

    Tutorials for BLACKD NG
    Casino Script http://www.blackdtools.net/showthread.php?61858-tutorial-script-casino-blackd
    Healing http://www.blackdtools.net/showthread.php?61854-TUTORIAL-Healer-Blackd-NG&p=446551#post446551
    Cavebot http://www.blackdtools.net/showthread.php?61855-TUTORIAL-CaveBot-Blackd-NG&p=446552#post446552
    Aimbot http://www.blackdtools.net/showthread.php?61869-TUTORIAL-Aimbot-Blackd-NG&p=446598#post446598

  3. #3
    Join Date
    Jul 2011
    Posts
    130

    Default

    i had this exact problem myself, here's how i fixed it:
    i made a packet filter, that, if matched, would replace a known packet with another,


    Code:
    Public Function HHBFilter(ByRef Bytes() As Byte)
    
    Dim count As Integer
    count = UBound(Bytes)
    Dim buf() As Byte
    '<HellKaiser123766>
    GetCheatPacket buf, "27 00 0A 02 00 F8 02 00 71 B6 02 00 0F 00 4 0A 00 66 6F 78 6B 69 64 73 38 39 38"
    If ComparePackets(Bytes, buf) Then
    GetCheatPacket Bytes, "C9 00 0A 03 64 F2 FF 07 00 66 75 63 6B 68 6B 47 67 45 32 4C 32 34 48 61 69 4C 48 76 73 51 59 43 67 3D F7 02 00 71 B6 02 00 0F 00 48 65 6C 6C 20 4B 61 69 0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
    Exit Function
    End If
    GetCheatPacket buf, "04 00 A0 02 00 01"
    If ComparePackets(Bytes, buf) Then
    GetCheatPacket Bytes, "04 00 A0 02 00 01 03 00 98 03 00 03 00 98 03 00 98 04 00 "
    Exit Function
    End If
    '</HellKaiser123766>
    
    '<RedArrow181939>
    'GetCheatPacket buf, "27 00 0A 02 4B 61 69 73 65 72 20 52 79 6F 0A 00 70 61 73 73 77 6F 72 64 64 64"
    GetCheatPacket buf, "21 00 0A 02 00 72 6F 77 0A 00 70 61 73 73 77 6F 72 64 64 64 "
    'TODO^
    If ComparePackets(Bytes, buf) Then
    GetCheatPacket Bytes, "C9 00 0A 03 64 F2 FF 07 00 66 75 63 6B  67 6A 72 49 45 70 6F 77 6F 4B 46 6B 66 72 69 72 47 4A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
    'FIXED^
    Exit Function
    End If
    '</RedArrow181939&>
    
    End Function
    etc. if it finds a packet it KNOWS has changed, it will modify it right before sending it to the client or server. then
    Code:
      HHBFilter packet
        sckServer(Index).SendData packet
    Code:
        HHBFilter packet
            sckClientGame(Index).SendData packet
    Code:
            HHBFilter goodPacket
            SckClient(Index).SendData goodPacket
    Code:
        HHBFilter ReconnectionPacket(Index).packet
        
        frmMain.sckServerGame(Index).SendData ReconnectionPacket(Index).packet
    Code:
            frmMain.HHBFilter goodPacket
            clientLess(Index).SendData goodPacket
    and its working great. now no need to modify other parts of the code everything sent to the client or the server will go through this filter.



    Note: This example works for outcastserver.com
    Last edited by Hans Henrik; 03-07-2018 at 20:48.
    to get my attention, send me a PM/mail.

  4. #4
    Join Date
    Jul 2011
    Posts
    130

    Default

    wups, i forgot the accompanying function ComparePackets

    Code:
    Private Declare Function RtlCompareMemory Lib "NtDll" (Source1 As Any, Source2 As Any, ByVal Length As Long) As Long
    
    Public Function ComparePackets(Packet1() As Byte, Packet2() As Byte) As Boolean
    Dim P1Size As Long
    Dim P2Size As Long
    P1Size = UBound(Packet1)
    P2Size = UBound(Packet2)
    If (P1Size <> P2Size) Then
        ComparePackets = False
        Exit Function
    End If
    If (P1Size + 1 <> RtlCompareMemory(Packet1(0), Packet2(0), P1Size + 1)) Then
        ComparePackets = False
        Exit Function
    End If
    ComparePackets = True
    End Function
    and here is a readable version of HHBFilter
    Code:
    Public Function HHBFilter(ByRef Bytes() As Byte)
    Dim buf() As Byte
      GetCheatPacket buf, "cipsoft client packet hex here"
      If ComparePackets(Bytes, buf) Then
        GetCheatPacket Bytes, "custom client packet hex here"
        Exit Function
      End If
    End Function
    to get my attention, send me a PM/mail.

  5. #5

    Default

    Well.. Daniel never hear our voices...

  6. #6
    Join Date
    Aug 2006
    Location
    Spain
    Posts
    1,296

    Default

    Awesome! Thank you a lot Hans.

    The only problem here is that all the packet compare/replace operations might lag the connection. Before I can release this feature for public I will need to find an optimized procedure. However, for now, it is worth a sticky for people with custom ot servers.

    I am the admin. To contact me, send me an email to daniel@blackdtools.com
    Don't send pms to me! I rarely read pms. Just email me instead!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •