Module: Webshellruby::Webshell

Defined in:
lib/webshellruby/webshell.rb

Constant Summary collapse

@@base_url =
'http://webshell.io/api'

Instance Method Summary collapse

Instance Method Details

#webshell_exec(cmd) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/webshellruby/webshell.rb', line 5

def webshell_exec cmd
  encode_cmd  = URI::encode cmd
  uniq_id     = Digest::SHA1.hexdigest UUID.new.generate
  request_url = @@base_url + '?response=json&request=' + encode_cmd + '&key=' + Webshellruby.api_key+ '&secret=' + Webshellruby.secret_key + '&cip=' + uniq_id
  result      = open(request_url) {|io| io.read}
  result_arr  = Oj.load(result)
  if result_arr.last['error']
    return false
  else
    return result_arr
  end
end

#webshell_html(cmd) ⇒ Object



18
19
20
21
# File 'lib/webshellruby/webshell.rb', line 18

def webshell_html cmd
  result = webshell_exec cmd
  return result[1]['view'].html_safe
end