Skip to content

Commit 07438d3

Browse files
committed
Land rapid7#4704, Asterisk 1.8 support for IAX2 stack
rapid7/warvox#27
2 parents ef21605 + ffe0e52 commit 07438d3

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

lib/rex/proto/iax2/call.rb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ def register
7272
end
7373

7474
chall = nil
75-
if res[2][14] == "\x00\x03" and res[2][IAX_IE_CHALLENGE_DATA]
75+
76+
# Look for IAX_AUTH_MD5 (2) as an available auth method
77+
if res[2][14].unpack("n")[0] & 2 <= 0
78+
dprint("REGAUTH: MD5 authentication is not enabled on the server")
79+
return
80+
end
81+
82+
if res[2][IAX_IE_CHALLENGE_DATA]
7683
self.dcall = res[0][0]
7784
chall = res[2][IAX_IE_CHALLENGE_DATA]
7885
end
@@ -114,9 +121,21 @@ def dial(number)
114121
# Handle authentication if its requested
115122
if res[1] == IAX_SUBTYPE_AUTHREQ
116123
chall = nil
117-
if res[2][14] == "\x00\x03" and res[1][15]
124+
125+
# Look for IAX_AUTH_MD5 (2) as an available auth method
126+
if res[2][14].unpack("n")[0] & 2 <= 0
127+
dprint("REGAUTH: MD5 authentication is not enabled on the server")
128+
return
129+
end
130+
131+
if res[2][IAX_IE_CHALLENGE_DATA]
118132
self.dcall = res[0][0]
119-
chall = res[2][15]
133+
chall = res[2][IAX_IE_CHALLENGE_DATA]
134+
end
135+
136+
if chall.nil?
137+
dprint("REGAUTH: No challenge data received")
138+
return
120139
end
121140

122141
self.client.send_authrep_chall_response(self, chall)

0 commit comments

Comments
 (0)