interactsh 0.9.2 → 0.9.4

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 -93
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b34b1f28ac601af7b3d0e6f6fbe9cc952f8ac86aa4b56f4b58eac7403a46fad1
4
- data.tar.gz: 78d1933787518e693380db20df67b3049a9e948a5d2cd1348be294ecbbf5d670
3
+ metadata.gz: 03cb293a428605a5f9bd9bf8ae807d3305e0021f88e32897ff43a296f4b452f2
4
+ data.tar.gz: 26f3566ad591699653cd710963b1b78e8ff47ca0238aa949889515af3a0301e2
5
5
  SHA512:
6
- metadata.gz: 8490d216a0037495457c5f170dbea3ca77330fad9d311de87d97ad89c36594e22c10ec9e79b4a7af9eef3cf12e01482541be7621a392e39fa6c9f6654ffedf8d
7
- data.tar.gz: b62e3f53d773bb04f771064a6b1502454b11f3bf494661d27c7afde90aa41f3a43996f0c30518569cb79a38efffbcf3ef0ad1f817be848c85f72fe96bea63179
6
+ metadata.gz: 9149747761e02c6bcd2b9a79e8ad69aeb25061e1c8e3c1e95d8b76fef505923ca988ef7000cd58b254914a8be8563c15a594b3293df77e0e8c08225bb424b112
7
+ data.tar.gz: a6c35ba927bd659c5f35156af3d6bacf86a98985d70e30b94f495587fe0351c412b757c7755d9303ee29bef21f77ab3f91e26f97a86feba12c7c5b08587d5643
data/lib/interactsh.rb CHANGED
@@ -1,93 +1,89 @@
1
- require 'openssl'
2
- require 'stringio'
3
- require 'jose'
4
- require 'securerandom'
5
- require 'base64'
6
- require 'json'
7
- require 'ruby_xid'
8
- require 'typhoeus'
9
-
10
- class Interactsh
11
- attr_reader :public_key_encoded, :secret, :correlation_id, :server, :random_data, :rsa, :token
12
-
13
- def initialize(server = 'interact.sh', token = nil)
14
- @rsa = OpenSSL::PKey::RSA.new(2048)
15
- @public_key = @rsa.public_key.to_pem
16
- @public_key_encoded = Base64.encode64(@public_key)
17
-
18
- @secret = SecureRandom.uuid
19
- @correlation_id = Xid.new.to_s
20
- @random_data = Array.new(13) { (Array('a'..'z') + Array(0..9)).sample }.join
21
-
22
- @server = server
23
- @token = token
24
-
25
- register
26
- end
27
-
28
- def get_domain
29
- "#{correlation_id}#{random_data}.#{server}"
30
- end
31
-
32
- def poll
33
- headers = { }
34
- headers['Authorization'] = token if token
35
-
36
- response = Typhoeus.get(
37
- File.join(server, "/poll?id=#{correlation_id}&secret=#{secret}"),
38
- headers: headers
39
- )
40
- decoded_datas = []
41
-
42
- if response&.code == 200
43
- datas = JSON.parse(response.body)
44
- unless datas.empty?
45
- datas["data"].each do |enc_data|
46
- decoded_datas << decrypt_data(datas["aes_key"], enc_data)
47
- end
48
- end
49
- else
50
- puts "[!] Interactsh - Problem with data recovery"
51
- return
52
- end
53
-
54
- decoded_datas
55
- end
56
-
57
- private
58
-
59
- def register
60
- data = {
61
- "public-key": public_key_encoded,
62
- "secret-key": secret,
63
- "correlation-id": correlation_id
64
- }.to_json
65
-
66
- headers = { 'Content-Type' => 'application/json' }
67
- headers['Authorization'] = token if token
68
-
69
- response = Typhoeus.post(
70
- File.join(server, '/register'),
71
- body: data,
72
- headers: headers
73
- )
74
-
75
- unless response.code == 200
76
- puts "[!] Interactsh - Problem with domain registration"
77
- end
78
- end
79
-
80
- def decrypt_data(aes_key, enc_data)
81
- pkey = OpenSSL::PKey::RSA.new(rsa)
82
- encrypted_aes_key = Base64.urlsafe_decode64(aes_key)
83
- decrypted_aes_key = JOSE::JWA::PKCS1::rsaes_oaep_decrypt(OpenSSL::Digest::SHA256, encrypted_aes_key, pkey)
84
-
85
- secretdata = Base64::decode64(enc_data)
86
- decipher = OpenSSL::Cipher::Cipher.new('aes-256-cfb')
87
- decipher.decrypt
88
- decipher.key = decrypted_aes_key
89
-
90
- # The data minus the size of the IV
91
- JSON.parse((decipher.update(secretdata) + decipher.final)[16..])
92
- end
93
- 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.2
4
+ version: 0.9.4
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: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jose
@@ -92,7 +92,7 @@ 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
98
  metadata: {}
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.1.2
114
+ rubygems_version: 3.4.19
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Interactsh Ruby Library