Commit Graph

2235 Commits

Author SHA1 Message Date
Brent Cook 800cdcc866 Land #8737, better handle sudden disconnects with SMTP servers 2017-07-23 15:04:50 -07:00
Brent Cook df22e098ed Land #8695, Fix #8675, Add Cache-Control header, also meta tag for BAP2 2017-07-23 07:17:45 -07:00
RageLtMan e787d43344 Implement wrap_double_quotes in Msf PSH namespace
This is the Msf side of Rex Powershell #7
2017-07-22 02:40:15 -04:00
Jin Qian 0f31edfe39 Change tab into space to be standard compliant
Thanks to Brent and Dave for pointing it out.
2017-07-18 16:17:53 -05:00
Jin Qian 6385593148 Fix SE campaign exception.
MS-2705, SE_campaign will crash when RCPT command got socket closure as a response. Thanks to Pearce for the triage.
2017-07-18 14:30:44 -05:00
RageLtMan 33a06faadb Remove use_single_quotes option from Msf namespace
Internally wrapped lines of powershell built by :cmd_psh_payload
in the Rex namespace require being able to place wrapping quotes
in different logical places for :generate_psh_command_line and
:run_hidden_psh methods. Using single quotes in the Arguments
parameter of the hidden PSH runner and double quotes after the
-Command flag maintains allows us to wrap the outer command in
double quotes, while properly ecaping and wrapping the arguments
parameter for PSH execution in single quotes.

This isn't ideal, in a perfect world we'd be escaping all nested
quotes and escape chars of any type valid for PSH. However, that
would require more manual testing than anyone has time for (now).
2017-07-18 03:34:02 -04:00
Dave Farrow 378375c822 replaced devil tabs with spaces 2017-07-17 20:29:33 -07:00
Dave Farrow e6fe90ea08 added robots.txt support for http exploit server 2017-07-17 17:47:36 -07:00
RageLtMan 1a3fe02db1 Psexec via PSH related fixes
Implement removal of comspec and use of the noninteractive option
in powershell payloads.

This is the Msf side of #6 for rex-powershell.

Testing:
  In-house testing on 2016 standard edition and win10, 201707 revs.
2017-07-16 05:48:11 -04:00
RageLtMan 7e487ec745 fix request_ops per bcoles 2017-07-13 01:16:27 -04:00
Brent Cook 345407b0a4 Rex::Encoder::XDR conflicts with the XDR gem 2017-07-12 11:52:10 -05:00
RageLtMan 5473b2132d Implement :request_url for Msf HttpClient mixin
To round out implementation of a simple path for users to access
HttpClient like Open or Net::HTTP, create :request_url method which
takes a single URL parameter, uses :request_opts_from_url to build
the request configuration for Rex::Proto::Http::Client, executes
a GET request with it, and disconnects the client unless keepalive
is specified as the second parameter to :request_url.

Example usage of functionality is implemented in http_pdf_authors.
2017-07-11 16:07:13 -04:00
wchen-r7 50b1ec4044 Fix #8675, Add Cache-Control header, also meta tag for BAP2
Hopefully that browsers will respect this.

Fix #8675
2017-07-10 16:05:09 -05:00
RageLtMan df697aa23c Implement HttpClient options generation from URL
To address the complexity which comes with the flexibility offered
by Rex::Proto::Http::Client and its Msf mixin descendant, a simple
process needs to be implemented for issuing a request using only
the URL string in order to provide ease of access to users who may
not have the time to study how these clients work in detail.

Implement :request_opts_from_url in Msf's HttpClient mixin such as
to extract the options required for :send_request_* from a URL
string passed into the method. This approach reduces HTTP requests
in the mixin to `send_request_raw(request_opts_from_url(url))` when
`url` is just a string.

Implement this approach in the http_pdf_authors gather module to
further reduce infrastructure complexity around the simple need to
acquire PDF files via HTTP/S.

Testing:
  Local to this module only, and in Pry of course. Seems to work...
2017-07-10 04:19:26 -04:00
William Webb 6349026134 Land #8442, Exploit module for Backup Exec Windows Agent UaF 2017-06-28 10:39:28 -05:00
RageLtMan deef4a94fe Allow DNS::Server::Cache to find '*' names
Allow retrieval of '*' from stored static entries for spoofing
all domains to any IP using wildcard names. Replace the wildcard
response with the name submitted to the search in the response.

Fix improper checks in DNS::Packet for Resolv objects from decode
to encode.

Misc cleanup for records not responding to :address, convenience
methods, and packet structure.
2017-06-23 19:59:01 -04:00
RageLtMan f24448c73a Add :client accessor to Remote::DNS::Client
Add convenience method for using the @dns_resolver instance var
via call to :client, which also performs resolver setup if none
exists when called.
2017-06-23 19:58:42 -04:00
RageLtMan dafadb94ff Address Egypt's GH comments
Remove redundant convenience accessors.
Clean up conditional logic.
Use Egypt's clean process_nameservers method.
2017-06-23 19:58:40 -04:00
RageLtMan de0867aaba Address wchen-r7's initial comments
Advanced options are now camel cased
Use :blank? on datastore options instead of serial checks for :nil?
and :empty?
Rex::Proto::DNS::Server :on_client_data updated to ask the tcp_sock
to close this client if it exists in the rescue clause.
2017-06-23 19:58:38 -04:00
RageLtMan 2347c8df99 Create basic packet manipulation modules
Create Rex::Proto::DNS::Packet and Packet::Raw to allow common
parsing, validation, and raw data operations across both Rex and
Msf namespaces.

The modules contain class methods and do not need to be mixed in
to use their functionality Packet.method is enough, and reduces GC
strain since new objects are not constantly being instantiated, and
these modules contain no internal state.

Clean up UDP socket leak from Rex::Proto::DNS::Server under certain
conditions.

Create Msf::Exploit::DNS::Common mixin to provide descendants with
access to Packet and the hostname Regex.

-----

Testing:
  Tested running the RC provided in the pull request
  Manual testing in IRB/Pry while porting PoC for CVE-2015-7547
2017-06-23 19:58:37 -04:00
RageLtMan 2679c26e88 Create and implement Rex::IO::GramServer mixin
Rex::IO::StreamServer provides consistent methods and accessors
for TcpServer type consumers, but includes logic for client actions
which are not relevant in a datagram context - connect and
disconnect actions, as well as any notion of stateful session
persistence (the clients queue) do not apply in this paradigm.

Implement a Rex::IO::GramServer mixin which provides common methods
for dispatching requests and sending responses. Defines the same
callback structure for procs as used in the StreamServer, though
utilizing dispatch_request_proc and send_response_proc with client
and data parameters for efficient interception of execution flow
when dealing with stateless comms.

Rewire Rex::Proto::DNS server to use instance variables along the
same convention as other modules, implement the GramServer mixin,
and minor misc cleanup.

-----

Change calling conventions in Rex::Proto::DNS::Server to match
other components.

Clean up the Msf::Exploit::DNS namespace with generic server
interfaces.

Fix the advanged options naming convention - as hdm pointed out,
evasion options use the '::' separator, advanced options use "_".

-----

Testing:
  Basic functional tests in Pry for now.
2017-06-23 19:58:37 -04:00
RageLtMan 8f9d98775b Export common socket functionality from TcpServer
Exploit::Remote::TcpServer contains functionality required by the
hybrid Udp/Tcp Exploit::Remote::DNS::Server. In order to avoid
having to maintain a set of compatible methods across the transport
implementations, create a new mixin "above" the TcpServer to handle
common socket operations - Exploit::Remote::SocketServer.

Copy Exploit::Remote::TcpServer to Exploit::Remote::SocketServer.
Remove common code from Exploit::Remote::TcpServer, remove TCP/SSL
specific code from Exploit::Remote::SocketServer. Require and
include Exploit::Remote::SocketServer in Exploit::Remote::TcpServer

Testing:
  Basic testing using the telnet capture server which utilzies the
modified Exploit::Remote::TcpServer mixin:

```
use auxiliary/server/capture/telnet
(2016-02-28)15:23 (S:0 J:0)msf  auxiliary(telnet) > exploit
[*] Auxiliary module execution completed
(2016-02-28)15:23 (S:0 J:1)msf  auxiliary(telnet) >
[*] [2016.02.28-15:23:39] Listening on 0.0.0.0:23...
[*] [2016.02.28-15:23:39] Server started.
[*] [2016.02.28-15:23:48] TELNET LOGIN 127.0.0.1:60408 jack / jill
Interrupt: use the 'exit' command to quit
```
2017-06-23 19:58:37 -04:00
RageLtMan 0e5ec4c646 Fix processing of static hosts in Msf...Server
The add_static_hosts method used old interfaces and had not been
tested prior.
Address the interfaces, functionally check the logic, and add the
method into start_service to automatically process the static
hosts entries set in the DS.
2017-06-23 19:58:36 -04:00
RageLtMan 2f0003b5bd Implement native DNS for Msf Namespace
Built atop the Rex::Proto::DNS work to implement mixins for client
and server functionality, providing common interfaces for querying
domain name servers, and providing domain name services to clients
across Rex sockets. Fully functional native DNS server module is
included to demonstrate functionality, serve as a spoofing DNS
server, a collecting proxy, or any other number of DNS functions.

-----

At the core of this work is a Rex::Proto::DNS::Resolver object
descended from Net::DNS::Resolver with overrides and alterations
for using Rex sockets. The sockets implementation has been in use
internally for a number of years and is well tested. Changes have
been made to provider better interface for higher level components.

The resolver provides forward lookup capability for the server
(Rex::Proto::DNS::Server) which also implements a self-pruning
Cache subclass capable of holding static entries. The server can
operate in TCP or UDP mode, and provides a common abstraction for
addressing TCP and UDP clients by passing a Rex::Socket::Udp
mock client around with the data object to higher level consumers.
Finally, as is standard practice when building full service objects
from Rex to Msf, the server allows consumers to efficiently take
execution control at the request and response handlers by passing
Procs into the constructor (or manually assigning at runtime) for
execution instead of the default call chain.

The service, lookup, and caching functionality is encapsulated and
stands on its own to be used by consumers other than the standard
Msf::Exploit::Remote namespaces. It is intended to serve as the
driver and transport handler for pending DNS tunnel transports,
and can be used by exploit and auxiliary modules directly.

-----

The Msf::Exploit::Remote namespace receives DNS, DNS::Client, and
DNS::Server mixins providing common interfaces for Rex::Proto::DNS
objects. These mixins create convenience methods for executing
queries, serving requests, and configuring the Rex providers.

DNS::Client mixin attempts to "intelligently" configure the client
resolver's name servers and options from the data store. Accessor,
query, and configuration methods are provided in this mixin. Of
note are the wildcard and switchdns methods which were adapted
from prior work by others (likely Carlos Perez) which can be used
by numerous consumer modules. Consumers should use setup_client
during their run call to ensure the resolver is appropriately
configured.

DNS::Server mixin creates common service wrappers for modules to
utilize along with a configuration mechanism analagous to the
one used by the Client mixin, called setup_server, and calling
the setup_client method if present. Note that when setup_server
is called, the consumer does not need to call setup_resolver.

------

At the framework module level, a native dns server is provided
to showcase the mixin functionality and provide everything from
normal DNS services, to tunneling proxies (with cache disabled),
spoofing services, and MITM functionality via the handler Procs
for requests and responses.

Use auxiliary/server/dns/native_server to get started.

-----

Testing:
  Basic local testing completed.
  Needs to be checked for info leaks - we used to leak a lot.
  Needs to be checked for functionality under varying configs.

Notes:
  We have a serious problem with the datastore somewhere in the
Msf namespace. Datastore options must be validated with
options.validate(datastore) or they are all Strings, which
completely destroys any type-dependent logic consuming
datastore values. This must be addressed separately and all
calls to options.validate(datastore) should be removed (other
work has included such calls as well, this just proved that
the problem exists upstream).

Future work:
  Implement sessions transports atop the DNS infrastructure in
order to provide native DNS tunneling.
2017-06-23 19:58:35 -04:00
L3cr0f 6a3fc618a4 Add bypassuac_injection_winsxs.rb module 2017-06-03 12:59:50 +02:00
HD Moore 66f06cd4e3 Fix small typos in comments 2017-05-28 14:40:33 -05:00
HD Moore 8caaba01f1 Add share enumeration methods to the SMB mixin 2017-05-26 17:01:18 -05:00
HD Moore 18a871d6a4 Delete the .so, add PID bruteforce option, cleanup 2017-05-25 16:03:14 -05:00
Matthew Daley 52363aec13 Add module for CVE-2017-8895, UAF in Backup Exec Windows agent
This module exploits a use-after-free vulnerability in the handling of
SSL NDMP connections in Veritas/Symantec Backup Exec's Remote Agent for
Windows. When SSL is re-established on a NDMP connection that previously
has had SSL established, the BIO struct for the connection's previous
SSL session is reused, even though it has previously been freed.

Successful exploitation will give remote code execution as the user of
the Backup Exec Remote Agent for Windows service, almost always
NT AUTHORITY\SYSTEM.
2017-05-24 00:18:20 +12:00
Renato Piccoli 29d1022ae2 Fix the rake spec failures under ruby 2.4.
Ths typo3_spec is giving some errors under ruby 2.4+
and OpenSSL 1.1+.
2017-05-21 21:56:04 +02:00
James Lee 4def7ce6cc Land #8327, Simplify storing credentials 2017-05-18 16:49:01 -05:00
wchen-r7 58d65ce4b5 Land #8380, check for command injection in smtp email addresses
aborts
2017-05-16 15:36:22 -05:00
Brent Cook e7be0af72e update bad mail checks 2017-05-14 22:13:31 -05:00
Brent Cook 8ac5d2d377 tidy up a bit while we're in here 2017-05-14 21:27:38 -05:00
Brent Cook 544ea6926c trim leading and trailing whitespace in mail addresses 2017-05-14 11:22:46 -05:00
RageLtMan cf29a512d0 Upstream Msf namespace PSH decompressor & decoder
Present convenience interfaces in Msf::Exploit::Powershell ns for
decoding and decompressing PSH strings built with Rex::Powershell
or compatible implementations.
2017-05-10 22:44:56 -04:00
Jeffrey Martin 63b6ab5355 simplify valid credential storage 2017-05-04 22:51:40 -05:00
Brent Cook 288cb6536d fix #8305, escape unadorned periods in the front of SMTP payloads 2017-04-26 16:05:46 -05:00
Christian Mehlmauer 3c260ea452 fix #7921, HttpTrace and chunked encoding 2017-04-05 22:58:11 +02:00
William Vu 1a96fb03ae Allow start_service to specify a resource
This overrides URIPATH and random_uri if opts['Path'] is specified.
2017-03-09 02:33:02 -06:00
William Vu 1a0b342e68 Add srvport to HttpServer
This allows URIPORT to override SRVPORT.
2017-03-09 02:24:22 -06:00
wchen-r7 f27ef55391 Land #7992, Improve Signature Evasions for browser exploits 2017-02-23 16:32:49 -06:00
Jeff Tang e3f613ecc6 Bypass: Metasploit OS detection
SEP is triggering on HTTP POSTs which start with `os_name`
2017-02-23 15:42:04 -05:00
Jeff Tang 84ab3c66cc Use obfuscated JS in BES 2017-02-22 12:47:36 -05:00
William Vu b06895b604 Hide RPORT more intelligently 2017-02-08 09:40:42 -06:00
William Vu 31f93de150 Update HttpClient and WordPress mixins 2017-02-06 04:40:26 -06:00
James Lee 3c7f78167a Push up the preamble and modernize style 2017-02-02 17:57:03 -06:00
Pearce Barry 9b16cdf602 Land #7845, Fix Msf::Exploit::EXE shellcode/template mismatch 2017-01-22 16:09:41 -06:00
Brent Cook 836da6177f Cipher::Cipher is deprecated 2017-01-22 10:20:03 -06:00
Brent Cook f69b4a330e handle Ruby 2.4 Fixnum/Bignum -> Integer deprecations 2017-01-22 10:20:03 -06:00