/checks/http/content/content.rb

https://github.com/intrigueio/intrigue-ident · Ruby · 63 lines · 62 code · 1 blank · 0 comment · 0 complexity · 189340f808f1c56793fd4a0ca458ab04 MD5 · raw file

  1. module Intrigue
  2. module Ident
  3. module Check
  4. class Content < Intrigue::Ident::Check::Base
  5. def generate_checks(url)
  6. [
  7. {
  8. type: "content",
  9. name:"MurmurHash Page Content",
  10. dynamic_result: lambda { |d| _body_raw_binary_checksum_mmh3(d) },
  11. paths: [ { path: "#{url}", follow_redirects: true } ],
  12. },
  13. {
  14. type: "content",
  15. name:"MurmurHash Favicon",
  16. dynamic_result: lambda { |d| _body_raw_binary_checksum_mmh3(d) },
  17. paths: [ { path: "#{url}/favicon.ico", follow_redirects: false } ],
  18. },
  19. {
  20. type: "content",
  21. name:"Location-Based Redirect",
  22. dynamic_result: lambda { |d| _first_header_capture(d,/^location:(.*)$/i) },
  23. paths: [ { path: "#{url}", follow_redirects: false } ],
  24. },
  25. {
  26. type: "content",
  27. name:"Directory Listing Detected",
  28. dynamic_result: lambda { |d| (
  29. _first_title_match(d,/Index of \//) ||
  30. _first_body_match(d, /<h1>Index of \//) ||
  31. _first_body_match(d, /\[To Parent Directory\]/) ) ? true : false },
  32. issues: ["directory_listing_detected"],
  33. paths: [ { path: "#{url}", follow_redirects: true } ],
  34. },
  35. {
  36. type: "content",
  37. name:"Form Detected",
  38. dynamic_result: lambda { |d| _first_body_match(d,/\<form/) ? true : false },
  39. paths: [ { path: "#{url}", follow_redirects: true } ],
  40. },
  41. {
  42. type: "content",
  43. name:"File Upload Form Detected",
  44. dynamic_result: lambda { |d| _first_body_match(d,/enctype=\"multipart\/form-data/) ? true : false },
  45. paths: [ { path: "#{url}", follow_redirects: true } ],
  46. },
  47. {
  48. type: "content",
  49. name:"Email Addresses Detected",
  50. dynamic_result: lambda { |d|
  51. email_address_regex = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
  52. captures = _all_body_captures(d,email_address_regex) || []
  53. captures.select{|e| !(e =~ /\.png$/) }.compact
  54. },
  55. paths: [ { path: "#{url}", follow_redirects: true } ],
  56. }
  57. ]
  58. end
  59. end
  60. end
  61. end
  62. end