Commit Graph

67 Commits (2ed05869b8e641ab8d465d214e7a51cd56ee0c19)

Author SHA1 Message Date
HD Moore 673e21cfaf Rework meterpreter SSL & pass datastore to handle_connection()
This allows HandlerSSLCert to be used to pass a SSL certificate into the Meterpreter handler. The datastore has to be passed into handle_connection() for this to work, as SSL needs to be initialized on Session.new. This still doesn't pass the datastore into Meterpreter directly, but allows the Session::Meterpreter code to extract and pass down the :ssl_cert option if it was specified. This also fixes SSL certificate caching by expiring the cached cert from the class variables if the configuration has changed. A final change is to create a new SSL SessionID for each connection versus reusing the SSL context, which is incorrect and may lead to problems in the future (if not already).
2014-11-22 15:35:00 -06:00
HD Moore dbb192532e Remove obsolete call to update_host_via_sysinfo() 2014-03-30 06:23:07 -07:00
Tod Beardsley 6e88bbd827
No need for that kind of language 2014-03-04 14:34:50 -06:00
James Lee e9ccec4755
Refactor load_session_info
All of this code is in sore need of some specs but I think this change
makes it a bit easier to understand what it is supposed to be doing.
2014-01-21 18:55:54 -06:00
Raphael Mudge ac151794f3 Make Meterpreter Session Address Resolution Sane
If MSF can not match the visible IP address of a Meterpreter session
to an interface--it will attempt to find an IP address associated
with a default route and use it as the session's address.

This commit fixes the logic associated with this process. The old
logic only considers one IP address per Interface, even though an
Interface may have multiple addresses/masks associated with it.

This flaw led to situations where MSF would favor an IPv6 link-local
address over the IPv4 address associated with the default route,
solely because the IPv4 address was not the first value in the
addresses array.

[FixRM #7259]
2014-01-21 00:32:50 -05:00
Tab Assassin 7e5e0f7fc8 Retab lib 2013-08-30 16:28:33 -05:00
James Lee f4498c3916 Remove $Id tags
Also adds binary coding magic comment to a few files
2013-05-20 16:21:03 -05:00
Luke Imhoff c210260845 Fix Undocumentable method, missing name YARD warning
[#46491831]

Comments at the start of the file with ## caused YARD to think the
comment was documenting the require call.  By removing the ##, the
warning disappeared.  I did not determine what is special about ## in
file comments.
2013-03-30 15:32:38 -05:00
HD Moore d656e3185f Mark all libraries as defaulting to 8-bit strings 2012-06-29 00:18:28 -05:00
James Lee 29e01760f0 Wrap more database usage in with_connection block 2012-04-19 23:51:20 -06:00
James Lee b58a87b7a8 Skip ::1 as well as 127.0.0.1 for session_host
Thanks rsmudge for pointing this out.

[Fixes #6599]
2012-04-08 14:58:39 -06:00
James Lee 40e1cafd6e Remove extraneous debug print 2012-03-14 11:07:31 -06:00
James Lee 1d99330795 Accept multiple addresses and netmasks
[See #6476]
2012-03-13 02:08:34 -06:00
James Lee f5e2d1c19b Grevious typo causing load_session_info failure
That's the problem with rescue ::Exception, it catches crap like this
and it takes a while before anyone notices. =(
2012-02-29 08:14:02 -07:00
James Lee 624e19fd8b Merge session-host-rework branch back to master
Squashed commit of the following:

commit 2f4e8df33c5b4baa8d6fd67b400778a3f93482aa
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 16:31:03 2012 -0700

    Clean up some rdoc comments

    This adds categories for the various interfaces that meterpreter and
    shell sessions implement so they are grouped logically in the docs.

commit 9d31bc1b35845f7279148412f49bda56a39c9d9d
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 13:00:25 2012 -0700

    Combine the docs into one output dir

    There's really no need to separate the API sections into their own
    directory.  Combining them makes it much easier to read.

commit eadd7fc136a9e7e4d9652d55dfb86e6f318332e0
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 08:27:22 2012 -0700

    Keep the order of iface attributes the same accross rubies

    1.8 doesn't maintain insertion order for Hash keys like 1.9 does so we
    end up with ~random order for the display with the previous technique.
    Switch to an Array instead of a Hash so it's always the same.

commit 6f66dd40f39959711f9bacbda99717253a375d21
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 08:23:35 2012 -0700

    Fix a few more compiler warnings

commit f39cb536a80c5000a5b9ca1fec5902300ae4b440
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 08:17:39 2012 -0700

    Fix a type-safety warning

commit 1e52785f38146515409da3724f858b9603d19454
Author: James Lee <egypt@metasploit.com>
Date:   Mon Feb 27 15:21:36 2012 -0700

    LHOST should be OptAddress, not OptAddressRange

commit acef978aa4233c7bd0b00ef63646eb4da5457f67
Author: James Lee <egypt@metasploit.com>
Date:   Sun Feb 26 17:45:59 2012 -0700

    Fix a couple of warnings and a typo

commit 29d87f88790aa1b3e5db6df650ecfb3fb93c675b
Author: HD Moore <hdm@digitaloffense.net>
Date:   Mon Feb 27 11:54:29 2012 -0600

    Fix ctype vs content_type typo

commit 83b5400356c47dd1973e6be3aa343084dfd09c73
Author: Gregory Man <man.gregory@gmail.com>
Date:   Sun Feb 26 15:38:33 2012 +0200

    Fixed scripts/meterpreter/enum_firefox to work with firefox > 3.6.x

commit 49c2c80b347820d02348d694cc71f1b3028b4365
Author: Steve Tornio <swtornio@gmail.com>
Date:   Sun Feb 26 07:13:13 2012 -0600

    add osvdb ref

commit e18e1fe97b89c3a2b8c22bc6c18726853d2c2bee
Author: Matt Andreko <mandreko@gmail.com>
Date:   Sat Feb 25 18:02:56 2012 -0500

    Added aspx target to msfvenom.  This in turn added it to msfencode as well.
    Ref: https://github.com/rapid7/metasploit-framework/pull/188
    Tested on winxp with IIS in .net 1.1 and 2.0 modes

commit e6aa5072112d79bbf8a4d2289cf8d301db3932f5
Author: Joshua J. Drake <github.jdrake@qoop.org>
Date:   Sat Feb 25 13:00:48 2012 -0600

    Fixes #6308: Fall back to 127.0.0.1 when SocketError is raised from the resolver

commit b3371e8bfeea4d84f9d0cba100352b57d7e9e78b
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 17:07:42 2012 -0700

    Simplify logic for whether an inner iface has the same address

commit 5417419f35a40d1c08ca11ca40744722692d3b0d
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 16:58:16 2012 -0700

    Whitespace

commit 9036875c2918439ae23e11ee7b958e30ccc29545
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 16:53:45 2012 -0700

    Set session info before worrying about address

    get_interfaces can take a while on Linux, grab uid and hostname earlier
    so we can give the user an idea of what they popped as soon as possible.

commit f34b51c6291031ab25b5bfb1ac6307a516ab0ee9
Author: James Lee <egypt@metasploit.com>
Date:   Tue Feb 28 16:48:42 2012 -0700

    Clean up rdoc

commit e61a0663454400ec66f59a80d18b0baff4cb8cd9
Author: HD Moore <hd_moore@rapid7.com>
Date:   Tue Feb 28 04:54:45 2012 -0600

    Ensure the architecture is only the first word (not the full WOW64
    message in some cases)

commit 4c701610976a92298c1182eecc9291a1b301e43b
Author: HD Moore <hd_moore@rapid7.com>
Date:   Tue Feb 28 04:49:17 2012 -0600

    More paranoia code, just in case RHOST is set to whitespace

commit c5ff89fe3dc9061e0fa9f761e6530f6571989d28
Author: HD Moore <hd_moore@rapid7.com>
Date:   Tue Feb 28 04:47:01 2012 -0600

    A few more small bug fixes to handle cases with an empty string target
    host resulting in a bad address

commit 462d0188a1298f29ac83b10349aec6737efc5b19
Author: HD Moore <hd_moore@rapid7.com>
Date:   Tue Feb 28 03:55:10 2012 -0600

    Fix up the logic (reversed by accident)

commit 2b2b0adaec2448423dbd3ec54d90a5721965e2df
Author: HD Moore <hd_moore@rapid7.com>
Date:   Mon Feb 27 23:29:52 2012 -0600

    Automatically parse system information and populate the db, identify and
    report NAT when detected, show the real session_host in the sessions -l
    listing

commit 547a4ab4c62dc3248f847dd5d305ad3b74157348
Author: HD Moore <hd_moore@rapid7.com>
Date:   Mon Feb 27 22:16:03 2012 -0600

    Fix typo introduced

commit 27a7b7961e61894bdecd55310a8f45d0917c5a5c
Author: HD Moore <hd_moore@rapid7.com>
Date:   Mon Feb 27 22:11:38 2012 -0600

    More session.session_host tweaks

commit e447302a1a9915795e89b5e29c89ff2ab9b6209b
Author: HD Moore <hd_moore@rapid7.com>
Date:   Mon Feb 27 22:08:20 2012 -0600

    Additional tunnel_peer changes

commit 93369fcffaf8c6b00d992526b4083acfce036bb3
Author: HD Moore <hd_moore@rapid7.com>
Date:   Mon Feb 27 22:06:21 2012 -0600

    Additional changes to session.session_host

commit c3552f66d158685909e2c8b51dfead7c240c4f40
Author: HD Moore <hd_moore@rapid7.com>
Date:   Mon Feb 27 22:00:19 2012 -0600

    Merge changes into the new branch
2012-02-28 18:29:39 -07:00
James Lee 46fef357f4 Clean up some rdoc comments
This adds categories for the various interfaces that meterpreter and
shell sessions implement so they are grouped logically in the docs.
2012-02-28 16:31:03 -07:00
James Lee a81868b6b3 Fix a nil comparison bug
I swear there was a ticket for this but now I can't find it.
2012-02-23 16:30:29 -07:00
HD Moore 3046896204 This commit makes the new unicode string encoding optional, it can be disabled by setting EnableUnicodeEncoding to false or through the 'disable_unicode_encoding' console command in the Meterpreter shell. Fixes #4986
git-svn-id: file:///home/svn/framework3/trunk@13278 4d416f70-5f16-0410-b530-b9f4589650da
2011-07-21 15:44:54 +00:00
James Lee e321d01cd4 actually do what the comment says it does instead of trying to read a bunch of times with a tiny timeout. fixes some issues with shell commands on meterpreter sessions
git-svn-id: file:///home/svn/framework3/trunk@13070 4d416f70-5f16-0410-b530-b9f4589650da
2011-06-30 05:05:02 +00:00
James Lee 1f72859874 set the session info when there is no database. fixes regression introduced by r12523
git-svn-id: file:///home/svn/framework3/trunk@12690 4d416f70-5f16-0410-b530-b9f4589650da
2011-05-23 16:01:24 +00:00
HD Moore 9ce47c01bd Reverting the autoload changes until we can upgrade to a new ActiveSupport library or find a workaround
git-svn-id: file:///home/svn/framework3/trunk@12600 4d416f70-5f16-0410-b530-b9f4589650da
2011-05-12 20:03:55 +00:00
James Lee 06779bc8c0 remove unnecessary requires for stuff in rex. autoload and a high-level require 'rex' in lib/msf/core.rb should take care of everything. see #4371, #4373, r12587, and r12554.
git-svn-id: file:///home/svn/framework3/trunk@12588 4d416f70-5f16-0410-b530-b9f4589650da
2011-05-12 00:53:33 +00:00
HD Moore 93b0c5beb3 Check for the database first
git-svn-id: file:///home/svn/framework3/trunk@12523 4d416f70-5f16-0410-b530-b9f4589650da
2011-05-03 04:49:18 +00:00
James Lee 9c1b4ddca5 add a load command. this will later deprecate the use command under meterpreter for 3.7 release
git-svn-id: file:///home/svn/framework3/trunk@12334 4d416f70-5f16-0410-b530-b9f4589650da
2011-04-16 13:59:57 +00:00
James Lee 96af5e2af6 store session info in the db
git-svn-id: file:///home/svn/framework3/trunk@12317 4d416f70-5f16-0410-b530-b9f4589650da
2011-04-14 18:28:44 +00:00
James Lee d6edeebcef actually log errors from reporting the session fingerprint. would have helped greatly in tracking down #4128
git-svn-id: file:///home/svn/framework3/trunk@12313 4d416f70-5f16-0410-b530-b9f4589650da
2011-04-13 23:03:00 +00:00
Mike Smith d5d9d56081 Create a dedicated db table to track sessions & session events.
* Add new db tables for session & session_events
* Migrate existing session data from events db table
* Modify session report methods to log to the new tables


git-svn-id: file:///home/svn/framework3/trunk@12273 4d416f70-5f16-0410-b530-b9f4589650da
2011-04-07 21:59:32 +00:00
Tod Beardsley 4a41e4e352 Fixes #3742 by sanitizing utf-8 characters for the username and system name in session.info.
Tested with German Win2k3EE and a session created with exploit/windows/mssql/mssql_payload.



git-svn-id: file:///home/svn/framework3/trunk@11848 4d416f70-5f16-0410-b530-b9f4589650da
2011-02-28 21:39:25 +00:00
James Lee 5e9fdc28e7 move shell token stuff up to a mixin so meterpreter can use it, too
git-svn-id: file:///home/svn/framework3/trunk@11682 4d416f70-5f16-0410-b530-b9f4589650da
2011-01-31 05:20:16 +00:00
James Lee d120892e7c post modules working for shell sessions, fixes #3541
git-svn-id: file:///home/svn/framework3/trunk@11599 4d416f70-5f16-0410-b530-b9f4589650da
2011-01-19 02:24:21 +00:00
Joshua Drake c27749db8e add default lookup_error function, fixes #2993
git-svn-id: file:///home/svn/framework3/trunk@10757 4d416f70-5f16-0410-b530-b9f4589650da
2010-10-19 22:53:15 +00:00
Joshua Drake e408d5a155 add windows error messages for windows meterpreter sessions, minor cleanups
git-svn-id: file:///home/svn/framework3/trunk@10605 4d416f70-5f16-0410-b530-b9f4589650da
2010-10-08 19:36:34 +00:00
HD Moore 2e9138ebbc This commit overhauls much of the meterpreter timeouts and staging processes. This fixes a bug with concurrent session handling, reduces CPU load by caching a single SSL certificate for all sessions, increases all of the critical timeouts, and generally makes mass ownage work better. We still need to limit the maximum number of concurrent on_session() threads to something sane to prevent sesssion spikes from dragging out the process even longer. The C-side meterpreter change is minimal and will only help with future compatibility if we move to non-blocking fd's for the SSL socket.
git-svn-id: file:///home/svn/framework3/trunk@10595 4d416f70-5f16-0410-b530-b9f4589650da
2010-10-08 04:11:47 +00:00
James Lee 161ae211c4 add a capabilities hash to the meterpreter client for determining whether libs are available on the server. eventually there should be a way to request this from the server directly instead of inferring it from platform
git-svn-id: file:///home/svn/framework3/trunk@9561 4d416f70-5f16-0410-b530-b9f4589650da
2010-06-18 23:15:48 +00:00
James Lee c1371c8758 add a method for checking if we support ssl and make sure we do before trying initializing the client
git-svn-id: file:///home/svn/framework3/trunk@9386 4d416f70-5f16-0410-b530-b9f4589650da
2010-06-01 17:00:00 +00:00
HD Moore c6c956ab46 Small patch to enable a new stager
git-svn-id: file:///home/svn/framework3/trunk@8984 4d416f70-5f16-0410-b530-b9f4589650da
2010-04-03 05:21:15 +00:00
HD Moore bb0db3cdf6 Closes command and meterpreter sessions in a much more consistent way
git-svn-id: file:///home/svn/framework3/trunk@8865 4d416f70-5f16-0410-b530-b9f4589650da
2010-03-21 04:24:27 +00:00
HD Moore ac0e6515ab Remove the PID from session.info, it doesn't add much value:
git-svn-id: file:///home/svn/framework3/trunk@8784 4d416f70-5f16-0410-b530-b9f4589650da
2010-03-11 14:21:46 +00:00
HD Moore 286bb09a56 Add a timeout wrapper, remove debug statement
git-svn-id: file:///home/svn/framework3/trunk@8773 4d416f70-5f16-0410-b530-b9f4589650da
2010-03-10 22:06:52 +00:00
HD Moore bfab49b9e9 Change the sessions -l output to show info and type vs description, automatically grab the user/hostname on startup (disabled with set AutoSystemInfo false)
git-svn-id: file:///home/svn/framework3/trunk@8772 4d416f70-5f16-0410-b530-b9f4589650da
2010-03-10 22:02:27 +00:00
James Lee 999feb879f setup the input/output handles correctly for meterpreter sessions so we can get the output from scripts
git-svn-id: file:///home/svn/framework3/trunk@8618 4d416f70-5f16-0410-b530-b9f4589650da
2010-02-24 16:46:47 +00:00
Joshua Drake b391abd32d adds scripting for command shell sessions
1. InitialAutoRunScript and AutoRunScript vars work
2. scripts/shells was created to hold them
3. *_shell methods were renamed shell_*
4. added "shell_command" method to command shell sessions
5. converted all uses of *_shell to shell_*
6. all payloads that produce command shell sessions include Msf::Sessions::CommandShellOptions



git-svn-id: file:///home/svn/framework3/trunk@8615 4d416f70-5f16-0410-b530-b9f4589650da
2010-02-24 01:19:59 +00:00
Joshua Drake b98868e32f check for script before trying to run it for all sessions
git-svn-id: file:///home/svn/framework3/trunk@8612 4d416f70-5f16-0410-b530-b9f4589650da
2010-02-23 20:54:18 +00:00
HD Moore a71e8d2af0 Fix up meterpreter script changes
git-svn-id: file:///home/svn/framework3/trunk@8611 4d416f70-5f16-0410-b530-b9f4589650da
2010-02-23 20:16:45 +00:00
Stephen Fewer 6335fde3e1 Commit the Ruby side for the UDP socket pivoting. Change the TCP client channel so the respective StreamAbstraction is responsible for monitoring its own rsock.
git-svn-id: file:///home/svn/framework3/trunk@8431 4d416f70-5f16-0410-b530-b9f4589650da
2010-02-09 16:45:46 +00:00
Stephen Fewer 7b34b46b68 Commit the ruby side for the meterpreter migration overhaul.
git-svn-id: file:///home/svn/framework3/trunk@8199 4d416f70-5f16-0410-b530-b9f4589650da
2010-01-22 19:47:36 +00:00
James Lee a9b1462e9d add a callback for session commands. fixes 618
git-svn-id: file:///home/svn/framework3/trunk@8075 4d416f70-5f16-0410-b530-b9f4589650da
2010-01-06 05:06:12 +00:00
James Lee 4f92d9f431 Revamp the event system and add some ui hooks. Sessions are still ghetto -- we get interact events (in a lame way) but no input or output events yet. see 619
git-svn-id: file:///home/svn/framework3/trunk@7947 4d416f70-5f16-0410-b530-b9f4589650da
2009-12-22 18:52:48 +00:00
HD Moore 8cb6cee2d1 Map class methods to instance
git-svn-id: file:///home/svn/framework3/trunk@6931 4d416f70-5f16-0410-b530-b9f4589650da
2009-08-01 04:12:19 +00:00
HD Moore b70dad9186 Merge the new stubs for meterpreter on other platforms
git-svn-id: file:///home/svn/framework3/trunk@6928 4d416f70-5f16-0410-b530-b9f4589650da
2009-08-01 03:50:40 +00:00