home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Networking / nmap-5.00-setup.exe / scripts / skypev2-version.nse < prev    next >
Text File  |  2009-07-06  |  1KB  |  43 lines

  1. description = [[
  2. Detects the Skype version 2 service.
  3. ]]
  4. author = "Brandon Enright <bmenrigh@ucsd.edu>" 
  5. license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
  6. categories = {"version"}
  7.  
  8. require "comm"
  9.  
  10. portrule = function(host, port)
  11.         return (port.number == 80 or port.number == 443 or
  12.                 port.service == nil or port.service == "" or
  13.                 port.service == "unknown")
  14.                and port.protocol == "tcp" and port.state == "open"
  15.                and port.service ~= "http" and port.service ~= "ssl/http"
  16. end
  17.  
  18. action = function(host, port)
  19.         local status, result = comm.exchange(host, port,
  20.                 "GET / HTTP/1.0\r\n\r\n", {bytes=26, proto=port.protocol})
  21.         if (not status) then
  22.                 return
  23.         end
  24.         if (result ~= "HTTP/1.0 404 Not Found\r\n\r\n") then
  25.                 return
  26.         end
  27.         -- So far so good, now see if we get random data for another request
  28.         status, result = comm.exchange(host, port,
  29.                 "random data\r\n\r\n", {bytes=15, proto=port.protocol})
  30.  
  31.         if (not status) then
  32.                 return
  33.         end
  34.         if string.match(result, "[^%s!-~].*[^%s!-~].*[^%s!-~]") then
  35.                 -- Detected
  36.                 port.version.name = "skype2"
  37.                 port.version.product = "Skype"
  38.                 nmap.set_port_version(host, port, "hardmatched")
  39.                 return  
  40.         end
  41.         return
  42. end
  43.