Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ntlmrelayx.py SOCKS option TypeError with socks5 #1025

Closed
mpgn opened this issue Jan 27, 2021 · 4 comments
Closed

ntlmrelayx.py SOCKS option TypeError with socks5 #1025

mpgn opened this issue Jan 27, 2021 · 4 comments

Comments

@mpgn
Copy link
Contributor

mpgn commented Jan 27, 2021

Configuration

impacket version: Impacket v0.9.23.dev1+20201123.132651.18df2123
Python version: 3.8
Target OS: Windows

Debug Output With Command String

When using socks option from ntlmrelayx.py, there is an error when trying to use secredump or any other tool with proxychains.

sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support -socks

...


ntlmrelayx> socks
Protocol  Target           Username                AdminStatus  Port 
--------  ---------------  ----------------------  -----------  ----
SMB       192.168.133.164  POUDLARD/ADMINISTRATOR  TRUE         445  
ntlmrelayx> 
ntlmrelayx> 
ntlmrelayx> 
ntlmrelayx> ----------------------------------------
Exception happened during processing of request from ('192.168.133.156', 39640)
Traceback (most recent call last):
  File "/usr/lib/python3.8/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python3.8/dist-packages/impacket-0.9.23.dev1+20201123.132651.18df2123-py3.8.egg/impacket/examples/ntlmrelayx/servers/socksserver.py", line 283, in __init__
    socketserver.BaseRequestHandler.__init__(self, request, client_address, server)
  File "/usr/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/local/lib/python3.8/dist-packages/impacket-0.9.23.dev1+20201123.132651.18df2123-py3.8.egg/impacket/examples/ntlmrelayx/servers/socksserver.py", line 305, in handle
    self.__connSocket.sendall(str(SOCKS5_GREETINGS_BACK()))
TypeError: __str__ returned non-string (type bytes)
----------------------------------------

I got this error when using proxychains:

$ proxychains secretsdump.py POUDLARD/[email protected] -no-pass
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.14
Impacket v0.9.23.dev1+20201123.132651.18df2123 - Copyright 2020 SecureAuth Corporation

[proxychains] Strict chain  ...  192.168.133.156:1080  ...  192.168.133.164:445 <--socket error or timeout!
[-] RemoteOperations failed: [Errno Connection error (192.168.133.164:445)] [Errno 111] Connection refused
[*] Cleaning up... 

$ nmap -v -p 445 192.168.133.164                                                                                                                                                                          130 ⨯
Starting Nmap 7.91 ( https://nmap.org ) at 2021-01-27 09:59 EST
Initiating Ping Scan at 09:59
Scanning 192.168.133.164 [2 ports]
Completed Ping Scan at 09:59, 0.00s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 09:59
Completed Parallel DNS resolution of 1 host. at 09:59, 0.02s elapsed
Initiating Connect Scan at 09:59
Scanning 192.168.133.164 [1 port]
Discovered open port 445/tcp on 192.168.133.164
Completed Connect Scan at 09:59, 0.00s elapsed (1 total ports)
Nmap scan report for 192.168.133.164
Host is up (0.00065s latency).

PORT    STATE SERVICE
445/tcp open  microsoft-ds

Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds

PCAP

no pcap

Additional context

fail when using socks option from ntlmrelayx using socks5 in proxychains but it works using socks4

@mpgn mpgn changed the title ntlmrelayx.py SOCKS option TypeError ntlmrelayx.py SOCKS option TypeError with socks5 Jan 27, 2021
@asolino
Copy link
Collaborator

asolino commented Jan 27, 2021

Thanks for the report @mpgn. I can reproduce it.
In the meantime switch to socks4 in your proxychains.conf. It should work with that version.

@mpgn
Copy link
Contributor Author

mpgn commented Jan 27, 2021

Yep, using socks4 it's working fine 👍

asolino added a commit that referenced this issue Jan 27, 2021
@asolino
Copy link
Collaborator

asolino commented Jan 27, 2021

Please git pull and retest @mpgn

@mpgn
Copy link
Contributor Author

mpgn commented Jan 27, 2021

can confirm it's working with socks5 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants