Guest User

MOBOTIX camera detection NSE script

a guest
Jun 6th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. local http = require "http"
  2. local nmap = require "nmap"
  3. local shortport = require "shortport"
  4. local stdnse = require "stdnse"
  5. local string = require "string"
  6.  
  7. description = [[
  8. Detects HTTP cameras.
  9.  
  10. Based on HTTP title script.
  11. ]]
  12.  
  13. ---
  14. --@output
  15. -- Nmap scan report for scanme.nmap.org (74.207.244.221)
  16. -- PORT   STATE SERVICE
  17. -- 80/tcp open  http
  18. -- |_http-title: Go ahead and ScanMe!
  19. --
  20. -- @xmloutput
  21. -- <elem key="title">Go ahead and ScanMe!</elem>
  22. -- @xmloutput
  23. -- <elem key="title">Wikipedia, the free encyclopedia</elem>
  24. -- <elem key="redirect_url">http://en.wikipedia.org/wiki/Main_Page</elem>
  25.  
  26. author = "Anonymous hacker"
  27.  
  28. license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
  29.  
  30. categories = {"default", "discovery", "safe"}
  31.  
  32.  
  33. portrule = shortport.http
  34.  
  35. action = function(host, port)
  36.   local resp, redirect_url, title
  37.  
  38.   resp = http.get( host, port, '/' )
  39.  
  40.   -- check for a redirect
  41.   if resp.location then
  42.     redirect_url = resp.location[#resp.location]
  43.     if resp.status and tostring( resp.status ):match( "30%d" ) then
  44.       resp = http.get( host, port, redirect_url )
  45.     end
  46.   end
  47.  
  48.   if ( not(resp.body) ) then
  49.     return
  50.   end
  51.  
  52.   -- try and match mobotix camera keywords
  53.   local match = string.match(resp.body, "[Mm][Oo][Bb][Oo][Tt][Ii][Xx]")
  54.  
  55.   if match then
  56.     return_val = "MOBOTIX camera detected"
  57.   else
  58.     return
  59.   end
  60.  
  61.  
  62.   local output_tab = stdnse.output_table()
  63.   output_tab.title = return_val
  64.   --output_tab.redirect_url = redirect_url
  65.  
  66.   local output_str = return_val
  67.  
  68.   return output_tab, output_str
  69. end
Advertisement
Add Comment
Please, Sign In to add comment