interactsh 0.9.3 → 0.9.5

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 +89 -89
  3. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6feebc6e3116675ca85a30c2f576d8a7f6eabd9d6becdf255eb36b9a9fe8bf60
4
- data.tar.gz: ba28a91c6fce3329f2995be8cfc46ac17c42aaa8485457891cb07d630c9ac22c
3
+ metadata.gz: be7cd0b58e166d53aa9edf095f4dde159ac905741fd65eb5a5552d5cad720be7
4
+ data.tar.gz: d327eb3559ed5c454cc2665fc1caebde8e1355870f15b0c69fad222df90f9c12
5
5
  SHA512:
6
- metadata.gz: caa7e51f65571b0357aa8a6e231fd546809782a0134cbcc5d05172881dd704052e616267ed8b2298b05418929b3c60d3ea8c33fb67e13bb0624072b32d38581c
7
- data.tar.gz: 96215db908a3feefe6b9fd9f6de54d853f88fa977bceec2a7090821c3052c29fd0370d5d77176c3f406628aa58da4587ccbf4296487f8b82b6ec581247b1cadb
6
+ metadata.gz: 585f819d0278768ffc8fa92f5effd191370a2d6c24a6aece64bb3c65bbac69e35d5c7d9ade71880c8b931b9e42b69f0fc7c8116f692969de1b50cfa09979c4da
7
+ data.tar.gz: dee1249d181970786fe6bec4494fbfabbef6496bc34af86e336fe4d98bebe63237f8082f8f274be879e63783f12db6d217ce08472d23bd8ef4077d845633b6ef
data/lib/interactsh.rb CHANGED
@@ -1,89 +1,89 @@
1
- # frozen_string_literal: true
2
-
3
- require 'openssl'
4
- require 'stringio'
5
- require 'jose'
6
- require 'securerandom'
7
- require 'base64'
8
- require 'json'
9
- require 'ruby_xid'
10
- require 'typhoeus'
11
-
12
- # InteractSH Ruby Library
13
- class Interactsh
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
1
+ # frozen_string_literal: true
2
+
3
+ require 'openssl'
4
+ require 'stringio'
5
+ require 'jose'
6
+ require 'securerandom'
7
+ require 'base64'
8
+ require 'json'
9
+ require 'ruby_xid'
10
+ require 'typhoeus'
11
+
12
+ # InteractSH Ruby Library
13
+ class Interactsh
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.3
4
+ version: 0.9.5
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-11-12 00:00:00.000000000 Z
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jose
@@ -92,10 +92,12 @@ extensions: []
92
92
  extra_rdoc_files: []
93
93
  files:
94
94
  - lib/interactsh.rb
95
- homepage: https://rubygems.org/gems/interactsh
95
+ homepage: https://github.com/JoshuaMart/Interactsh-Library
96
96
  licenses:
97
97
  - MIT
98
- metadata: {}
98
+ metadata:
99
+ source_code_uri: https://github.com/JoshuaMart/Interactsh-Library
100
+ homepage_uri: https://github.com/JoshuaMart/Interactsh-Library
99
101
  post_install_message:
100
102
  rdoc_options: []
101
103
  require_paths:
@@ -111,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
113
  - !ruby/object:Gem::Version
112
114
  version: '0'
113
115
  requirements: []
114
- rubygems_version: 3.1.2
116
+ rubygems_version: 3.4.19
115
117
  signing_key:
116
118
  specification_version: 4
117
119
  summary: Interactsh Ruby Library