interactsh 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/interactsh.rb +80 -87
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa5e0570c9ba1bfbd8b942a773c864d12b2c1f87dbad8250e7051d9c30c63959
4
- data.tar.gz: bb0a357e26c3e78814c3f99c10ca175ec0e792d84d06a35b1359249a087447b1
3
+ metadata.gz: 6feebc6e3116675ca85a30c2f576d8a7f6eabd9d6becdf255eb36b9a9fe8bf60
4
+ data.tar.gz: ba28a91c6fce3329f2995be8cfc46ac17c42aaa8485457891cb07d630c9ac22c
5
5
  SHA512:
6
- metadata.gz: d959d05cd3089d43782485be925175a31d5edbca2283547fd74be111922b99c0ab69197f0704aa15060596fe56afae4cac0194b068ff33635d62bdb6429fc2c7
7
- data.tar.gz: 716b1e0e3219ae9caf4c1460af18068c5fe0959ef5dd5d19993cfbbae066c133dc8a6310da0c4210ff37c7912fe45e6fdbc0d28d9b62744ab1488f6d46db80d5
6
+ metadata.gz: caa7e51f65571b0357aa8a6e231fd546809782a0134cbcc5d05172881dd704052e616267ed8b2298b05418929b3c60d3ea8c33fb67e13bb0624072b32d38581c
7
+ data.tar.gz: 96215db908a3feefe6b9fd9f6de54d853f88fa977bceec2a7090821c3052c29fd0370d5d77176c3f406628aa58da4587ccbf4296487f8b82b6ec581247b1cadb
data/lib/interactsh.rb CHANGED
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'openssl'
4
+ require 'stringio'
2
5
  require 'jose'
3
6
  require 'securerandom'
4
7
  require 'base64'
@@ -6,91 +9,81 @@ require 'json'
6
9
  require 'ruby_xid'
7
10
  require 'typhoeus'
8
11
 
12
+ # InteractSH Ruby Library
9
13
  class Interactsh
10
- attr_reader :public_key_encoded, :secret, :correlation_id, :server, :random_data, :rsa, :token
11
-
12
- def initialize(server = 'interact.sh', token = nil)
13
- @rsa = OpenSSL::PKey::RSA.new(2048)
14
- @public_key = @rsa.public_key.to_pem
15
- @public_key_encoded = Base64.encode64(@public_key)
16
-
17
- @secret = SecureRandom.uuid
18
- @correlation_id = Xid.new.to_s
19
- @random_data = Array.new(13) { (Array('a'..'z') + Array(0..9)).sample }.join
20
-
21
- @server = server
22
- @token = token
23
-
24
- register
25
- end
26
-
27
- def get_domain
28
- "#{correlation_id}#{random_data}.#{server}"
29
- end
30
-
31
- def poll
32
- headers = { }
33
- headers['Authorization'] = token if token
34
-
35
- request = Typhoeus::Request.new(
36
- File.join(server, "/poll?id=#{correlation_id}&secret=#{secret}"),
37
- headers: headers
38
- )
39
- request.run
40
-
41
- decoded_datas = []
42
-
43
- if request.response.code == 200
44
- datas = JSON.parse(request.response.body)
45
- unless datas.empty?
46
- datas["data"].each do |enc_data|
47
- decoded_datas << decrypt_data(datas["aes_key"], enc_data)
48
- end
49
- end
50
- else
51
- puts "[!] Interactsh - Problem with data recovery"
52
- return
53
- end
54
-
55
- decoded_datas
56
- end
57
-
58
- private
59
-
60
- def register
61
- data = {
62
- "public-key": public_key_encoded,
63
- "secret-key": secret,
64
- "correlation-id": correlation_id
65
- }.to_json
66
-
67
- headers = { 'Content-Type' => 'application/json' }
68
- headers['Authorization'] = token if token
69
-
70
- request = Typhoeus::Request.new(
71
- File.join(server, '/register'),
72
- method: :post,
73
- body: data,
74
- headers: headers
75
- )
76
- request.run
77
-
78
- unless request.response.code == 200
79
- puts "[!] Interactsh - Problem with domain registration"
80
- end
81
- end
82
-
83
- def decrypt_data(aes_key, enc_data)
84
- pkey = OpenSSL::PKey::RSA.new(rsa)
85
- encrypted_aes_key = Base64.urlsafe_decode64(aes_key)
86
- decrypted_aes_key = JOSE::JWA::PKCS1::rsaes_oaep_decrypt(OpenSSL::Digest::SHA256, encrypted_aes_key, pkey)
87
-
88
- secretdata = Base64::decode64(enc_data)
89
- decipher = OpenSSL::Cipher::Cipher.new('aes-256-cfb')
90
- decipher.decrypt
91
- decipher.key = decrypted_aes_key
92
-
93
- # The data minus the size of the IV
94
- JSON.parse((decipher.update(secretdata) + decipher.final)[16..])
95
- end
96
- end
14
+ attr_reader :public_key_encoded, :secret, :server, :random_data, :rsa, :token
15
+
16
+ def initialize(server = 'interact.sh', token = nil)
17
+ @rsa = OpenSSL::PKey::RSA.new(2048)
18
+ @public_key = @rsa.public_key.to_pem
19
+ @public_key_encoded = Base64.encode64(@public_key)
20
+
21
+ @secret = SecureRandom.uuid
22
+ @random_data = Array.new(13) { (Array('a'..'z') + Array(0..9)).sample }.join
23
+
24
+ @server = server
25
+ @token = token
26
+ end
27
+
28
+ def new_domain
29
+ correlation_id = Xid.new.to_s
30
+ register(correlation_id)
31
+
32
+ "#{correlation_id}#{random_data}.#{server}"
33
+ end
34
+
35
+ def poll(host)
36
+ correlation_id = host[0..19]
37
+ headers = {}
38
+ headers['Authorization'] = token if token
39
+
40
+ response = Typhoeus.get(File.join(server, "/poll?id=#{correlation_id}&secret=#{secret}"), headers: headers)
41
+ unless response&.code == 200
42
+ puts '[!] Interactsh - Problem with data recovery'
43
+ return
44
+ end
45
+
46
+ datas = JSON.parse(response.body)
47
+ parse_poll_datas(datas)
48
+ end
49
+
50
+ private
51
+
52
+ def parse_poll_datas(datas)
53
+ decoded_datas = []
54
+
55
+ unless datas.empty?
56
+ datas['data'].each do |enc_data|
57
+ decoded_datas << decrypt_data(datas['aes_key'], enc_data)
58
+ end
59
+ end
60
+
61
+ decoded_datas
62
+ end
63
+
64
+ def register(correlation_id)
65
+ data = { "public-key": public_key_encoded, "secret-key": secret, "correlation-id": correlation_id }.to_json
66
+
67
+ headers = { 'Content-Type' => 'application/json' }
68
+ headers['Authorization'] = token if token
69
+
70
+ response = Typhoeus.post(File.join(server, '/register'), body: data, headers: headers)
71
+ return if response.code == 200
72
+
73
+ puts '[!] Interactsh - Problem with domain registration'
74
+ end
75
+
76
+ def decrypt_data(aes_key, enc_data)
77
+ pkey = OpenSSL::PKey::RSA.new(rsa)
78
+ encrypted_aes_key = Base64.urlsafe_decode64(aes_key)
79
+ decrypted_aes_key = JOSE::JWA::PKCS1.rsaes_oaep_decrypt(OpenSSL::Digest::SHA256, encrypted_aes_key, pkey)
80
+
81
+ secretdata = Base64.decode64(enc_data)
82
+ decipher = OpenSSL::Cipher.new('aes-256-cfb')
83
+ decipher.decrypt
84
+ decipher.key = decrypted_aes_key
85
+
86
+ # The data minus the size of the IV
87
+ JSON.parse((decipher.update(secretdata) + decipher.final)[16..])
88
+ end
89
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interactsh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua MARTINELLE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-13 00:00:00.000000000 Z
11
+ date: 2022-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jose