Git Product home page Git Product logo

ntlmrelayx.py_to_exe's Introduction

Intro

While trying to convert a current version of impackets ntlmrelayx.py to an exe with pyinstaller, I stumbled upon a shitload of problems. I managed to get it at least partially working with the help of https://twitter.com/Geiseric4

Tools

https://pyinstaller.org/en/stable/index.html
https://github.com/fortra/impacket

My setup is running on a Commando VM on a Windows 10 box with newest Python 3.11.

Install steps

  1. Install PyInstaller: pip install pyinstaller or pip install --upgrade pyinstaller
  2. Installed impacket: pip install impacket
  3. Install missing python dependencies (at least I needed to): pip install dsinternals. pyreadline, uuid

Build steps

You have to tamper the original ntlmrelayx.py (included in this repo as ntlmrelayx_original.py) in order for it to work. The ntlmrelayx.py in this repo is the already prepared version.
The changes are:

After line 55

from impacket.examples.ntlmrelayx.servers.socksserver import SOCKS

from impacket.examples.ntlmrelayx.clients.dcsyncclient import DCSYNCRelayClient
from impacket.examples.ntlmrelayx.clients.httprelayclient import HTTPRelayClient,HTTPSRelayClient
from impacket.examples.ntlmrelayx.clients.rpcrelayclient import RPCRelayClient
from impacket.examples.ntlmrelayx.clients.smbrelayclient import SMBRelayClient
from impacket.examples.ntlmrelayx.clients.smtprelayclient import SMTPRelayClient
from impacket.examples.ntlmrelayx.clients.ldaprelayclient import LDAPRelayClient,LDAPSRelayClient
from impacket.examples.ntlmrelayx.clients.mssqlrelayclient import MSSQLRelayClient
from impacket.examples.ntlmrelayx.clients.imaprelayclient import IMAPRelayClient,IMAPSRelayClient
from impacket.examples.ntlmrelayx.attacks.dcsyncattack import DCSYNCAttack
from impacket.examples.ntlmrelayx.attacks.httpattack import HTTPAttack
from impacket.examples.ntlmrelayx.attacks.httpattacks import adcsattack
from impacket.examples.ntlmrelayx.attacks.ldapattack import LDAPAttack
from impacket.examples.ntlmrelayx.attacks.mssqlattack import MSSQLAttack
from impacket.examples.ntlmrelayx.attacks.smbattack import SMBAttack
from impacket.examples.ntlmrelayx.attacks.imapattack import IMAPAttack
from impacket.examples.ntlmrelayx.attacks.rpcattack import RPCAttack

PROTOCOL_ATTACKS = {"DCSYNC":DCSYNCAttack, "HTTP":HTTPAttack, "HTTPS":adcsattack ,"IMAP":IMAPAttack,"IMAPS":IMAPAttack,"SMB":SMBAttack,"RPC":RPCAttack,"MSSQL":MSSQLAttack,"LDAP":LDAPAttack, "LDAPS":LDAPAttack}
PROTOCOL_CLIENTS = {"DCSYNC":DCSYNCRelayClient, "HTTP":HTTPRelayClient, "HTTPS":HTTPSRelayClient, "SMTP":SMTPRelayClient, "LDAPS":LDAPSRelayClient, "IMAP":IMAPRelayClient, "IMAPS":IMAPSRelayClient, "SMB":SMBRelayClient,"RPC":RPCRelayClient,"MSSQL":MSSQLRelayClient,"LDAP":LDAPRelayClient}

RELAY_SERVERS = []

Replace line 401

# Let's register the protocol clients we have
    # ToDo: Do this better somehow
    for x in PROTOCOL_CLIENTS.keys():
        logging.info('Protocol Client %s loaded..' % x)

Lastly we can compile the .py to an exe (you need to include the paths to the python packages for impacket and uuid to wherever they are stored on your system):

pyinstaller ntlmrelayx.py --onefile --path C:\Python311\Lib\site-packages\impacket,C:\Python311\Lib\site-packages,C:\Python311\Lib

Run

Run as you normally would do

./ntlmrelayx.exe -h
./ntlmrelayx.exe -t ldaps://1.2.3.4 --no-smb-server
./ntlmrelayx.exe -t ldaps://1.2.3.4 -i
...

Errors

If you get PermissionError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions this is because you don't have access to start a socket listening on 445, as this is blocked by Windows own SMB server.
In order to be able to listen for SMB traffic on 445, we need to disable the SMB-Server with the provided commands:

reg add HKLM\SYSTEM\CurrentControlSet\Services\NetBT /v SMBDeviceEnabled /t REG_QWORD /d 0  
Stop-Service "LanmanServer" -Force
Set-Service "LanmanServer" -StartupType Disabled
Reboot  

Updates

Currently not working / problems / resolved:

  • As of today, 15.05.2023 interactive LDAPS shell is working, but enumeration e.g. is not. Currently not able to figure out why.
  • Socks option currently not working

ntlmrelayx.py_to_exe's People

Contributors

erjanmx avatar luemmelsec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ntlmrelayx.py_to_exe's Issues

Error when executing the binary [TypeError: NTLMRelayxConfig.setLDAPOptions() missing 1 required positional argument: 'adddnsrecord']

So, I'm getting the following error when running the binary:

PS C:\Python\dist> .\ntlmrelayx.exe -t http://adcs.local/certsrv/certfnsh.asp -smb2support --adcs
Impacket v0.11.0 - Copyright 2023 Fortra

[] Protocol Client DCSYNC loaded..
[
] Protocol Client HTTP loaded..
[] Protocol Client HTTPS loaded..
[
] Protocol Client SMTP loaded..
[] Protocol Client LDAPS loaded..
[
] Protocol Client IMAP loaded..
[] Protocol Client IMAPS loaded..
[
] Protocol Client SMB loaded..
[] Protocol Client RPC loaded..
[
] Protocol Client MSSQL loaded..
[] Protocol Client LDAP loaded..
[
] Running in relay mode to single host
Traceback (most recent call last):
File "ntlmrelayx.py", line 475, in
File "ntlmrelayx.py", line 178, in start_servers
TypeError: NTLMRelayxConfig.setLDAPOptions() missing 1 required positional argument: 'adddnsrecord'
[35208] Failed to execute script 'ntlmrelayx' due to unhandled exception!

I installed it as shown in the README.

Looking for the error "TypeError: NTLMRelayxConfig.setLDAPOptions() missing 1 required positional argument: 'adddnsrecord'" I found this link: fortra/impacket#1459

Apparently it's a problem related to the impacket version - I'm using the latest version impacket in c:\python\lib\site-packages (0.11.0) - Or it's related to the python version, but I'm using one of the most recent versions .

PS C:\Python\dist> python --version
Python 3.12.2

I did the conversion based on your already modified file (https://github.com/LuemmelSec/ntlmrelayx.py_to_exe/blob/main/ntlmrelayx.py)

Have you ever seen this error message?

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.