PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/nselib/data/http-default-accounts-fingerprints.lua

https://github.com/prakashgamit/nmap
Lua | 252 lines | 181 code | 15 blank | 56 comment | 12 complexity | 1e4835611d99bf6ded2141234a74d016 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, LGPL-2.0, LGPL-2.1
  1. local http = require "http"
  2. local table = require "table"
  3. local url = require "url"
  4. ---
  5. -- http-default-accounts-fingerprints.lua
  6. -- This file contains fingerprint data for http-default-accounts.nse
  7. --
  8. -- STRUCTURE:
  9. -- * <code>name</code> - Descriptive name
  10. -- * <code>category</code> - Category
  11. -- * <code>login_combos</code>
  12. ---- * <code>username</code> - Default username
  13. ---- * <code>password</code> - Default password
  14. -- * <code>paths</code> - Paths table containing the possible location of the target
  15. -- * <code>target_check</code> - Validation function of the target (optional)
  16. -- * <code>login_check</code> - Login function of the target
  17. --
  18. -- TODO: Update the functionality of <code>target_check</code> to differentiate
  19. -- between valid HTTP/200 and a custom error page.
  20. ---
  21. ---
  22. -- Requests given path using basic authentication.
  23. -- @param host Host table
  24. -- @param port Port table
  25. -- @param path Path to request
  26. -- @param user Username for Basic Auth
  27. -- @param pass Password for Basic Auth
  28. -- @param digest_auth Digest Authentication
  29. -- @return True if login in was successful
  30. ---
  31. local function try_http_basic_login(host, port, path, user, pass, digest_auth)
  32. local credentials = {username = user, password = pass, digest = digest_auth}
  33. local req = http.get(host, port, path, {no_cache=true, auth=credentials, redirect_ok = false})
  34. if req.status and req.status ~= 401 and req.status ~= 403 then
  35. return true
  36. end
  37. return false
  38. end
  39. ---
  40. -- Tries to login with a http post, if the FAIL string is not found
  41. -- we assume login in was successful
  42. -- @param host Host table
  43. -- @param port Port table
  44. -- @param target Target file
  45. -- @param failstr String shown when login in fails
  46. -- @param params Post parameters
  47. -- @param follow_redirects True if you want redirects to be followed
  48. -- @return True if login in was successful
  49. ---
  50. local function try_http_post_login(host, port, path, target, failstr, params, follow_redirects)
  51. local req = http.post(host, port, url.absolute(path, target), {no_cache=true}, nil, params)
  52. if not req.status then return false end
  53. local status = tonumber(req.status) or 0
  54. if follow_redirects and ( status > 300 and status < 400 ) then
  55. req = http.get(host, port, url.absolute(path, req.header.location), { no_cache = true, redirect_ok = false })
  56. end
  57. if req.status and req.status ~= 404 and not(http.response_contains(req, failstr)) then
  58. return true
  59. end
  60. return false
  61. end
  62. ---
  63. -- Returns authentication realm advertised in an HTTP response
  64. -- @param response HTTP response object, such as a result from http.get()
  65. -- @return realm found in response header WWW-Authenticate
  66. -- (or nil if not present)
  67. ---
  68. local function http_auth_realm(response)
  69. local auth = response.header["www-authenticate"] or ""
  70. return auth:match('%srealm="([^"]*)')
  71. end
  72. fingerprints = {}
  73. ---
  74. --WEB
  75. ---
  76. table.insert(fingerprints, {
  77. name = "Cacti",
  78. category = "web",
  79. paths = {
  80. {path = "/cacti/"}
  81. },
  82. target_check = function (host, port, path, response)
  83. return response.status == 200
  84. end,
  85. login_combos = {
  86. {username = "admin", password = "admin"}
  87. },
  88. login_check = function (host, port, path, user, pass)
  89. return try_http_post_login(host, port, path, "index.php", "Invalid User Name/Password", {action="login", login_username=user, login_password=pass}, false)
  90. end
  91. })
  92. table.insert(fingerprints, {
  93. name = "Apache Tomcat",
  94. category = "web",
  95. paths = {
  96. {path = "/manager/html/"},
  97. {path = "/tomcat/manager/html/"}
  98. },
  99. target_check = function (host, port, path, response)
  100. return http_auth_realm(response) == "Tomcat Manager Application"
  101. end,
  102. login_combos = {
  103. {username = "tomcat", password = "tomcat"},
  104. {username = "admin", password = "admin"},
  105. -- http://cve.mitre.org/cgi-bin/cvename.cgi?name=2009-4189
  106. {username = "ovwebusr", password = "OvW*busr1"},
  107. -- http://cve.mitre.org/cgi-bin/cvename.cgi?name=2009-4188
  108. {username = "j2deployer", password = "j2deployer"}
  109. },
  110. login_check = function (host, port, path, user, pass)
  111. return try_http_basic_login(host, port, path, user, pass, false)
  112. end
  113. })
  114. table.insert(fingerprints, {
  115. name = "Apache Axis2",
  116. category = "web",
  117. paths = {
  118. {path = "/axis2/axis2-admin/"}
  119. },
  120. target_check = function (host, port, path, response)
  121. return response.status == 200
  122. end,
  123. login_combos = {
  124. {username = "admin", password = "axis2"}
  125. },
  126. login_check = function (host, port, path, user, pass)
  127. return try_http_post_login(host, port, path, "login", "Invalid auth credentials!", {submit="+Login+", userName=user, password=pass})
  128. end
  129. })
  130. ---
  131. --ROUTERS
  132. ---
  133. table.insert(fingerprints, {
  134. name = "Arris 2307",
  135. category = "routers",
  136. paths = {
  137. {path = "/logo_t.gif"}
  138. },
  139. target_check = function (host, port, path, response)
  140. return response.status == 200
  141. end,
  142. login_combos = {
  143. {username = "", password = ""}
  144. },
  145. login_check = function (host, port, path, user, pass)
  146. return try_http_post_login(host, port, path, "login.cgi", "Login Error !!", {action="submit", page="", logout="", pws=pass})
  147. end
  148. })
  149. table.insert(fingerprints, {
  150. name = "Cisco IOS",
  151. category = "routers",
  152. paths = {
  153. {path = "/exec/show/log/CR"},
  154. {path = "/level/15/exec/-/configure/http"},
  155. {path = "/level/15/exec/-"},
  156. {path = "/level/15/"}
  157. },
  158. target_check = function (host, port, path, response)
  159. local realm = http_auth_realm(response) or ""
  160. -- Exact PCRE: "^level 15?( or view)? access$"
  161. return realm:gsub("_"," "):find("^level 15? .*access$")
  162. end,
  163. login_combos = {
  164. {username = "", password = ""},
  165. {username = "cisco", password = "cisco"}
  166. },
  167. login_check = function (host, port, path, user, pass)
  168. return try_http_basic_login(host, port, path, user, pass, false)
  169. end
  170. })
  171. table.insert(fingerprints, {
  172. name = "Cisco WAP200",
  173. category = "routers",
  174. paths = {
  175. {path = "/StatusLan.htm"}
  176. },
  177. target_check = function (host, port, path, response)
  178. return http_auth_realm(response) == "Linksys WAP200"
  179. end,
  180. login_combos = {
  181. {username = "admin", password = "admin"}
  182. },
  183. login_check = function (host, port, path, user, pass)
  184. return try_http_basic_login(host, port, path, user, pass, false)
  185. end
  186. })
  187. table.insert(fingerprints, {
  188. name = "Cisco WAP55AG",
  189. category = "routers",
  190. paths = {
  191. {path = "/WPA_Preshared.asp"}
  192. },
  193. target_check = function (host, port, path, response)
  194. return http_auth_realm(response) == "Linksys WAP55AG"
  195. end,
  196. login_combos = {
  197. {username = "", password = "admin"}
  198. },
  199. login_check = function (host, port, path, user, pass)
  200. return try_http_basic_login(host, port, path, user, pass, false)
  201. end
  202. })
  203. table.insert(fingerprints, {
  204. name = "Nortel VPN Router",
  205. category = "routers",
  206. paths = {
  207. {path = "/manage/bdy_sys.htm"}
  208. },
  209. target_check = function (host, port, path, response)
  210. return http_auth_realm(response) == "Management(1)"
  211. end,
  212. login_combos = {
  213. {username = "admin", password = "setup"}
  214. },
  215. login_check = function (host, port, path, user, pass)
  216. return try_http_basic_login(host, port, path, user, pass, false)
  217. end
  218. })
  219. ---
  220. --Digital recorders
  221. ---
  222. table.insert(fingerprints, {
  223. name = "Digital Sprite 2",
  224. category = "security",
  225. paths = {
  226. {path = "/frmpages/index.html"}
  227. },
  228. target_check = function (host, port, path, response)
  229. return http_auth_realm(response) == "WebPage Configuration"
  230. end,
  231. login_combos = {
  232. {username = "dm", password = "web"}
  233. },
  234. login_check = function (host, port, path, user, pass)
  235. return try_http_basic_login(host, port, path, user, pass, true)
  236. end
  237. })