recvfrom_nonblock need flag = 0, not nil
parent
f1fa65b9a3
commit
d5bc6a089f
|
@ -33,8 +33,10 @@ class Datagram < Rex::Post::Meterpreter::Channel
|
||||||
'udp'
|
'udp'
|
||||||
end
|
end
|
||||||
|
|
||||||
def recvfrom_nonblock(length,flags = nil)
|
def recvfrom_nonblock(length, flags = 0)
|
||||||
return [super(length, flags)[0], super(length, flags)[0]]
|
data = super(length, flags)[0]
|
||||||
|
sockaddr = super(length, flags)[0]
|
||||||
|
[data, sockaddr]
|
||||||
end
|
end
|
||||||
|
|
||||||
def send(buf, flags, saddr)
|
def send(buf, flags, saddr)
|
||||||
|
@ -53,17 +55,12 @@ class Datagram < Rex::Post::Meterpreter::Channel
|
||||||
)
|
)
|
||||||
|
|
||||||
if peerhost && peerport
|
if peerhost && peerport
|
||||||
# Maxlen here is 65507, to ensure we dont overflow, we need to write twice
|
# A datagram can be maximum 65507 bytes, truncate longer messages
|
||||||
# If the other side has a full 64k, handle by splitting up the datagram and
|
rsock.syswrite(data[0..65506])
|
||||||
# writing multiple times along with the sockaddr. Consumers calling recvfrom
|
|
||||||
# repeatedly will buffer up all the pieces.
|
# We write the data and sockaddr data to the local socket, the pop it
|
||||||
while data.length > 65507
|
# back in recvfrom_nonblock.
|
||||||
rsock.syswrite(data[0..65506])
|
rsock.syswrite(Rex::Socket.to_sockaddr(peerhost, peerport))
|
||||||
rsock.syswrite(Rex::Socket.to_sockaddr(peerhost,peerport))
|
|
||||||
data = data - data[0..65506]
|
|
||||||
end
|
|
||||||
rsock.syswrite(data)
|
|
||||||
rsock.syswrite(Rex::Socket.to_sockaddr(peerhost,peerport))
|
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue