interactsh 0.9

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 +7 -0
  2. data/lib/interactsh.rb +96 -0
  3. metadata +84 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 37bf4d4f80b1a9de3369a25fbdd49dd65d906ff904f30aa7ef47a8c34776704c
4
+ data.tar.gz: d2b126ee317874046701adccd5e1707d5052665ac7587d3aa97d83bc28d21a21
5
+ SHA512:
6
+ metadata.gz: 0d19f10e2cb075156372f0198b80ce53ef61bf1ba6c4b67957dc2d85da2d4452800d4070227640ae17d88b3048cb18f2d954687f459524f3f633d0a5c4e9865f
7
+ data.tar.gz: 44a7331deb7897b52d3ee801d8e11b1542c00e718649c124478f7f46a0f9f33a073adacfe29e1d35d587f337a64e772c21dd2261ca5aabfbfc363c99efe6596c
data/lib/interactsh.rb ADDED
@@ -0,0 +1,96 @@
1
+ require 'openssl'
2
+ require 'jose'
3
+ require 'securerandom'
4
+ require 'base64'
5
+ require 'json'
6
+ require 'ruby_xid'
7
+ require 'typhoeus'
8
+
9
+ 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
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: interactsh
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.9'
5
+ platform: ruby
6
+ authors:
7
+ - Joshua MARTINELLE
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-09-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby_xid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.7
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.7
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.7
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: typhoeus
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.4'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.4.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.4'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.4.0
53
+ description:
54
+ email:
55
+ - contact@jomar.fr
56
+ executables: []
57
+ extensions: []
58
+ extra_rdoc_files: []
59
+ files:
60
+ - lib/interactsh.rb
61
+ homepage: https://rubygems.org/gems/interactsh
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.7.1
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.1.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Interactsh Ruby Library
84
+ test_files: []