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

Stracktrace when attempting to connect to a likely non windows host #373

Closed
nikaiw opened this issue Jul 19, 2024 · 1 comment · Fixed by #376
Closed

Stracktrace when attempting to connect to a likely non windows host #373

nikaiw opened this issue Jul 19, 2024 · 1 comment · Fixed by #376
Labels
bug Something isn't working

Comments

@nikaiw
Copy link
Contributor

nikaiw commented Jul 19, 2024

*** Version used ***

  • impacket 0.12.0.dev1+20240321.171907.9419e83
  • netexec 1.2.0+3a5c109, installed using Python 3.10.12

*** Reproduction steps ***
nxc smb target -M ioxidresolver

[17:13:28] ERROR    Exception while calling proto_flow() on target ip: Could not connect: [Errno 111] Connection refused                                                                                           connection.py:151

/home/user/tools/NetExec/venv/lib/python3.10/site-packages/impacket/dcerpc/v5/transport.py:352 in connect
                                                                                                         
  349 │   │   self.__socket = socket.socket(af, socktype, proto)                                         
  350 │   │   try:                                                                                       
  351 │   │   │   self.__socket.settimeout(self.get_connect_timeout())                                   
❱ 352 │   │   │   self.__socket.connect(sa)                                                              
  353 │   │   except socket.error as msg:                                                                
  354 │   │   │   self.__socket.close()                                                                  
  355 │   │   │   raise DCERPCException("Could not connect: %s" % msg)                                   

ConnectionRefusedError: [Errno 111] Connection refused              
                                                                    
During handling of the above exception, another exception occurred: 

/home/user/tools/NetExec/venv/lib/python3.10/site-packages/nxc/connection.py:143 in __init__             
                                                                                                         
  140 │   │                                                                                              
  141 │   │   try:                                                                                       
  142 │   │   │   #before = set(list_open_sockets())                                                     
❱ 143 │   │   │   self.proto_flow()                                                                      
  144 │   │   │   #after = set(list_open_sockets())                                                      
  145 │   │   │   #leaked_sockets = after - before                                                       
  146 │   │   │   #if leaked_sockets:                                                                    
                                                                                                         
/home/user/tools/NetExec/venv/lib/python3.10/site-packages/nxc/connection.py:205 in proto_flow           
                                                                                                         
  202 │   │   │   if self.print_host_info() and (self.login() or (self.username == "" and                
      self.password == "")):                                                                             
  203 │   │   │   │   if hasattr(self.args, "module") and self.args.module:                              
  204 │   │   │   │   │   self.logger.debug("Calling modules")                                           
❱ 205 │   │   │   │   │   self.call_modules()                                                            
  206 │   │   │   │   else:                                                                              
  207 │   │   │   │   │   self.logger.debug("Calling command arguments")                                 
  208 │   │   │   │   │   self.call_cmd_args()                                                           
                                                                                                         
/home/user/tools/NetExec/venv/lib/python3.10/site-packages/nxc/connection.py:259 in call_modules         
                                                                                                         
  256 │   │   │                                                                                          
  257 │   │   │   if hasattr(module, "on_login"):                                                        
  258 │   │   │   │   self.logger.debug(f"Module {module.name} has on_login method")                     
❱ 259 │   │   │   │   module.on_login(context, self)                                                     
  260 │   │   │                                                                                          
  261 │   │   │   if self.admin_privs and hasattr(module, "on_admin_login"):                             
  262 │   │   │   │   self.logger.debug(f"Module {module.name} has on_admin_login method")               
                                                                                                         
/home/user/tools/NetExec/venv/lib/python3.10/site-packages/nxc/modules/IOXIDResolver.py:29 in on_login   
                                                                                                         
  26 │   │                                                                                               
  27 │   │   portmap = rpctransport.get_dce_rpc()                                                        
  28 │   │   portmap.set_auth_level(authLevel)                                                           
❱ 29 │   │   portmap.connect()                                                                           
  30 │   │                                                                                               
  31 │   │   objExporter = IObjectExporter(portmap)                                                      
  32 │   │   bindings = objExporter.ServerAlive2()                                                       
                                                                                                         
/home/user/tools/NetExec/venv/lib/python3.10/site-packages/impacket/dcerpc/v5/rpcrt.py:803 in connect    
                                                                                                         
   800 │   │   self._ctx = ctx_id                                                                        
   801 │                                                                                                 
   802 │   def connect(self):                                                                            
❱  803 │   │   return self._transport.connect()                                                          
   804 │                                                                                                 
   805 │   def disconnect(self):                                                                         
   806 │   │   return self._transport.disconnect()                                                       
                                                                                                         
/home/user/tools/NetExec/venv/lib/python3.10/site-packages/impacket/dcerpc/v5/transport.py:355 in connect
                                                                                                         
  352 │   │   │   self.__socket.connect(sa)                                                              
  353 │   │   except socket.error as msg:                                                                
  354 │   │   │   self.__socket.close()                                                                  
❱ 355 │   │   │   raise DCERPCException("Could not connect: %s" % msg)                                   
  356 │   │   return 1                                                                                   
  357 │                                                                                                  
  358 │   def disconnect(self):                                                                          

DCERPCException: Could not connect: [Errno 111] Connection refused

EDIT by @NeffIsBack: formatting

@nikaiw nikaiw changed the title Stracktrace when attempting to connect a likely non windows host Stracktrace when attempting to connect to a likely non windows host Jul 19, 2024
@NeffIsBack NeffIsBack added the bug Something isn't working label Jul 19, 2024
@nikaiw
Copy link
Contributor Author

nikaiw commented Jul 19, 2024

fixed with #376

@nikaiw nikaiw closed this as completed Jul 19, 2024
NeffIsBack added a commit that referenced this issue Jul 19, 2024
Add try&except block for DCERPCExceptions to fix #373
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants