rex-socket 0.1.60 → 0.1.61

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a61eea97f22de5fbf53bd8b10afdc2a49affa0d3ced6a6457dbc78c7c13f88c4
4
- data.tar.gz: 0b43ec7143f9dca80b8bc38105e6873252eda7b19b023e393432580169002620
3
+ metadata.gz: 768cf09e183ef82a282e1173e076723617fa5d1d3ef6d159930c5f080e62267c
4
+ data.tar.gz: 9cfe878cd33e159f58803d2012150d20f2d9a934222e71e674618b553ef3f4ed
5
5
  SHA512:
6
- metadata.gz: c055962142f5fcadf24016b0274d065dafe53b47bff9a290fed250fe8a99a11a4a6a29b414b6d9656ce3304903ae4c620c03601235b6008f047e2ad171f2e375
7
- data.tar.gz: 37943cfd24524c9a8474132c1d7cb3051a221173ad493ed7a3ad103e1223163bd1bc7da1639b21fa6c36add59c3777012aee7acdd6484e0c1f45230722d34c56
6
+ metadata.gz: 3135f51b48c61967266a771006fd0b432061f2c2717025695f9843cde59b40d7abf60c4bd7d92f957b9f574700cce4cdc0997e9707b5f2026eab1afd8a879696
7
+ data.tar.gz: c2874c8b85019ae4af581bd1d00e046b46d9c82b34b8032c13cc88547966706cde53775f80c856e5f4658ed186adc3aa836bf626f7c530e208ee1e46cc7c2493
@@ -51,6 +51,8 @@ class Rex::Socket::Parameters
51
51
  #
52
52
  # @option hash [String] 'PeerHost' The remote host to connect to
53
53
  # @option hash [String] 'PeerHostname' The unresolved remote hostname, used to specify Server Name Indication (SNI)
54
+ # @option hash [String] 'SSLKeyLogFile' The SSL key log file path, used for network capture
55
+ # decryption which is useful to decrypt TLS traffic in wireshark
54
56
  # @option hash [String] 'PeerAddr' (alias for 'PeerHost')
55
57
  # @option hash [Fixnum] 'PeerPort' The remote port to connect to
56
58
  # @option hash [String] 'LocalHost' The local host to communicate from, if any
@@ -116,6 +118,10 @@ class Rex::Socket::Parameters
116
118
  self.sslctx = hash['SSLContext']
117
119
  end
118
120
 
121
+ if (hash['SSLKeyLogFile'])
122
+ self.sslkeylogfile = hash['SSLKeyLogFile']
123
+ end
124
+
119
125
  self.ssl_version = hash.fetch('SSLVersion', nil)
120
126
 
121
127
  supported_ssl_verifiers = %W{CLIENT_ONCE FAIL_IF_NO_PEER_CERT NONE PEER}
@@ -302,6 +308,11 @@ class Rex::Socket::Parameters
302
308
  # @return [String]
303
309
  attr_accessor :peerhostname
304
310
 
311
+ # The SSL key log file path, equivalent to the sslkeylogfile parameter hash
312
+ # key.
313
+ # @return [String]
314
+ attr_accessor :sslkeylogfile
315
+
305
316
  # The remote port. Equivalent to the PeerPort parameter hash key.
306
317
  # @return [Fixnum]
307
318
  attr_writer :peerport
@@ -84,6 +84,20 @@ begin
84
84
  # Build the SSL connection
85
85
  self.sslctx = OpenSSL::SSL::SSLContext.new(version)
86
86
 
87
+ # writing to the sslkeylogfile is required, it adds support for network capture decryption which is useful to
88
+ # decrypt TLS traffic in wireshark
89
+ if sslkeylogfile
90
+ unless self.sslctx.respond_to?(:keylog_cb)
91
+ raise 'Unable to create sslkeylogfile - Ruby 3.2 or above required for this functionality'
92
+ end
93
+
94
+ self.sslctx.keylog_cb = proc do |_sock, line|
95
+ File.open(sslkeylogfile, 'ab') do |file|
96
+ file.write("#{line}\n")
97
+ end
98
+ end
99
+ end
100
+
87
101
  # Configure client certificate
88
102
  if params and params.ssl_client_cert
89
103
  self.sslctx.cert = OpenSSL::X509::Certificate.new(params.ssl_client_cert)
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Socket
3
- VERSION = "0.1.60"
3
+ VERSION = "0.1.61"
4
4
  end
5
5
  end
data/lib/rex/socket.rb CHANGED
@@ -805,6 +805,7 @@ module Socket
805
805
  if (params)
806
806
  self.peerhost = params.peerhost
807
807
  self.peerhostname = params.peerhostname
808
+ self.sslkeylogfile = params.sslkeylogfile
808
809
  self.peerport = params.peerport
809
810
  self.localhost = params.localhost
810
811
  self.localport = params.localport
@@ -888,6 +889,10 @@ module Socket
888
889
  #
889
890
  attr_reader :peerhostname
890
891
  #
892
+ # The SSL key log file path.
893
+ #
894
+ attr_reader :sslkeylogfile
895
+ #
891
896
  # The peer port of the connected socket.
892
897
  #
893
898
  attr_reader :peerport
@@ -912,7 +917,7 @@ module Socket
912
917
 
913
918
  protected
914
919
 
915
- attr_writer :peerhost, :peerhostname, :peerport, :localhost, :localport # :nodoc:
920
+ attr_writer :peerhost, :peerhostname, :sslkeylogfile, :peerport, :localhost, :localport # :nodoc:
916
921
  attr_writer :context # :nodoc:
917
922
  attr_writer :ipv # :nodoc:
918
923
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-socket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.60
4
+ version: 0.1.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-09 00:00:00.000000000 Z
11
+ date: 2025-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake