Class: ViolentRuby::BannerGrabber
- Inherits:
-
Object
- Object
- ViolentRuby::BannerGrabber
- Defined in:
- lib/violent_ruby/banner_grabber/banner_grabber.rb
Overview
This Banner Grabber class is meant to provide a simple interface to, well… grab banners from services running on a target to determine the potential attack vectors avaialable to you.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#connect(ip, port) ⇒ TCPSocket, false
Connect to a given IP address and port.
-
#grab(args = {}) {|Hash| ... } ⇒ Object
(also: #grab!)
Attempt to grab the banner.
-
#initialize(args = {}) {|Hash| ... } ⇒ void
constructor
Create a new Banner Grabber.
Constructor Details
#initialize(args = {}) {|Hash| ... } ⇒ void
Create a new Banner Grabber. If a block if given,
47 48 49 50 |
# File 'lib/violent_ruby/banner_grabber/banner_grabber.rb', line 47 def initialize(args = {}) @ips = use_ips(args) if args[:ips] || args[:ip] @ports = use_ports(args) if args[:ports] || args[:port] end |
Instance Attribute Details
#ips ⇒ Object
33 34 35 |
# File 'lib/violent_ruby/banner_grabber/banner_grabber.rb', line 33 def ips @ips end |
#ports ⇒ Object
35 36 37 |
# File 'lib/violent_ruby/banner_grabber/banner_grabber.rb', line 35 def ports @ports end |
Instance Method Details
#connect(ip, port) ⇒ TCPSocket, false
Connect to a given IP address and port.
89 90 91 92 93 |
# File 'lib/violent_ruby/banner_grabber/banner_grabber.rb', line 89 def connect(ip, port) TCPSocket.new(ip, port) rescue false end |
#grab(args = {}) {|Hash| ... } ⇒ Object Also known as: grab!
Attempt to grab the banner. Optionally, an HTTP option can help simulate HTTP GET requests to a webserver.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/violent_ruby/banner_grabber/banner_grabber.rb', line 59 def grab(args = {}) ips = use_ips(args) ports = use_ports(args) ips.each do |ip| ports.each do |port| if socket = connect(ip, port) if args[:http] socket.puts("GET / HTTP/1.1\r\nHost:3.1.3.3.7\r\n\r\n") end unless = socket.recv(1024) = false end end if socket yield format_result(ip, port, true, ) socket.close else yield format_result(ip, port, false) end end end end |