Class: Interactsh::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/interactsh/client.rb

Overview

Main client class for Interactsh interaction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server = 'oast.me', token = nil) ⇒ Client

Creates a new Interactsh client

Parameters:

  • server (String) (defaults to: 'oast.me')

    The Interactsh server to use (default: 'oast.me')

  • token (String, nil) (defaults to: nil)

    Optional authentication token



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_encodedObject (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_dataObject (readonly)

Returns the value of attribute random_data.



6
7
8
# File 'lib/interactsh/client.rb', line 6

def random_data
  @random_data
end

#rsaObject (readonly)

Returns the value of attribute rsa.



6
7
8
# File 'lib/interactsh/client.rb', line 6

def rsa
  @rsa
end

#secretObject (readonly)

Returns the value of attribute secret.



6
7
8
# File 'lib/interactsh/client.rb', line 6

def secret
  @secret
end

#serverObject (readonly)

Returns the value of attribute server.



6
7
8
# File 'lib/interactsh/client.rb', line 6

def server
  @server
end

#tokenObject (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_domainString

Generates a new domain for interaction testing

Returns:

  • (String)

    The generated domain name 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

Parameters:

  • host (String)

    The host to poll data for

Returns:

  • (Array)

    Array of interaction data or empty array if no data found

Raises:



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