rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
33.93k stars 13.94k forks source link

Rex::Proto::SMB::Exceptions::LoginError Login Failed: undefined method `force_encoding' for nil:NilClass #15916

Closed bcoles closed 2 years ago

bcoles commented 2 years ago

Reproduce:

Log:

[-] 172.16.191.123:445 - Exploit failed [no-access]: Rex::Proto::SMB::Exceptions::LoginError Login Failed: undefined method `force_encoding' for nil:NilClass

The failure is unavoidable, but the error message is obtuse. The correct error message can be restored by setting smbuser and smbpass to empty strings.

msf6 exploit(windows/smb/ms07_029_msdns_zonename) > set smbpass ""
smbpass => 
msf6 exploit(windows/smb/ms07_029_msdns_zonename) > set smbuser ""
smbuser => 
msf6 exploit(windows/smb/ms07_029_msdns_zonename) > run

[*] Started reverse TCP handler on 172.16.191.192:4444 
[*] 172.16.191.123:445 - Detected a Windows 2000 SP0-SP4 target...
[*] 172.16.191.123:445 - Trying target Windows 2000 Server SP0-SP4+ English...
[*] 172.16.191.123:445 - Binding to 50abc2a4-574d-40b3-9d66-ee4fd5fba076:5.0@ncacn_np:172.16.191.123[\dnsserver] ...
[-] 172.16.191.123:445 - Exploit failed [no-access]: Rex::Proto::SMB::Exceptions::ErrorCode The server responded with error: STATUS_ACCESS_DENIED (Command=162 WordCount=0)
[*] Exploit completed, but no session was created.
msf6 exploit(windows/smb/ms07_029_msdns_zonename) > 
3V3RYONE commented 2 years ago

Hey @bcoles , I would like to work on this issue! May I?

bcoles commented 2 years ago

Hey @bcoles , I would like to work on this issue! May I?

All yours.

3V3RYONE commented 2 years ago

Update :
I am working on tracing the call to the exception in the libraries.
I feel there is a not a check on NULL parameters (user and pass) in the exception; but there is a check on empty string parameters.
I am trying to get it fixed soon. :D

3V3RYONE commented 2 years ago

Update @bcoles

Hey, I have fixed the bug, by manually going through the call stacks.
Now we don't get this error message if we unset the smbuser and smbpass then run.

Log:

msf6 exploit(windows/smb/ms07_029_msdns_zonename) > unset smbuser
Unsetting smbuser...
msf6 exploit(windows/smb/ms07_029_msdns_zonename) > unset smbpass
Unsetting smbpass...
msf6 exploit(windows/smb/ms07_029_msdns_zonename) > run

[*] Started reverse TCP handler on 192.168.1.105:4444 
[*] 192.168.1.103:445 - Unknown OS: Windows 7 Professional 7601 Service Pack 1
[*] Exploit completed, but no session was created.

Now, I just have to confirm this by using the debugger call stacks and then create a PR with a unit test written.
It was amazing :D

3V3RYONE commented 2 years ago

Hey, its my exam week going on.. I am seriously doing this PR the first thing after this weekend..
Really sorry for the delay :(

bcoles commented 2 years ago

Hey, its my exam week going on.. I am seriously doing this PR the first thing after this weekend.. Really sorry for the delay :(

No worries. Good luck :)

3V3RYONE commented 2 years ago

hey @bcoles , thank you so much for your wishes :) ..
Finally I did a PR.. you can check it out in your time :D