GithubHelp home page GithubHelp logo

modulexcite / mssqlproxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blackarrowsec/mssqlproxy

0.0 0.0 0.0 181 KB

mssqlproxy is a toolkit aimed to perform lateral movement in restricted environments through a compromised Microsoft SQL Server via socket reuse.

License: Other

C# 6.30% Python 51.57% C++ 37.92% C 4.21%

mssqlproxy's Introduction

mssqlproxy

mssqlproxy is a toolkit aimed to perform lateral movement in restricted environments through a compromised Microsoft SQL Server via socket reuse. The client requires impacket and sysadmin privileges on the SQL server.

Please read this article carefully before continuing.

It consists of three parts:

  • CLR assembly: Compile assembly.cs
  • Core DLL: Compile reciclador.sln
  • Client: mssqlclient.py (based on Impacket's example)

You can compile the libraries or download them from releases (x64).

Compilation

To generate the core DLL, just import the project to Visual Studio (reciclador.sln) and compile it.

To generate the CLR assembly, first you need to find the C# compiler:

Get-ChildItem -Recurse "C:\Windows\Microsoft.NET\" -Filter "csc.exe" | Sort-Object fullname -Descending | Select-Object fullname -First 1 -ExpandProperty fullname

Then,

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /target:library .\assembly.cs

Usage

Once the two libraries are compiled, upload the core DLL (reciclador) to the target server.

Authentication options are the same as the ones in the original mssqlclient. mssqlproxy options:

proxy mode:
  -reciclador path      Remote path where DLL is stored in server
  -install              Installs CLR assembly
  -uninstall            Uninstalls CLR assembly
  -check                Checks if CLR is ready
  -start                Starts proxy
  -local-port port      Local port to listen on
  -clr local_path       Local CLR path
  -no-check-src-port    Use this option when connection is not direct (e.g. proxy)

We have also implemented two commands (within the SQL shell) for downloading and uploading files. Relating to the proxy stuff, we have four commands:

  • install: Creates the CLR assembly and links it to a stored procedure. You need to provide the -clr param to read the generated CLR from a local DLL file.
  • uninstall: Removes what install created.
  • check: Checks if everything is ready to start the proxy. Requires to provide the server DLL location (-reciclador), which can be uploaded using the upload command.
  • start: Starts the proxy. If -local-port is not specified, it will listen on port 1337/tcp.

Once the proxy is started, you can plug in your proxychains ;)

asciicast

Note #1: if using a non-direct connection (e.g. proxies in between), the -no-check-src-port flag is needed, so the server only checks the source address.

Note #2: at the moment, only IPv4 targets are supported (nor DNS neither IPv6 addresses).

Note #3: use carefully! by now the MSSQL service will crash if you try to establish multiple concurrent connections

Important: It's important to stop the mssqlproxy by pressing Ctrl+C on the client. If not, the server may crash and you will have to restart the MSSQL service manually.

Authors

Pablo Martinez (@xassiz), Juan Manuel Fernandez (@TheXC3LL)

References

License

All the code included in this project is licensed under the terms of the MIT license. The mssqlclient.py is based on Impacket.

mssqlproxy's People

Contributors

xassiz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.