Metasploit mailing list archives

sending UDP to broadcast address


From: dninja at gmail.com (Robin Wood)
Date: Sun, 12 Jul 2009 00:34:27 +0100

Hi
I'm trying to write a aux module which sends UDP traffic to the
broadcast address. I've got the following code but it doesn't send any
data out.

            # Create an unbound UDP socket
            udp_sock = Rex::Socket::Udp.create(
                'Context'   =>
                    {
                        'Msf'        => framework,
                        'MsfExploit' => self,
                    }
            )

            request = DHCP::Request.new
            payload = request.pack
            sent = udp_sock.sendto(payload, "255.255.255.255", 67)
            if sent == nil
                print "failed to send to broadcast\n"
            end

I've tried <broadcast> and still can't get anything. I've dug through
the socket and udp libraries and can't work out what I'm doing wrong.
If I put a unicast IP or a hostname as the sendto parameter the code
works.

What am I doing wrong?

Robin


Current thread: