Class: Interactsh
- Inherits:
-
Object
- Object
- Interactsh
- Defined in:
- lib/interactsh.rb
Overview
InteractSH Ruby Library
Instance Attribute Summary collapse
-
#public_key_encoded ⇒ Object
readonly
Returns the value of attribute public_key_encoded.
-
#random_data ⇒ Object
readonly
Returns the value of attribute random_data.
-
#rsa ⇒ Object
readonly
Returns the value of attribute rsa.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(server = 'interact.sh', token = nil) ⇒ Interactsh
constructor
A new instance of Interactsh.
- #new_domain ⇒ Object
- #poll(host) ⇒ Object
Constructor Details
#initialize(server = 'interact.sh', token = nil) ⇒ Interactsh
Returns a new instance of Interactsh.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/interactsh.rb', line 16 def initialize(server = 'interact.sh', token = nil) @rsa = OpenSSL::PKey::RSA.new(2048) @public_key = @rsa.public_key.to_pem @public_key_encoded = Base64.encode64(@public_key) @secret = SecureRandom.uuid @random_data = Array.new(13) { (Array('a'..'z') + Array(0..9)).sample }.join @server = server @token = token end |
Instance Attribute Details
#public_key_encoded ⇒ Object (readonly)
Returns the value of attribute public_key_encoded.
14 15 16 |
# File 'lib/interactsh.rb', line 14 def public_key_encoded @public_key_encoded end |
#random_data ⇒ Object (readonly)
Returns the value of attribute random_data.
14 15 16 |
# File 'lib/interactsh.rb', line 14 def random_data @random_data end |
#rsa ⇒ Object (readonly)
Returns the value of attribute rsa.
14 15 16 |
# File 'lib/interactsh.rb', line 14 def rsa @rsa end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
14 15 16 |
# File 'lib/interactsh.rb', line 14 def secret @secret end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
14 15 16 |
# File 'lib/interactsh.rb', line 14 def server @server end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
14 15 16 |
# File 'lib/interactsh.rb', line 14 def token @token end |
Instance Method Details
#new_domain ⇒ Object
28 29 30 31 32 33 |
# File 'lib/interactsh.rb', line 28 def new_domain correlation_id = Xid.new.to_s register(correlation_id) "#{correlation_id}#{random_data}.#{server}" end |
#poll(host) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/interactsh.rb', line 35 def poll(host) correlation_id = host[0..19] headers = {} headers['Authorization'] = token if token response = Typhoeus.get(File.join(server, "/poll?id=#{correlation_id}&secret=#{secret}"), headers: headers) unless response&.code == 200 puts '[!] Interactsh - Problem with data recovery' return end datas = JSON.parse(response.body) parse_poll_datas(datas) end |