Advertisement
r00t-3xp10it

phpipam.nse [check multiple vulnerabilities]

Sep 6th, 2016
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.88 KB | None | 0 0
  1. ---
  2. -- Nmap NSE phpipam.nse - Version 1.5
  3. -- Copy script to: /usr/share/nmap/scripts/phpipam.nse
  4. -- Update NSE database: sudo nmap --script-updatedb
  5. -- executing: nmap --script-help phpipam.nse
  6. -- executing: nmap -sV -Pn -p 80 --open --script phpipam.nse <target>
  7. -- executing: nmap -sS -Pn -p 80 --open --reason --script phpipam.nse --script-args uri=/phpipam.php <target>
  8. ---
  9.  
  10.  
  11. -- SCRIPT BANNER DESCRIPTION --
  12. description = [[
  13.  
  14. Module Author: r00t-3xp10it
  15. Vuln discover: Saeed reza
  16. NSE script to detect multiple vulnerabilitys in phpipam (1.2.1) open-source web IP address management application (IPAM).
  17. we can use script arguments to scan for a diferent url ( --script-args uri=<vulnerable url to scan> <target> ).
  18.  
  19. Some Syntax examples:
  20. nmap --script-help phpipam.nse
  21. nmap -sV -Pn -p 80 --script phpipam.nse <target>
  22. nmap -sV -Pn -p 80 --open --script phpipam.nse <target>
  23. nmap -sV -Pn -p 80 --open --reason --script phpipam.nse 192.168.1.0/24
  24. nmap -sS -Pn -p 80 --open --reason --script phpipam.nse --script-args uri=/phpipam.php <target>
  25. nmap -sS -T4 -iR 300 -Pn -p 80 --open --reason --script phpipam.nse -oN /root/phpipam-vuln-report.log
  26.  
  27. ]]
  28.  
  29. ---
  30. -- @usage
  31. -- nmap --script-help phpipam.nse
  32. -- nmap -sV -Pn -p 80 --script phpipam.nse <target>
  33. -- nmap -sV -Pn -p 80 --open --script phpipam.nse <target>
  34. -- nmap -sS -Pn -p 80 --open --reason --script phpipam.nse --script-args uri=/phpipam.php <target>
  35. -- nmap -sS -T4 -iR 300 -Pn -p 80 --open --reason --script phpipam.nse -oN /root/phpipam-vuln-report.log
  36. -- @output
  37. -- PORT   STATE SERVICE VERSION
  38. -- 80/tcp open  http    phpipam 1.2.1
  39. -- | phpipam: 1.2.1 multiple vulnerabilities
  40. -- |   State: VULNERABLE
  41. -- |   Returned: 200 (likelly exploitable)
  42. -- |     Disclosure date: 21 set 2016
  43. -- |     Vuln discover: Saeed reza
  44. -- |     Module Author: r00t-3xp10it
  45. -- |
  46. -- |     Description:
  47. -- |       phpipam is an open-source web IP address management application, its goal is to provide light
  48. -- |       modern and useful IP address management. It is php-based application with MySQL database backend,
  49. -- |       using jQuery libraries, ajax and some HTML5/CSS3 features.
  50. -- |       [SQLI GET] => http://[Site]/phpipam/?page=tools&section=changelog&subnetId=a&sPage=50'
  51. -- |       [XSS POST] => http://[Site]/phpipam/app/admin/widgets/edit.php/wid=1><SCRIPT>ALERT(DOCUMENT.COOKIE);</SCRIPT>&action=edit
  52. -- |
  53. -- |     References:
  54. -- |       Vendor: http://phpipam.net/
  55. -- |       Vuln Discover: http://0day.today/exploit/25375
  56. -- |       Module Author: https://sourceforge.net/u/peterubuntu10/profile/
  57. -- |_
  58. -- @args payload.uri the path name to search. Default: /phpipam.html
  59. ---
  60.  
  61. author = "r00t-3xp10it"
  62. license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
  63. categories = {"safe", "discovery", "vuln"}
  64.  
  65.  
  66.  
  67. -- DEPENDENCIES (lua nse libraries) --
  68. local stdnse = require ('stdnse') --> required to use nse arguments
  69. local shortport = require "shortport"
  70. local string = require "string"
  71. local http = require "http"
  72.  
  73.  
  74.  
  75. -- THE RULE SECTION --
  76. -- portrule = shortport.http --> updated to scan only the selected ports/proto/services
  77. portrule = shortport.port_or_service({80, 443}, "http, https", "tcp", "open")
  78. -- local uri = "/phpipam.html" --> updated to use script @args payload.uri
  79. local uri = stdnse.get_script_args(SCRIPT_NAME..".uri") or "/phpipam.html"
  80.  
  81.  
  82.  
  83. -- THE ACTION SECTION --
  84. action = function(host, port)
  85. local response = http.get(host, port, uri)
  86.  
  87.   -- check if target its phpipam based website
  88.   if ( response.status == 200 ) then
  89.     local title = string.match(response.body, "<[Tt][Ii][Tt][Ll][Ee][^>]*>phpipam ([^<]*)</[Tt][Ii][Tt][Ll][Ee]>")
  90.  
  91.     -- check the phpipam version installed
  92.     if ( title == "1.2.1" ) then
  93.       -- VULNERABLE nse module output display
  94.       return "1.2.1 multiple vulnerabilities\n   STATUS: VULNERABLE\n   Returned: "..response.status.." (likelly exploitable)\n     Disclosure date: 21 set 2016\n     Vuln discover: Saeed reza\n     Module Author: r00t-3xp10it\n\n     Description:\n       phpipam is an open-source web IP address management application, its goal is to provide light\n       modern and useful IP address management. It is php-based application with MySQL database backend,\n       using jQuery libraries, ajax and some HTML5/CSS3 features.\n       [SQLI GET] => http://[Site]/phpipam/?page=tools&section=changelog&subnetId=a&sPage=50'\n       [XSS POST] => http://[Site]/phpipam/app/admin/widgets/edit.php/wid=1><SCRIPT>ALERT(DOCUMENT.COOKIE);</SCRIPT>&action=edit\n\n     References:\n       Vendor: http://phpipam.net/\n       Vuln Discover: http://0day.today/exploit/25375\n       Module Author: https://sourceforge.net/u/peterubuntu10/profile/\n\n"
  95.     else
  96.       -- NOT VULNERABLE version install found (1.2.1) of phpipam in target system
  97.       return "\n  STATUS: NOT VULNERABLE\n    "..uri..": 200 Found\n    version: "..title.."\n    Module Author: r00t-3xp10it\n\n"
  98.     end
  99.  
  100.   -- check for diferent google return codes
  101.   -- to display a NON VULNERABLE output...
  102.   elseif ( response.status == 404 ) then
  103.     return "\n  STATUS: NOT VULNERABLE\n    Returned: "..response.status.." NOT FOUND\n    Module Author: r00t-3xp10it\n\n"
  104.   elseif ( response.status == 400 ) then
  105.     return "\n  STATUS: NOT VULNERABLE\n    Returned: "..response.status.." BAD REQUEST\n    Module Author: r00t-3xp10it\n\n"
  106.   elseif ( response.status == 401 ) then
  107.     return "\n  STATUS: NOT VULNERABLE\n    Returned: "..response.status.." UNAUTHORIZED\n    Module Author: r00t-3xp10it\n\n"
  108.   elseif ( response.status == 302 ) then
  109.     return "\n  STATUS: NOT VULNERABLE\n    Returned: "..response.status.." REDIRECTED\n    Module Author: r00t-3xp10it\n\n"
  110.   else
  111.     -- I dont want to write more response.status ... so i let my module displays the returned code :D
  112.     return "\n  STATUS: NOT VULNERABLE\n    Returned: "..response.status.." response code\n    Module Author: r00t-3xp10it\n\n"
  113.   end
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement