Skip to content

smb-enum-shares fails with NT_STATUS_NO_MEDIA_IN_DEVICE #2272

Description

@dsolstad

Describe the bug
smb-enum-shares fails with the error "NT_STATUS_NO_MEDIA_IN_DEVICE". However, running nmap with -d shows that the plugin does find shares and iterates through them, but fails on a certain share and the plugin doesn't output any shares that it found. On other hosts in the same network, it works perfectly. Other tools, such as PowerView finds the shares as expected.
According to Microsoft, the error code is explained like this:

{No Disk} There is no disk in the drive.
Insert a disk into drive %hs.

I think the issue might be the return statement on line 3313 in smb.lua, that ends the function without it getting to return share_details on line 3320.

  for i = 1, #shares, 1 do
    local status, result
    stdnse.debug1("SMB: Getting information for share: %s", shares[i])
    status, result = share_get_details(host, shares[i])
    if(status == false and result == 'NT_STATUS_BAD_NETWORK_NAME') then
      stdnse.debug1("SMB: Share doesn't exist: %s", shares[i])
    elseif(status == false) then
      stdnse.debug1("SMB: Error while getting share details: %s", result)
      return false, result # <----------------
    else
      -- Save the share details
      table.insert(share_details, result)
    end
  end

  return true, share_details, extra # <--------------

Update: I have confirmed that removing line 3313 fixes the issue.

To Reproduce
nmap -sT -p T:137,139,445 --script smb-enum-shares --script-args smbdomain=,smbusername=,smbpassword=

Version info (please complete the following information):

  • OS: Windows 10
  • Nmap: 7.91

Additional context
It should be noted that I am running nmap without admin privileges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions