Extract GUIDs from a packet using Lua patterns (7.3.5) menu

User Tag List

Results 1 to 6 of 6
  1. #1
    IFireEagle's Avatar Member
    Reputation
    9
    Join Date
    Dec 2013
    Posts
    20
    Thanks G/R
    3/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Extract GUIDs from a packet using Lua patterns (7.3.5)

    Hi, don't know if I'm posting in the right section, but packet and memory editing are a bit common, so.
    Actually, I'm facing to a wall since I tried a whole day to extract one or multiples GUIDs from a packet. I found some patterns (this one, is the best I made but can fail %x%xA0%x-040C).
    Problem, is that I can't found a pattern totally reliable, you will understand with examples below.

    For example, I want to extract item GUIDs from this fake packet :
    Code:
    6D 32 01 00 00 00 0F A0 6F AD 3E 9C 04 0C 02 00 00 00 0F A0 2E 8B 1A 5C 04 0C
    If I apply this pattern, it works without fail :
    Code:
    for guid in string.gmatch(UnsplitBytes(data), "%x%xA0%x-040C") do
     print(guid);
    end
    
    -- Output : 0F A0 6F AD 3E 9C 04 0C - 0F A0 2E 8B 1A 5C 04 0C
    But with those packet, it fails :
    Code:
    6D 32 00 00 A0 02 00 00 0F A0 6F AD 3E 9C 04 0C 00 00 00 00 00 00 0F A0 2E 8B 1A 5C 04 0C
    6D 32 00 00 0A 06 00 00 0F A0 6F AD 3E 9C 04 0C 00 00 00 00 00 00 0F A0 2E 8B 1A 5C 04 0C
    Code:
    for guid in string.gmatch(UnsplitBytes(data), "%x%xA0%x-040C") do
     print(guid);
    end
    
    -- Output : 00 A0 02 00 00 0F A0 6F AD 3E 9C 04 0C - 0F A0 2E 8B 1A 5C 04 0C
    -- Output : 0 0A 02 00 00 0F A0 6F AD 3E 9C 04 0C - 0F A0 2E 8B 1A 5C 04 0C
    Note : I remove all spaces between each bytes before apply the pattern.

    So, I can't find how to handle this problem.
    Thanks for any help.

    GUID structure (simplified) for whos don't know (don't know if in memory, this is the same) :
    Code:
    AA BB XX (CC) 04 DD
    
    AA = GUID length (also named GUID Low Mask).
    01 for 1 byte
    03 for 2 bytes
    07 for 3 bytes
    0F for 4 bytes
    ...
    
    BB = ID length (also named GUID High Mask).
    A0 if no ID
    A1 for 1 byte
    A3 for 2 bytes
    A7 for 3 bytes
    ...
    
    XX = Object GUID
    CC = Object ID (some objects don't require their ID in their GUID, like Items or Players).
    04 = Constant, doesn't change.
    DD = Object Type ID (Item, GameObject, Unit...).
    
    If I take a GUID from my examples above :
    [0F] [A0] [2E 8B 1A 5C] [04] [0C]
    
    [2E 8B 1A 5C] = Item GUID (of 4 bytes).
    [0F] = because the GUID is 4 bytes.
    [A0] = because there is no ID for an item GUID.
    [04] = always the same.
    [0C] = Item Type ID

    Extract GUIDs from a packet using Lua patterns (7.3.5)
  2. #2
    mdX7's Avatar Member Authenticator enabled
    Reputation
    1
    Join Date
    Jul 2017
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot simply find a guid in the pure packet data using patterns. Imagine that there's a packet with 128 bits of random data that just looks like a guid but are several different fields. Patterns will always fail in this case.
    You could either try to parse the whole packet (or at least until the field you want) and then extract the guid from there or hook GetPacketGuid128/WritePacketGuid128. I don't know if Warden is scanning for hooks in there though. Safest method would be parsing the packet. Keep in mind that the structure may change between patches.

  3. #3
    IFireEagle's Avatar Member
    Reputation
    9
    Join Date
    Dec 2013
    Posts
    20
    Thanks G/R
    3/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I suspected that it wasn't possible, but I prefered to ask since I'm not super strong with patterns.
    I have an idea though, I calculate how many bytes the GUID have with the low mask (0F) and if there is the same bytes number between 0F A0 and 04 0C then, this is a GUID. If this is not a guid, then continue until find a valid GUID. Have to see if is it possible to code this in Lua.
    Should greatly reduce chances to extract a wrong data to near 0%.

    I'm using EWT Lua API to manipulate packets directly in-game with my own AddOn, so I'm restricted to Lua only.
    Last edited by IFireEagle; 08-09-2018 at 02:19 PM.

  4. #4
    DarkLinux's Avatar Former Staff
    CoreCoins Purchaser Authenticator enabled
    Reputation
    1584
    Join Date
    May 2010
    Posts
    1,828
    Thanks G/R
    188/531
    Trade Feedback
    16 (100%)
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    No idea if this help, but should give you an idea how a guid gets converted
    7.3.5-godscale/ObjectGuid.cpp at a6c03c9492fa33803e5d5abaf0f7471a717ff334 . magnah/7.3.5-godscale . GitHub
    look for,
    Code:
    ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
    ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)

  5. #5
    IFireEagle's Avatar Member
    Reputation
    9
    Join Date
    Dec 2013
    Posts
    20
    Thanks G/R
    3/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I will see what I can do.

  6. #6
    IFireEagle's Avatar Member
    Reputation
    9
    Join Date
    Dec 2013
    Posts
    20
    Thanks G/R
    3/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by IFireEagle View Post
    Yeah, I suspected that it wasn't possible, but I prefered to ask since I'm not super strong with patterns.
    I have an idea though, I calculate how many bytes the GUID have with the low mask (0F) and if there is the same bytes number between 0F A0 and 04 0C then, this is a GUID. If this is not a guid, then continue until find a valid GUID. Have to see if is it possible to code this in Lua.
    Should greatly reduce chances to extract a wrong data to near 0%.

    I'm using EWT Lua API to manipulate packets directly in-game with my own AddOn, so I'm restricted to Lua only.
    My idea works great.
    It can only fail in the case where there is exactly this sort of data (probability are nearly null I think) :
    "07 A0 01 A0 AA 04 08"
    "03 A3 01 A1 AA BB 04 20"

    My function takes an entire packet or a piece, we specify what kind of guid we want (if we want items guids, npcs guids...), and the function returns in a table all guids found (with their positions in the string).

Similar Threads

  1. [Gold] Guide to Making lots of gold from guilds - to use must have a good amount of gold
    By CrazyBaller in forum World of Warcraft Guides
    Replies: 19
    Last Post: 09-06-2012, 08:08 AM
  2. [Guide] Making portals that stay forever using LUA.
    By Jackie Moon in forum WoW EMU Guides & Tutorials
    Replies: 9
    Last Post: 06-21-2008, 07:42 AM
  3. Beginners LUA Guide From Nub to Expert [updating]
    By mager1794 in forum WoW EMU Guides & Tutorials
    Replies: 0
    Last Post: 06-19-2008, 03:17 AM
  4. Any1 have the guide from www.ultimatewowguide.com
    By oooscorpion in forum World of Warcraft General
    Replies: 0
    Last Post: 03-24-2007, 03:37 PM
  5. WOW GUide FROM RED GUIDES.. ( WOW UNDERGROUND)
    By Elites360 in forum World of Warcraft Guides
    Replies: 12
    Last Post: 11-01-2006, 05:05 PM
All times are GMT -5. The time now is 02:27 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search