Simple Ruby

Ruby code posted by crackerjack
created at 12 Jan 03:01, updated at 24 May 13:51

Edit | Back
1
2
3
4
5
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
require 'rubygems'
require 'sinatra'
require 'haml'

require 'whois'

get '/' do
  haml :index
end

# whois
get '/whois' do
  haml :whois
end

post '/whois' do
  @host = params[:host]
  @results = Whois.whois(@host)

  haml :whois
end

# traceroute
get '/traceroute' do
  haml :traceroute
end

post '/traceroute' do
  @host = params[:host]

  # For security reasons, remove all quote
  # characters from the hostname
  @host.gsub!(/"/,'')
  
  @results = `traceroute "#{@host}"`

  haml :traceroute
end
541 Bytes in 5 ms with coderay