Class: Interactsh::Client
- Inherits:
-
Object
- Object
- Interactsh::Client
- Defined in:
- lib/interactsh/client.rb
Overview
Main client class for Interactsh interaction
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 = 'oast.me', token = nil) ⇒ Client
constructor
Creates a new Interactsh client.
-
#new_domain ⇒ String
Generates a new domain for interaction testing.
-
#poll(host) ⇒ Array
Polls the server for interaction data for a given host.
Constructor Details
#initialize(server = 'oast.me', token = nil) ⇒ Client
Creates a new Interactsh client
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/interactsh/client.rb', line 12 def initialize(server = 'oast.me', token = nil) @rsa = OpenSSL::PKey::RSA.new(2048) @public_key = @rsa.public_key.to_pem @public_key_encoded = Base64.strict_encode64(@public_key) @secret = Utils.generate_uuid @random_data = Utils.generate_random_string(13) @server = server @token = token @http_client = HttpClient.new(server, token) @crypto = Crypto.new(@rsa) end |
Instance Attribute Details
#public_key_encoded ⇒ Object (readonly)
Returns the value of attribute public_key_encoded.
6 7 8 |
# File 'lib/interactsh/client.rb', line 6 def public_key_encoded @public_key_encoded end |
#random_data ⇒ Object (readonly)
Returns the value of attribute random_data.
6 7 8 |
# File 'lib/interactsh/client.rb', line 6 def random_data @random_data end |
#rsa ⇒ Object (readonly)
Returns the value of attribute rsa.
6 7 8 |
# File 'lib/interactsh/client.rb', line 6 def rsa @rsa end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
6 7 8 |
# File 'lib/interactsh/client.rb', line 6 def secret @secret end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
6 7 8 |
# File 'lib/interactsh/client.rb', line 6 def server @server end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/interactsh/client.rb', line 6 def token @token end |
Instance Method Details
#new_domain ⇒ String
Generates a new domain for interaction testing
29 30 31 32 33 34 |
# File 'lib/interactsh/client.rb', line 29 def new_domain correlation_id = Xid.new.to_s register(correlation_id) "#{correlation_id}#{random_data}.#{server}" end |
#poll(host) ⇒ Array
Polls the server for interaction data for a given host
41 42 43 44 45 46 47 48 49 |
# File 'lib/interactsh/client.rb', line 41 def poll(host) correlation_id = host[0..19] response = @http_client.make_poll_request(correlation_id, secret) return [] unless @http_client.response_successful?(response) data = JSON.parse(response.body) parse_poll_data(data) end |