Bonjour,
je cherche a faire un détecteur d'archi monstre sur la map. Je voudrai par exemple une alerte quand je passe sur une map sur laquelle il y a un archi. Mais problème je decode mal mon paquet. Apres mon échec a la main j'ai voulu essayer de la faire via un script Python que je peux vous joindre :
j'ai essayé de traduit les fonctions readVar en python mais n'etant pas trop sur de moi j'ai aussi récupéré les fonctions du bot de labo : https://github.com/louisabraham/LaBot/blob/master/labot/data/binrw.py
voila mon paquet dofus si jamais :
qui est donc une chaine de caractère.
En éxécutant ce script j'obtient cet affichage: ( de la forme var value ou var iemeTourDeBoucle value)
je pense que le bug arrive assez tot car genericIds qui est la liste des id des mobs est a 0. Donc l'id du premier mob serait 0
Et je précise que la fonction searchMob recherche deux octects 0C4C car cela devrait être le début de la partie GameRolePlayGroupMonsterInformations
Je pense que le problème vient soit d'une lecture qui aurait du etre faite en big ou des fonctions readVar que je ne comprends pas tellement.
merci d'avance. J'espère que mon poste n'est pas trop moche, c'est mon premier
je cherche a faire un détecteur d'archi monstre sur la map. Je voudrai par exemple une alerte quand je passe sur une map sur laquelle il y a un archi. Mais problème je decode mal mon paquet. Apres mon échec a la main j'ai voulu essayer de la faire via un script Python que je peux vous joindre :
Code:
import pyshark
#import io
import math
INT_SIZE = 32
SHORT_SIZE = 16
SHORT_MIN_VALUE = -32768
SHORT_MAX_VALUE = 32767
UNSIGNED_SHORT_MAX_VALUE = 65536
CHUNCK_BIT_SIZE = 7
MAX_ENCODING_LENGTH:int = math.ceil(INT_SIZE / CHUNCK_BIT_SIZE)
MASK_10000000 = 128
MASK_01111111 = 127
cap = pyshark.FileCapture(r'test2.pcapng')
data = cap[10].data.data
class Paquet:
def __init__(self, paquet):
self.paquet=paquet
#self.fromhex(paquet)
self.pos=0
def getitem(self,i, n=1):
return self.paquet[i:i+n]
def __len__(self):
return len(self.paquet)
def fromhex(self, paquet):
self.paquet = bytearray.fromhex(paquet)
def verif(self, l):
if len(self) < self.pos + l:
raise IndexError(self.pos, l, len(self))
def read(self,l):
self.verif(l)
res = self.paquet[self.pos:self.pos+l]
self.pos+=l
return res
def readDouble(self):
res = self.read(16)
return int(res,16)
def readByte(self):
res = self.read(2)
return int(res,16)
def reset(self):
self.pos=0
def readShort(self):
res = self.read(4)
return int(res,16)
def readProtocolId(self):
res = self.read(4)
return int(res, 16) >> 2
def readVarShort(self):
b= 0
value = 0
offset = 0
hasNext= False
while(offset < SHORT_SIZE):
b = self.readByte()
hasNext = (b & MASK_10000000) == MASK_10000000
if(offset > 0):
value += (b & MASK_01111111) << offset
else:
value += b & MASK_01111111
offset += CHUNCK_BIT_SIZE
if(not hasNext):
return value
def searchMob(self):
cont=1
c0 = 0
while cont==1:
prem = self.readByte()
if c0==1:
if prem==76:
break
else:
c0=0
elif prem ==12:
c0=1
def readInt(self):
res = self.read(8)
return int(res,16)
def readVarInt(self):
ans = 0
for i in range(0, 32, 7):
b = self.readByte()
ans += (b & 0b01111111) << i
if not b & 0b10000000:
return ans
raise Exception("Too much data")
pack = Paquet(data)
def entityLookDeser(pack):
bonesId = pack.readVarShort()
print("bonesId",bonesId)
skinsLen = pack.readShort()
print("skinsLen",skinsLen)
for i in range(skinsLen):
tmp = pack.readVarShort()
print("skinsLen", i," ",tmp)
indexedColorsLen = pack.readShort()
print("indexedColorsLen",skinsLen)
for i in range(indexedColorsLen):
tmp =pack.readInt()
print("indexedColorsLen", i," ",tmp)
scalesLen = pack.readShort()
print("scalesLen",skinsLen)
for i in range(scalesLen):
tmp =pack.readVarShort()
print("scalesLen", i," ",tmp)
subentitiesLen = pack.readShort()
print("subentitiesLen",skinsLen)
for i in range(subentitiesLen):
#subentity
tmp =pack.readByte()
print("subentitiesLen", i," ",tmp)
tmp =pack.readByte()
print("subentitiesLen", i," ",tmp)
entityLookDeser(pack)
def analyse(pack=pack):
protocolId = pack.readProtocolId()
if protocolId!=1182:
return 0
# subArea = pack.readVarShort()
# mapId = pack.readDouble()
# houseLen = pack.readShort()
# for i in range(houseLen):
pack.searchMob()
contextualIdFunc = pack.readDouble()
print("contextualIdFunc",contextualIdFunc)
id2 = pack.readShort()
print("id2",id2)
cellId = pack.readShort()
print("cellId",cellId)
direction = pack.readByte()
print("direction",direction)
entityLookDeser(pack)
box0 = pack.readByte()
print("box0",box0)
id1 = pack.readShort() #groupMonsterStaticInformations
print("id1",id1)
genericIds = []
genericIds.append(pack.readInt())
print("genericIds",genericIds)
grade = pack.readByte()
print("grade",grade)
level = pack.readShort()
print("level",level)
underlings = pack.readShort()
print("underlings",underlings)
for i in range(underlings):
genericIds.append(pack.readInt())
print("genericIds",genericIds)
grade = pack.readByte()
print("grade",grade)
level = pack.readShort()
print("level",level)
entityLookDeser(pack)
lootShareFunc = pack.readByte()
print("lootShareFunc",lootShareFunc)
alignment = pack.readByte()
print("alignment",alignment)
return genericIds
voila mon paquet dofus si jamais :
'127a02110241a628140200000000000004253c42437123001900001d000126000100035adc109a02000501ffc86702e1710e035864000459331005fa950f00018c010000000a426f7567696f727374651d7b00080000000001e080ef00000042437123001f00000c4cc0d38840000000001d0000bc01b402000000000000000000240a0000094101002a0000ffff0c4cc0d38880000000001d00022007b602000000000000000000240a0000005401002a00030000010d01002ae530000000000001960100000000005403002eb60200000000000000000000005101002ab4020000000000000000ffff0c4cc0d388c0000000001d0001c9018503000000000000000000240a000000eb05003200040000011001002ae6300000000000019601000000000110040030e630000000000001960100000000010e02002ce73000000000000196010000000000eb05003285030000000000000000ffff000509ce0007ce1f000000ff000000011a804508100ae301008512a00007ce10ffffffff000000000109ce0007ce1e000000fe00011a804408100ae1000001008512a00007ce14ffffffff00011a80b80108100af100000012a00007ce0effffffff00011a80b80108100ae400000000020007ce1fe50200010007ce1ed60100010000000001000c8203900391039f03ab03ae03b803bb03c703d503d603e403000c91019e019f01ad01ae01bb01bc01ca01cb01d801d901e70117a90300505039290b0001b2809892ee040001007ab50b42437123001900000008002768'
En éxécutant ce script j'obtient cet affichage: ( de la forme var value ou var iemeTourDeBoucle value)
contextualIdFunc 13894599083827396608
id2 7424
cellId 188
direction 1
bonesId 308
skinsLen 0
indexedColorsLen 0
scalesLen 0
subentitiesLen 0
box0 0
id1 9226
genericIds [0]
grade 9
level 16641
underlings 42 genericIds [0, 0] grade 255 level 65292 bonesId 76 skinsLen 49363 skinsLen 0 8 skinsLen 1 0 skinsLen 2 0 skinsLen 3 0 skinsLen 4 29 skinsLen 5 0 skinsLen 6 2 skinsLen 7 32 skinsLen 8 7 skinsLen 9 310 skinsLen 10 0 skinsLen 11 0 skinsLen 12 0 skinsLen 13 0 skinsLen 14 0 skinsLen 15 0 skinsLen 16 0 skinsLen 17 0 skinsLen 18 0 skinsLen 19 36 skinsLen 20 10 skinsLen 21 0 skinsLen 22 0 skinsLen 23 0 skinsLen 24 84 skinsLen 25 1 skinsLen 26 0 skinsLen 27 42 skinsLen 28 0 skinsLen 29 3 skinsLen 30 0 skinsLen 31 0 skinsLen 32 1 skinsLen 33 13 skinsLen 34 1 skinsLen 35 0 skinsLen 36 42 skinsLen 37 6245 skinsLen 38 0 skinsLen 39 0 skinsLen 40 0 skinsLen 41 0 skinsLen 42 0 skinsLen 43 1 skinsLen 44 150 skinsLen 45 0 skinsLen 46 0 skinsLen 47 0 skinsLen 48 0 skinsLen 49 0 skinsLen 50 84 skinsLen 51 3 skinsLen 52 0 skinsLen 53 46 skinsLen 54 310 skinsLen 55 0 skinsLen 56 0 skinsLen 57 0 skinsLen 58 0 skinsLen 59 0 skinsLen 60 0 skinsLen 61 0 skinsLen 62 0 skinsLen 63 0 skinsLen 64 0 skinsLen 65 0 skinsLen 66 81 skinsLen 67 1 skinsLen 68 0 skinsLen 69 42 skinsLen 70 308 skinsLen 71 0 skinsLen 72 0 skinsLen 73 0 skinsLen 74 0 skinsLen 75 0 skinsLen 76 0 skinsLen 77 0 skinsLen 78 0 skinsLen 79 212991 skinsLen 80 76 skinsLen 81 None skinsLen 82 64 skinsLen 83 0 skinsLen 84 0 skinsLen 85 0 skinsLen 86 29 skinsLen 87 0 skinsLen 88 1 skinsLen 89 201 skinsLen 90 389 skinsLen 91 0 skinsLen 92 0 skinsLen 93 0 skinsLen 94 0 skinsLen 95 0 skinsLen 96 0 skinsLen 97 0 skinsLen 98 0 skinsLen 99 0 skinsLen 100 36 skinsLen 101 10 skinsLen 102 0 skinsLen 103 0 skinsLen 104 0 skinsLen 105 747 skinsLen 106 0 skinsLen 107 50 skinsLen 108 0 skinsLen 109 4 skinsLen 110 0 skinsLen 111 0 skinsLen 112 1 skinsLen 113 16 skinsLen 114 1 skinsLen 115 0 skinsLen 116 42 skinsLen 117 6246 skinsLen 118 0 skinsLen 119 0 skinsLen 120 0 skinsLen 121 0 skinsLen 122 0 skinsLen 123 1 skinsLen 124 150 skinsLen 125 0 skinsLen 126 0 skinsLen 127 0 skinsLen 128 0 skinsLen 129 1 skinsLen 130 16 skinsLen 131 4 skinsLen 132 0 skinsLen 133 48 skinsLen 134 6246 skinsLen 135 0 skinsLen 136 0 skinsLen 137 0 skinsLen 138 0 skinsLen 139 0 skinsLen 140 1 skinsLen 141 150 skinsLen 142 0 skinsLen 143 0 skinsLen 144 0 skinsLen 145 0 skinsLen 146 1 skinsLen 147 14 skinsLen 148 2 skinsLen 149 0 skinsLen 150 44 skinsLen 151 6247 skinsLen 152 0 skinsLen 153 0 skinsLen 154 0 skinsLen 155 0 skinsLen 156 0 skinsLen 157 1 skinsLen 158 150 skinsLen 159 0 skinsLen 160 0 skinsLen 161 0 skinsLen 162 0 skinsLen 163 0 skinsLen 164 747 skinsLen 165 0 skinsLen 166 50 skinsLen 167 389 skinsLen 168 0 skinsLen 169 0 skinsLen 170 0 skinsLen 171 0 skinsLen 172 0 skinsLen 173 0 skinsLen 174 0 skinsLen 175 0 skinsLen 176 16383 skinsLen 177 5 skinsLen 178 9 skinsLen 179 78 skinsLen 180 7 skinsLen 181 4046 skinsLen 182 0 skinsLen 183 0 skinsLen 184 0 skinsLen 185 127 skinsLen 186 0 skinsLen 187 0 skinsLen 188 1 skinsLen 189 26 skinsLen 190 8832 skinsLen 191 8 skinsLen 192 16 skinsLen 193 10 skinsLen 194 227 skinsLen 195 0 skinsLen 196 2309 skinsLen 197 32 skinsLen 198 7 skinsLen 199 2126 skinsLen 200 None skinsLen 201 127 skinsLen 202 0 skinsLen 203 0 skinsLen 204 0 skinsLen 205 1 skinsLen 206 9 skinsLen 207 78 skinsLen 208 7 skinsLen 209 3918 skinsLen 210 0 skinsLen 211 0 skinsLen 212 0 skinsLen 213 126 skinsLen 214 1 skinsLen 215 26 skinsLen 216 8704 skinsLen 217 8 skinsLen 218 16 skinsLen 219 10 skinsLen 220 97 skinsLen 221 0 skinsLen 222 1 skinsLen 223 0 skinsLen 224 2309 skinsLen 225 32 skinsLen 226 7 skinsLen 227 2638 skinsLen 228 None skinsLen 229 127 skinsLen 230 1 skinsLen 231 26 skinsLen 232 23552 skinsLen 233 8 skinsLen 234 16 skinsLen 235 10 skinsLen 236 113 skinsLen 237 0 skinsLen 238 0 skinsLen 239 18 skinsLen 240 32 skinsLen 241 7 skinsLen 242 1870 skinsLen 243 None skinsLen 244 127 skinsLen 245 1 skinsLen 246 26 skinsLen 247 23552 skinsLen 248 8 skinsLen 249 16 skinsLen 250 10 skinsLen 251 100 skinsLen 252 0 skinsLen 253 0 skinsLen 254 0 skinsLen 255 2 skinsLen 256 0 skinsLen 257 7 skinsLen 258 4046 skinsLen 259 357 skinsLen 260 0 skinsLen 261 1 skinsLen 262 0 skinsLen 263 7 skinsLen 264 3918 skinsLen 265 214 skinsLen 266 0 skinsLen 267 1 skinsLen 268 0 skinsLen 269 0 skinsLen 270 0 skinsLen 271 0 skinsLen 272 1 skinsLen 273 0 skinsLen 274 12 skinsLen 275 386 skinsLen 276 400 skinsLen 277 401 skinsLen 278 415 skinsLen 279 427 skinsLen 280 430 skinsLen 281 440 skinsLen 282 443 skinsLen 283 455 skinsLen 284 469 skinsLen 285 470 skinsLen 286 484 skinsLen 287 0 skinsLen 288 12 skinsLen 289 145 skinsLen 290 158 skinsLen 291 159 skinsLen 292 173 skinsLen 293 174 skinsLen 294 187 skinsLen 295 188 skinsLen 296 202 skinsLen 297 203 skinsLen 298 216 skinsLen 299 217 skinsLen 300 231 skinsLen 301 23 skinsLen 302 425 skinsLen 303 0 skinsLen 304 80 skinsLen 305 80 skinsLen 306 57 skinsLen 307 41 skinsLen 308 11 skinsLen 309 0 skinsLen 310 1 skinsLen 311 None skinsLen 312 79634 skinsLen 313 0 skinsLen 314 1 skinsLen 315 0 skinsLen 316 122 skinsLen 317 1461 skinsLen 318 66 skinsLen 319 67 skinsLen 320 113 skinsLen 321 35 skinsLen 322 0 skinsLen 323 25 skinsLen 324 0 skinsLen 325 0 skinsLen 326 0 skinsLen 327 8 skinsLen 328 0 skinsLen 329 39 skinsLen 330 104
id2 7424
cellId 188
direction 1
bonesId 308
skinsLen 0
indexedColorsLen 0
scalesLen 0
subentitiesLen 0
box0 0
id1 9226
genericIds [0]
grade 9
level 16641
underlings 42 genericIds [0, 0] grade 255 level 65292 bonesId 76 skinsLen 49363 skinsLen 0 8 skinsLen 1 0 skinsLen 2 0 skinsLen 3 0 skinsLen 4 29 skinsLen 5 0 skinsLen 6 2 skinsLen 7 32 skinsLen 8 7 skinsLen 9 310 skinsLen 10 0 skinsLen 11 0 skinsLen 12 0 skinsLen 13 0 skinsLen 14 0 skinsLen 15 0 skinsLen 16 0 skinsLen 17 0 skinsLen 18 0 skinsLen 19 36 skinsLen 20 10 skinsLen 21 0 skinsLen 22 0 skinsLen 23 0 skinsLen 24 84 skinsLen 25 1 skinsLen 26 0 skinsLen 27 42 skinsLen 28 0 skinsLen 29 3 skinsLen 30 0 skinsLen 31 0 skinsLen 32 1 skinsLen 33 13 skinsLen 34 1 skinsLen 35 0 skinsLen 36 42 skinsLen 37 6245 skinsLen 38 0 skinsLen 39 0 skinsLen 40 0 skinsLen 41 0 skinsLen 42 0 skinsLen 43 1 skinsLen 44 150 skinsLen 45 0 skinsLen 46 0 skinsLen 47 0 skinsLen 48 0 skinsLen 49 0 skinsLen 50 84 skinsLen 51 3 skinsLen 52 0 skinsLen 53 46 skinsLen 54 310 skinsLen 55 0 skinsLen 56 0 skinsLen 57 0 skinsLen 58 0 skinsLen 59 0 skinsLen 60 0 skinsLen 61 0 skinsLen 62 0 skinsLen 63 0 skinsLen 64 0 skinsLen 65 0 skinsLen 66 81 skinsLen 67 1 skinsLen 68 0 skinsLen 69 42 skinsLen 70 308 skinsLen 71 0 skinsLen 72 0 skinsLen 73 0 skinsLen 74 0 skinsLen 75 0 skinsLen 76 0 skinsLen 77 0 skinsLen 78 0 skinsLen 79 212991 skinsLen 80 76 skinsLen 81 None skinsLen 82 64 skinsLen 83 0 skinsLen 84 0 skinsLen 85 0 skinsLen 86 29 skinsLen 87 0 skinsLen 88 1 skinsLen 89 201 skinsLen 90 389 skinsLen 91 0 skinsLen 92 0 skinsLen 93 0 skinsLen 94 0 skinsLen 95 0 skinsLen 96 0 skinsLen 97 0 skinsLen 98 0 skinsLen 99 0 skinsLen 100 36 skinsLen 101 10 skinsLen 102 0 skinsLen 103 0 skinsLen 104 0 skinsLen 105 747 skinsLen 106 0 skinsLen 107 50 skinsLen 108 0 skinsLen 109 4 skinsLen 110 0 skinsLen 111 0 skinsLen 112 1 skinsLen 113 16 skinsLen 114 1 skinsLen 115 0 skinsLen 116 42 skinsLen 117 6246 skinsLen 118 0 skinsLen 119 0 skinsLen 120 0 skinsLen 121 0 skinsLen 122 0 skinsLen 123 1 skinsLen 124 150 skinsLen 125 0 skinsLen 126 0 skinsLen 127 0 skinsLen 128 0 skinsLen 129 1 skinsLen 130 16 skinsLen 131 4 skinsLen 132 0 skinsLen 133 48 skinsLen 134 6246 skinsLen 135 0 skinsLen 136 0 skinsLen 137 0 skinsLen 138 0 skinsLen 139 0 skinsLen 140 1 skinsLen 141 150 skinsLen 142 0 skinsLen 143 0 skinsLen 144 0 skinsLen 145 0 skinsLen 146 1 skinsLen 147 14 skinsLen 148 2 skinsLen 149 0 skinsLen 150 44 skinsLen 151 6247 skinsLen 152 0 skinsLen 153 0 skinsLen 154 0 skinsLen 155 0 skinsLen 156 0 skinsLen 157 1 skinsLen 158 150 skinsLen 159 0 skinsLen 160 0 skinsLen 161 0 skinsLen 162 0 skinsLen 163 0 skinsLen 164 747 skinsLen 165 0 skinsLen 166 50 skinsLen 167 389 skinsLen 168 0 skinsLen 169 0 skinsLen 170 0 skinsLen 171 0 skinsLen 172 0 skinsLen 173 0 skinsLen 174 0 skinsLen 175 0 skinsLen 176 16383 skinsLen 177 5 skinsLen 178 9 skinsLen 179 78 skinsLen 180 7 skinsLen 181 4046 skinsLen 182 0 skinsLen 183 0 skinsLen 184 0 skinsLen 185 127 skinsLen 186 0 skinsLen 187 0 skinsLen 188 1 skinsLen 189 26 skinsLen 190 8832 skinsLen 191 8 skinsLen 192 16 skinsLen 193 10 skinsLen 194 227 skinsLen 195 0 skinsLen 196 2309 skinsLen 197 32 skinsLen 198 7 skinsLen 199 2126 skinsLen 200 None skinsLen 201 127 skinsLen 202 0 skinsLen 203 0 skinsLen 204 0 skinsLen 205 1 skinsLen 206 9 skinsLen 207 78 skinsLen 208 7 skinsLen 209 3918 skinsLen 210 0 skinsLen 211 0 skinsLen 212 0 skinsLen 213 126 skinsLen 214 1 skinsLen 215 26 skinsLen 216 8704 skinsLen 217 8 skinsLen 218 16 skinsLen 219 10 skinsLen 220 97 skinsLen 221 0 skinsLen 222 1 skinsLen 223 0 skinsLen 224 2309 skinsLen 225 32 skinsLen 226 7 skinsLen 227 2638 skinsLen 228 None skinsLen 229 127 skinsLen 230 1 skinsLen 231 26 skinsLen 232 23552 skinsLen 233 8 skinsLen 234 16 skinsLen 235 10 skinsLen 236 113 skinsLen 237 0 skinsLen 238 0 skinsLen 239 18 skinsLen 240 32 skinsLen 241 7 skinsLen 242 1870 skinsLen 243 None skinsLen 244 127 skinsLen 245 1 skinsLen 246 26 skinsLen 247 23552 skinsLen 248 8 skinsLen 249 16 skinsLen 250 10 skinsLen 251 100 skinsLen 252 0 skinsLen 253 0 skinsLen 254 0 skinsLen 255 2 skinsLen 256 0 skinsLen 257 7 skinsLen 258 4046 skinsLen 259 357 skinsLen 260 0 skinsLen 261 1 skinsLen 262 0 skinsLen 263 7 skinsLen 264 3918 skinsLen 265 214 skinsLen 266 0 skinsLen 267 1 skinsLen 268 0 skinsLen 269 0 skinsLen 270 0 skinsLen 271 0 skinsLen 272 1 skinsLen 273 0 skinsLen 274 12 skinsLen 275 386 skinsLen 276 400 skinsLen 277 401 skinsLen 278 415 skinsLen 279 427 skinsLen 280 430 skinsLen 281 440 skinsLen 282 443 skinsLen 283 455 skinsLen 284 469 skinsLen 285 470 skinsLen 286 484 skinsLen 287 0 skinsLen 288 12 skinsLen 289 145 skinsLen 290 158 skinsLen 291 159 skinsLen 292 173 skinsLen 293 174 skinsLen 294 187 skinsLen 295 188 skinsLen 296 202 skinsLen 297 203 skinsLen 298 216 skinsLen 299 217 skinsLen 300 231 skinsLen 301 23 skinsLen 302 425 skinsLen 303 0 skinsLen 304 80 skinsLen 305 80 skinsLen 306 57 skinsLen 307 41 skinsLen 308 11 skinsLen 309 0 skinsLen 310 1 skinsLen 311 None skinsLen 312 79634 skinsLen 313 0 skinsLen 314 1 skinsLen 315 0 skinsLen 316 122 skinsLen 317 1461 skinsLen 318 66 skinsLen 319 67 skinsLen 320 113 skinsLen 321 35 skinsLen 322 0 skinsLen 323 25 skinsLen 324 0 skinsLen 325 0 skinsLen 326 0 skinsLen 327 8 skinsLen 328 0 skinsLen 329 39 skinsLen 330 104
je pense que le bug arrive assez tot car genericIds qui est la liste des id des mobs est a 0. Donc l'id du premier mob serait 0
Et je précise que la fonction searchMob recherche deux octects 0C4C car cela devrait être le début de la partie GameRolePlayGroupMonsterInformations
Je pense que le problème vient soit d'une lecture qui aurait du etre faite en big ou des fonctions readVar que je ne comprends pas tellement.
merci d'avance. J'espère que mon poste n'est pas trop moche, c'est mon premier
Dernière édition: