Class: Yawast::Scanner::Generic
- Inherits:
-
Object
- Object
- Yawast::Scanner::Generic
- Defined in:
- lib/scanner/generic.rb
Class Method Summary collapse
- .check_options(uri) ⇒ Object
- .check_propfind(uri) ⇒ Object
- .check_trace(uri) ⇒ Object
- .directory_search(uri, recursive, banner = true) ⇒ Object
- .head_info(head) ⇒ Object
- .server_info(uri, options) ⇒ Object
Class Method Details
.check_options(uri) ⇒ Object
254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/scanner/generic.rb', line 254 def self.(uri) begin req = Yawast::Shared::Http.get_http(uri) req.use_ssl = uri.scheme == 'https' headers = Yawast::Shared::Http.get_headers res = req.request(Options.new('/', headers)) if res['Public'] != nil Yawast::Utilities.puts_info "Public HTTP Verbs (OPTIONS): #{res['Public']}" puts '' end end end |
.check_propfind(uri) ⇒ Object
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/scanner/generic.rb', line 285 def self.check_propfind(uri) begin req = Yawast::Shared::Http.get_http(uri) req.use_ssl = uri.scheme == 'https' headers = Yawast::Shared::Http.get_headers res = req.request(Propfind.new('/', headers)) if res.code.to_i <= 400 && res.body.length > 0 && res['Content-Type'] == 'text/xml' Yawast::Utilities.puts_warn 'Possible Info Disclosure: PROPFIND Enabled' puts "\t\t\"curl -X PROPFIND #{uri}\"" puts '' end end end |
.check_trace(uri) ⇒ Object
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/scanner/generic.rb', line 269 def self.check_trace(uri) begin req = Yawast::Shared::Http.get_http(uri) req.use_ssl = uri.scheme == 'https' headers = Yawast::Shared::Http.get_headers res = req.request(Trace.new('/', headers)) if res.body.include? 'TRACE / HTTP/1.1' Yawast::Utilities.puts_warn 'HTTP TRACE Enabled' puts "\t\t\"curl -X TRACE #{uri}\"" puts '' end end end |
.directory_search(uri, recursive, banner = true) ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/scanner/generic.rb', line 215 def self.directory_search(uri, recursive, = true) if if recursive puts 'Recursively searching for common directories (this will take a while)...' else puts 'Searching for common directories...' end end begin req = Yawast::Shared::Http.get_http(uri) req.use_ssl = uri.scheme == 'https' req.keep_alive_timeout = 600 headers = Yawast::Shared::Http.get_headers req.start do |http| File.open(File.dirname(__FILE__) + '/../resources/common.txt', "r") do |f| f.each_line do |line| check = uri.copy check.path = check.path + "#{line.strip}/" res = http.head(check, headers) if res.code == '200' Yawast::Utilities.puts_info "\tFound: '#{check.to_s}'" directory_search check, recursive, false if recursive elsif res.code == '301' Yawast::Utilities.puts_info "\tFound Redirect: '#{check.to_s} -> '#{res['Location']}'" end end end end rescue => e Yawast::Utilities.puts_error "Error searching for directories (#{e.message})" end puts '' if end |
.head_info(head) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/scanner/generic.rb', line 82 def self.head_info(head) begin server = '' powered_by = '' = Array.new pingback = '' = '' = '' csp = '' backend_server = '' runtime = '' xss_protection = '' via = '' hpkp = '' Yawast::Utilities.puts_info 'HEAD:' head.each do |k, v| Yawast::Utilities.puts_info "\t\t#{k}: #{v}" server = v if k.downcase == 'server' powered_by = v if k.downcase == 'x-powered-by' pingback = v if k.downcase == 'x-pingback' = v if k.downcase == 'x-frame-options' = v if k.downcase == 'x-content-type-options' csp = v if k.downcase == 'content-security-policy' backend_server = v if k.downcase == 'x-backend-server' runtime = v if k.downcase == 'x-runtime' xss_protection = v if k.downcase == 'x-xss-protection' via = v if k.downcase == 'via' hpkp = v if k.downcase == 'public-key-pins' if k.downcase == 'set-cookie' #this chunk of magic manages to properly split cookies, when multiple are sent together v.gsub(/(,([^;,]*=)|,$)/) { "\r\n#{$2}" }.split(/\r\n/).each { |c| .push(c) } end end puts '' if server != '' Yawast::Scanner::Apache.(server) Yawast::Scanner::Php.(server) Yawast::Scanner::Iis.(server) Yawast::Scanner::Nginx.(server) if server == 'cloudflare-nginx' Yawast::Utilities.puts_info 'NOTE: Server appears to be Cloudflare; WAF may be in place.' puts end end if powered_by != '' Yawast::Utilities.puts_warn "X-Powered-By Header Present: #{powered_by}" end if xss_protection == '0' Yawast::Utilities.puts_warn 'X-XSS-Protection Disabled Header Present' end unless pingback == '' Yawast::Utilities.puts_info "X-Pingback Header Present: #{pingback}" end unless runtime == '' if runtime.is_number? Yawast::Utilities.puts_warn 'X-Runtime Header Present; likely indicates a RoR application' else Yawast::Utilities.puts_warn "X-Runtime Header Present: #{runtime}" end end unless backend_server == '' Yawast::Utilities.puts_warn "X-Backend-Server Header Present: #{backend_server}" end unless via == '' Yawast::Utilities.puts_warn "Via Header Present: #{via}" end if == '' Yawast::Utilities.puts_warn 'X-Frame-Options Header Not Present' else if .downcase == 'allow' Yawast::Utilities.puts_vuln "X-Frame-Options Header: #{frame_options}" else Yawast::Utilities.puts_info "X-Frame-Options Header: #{frame_options}" end end if == '' Yawast::Utilities.puts_warn 'X-Content-Type-Options Header Not Present' else Yawast::Utilities.puts_info "X-Content-Type-Options Header: #{content_options}" end if csp == '' Yawast::Utilities.puts_warn 'Content-Security-Policy Header Not Present' end if hpkp == '' Yawast::Utilities.puts_warn 'Public-Key-Pins Header Not Present' end puts '' unless .empty? Yawast::Utilities.puts_info 'Cookies:' .each do |val| Yawast::Utilities.puts_info "\t\t#{val.strip}" elements = val.strip.split(';') #check for secure cookies unless elements.include? ' Secure' Yawast::Utilities.puts_warn "\t\t\tCookie missing Secure flag" end #check for HttpOnly cookies unless elements.include? ' HttpOnly' Yawast::Utilities.puts_warn "\t\t\tCookie missing HttpOnly flag" end end puts '' end puts '' rescue => e Yawast::Utilities.puts_error "Error getting head information: #{e.message}" raise end end |
.server_info(uri, options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/scanner/generic.rb', line 6 def self.server_info(uri, ) begin puts 'DNS Information:' dns = Resolv::DNS.new Resolv::DNS.open do |resv| a = resv.getresources(uri.host, Resolv::DNS::Resource::IN::A) unless a.empty? a.each do |ip| begin host_name = dns.getname(ip.address) rescue host_name = 'N/A' end Yawast::Utilities.puts_info "\t\t#{ip.address} (#{host_name})" # if address is private, force internal SSL mode, don't show links if IPAddr.new(ip.address.to_s, Socket::AF_INET).private? .internalssl = true else puts "\t\t\t\thttps://www.shodan.io/host/#{ip.address}" puts "\t\t\t\thttps://censys.io/ipv4/#{ip.address}" end end end aaaa = resv.getresources(uri.host, Resolv::DNS::Resource::IN::AAAA) unless aaaa.empty? aaaa.each do |ip| begin host_name = dns.getname(ip.address) rescue host_name = 'N/A' end Yawast::Utilities.puts_info "\t\t#{ip.address} (#{host_name})" # if address is private, force internal SSL mode, don't show links if IPAddr.new(ip.address.to_s, Socket::AF_INET6).private? .internalssl = true else puts "\t\t\t\thttps://www.shodan.io/host/#{ip.address.to_s.downcase}" end end end txt = resv.getresources(uri.host, Resolv::DNS::Resource::IN::TXT) unless txt.empty? txt.each do |rec| Yawast::Utilities.puts_info "\t\tTXT: #{rec.data}" end end mx = resv.getresources(uri.host, Resolv::DNS::Resource::IN::MX) unless mx.empty? mx.each do |rec| Yawast::Utilities.puts_info "\t\tMX: #{rec.exchange} (#{rec.preference})" end end ns = resv.getresources(uri.host, Resolv::DNS::Resource::IN::NS) unless ns.empty? ns.each do |rec| Yawast::Utilities.puts_info "\t\tNS: #{rec.name}" end end end puts rescue => e Yawast::Utilities.puts_error "Error getting basic information: #{e.message}" raise end end |