You're right, UDP scanning is inherently unreliable. You could do what nmap does and send a simple empty UDP packet to every port. The host will respond with an ICMP type 3 (Destination unreachable) packet if the port is closed. If it doesn't send back an ICMP message, the port is either open or behind a firewall which dropped your UDP packet (in the latter case you can forget about scanning for open ports with this method).

Actually, I'd suggest you look at using nmap for this task (maybe with one of the Nmap modules from CPAN), it has lots of inbuilt probes for specific services which can be used to more reliably detect whether a port is open, and the service version behind it. If you don't you should at least read the manpage, it also explains about ICMP response rate limiting in many operating systems.


There are ten types of people: those that understand binary and those that don't.

In reply to Re: UDP port scan? by tirwhan
in thread UDP port scan? by pileofrogs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.