summaryrefslogtreecommitdiff
path: root/servergreps
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-19 18:01:33 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-19 22:52:14 +0300
commit1ec0f534c8f38c605f638282b4432e558106d699 (patch)
treeb068a98f8aac0aada6869d6e3f2ba3835fcd56ee /servergreps
parent59b06bd0e6054ee42e4fb159b8ef44a50d3fb720 (diff)
downloadevol-tools-1ec0f534c8f38c605f638282b4432e558106d699.tar.gz
evol-tools-1ec0f534c8f38c605f638282b4432e558106d699.tar.bz2
evol-tools-1ec0f534c8f38c605f638282b4432e558106d699.tar.xz
evol-tools-1ec0f534c8f38c605f638282b4432e558106d699.zip
servergreps: move out packet search shared code into utils.
Diffstat (limited to 'servergreps')
-rwxr-xr-xservergreps/hercules/src/brathena.py61
-rwxr-xr-xservergreps/hercules/src/hercules.py69
-rwxr-xr-xservergreps/hercules/src/idathena.py58
-rwxr-xr-xservergreps/hercules/src/ragemu.py51
-rwxr-xr-xservergreps/hercules/src/rathena.py58
-rwxr-xr-xservergreps/hercules/src/threeceam.py66
-rwxr-xr-xservergreps/hercules/src/utils.py70
7 files changed, 90 insertions, 343 deletions
diff --git a/servergreps/hercules/src/brathena.py b/servergreps/hercules/src/brathena.py
index 8c0e204..d0a62f8 100755
--- a/servergreps/hercules/src/brathena.py
+++ b/servergreps/hercules/src/brathena.py
@@ -26,17 +26,6 @@ class Brathena:
namedPacketre = re.compile(
"((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- ourPacketre = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
- ourPacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);")
- ourPacketre3 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- ourPacketre4 = re.compile(" cmd([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre5 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(count[*]p_len)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
outPacketLoginre = re.compile(
"([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
@@ -99,20 +88,14 @@ class Brathena:
elif filt.search(file1):
with open(file2, "r") as f:
for line in f:
- m = self.ourPacketre4.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre5.findall(line)
+ Utils.getOutPackets(line, self)
+ m = self.serverpacketLoginOutre.findall(line)
if len(m) > 0:
for str in m:
- data = str[9]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
+ if str[2] in self.loginPacketNameToId:
+ data = str[2]
+ data = self.loginPacketNameToId[data]
+ self.addServerPacket(data)
m = self.outPacketLoginre.findall(line)
if len(m) > 0:
for str in m:
@@ -120,38 +103,6 @@ class Brathena:
while len(data) < 4:
data = "0" + data
self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.ourPacketre.findall(line)
- if len(m) == 0:
- m = self.ourPacketre3.findall(line)
- if len(m) > 0:
- for str in m:
- if str[9] == "0":
- continue
- data = str[9]
- if data == "cmd":
- continue
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
-
- m = self.ourPacketre2.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] == "0":
- continue
- data = str[2]
- if len(data) > 2 and data[0:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.serverpacketLoginOutre.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] in self.loginPacketNameToId:
- data = str[2]
- data = self.loginPacketNameToId[data]
- self.addServerPacket(data)
m = self.packetLenre.findall(line)
if len(m) > 0:
for str in m:
diff --git a/servergreps/hercules/src/hercules.py b/servergreps/hercules/src/hercules.py
index c2f41d3..344ec31 100755
--- a/servergreps/hercules/src/hercules.py
+++ b/servergreps/hercules/src/hercules.py
@@ -26,21 +26,6 @@ class Hercules:
namedPacketre = re.compile(
"((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- ourPacketre = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
- ourPacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);")
- ourPacketre3 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- ourPacketre4 = re.compile(" cmd([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre5 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(count[*]p_len)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- outPacketLoginre = re.compile(
- "([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
- "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
- serverpacketLoginOutre = re.compile("packet_id([ ]*)=([ ]*)(?P<name>[\w_]+);")
clientpacketre = re.compile(
"(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
",(?P<function>[0-9a-zA-Z_>-]+)(,|[)])")
@@ -52,6 +37,10 @@ class Hercules:
clientpacketLenre = re.compile(
"(\t*)packet[(]0x(?P<packet>[0-9a-fA-F]+),(?P<len>[\w-]+)" +
"[)]")
+ outPacketLoginre = re.compile(
+ "([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
+ "([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
+ serverpacketLoginOutre = re.compile("packet_id([ ]*)=([ ]*)(?P<name>[\w_]+);")
def collectNamedPackets(self, fileName):
with open(fileName, "r") as f:
@@ -99,20 +88,14 @@ class Hercules:
elif filt.search(file1):
with open(file2, "r") as f:
for line in f:
- m = self.ourPacketre4.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre5.findall(line)
+ Utils.getOutPackets(line, self)
+ m = self.serverpacketLoginOutre.findall(line)
if len(m) > 0:
for str in m:
- data = str[9]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
+ if str[2] in self.loginPacketNameToId:
+ data = str[2]
+ data = self.loginPacketNameToId[data]
+ self.addServerPacket(data)
m = self.outPacketLoginre.findall(line)
if len(m) > 0:
for str in m:
@@ -120,38 +103,6 @@ class Hercules:
while len(data) < 4:
data = "0" + data
self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.ourPacketre.findall(line)
- if len(m) == 0:
- m = self.ourPacketre3.findall(line)
- if len(m) > 0:
- for str in m:
- if str[9] == "0":
- continue
- data = str[9]
- if data == "cmd":
- continue
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
-
- m = self.ourPacketre2.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] == "0":
- continue
- data = str[2]
- if len(data) > 2 and data[0:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.serverpacketLoginOutre.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] in self.loginPacketNameToId:
- data = str[2]
- data = self.loginPacketNameToId[data]
- self.addServerPacket(data)
m = self.packetLenre.findall(line)
if len(m) > 0:
for str in m:
diff --git a/servergreps/hercules/src/idathena.py b/servergreps/hercules/src/idathena.py
index 4b51b52..07b04b9 100755
--- a/servergreps/hercules/src/idathena.py
+++ b/servergreps/hercules/src/idathena.py
@@ -25,18 +25,6 @@ class Idathena:
namedPacketre = re.compile(
"((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- ourPacketre = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
- ourPacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);")
- ourPacketre3 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- ourPacketre4 = re.compile(" cmd([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre5 = re.compile("int cmde([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre6 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(count[*]p_len)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
outPacketLoginre = re.compile(
"([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
@@ -98,27 +86,7 @@ class Idathena:
elif filt.search(file1):
with open(file2, "r") as f:
for line in f:
- m = self.ourPacketre4.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre5.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre6.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[9]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
+ Utils.getOutPackets(line, self)
m = self.outPacketLoginre.findall(line)
if len(m) > 0:
for str in m:
@@ -126,30 +94,6 @@ class Idathena:
while len(data) < 4:
data = "0" + data
self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.ourPacketre.findall(line)
- if len(m) == 0:
- m = self.ourPacketre3.findall(line)
- if len(m) > 0:
- for str in m:
- if str[9] == "0":
- continue
- data = str[9]
- if data == "cmd":
- continue
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre2.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] == "0":
- continue
- data = str[2]
- if len(data) > 2 and data[0:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
m = self.serverpacketLoginOutre.findall(line)
if len(m) > 0:
for str in m:
diff --git a/servergreps/hercules/src/ragemu.py b/servergreps/hercules/src/ragemu.py
index 15f20d0..a06dc5f 100755
--- a/servergreps/hercules/src/ragemu.py
+++ b/servergreps/hercules/src/ragemu.py
@@ -26,17 +26,6 @@ class Ragemu:
namedPacketre = re.compile(
"((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- ourPacketre = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
- ourPacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);")
- ourPacketre3 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- ourPacketre4 = re.compile(" cmd([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre5 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(count[*]p_len)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
outPacketLoginre = re.compile(
"([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
@@ -99,20 +88,7 @@ class Ragemu:
elif filt.search(file1):
with open(file2, "r") as f:
for line in f:
- m = self.ourPacketre4.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre5.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[9]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
+ Utils.getOutPackets(line, self)
m = self.outPacketLoginre.findall(line)
if len(m) > 0:
for str in m:
@@ -120,31 +96,6 @@ class Ragemu:
while len(data) < 4:
data = "0" + data
self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.ourPacketre.findall(line)
- if len(m) == 0:
- m = self.ourPacketre3.findall(line)
- if len(m) > 0:
- for str in m:
- if str[9] == "0":
- continue
- data = str[9]
- if data == "cmd":
- continue
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
-
- m = self.ourPacketre2.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] == "0":
- continue
- data = str[2]
- if len(data) > 2 and data[0:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
m = self.serverpacketLoginOutre.findall(line)
if len(m) > 0:
for str in m:
diff --git a/servergreps/hercules/src/rathena.py b/servergreps/hercules/src/rathena.py
index 4ff10f4..78f14b4 100755
--- a/servergreps/hercules/src/rathena.py
+++ b/servergreps/hercules/src/rathena.py
@@ -25,18 +25,6 @@ class Rathena:
namedPacketre = re.compile(
"((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- ourPacketre = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
- ourPacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);")
- ourPacketre3 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- ourPacketre4 = re.compile(" cmd([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre5 = re.compile("int cmde([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre6 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(count[*]p_len)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
outPacketLoginre = re.compile(
"([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
@@ -98,27 +86,7 @@ class Rathena:
elif filt.search(file1):
with open(file2, "r") as f:
for line in f:
- m = self.ourPacketre4.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre5.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre6.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[9]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
+ Utils.getOutPackets(line, self)
m = self.outPacketLoginre.findall(line)
if len(m) > 0:
for str in m:
@@ -126,30 +94,6 @@ class Rathena:
while len(data) < 4:
data = "0" + data
self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.ourPacketre.findall(line)
- if len(m) == 0:
- m = self.ourPacketre3.findall(line)
- if len(m) > 0:
- for str in m:
- if str[9] == "0":
- continue
- data = str[9]
- if data == "cmd":
- continue
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre2.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] == "0":
- continue
- data = str[2]
- if len(data) > 2 and data[0:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
m = self.serverpacketLoginOutre.findall(line)
if len(m) > 0:
for str in m:
diff --git a/servergreps/hercules/src/threeceam.py b/servergreps/hercules/src/threeceam.py
index e7b41c4..ad1341d 100755
--- a/servergreps/hercules/src/threeceam.py
+++ b/servergreps/hercules/src/threeceam.py
@@ -25,19 +25,6 @@ class Threeceam:
namedPacketre = re.compile(
"((\t|[ ])*)(?P<name>[\w0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<value>[0-9a-fA-F]+)")
- ourPacketre = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
- ourPacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);")
- ourPacketre3 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
- ourPacketre4 = re.compile(" cmd([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre5 = re.compile("int cmde([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre6 = re.compile(" (packet|packet_num|PacketType|packet_type)([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
- ourPacketre7 = re.compile(
- "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
- "(count[*]p_len)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
outPacketLoginre = re.compile(
"([ ]*)PACKET_ID_(?P<name>[A-Z0-9_]+)([ ]*)=" +
"([ ]*)0x(?P<packet>[0-9a-fA-F]+),")
@@ -99,34 +86,7 @@ class Threeceam:
elif filt.search(file1):
with open(file2, "r") as f:
for line in f:
- m = self.ourPacketre4.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre5.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[2]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre6.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[3]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre7.findall(line)
- if len(m) > 0:
- for str in m:
- data = str[9]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
+ Utils.getOutPackets(line, self)
m = self.outPacketLoginre.findall(line)
if len(m) > 0:
for str in m:
@@ -134,30 +94,6 @@ class Threeceam:
while len(data) < 4:
data = "0" + data
self.loginPacketNameToId["PACKET_ID_" + str[1]] = data
- m = self.ourPacketre.findall(line)
- if len(m) == 0:
- m = self.ourPacketre3.findall(line)
- if len(m) > 0:
- for str in m:
- if str[9] == "0":
- continue
- data = str[9]
- if data == "cmd":
- continue
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
- m = self.ourPacketre2.findall(line)
- if len(m) > 0:
- for str in m:
- if str[2] == "0":
- continue
- data = str[2]
- if len(data) > 2 and data[0:2] == "0x":
- data = data[2:]
- while len(data) < 4:
- data = "0" + data
- self.addServerPacket(data)
m = self.serverpacketLoginOutre.findall(line)
if len(m) > 0:
for str in m:
diff --git a/servergreps/hercules/src/utils.py b/servergreps/hercules/src/utils.py
index b89051c..de42a36 100755
--- a/servergreps/hercules/src/utils.py
+++ b/servergreps/hercules/src/utils.py
@@ -10,6 +10,19 @@ class Utils:
casere = re.compile("^case 0x(?P<packet>[0-9a-fA-F]+)[:]")
charParseFunctionre = re.compile(
"(?P<function>chr->[0-9a-zA-Z_>-]+)([(]|[ ][(])");
+ ourPacketre = re.compile(
+ "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
+ "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+)([ ]*)[;]")
+ ourPacketre2 = re.compile("PacketType([ ]*)=([ ]*)(?P<name>[\w_]+);")
+ ourPacketre3 = re.compile(
+ "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
+ "(?P<offset>0)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
+ ourPacketre4 = re.compile(" cmd([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
+ ourPacketre5 = re.compile(
+ "(WFIFOW|WBUFW)([ ]*)[(]([ ]*)([\w>_-]+),([ ]*)" +
+ "(count[*]p_len)([ ]*)[)]([ ]*)=([ ]*)(?P<packet>[0-9\w]+)([ ]*)[;]")
+ ourPacketre6 = re.compile("int cmde([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
+ ourPacketre7 = re.compile(" (packet|packet_num|PacketType|packet_type)([ ]*)=([ ]*)0x(?P<packet>[0-9a-fA-F]+);")
@staticmethod
def enumCasePackets(fileName, startCode):
@@ -44,3 +57,60 @@ class Utils:
else:
yield (func, packets[0])
break
+
+
+ @staticmethod
+ def getOutPackets(line, server):
+ packets = []
+ m = Utils.ourPacketre4.findall(line)
+ if len(m) > 0:
+ for str in m:
+ data = str[2]
+ while len(data) < 4:
+ data = "0" + data
+ server.addServerPacket(data)
+ m = Utils.ourPacketre5.findall(line)
+ if len(m) > 0:
+ for str in m:
+ data = str[9]
+ while len(data) < 4:
+ data = "0" + data
+ server.addServerPacket(data)
+ m = Utils.ourPacketre.findall(line)
+ if len(m) == 0:
+ m = Utils.ourPacketre3.findall(line)
+ if len(m) > 0:
+ for str in m:
+ if str[9] == "0":
+ continue
+ data = str[9]
+ if data == "cmd":
+ continue
+ while len(data) < 4:
+ data = "0" + data
+ server.addServerPacket(data)
+ m = Utils.ourPacketre2.findall(line)
+ if len(m) > 0:
+ for str in m:
+ if str[2] == "0":
+ continue
+ data = str[2]
+ if len(data) > 2 and data[0:2] == "0x":
+ data = data[2:]
+ while len(data) < 4:
+ data = "0" + data
+ server.addServerPacket(data)
+ m = Utils.ourPacketre6.findall(line)
+ if len(m) > 0:
+ for str in m:
+ data = str[2]
+ while len(data) < 4:
+ data = "0" + data
+ server.addServerPacket(data)
+ m = Utils.ourPacketre7.findall(line)
+ if len(m) > 0:
+ for str in m:
+ data = str[3]
+ while len(data) < 4:
+ data = "0" + data
+ server.addServerPacket(data)