-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
smb.lua: fix bug in start_session_basic while parsing status #1480
Conversation
Alternative solution for same issue in #1714 |
A fix for this issue has been committed as r37730. Please note that your fix does not properly rectify the issue: By replacing the return false, get_status_name(status) never gets executed but it also means that the real status, captured in the inner Thank you for contributing to nmap! |
Thanks for your feedback! I chose to use a different variable because IMO there's a confusion risk since -- Read the result
status, header, parameters, data = smb_read(smb)
if(status ~= true) then
return false, header
end Then it's used to collect integer return codes that are mapped with Anyway, if the return status from if(status ~= true) then
return false, header I don't see how the caller could get something else or miss the real |
Choosing a different variable is fine, as it prevents confusion when the same variable is used for different purposes. No dispute there. If you still do not see where your fix is falling short then ask yourself the following question: With your fix, is the function ever going to execute line return false, get_status_name(status) that is outside of the while-loop and correctly interpret the numerical code collected inside the loop? |
No it won't be executed because the following Lines 1198 to 1201 in ce28753
Even before it has a chance of collecting a return code in status and reaching what you mentioned:Lines 1288 to 1289 in ce28753
But according to me it's the same with r37730, isn't it? If it would have been a |
(doing some more tests... :)) |
Consider the consequences of your fix causing the outer |
Show me that r37730 will ever have |
Okayyy I got it :) I was misinterpreting something... Thank you for insisting! I look forward to getting a review from your keen eyes on my other SMB PRs! |
When using the "smb-os-discovery" script against a host which refuses connection with anonymous and guest accounts, and with the latest Nmap version from Git, we have an error:
After adding a few
print
, I understood that there was a confusion aroundstatus
since in the same function it's used for two purposes:smb_read
, as a boolean:nmap/nselib/smb.lua
Lines 1196 to 1199 in 1650469
smb.get_status_name
):nmap/nselib/smb.lua
Line 1206 in 1650469
After the patch, we have:
("No accounts left to try" comes from the smbauth lib)
The error displayed is different from what we see with the latest 7.70 release:
This error was better but I'm wondering if it was intended or if it is thanks to a lucky bug. We have a loop which tries to connect with two accounts, here the status is the same for both (NT_STATUS_ACCESS_DENIED) but it could have been different. And with this code, we only would see the status code for the last try, not the previous.
FYI, git bisect tells me that the difference between the latest version from source and the latest 7.70 release, comes from fd86015