chronoleak 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4909841067ed65fe72ed30312f04d82b0e232299aa8c2e74f84116b3a462179e
4
+ data.tar.gz: f341b5fc125a0d0c3c64a253af6ba208e89d81ce6322d6dd60a67d864b49f8d3
5
+ SHA512:
6
+ metadata.gz: b1abc9cbedbf2820a7e50db904fb6591cfe0a4cbe2c66532549bf4b9a5e083a220ce0b11f8886298eea5cdc020a2c3342938bc0e2f0d48677252b7cd3476c45b
7
+ data.tar.gz: a0dbc3164f45ac7ea9340d51c06d00b81ce2f99a8e6c7741d42a208e2421d034bb2a130cd5d040a10131ada4abed8d11f94bc022b86e0fc6e16e35cd1c594e4c
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alexandre ZANNI (@noraj)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/bin/chronoleak ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Project internal
5
+ require 'chronoleak'
6
+
7
+ if __FILE__ == $PROGRAM_NAME
8
+ log = ChronoLeak::TermLog.new
9
+ if ARGV.size == 1 && !['-h', '--help'].include?(ARGV.first)
10
+ ip_addr = ARGV.first
11
+ hping = "sudo hping3 #{ip_addr} --icmp --icmp-ts -c 1"
12
+ out = ''
13
+ Open3.popen3(hping) do |_stdin, stdout, stderr, _thread|
14
+ out = stdout.read
15
+ err = stderr.read
16
+ if /hping3: command not found/.match?(err)
17
+ log.fatal "hping not installed - 'hping3' command must be accessible in PATH"
18
+ log.fatal 'See the package for your distro on https://repology.org/project/hping/versions.'
19
+ raise(StandardError, "Command failed: #{hping}")
20
+ elsif /100% packet loss/.match?(err)
21
+ log.fatal 'ICMP timestamp requests (13) or ICMP timestamp replies (14) filtered.'
22
+ raise(StandardError, 'hping command executed successfully but received no response.')
23
+ end
24
+ end
25
+ timestamp_ms = out.match(/Transmit=(?<timestamp>\d+)/)[:timestamp].to_i
26
+ puts ChronoLeak.display_times(timestamp_ms)
27
+ else
28
+ puts "#{__FILE__} <IP_address_or_domain>"
29
+ puts
30
+ puts "Version: #{ChronoLeak::VERSION} - ICMP Timestamp Remote Time Leaker"
31
+ puts
32
+ puts 'Nessus - ICMP Timestamp Request Remote Date Disclosure - https://www.tenable.com/plugins/nessus/10114'
33
+ puts 'CVE-1999-0524 - https://www.tenable.com/cve/CVE-1999-0524'
34
+ end
35
+ log.close
36
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChronoLeak
4
+ VERSION = '0.0.1'
5
+ end
data/lib/chronoleak.rb ADDED
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Standard library
5
+ require 'logger'
6
+ require 'open3'
7
+ require 'time'
8
+ # Project internal
9
+ require 'chronoleak/version'
10
+
11
+ # Display ICMP timestamp in human form
12
+ module ChronoLeak
13
+ # @param timestamp_ms [Integer]
14
+ # @return [Time]
15
+ def self.timestamp_to_time(timestamp_ms)
16
+ seconds_since_midnight = timestamp_ms / 1000
17
+ Time.at(seconds_since_midnight)
18
+ end
19
+
20
+ # @param timestamp_ms [Integer]
21
+ # @return [String]
22
+ def self.timestamp_to_time_bis(timestamp_ms)
23
+ timestamp_h = timestamp_ms / 3_600_000.0
24
+ hours = timestamp_h.to_i
25
+ minutes_f = (timestamp_h - hours) * 60
26
+ minutes = minutes_f.to_i
27
+ seconds = ((minutes_f - minutes) * 60).to_i
28
+ format('%<h>02d:%<m>02d:%<s>02d', h: hours, m: minutes, s: seconds)
29
+ end
30
+
31
+ # @param timestamp_ms [Integer]
32
+ # @return [String]
33
+ def self.timestamp_to_time_ter(timestamp_ms)
34
+ total_seconds = timestamp_ms / 1000
35
+ hours = (total_seconds / 3600).floor % 24
36
+ minutes = (total_seconds % 3600) / 60
37
+ seconds = total_seconds % 60
38
+ format('%<h>02d:%<m>02d:%<s>02d', h: hours, m: minutes, s: seconds)
39
+ end
40
+
41
+ # @param timestamp_ms [Integer]
42
+ def self.display_times(timestamp_ms)
43
+ remote_time = timestamp_to_time(timestamp_ms)
44
+ puts TermLog.colorize(:blue, 'Remote time:')
45
+ puts format_time(remote_time.utc)
46
+ puts format_time(remote_time.getlocal)
47
+ puts
48
+ puts TermLog.colorize(:blue, 'Local time:')
49
+ mytime = Time.now
50
+ puts format_time(mytime.utc)
51
+ puts format_time(mytime.getlocal)
52
+ puts
53
+ puts TermLog.colorize(:blue, 'Time shift:')
54
+ puts time_diff(remote_time, mytime)
55
+ end
56
+
57
+ # @param time [Time]
58
+ def self.format_time(time)
59
+ "#{time.strftime('%H:%M:%S')} #{time.zone}"
60
+ end
61
+
62
+ # @param time_a [Time]
63
+ # @param time_b [Time]
64
+ # @return [String]
65
+ def self.time_diff(time_a, time_b)
66
+ a = Time.new(1970, 1, 1, time_a.hour, time_a.min, time_a.sec)
67
+ b = Time.new(1970, 1, 1, time_b.hour, time_b.min, time_b.sec)
68
+ diff = a > b ? a - b : b - a
69
+ Time.at(diff).utc.strftime('%H:%M:%S')
70
+ end
71
+
72
+ # Wrapper around the Logger class to get shorter syntax
73
+ class TermLog
74
+ COLORS = {
75
+ red: 31,
76
+ green: 32,
77
+ yellow: 33,
78
+ blue: 34,
79
+ pink: 35,
80
+ light_blue: 36
81
+ }.freeze
82
+
83
+ def initialize
84
+ @logger = Logger.new($stdout)
85
+ end
86
+
87
+ def self.colorize(color, msg)
88
+ "\e[#{COLORS[color]}m#{msg}\e[0m"
89
+ end
90
+
91
+ def fatal(msg)
92
+ @logger.fatal(TermLog.colorize(:red, msg))
93
+ end
94
+
95
+ def close
96
+ @logger.close
97
+ end
98
+ end
99
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chronoleak
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexandre ZANNI
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-03-30 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: logger
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "<"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "<"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.0'
26
+ description: Leaks time on a remote machine by using ICMP timestamp requests (13)
27
+ and replies (14).
28
+ email: alexandre.zanni@europe.com
29
+ executables:
30
+ - chronoleak
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - bin/chronoleak
36
+ - lib/chronoleak.rb
37
+ - lib/chronoleak/version.rb
38
+ homepage: https://github.com/noraj/ChronoLeak
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ bug_tracker_uri: https://github.com/noraj/ChronoLeak/issues
43
+ changelog_uri: https://github.com/noraj/ChronoLeak/releases
44
+ documentation_uri: https://noraj.github.io/ChronoLeak/
45
+ homepage_uri: https://github.com/noraj/ChronoLeak
46
+ source_code_uri: https://github.com/noraj/ChronoLeak/
47
+ funding_uri: https://github.com/sponsors/noraj
48
+ rubygems_mfa_required: 'true'
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.1.0
57
+ - - "<"
58
+ - !ruby/object:Gem::Version
59
+ version: '4.0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.6.2
67
+ specification_version: 4
68
+ summary: ICMP Timestamp Remote Time Leaker.
69
+ test_files: []