Class: Interactsh

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

Overview

InteractSH Ruby Library

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Returns the value of attribute random_data.



14
15
16
# File 'lib/interactsh.rb', line 14

def random_data
  @random_data
end

#rsaObject (readonly)

Returns the value of attribute rsa.



14
15
16
# File 'lib/interactsh.rb', line 14

def rsa
  @rsa
end

#secretObject (readonly)

Returns the value of attribute secret.



14
15
16
# File 'lib/interactsh.rb', line 14

def secret
  @secret
end

#serverObject (readonly)

Returns the value of attribute server.



14
15
16
# File 'lib/interactsh.rb', line 14

def server
  @server
end

#tokenObject (readonly)

Returns the value of attribute token.



14
15
16
# File 'lib/interactsh.rb', line 14

def token
  @token
end

Instance Method Details

#new_domainObject



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