Commit Graph

155 Commits

Author SHA1 Message Date
sjanusz-r7 566e12b69e Add error_callback to SSH Command Stream 2024-11-25 16:43:59 +00:00
sjanusz-r7 358e79bd3c Handle SSH errors by closing the session 2024-11-17 14:53:42 +00:00
sjanusz-r7 f6a51610ad Add handle_error to command_stream 2024-11-17 14:25:22 +00:00
adfoster-r7 49a7caf097 Fix windows DNS crash on bootup 2024-10-01 13:04:27 +01:00
Stephen Fewer ad98d749ca Instead of only setting a single domain name via self.domain, set self.searchlist which already supports an array of items (thanks Spencer!).
Co-authored-by: Spencer McIntyre <58950994+smcintyre-r7@users.noreply.github.com>
2024-09-23 15:50:24 +01:00
sfewer-r7 9be50f74a8 The first array item will either be nil, or an array of domain names, so we pick the first one to avoid a NoMethodError for a =~ operation on an array object, during a call to the method valid? 2024-09-19 10:40:01 +01:00
Spencer McIntyre cf6d324832 Nameservers from resolv.conf must be IP addresses
Fixes an infinite recursion error where Metasploit would attempt to
resolve a nameserver specified as a hostname in /etc/resolv.conf while
initializing.

Values for the namserver key in the resolv.conf file must be IP
addresses per the man page while the Resolver class in theory allows
them to be added by hostname however an existing one must be defined by
which it will be resolved.

This notably prevents IPv6 addresses with a scope ID from being allowed
in Ruby versions < 3.1.
2024-04-25 16:21:04 -04:00
Spencer McIntyre 319cff7d3a Change the DNS timeout from 30 to 5 seconds
Also, add the #to_i method for timeouts
This makes it compatible with Rex Sockets later on
2024-02-08 11:22:33 -05:00
Spencer McIntyre 20f73867ca Print the default domain and search list too 2024-02-08 11:22:32 -05:00
adfoster-r7 7ce13101df Ensure DNS command config loading does not crash msfconsole 2024-01-29 13:23:18 +00:00
adfoster-r7 f56c9fc9ac Land #18662, Fix dns resolution skipping over nameservers with valid responses 2024-01-19 16:44:16 +00:00
h00die 6a851855a8 spelling fixes for lib folder 2024-01-06 15:54:49 -05:00
Dean Welch f92b2662c4 Fix dns resolution skipping over nameservers with valid responses 2024-01-04 14:10:45 +00:00
sjanusz-r7 560f668906 Fix net-ssh lib now requiring ssh key type 2023-12-12 14:22:06 +00:00
Ashley Donaldson 473ded345b Fix UDP detection when DNS resolution is not on 2023-11-23 10:34:09 +11:00
adfoster-r7 085943bd78 Add Ruby 3.3.0-preview1 to test suite 2023-06-29 22:53:17 +01:00
adfoster-r7 a9ccfe31b7 Merge branch 'upstream-master' into merge-msf-6.2.31-into-kerberos-feature-branch 2022-12-13 19:40:39 +00:00
bcoles 431804ef15 Fix typos: Replace 'the the' with 'the' 2022-12-04 17:41:24 +11:00
Ashley Donaldson f16e2cfb35 Send TGT to WinRM to allow further access of network resources (kerberos double hop) 2022-07-27 16:19:09 +01:00
Ashley Donaldson 39f90d95b1 Create sessions for winrm_login successes.
Reuses the connection, so that authentication doesn't need to happen again
2022-07-08 16:57:09 +10:00
Ashley Donaldson b2eb348d94 Added WinRM using Kerberos, including encryption 2022-07-07 13:17:09 +10:00
Ashley Donaldson 9d8193150f Allow running a shell command separately to the currently interactive shell 2021-09-21 19:12:49 +10:00
Ashley Donaldson 91d0a6cc55 Re-auth after the session times out
This seems to happen after 8 hours. WinRM doesn't like having bodies
in the authentication requests, so we force the HTTP client to send
an empty one first
2021-09-17 07:32:18 +10:00
Ashley Donaldson 5dceb48553 Fixed rubocop issues 2021-09-13 11:40:03 +10:00
Ashley Donaldson 44455fd165 Added some comments for clarity 2021-09-12 19:38:16 +10:00
Ashley Donaldson 50e31917da Emulate a stream to make the base command shell happy 2021-09-10 17:45:08 +10:00
Ashley Donaldson 0927737948 Adapted WinRM module logging to MSF logging
Separated WinRM module into separate files
2021-09-10 15:54:50 +10:00
Ashley Donaldson b0e1502c86 Implemented suggestions from code review
- Use a literal hash
- Comment meaning of NTLM transforms
- store loot with data ready to go, to keep database in sync with file
2021-09-10 08:25:25 +10:00
Ashley Donaldson 5cffa86e30 Removed unused code 2021-09-10 07:46:05 +10:00
Ashley Donaldson cf09d56be0 Support re-authentication during the shell
After 8 hours, the server requests re-authentication, so need to support that.
2021-09-10 07:41:31 +10:00
Ashley Donaldson 9ea3be903d Just use cmd, as powershell <= 3.0 doesn't actually use stdout/stderr 2021-09-09 22:40:43 +10:00
Ashley Donaldson c33b850ff8 Support terminating processes early by sending a Ctrl+C signal 2021-09-09 22:08:33 +10:00
Ashley Donaldson 3acddf75b4 Suggested changes from code review
* Report socket info
* Use existing Event class
* Remove debugging prints
* Comment obscure constant
2021-09-08 07:36:59 +10:00
Ashley Donaldson 00100f426c Handle the server ceasing to respond 2021-09-06 23:24:23 +10:00
Ashley Donaldson 0e103e8550 Enabled encryption for WinRM when using Negotiate auth 2021-09-06 22:25:34 +10:00
Ashley Donaldson eeef8a3085 Support domain login in WinRM module 2021-09-06 10:25:36 +10:00
Ashley Donaldson 7a75a91dc6 Request stdout on a separate thread, so we are alerted when the shell dies. 2021-09-06 09:33:44 +10:00
Ashley Donaldson b50a1aa988 Moved reusable functionality into separate file 2021-09-02 21:58:07 +10:00
Spencer McIntyre 51f8808bed Fix the representation of IPv6 addresses 2021-06-29 14:21:36 -04:00
CSharperMantle d99c2ac783 linguistic fixes of 'does not exists' 2020-12-23 11:36:38 +08:00
Spencer McIntyre f8fe5974be Properly skip over unsupported RRs when doing DNS zone transfers 2020-05-06 13:15:33 -04:00
William Vu e9b3502f98 Fix Net::SSH::CommandStream session open failure
I suspected this might be a problem for libssh servers.
2018-11-02 01:08:05 -05:00
William Vu 4182777488 Support SSH shell/exec channel request output
Looks like channel[:data] was initialized but never used.
2018-10-23 09:34:12 -05:00
William Vu cf00f20e11 Update Net::SSH::CommandStream exception handling 2018-10-18 22:45:16 -05:00
William Vu 6fd53fcb6a Fix whitespace further 2018-10-17 15:45:02 -05:00
William Vu 1e1950c83d Prefer keyword args after all
SINCE we've been using only the first two params, we're fine!
2018-10-17 15:41:19 -05:00
William Vu a453760aa4 Add PTY option to Net::SSH::CommandStream
This allows us to spawn a PTY for our shell session. Note that this will
write us to {u,w}tmp and lastlog, so use this option with care.

And yes, I did change the API, but up until now, we've been using only
the first two parameters. We should be using keyword args. /shrug
2018-10-17 15:40:13 -05:00
Sonny Gonzalez f5ccdcfcd2 Net SSH CommandStream fixes implemented
* Net::SSH::CommandStream typos fixed
* Net::SSH::CommandStream cleanup made more robust and refactored
* require 'net/ssh/command_stream' added to various modules
2018-07-25 11:22:28 -05:00
Brent Cook b1d0529161 prefer 'shell' channels over 'exec' channels for ssh
If a command is not specified to CommandStream, request a "shell"
session rather than running exec. This allows targets that do not have a
true "shell" which supports exec to instead return a raw shell session.
2018-02-08 02:21:16 -06:00
RageLtMan 7cc7fe71db Address net-dns additional records empty array
Conversion between packet formats can create empty additional
answers fields, which net-dns cannot handle.

Update net-dns' packet parser to be able to deal with empty arrays
such that it doesn't try to call :data on a nil, which is the only
element of an empty array.

Props to mubix for identifying this issues.
2017-06-24 20:27:19 -04:00