Skip to content

Commit

Permalink
Merge pull request IOActive#1 from niekt0/master
Browse files Browse the repository at this point in the history
nice improvement, thanks
  • Loading branch information
hugsy committed Feb 1, 2015
2 parents 42be554 + e345128 commit cd35313
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions jdwp-shellifier.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/python
################################################################################
#
# Univeral JDWP shellifier
Expand Down Expand Up @@ -109,6 +110,8 @@ def read_reply(self):

def parse_entries(self, buf, formats, explicit=True):
entries = []
index = 0


if explicit:
nb_entries = struct.unpack(">I", buf[:4])[0]
Expand All @@ -120,27 +123,28 @@ def parse_entries(self, buf, formats, explicit=True):
data = {}
for fmt, name in formats:
if fmt == "L" or fmt == 8:
data[name] = int(struct.unpack(">Q", buf[:8])[0])
buf = buf[8:]
data[name] = int(struct.unpack(">Q",buf[index:index+8]) [0])
index += 8
elif fmt == "I" or fmt == 4:
data[name] = int(struct.unpack(">I", buf[:4])[0])
buf = buf[4:]
data[name] = int(struct.unpack(">I", buf[index:index+4])[0])
index += 4
elif fmt == 'S':
l = struct.unpack(">I", buf[:4])[0]
data[name] = buf[4:4+l]
buf = buf[4+l:]
l = struct.unpack(">I", buf[index:index+4])[0]
data[name] = buf[index+4:index+4+l]
index += 4+l
elif fmt == 'C':
data[name] = ord(struct.unpack(">c", buf[:1])[0])
buf = buf[1:]
elif fmt == 'Z': # zpecifics
t = ord(struct.unpack(">c", buf[:1])[0])
if t == 115: # string (objid)
s = self.solve_string(buf[1:9])
data[name] = ord(struct.unpack(">c", buf[index])[0])
index += 1
elif fmt == 'Z':
t = ord(struct.unpack(">c", buf[index])[0])
if t == 115:
s = self.solve_string(buf[index+1:index+9])
data[name] = s
buf = buf[9:]
elif t == 73: # int
data[name] = struct.unpack(">I", buf[1:5])[0]
buf = struct.unpack(">I", buf[5:9])
index+=9
elif t == 73:
data[name] = struct.unpack(">I", buf[index+1:index+5])[0]
buf = struct.unpack(">I", buf[index+5:index+9])
index=0

else:
print "Error"
Expand Down

0 comments on commit cd35313

Please sign in to comment.