go-smb2 icon indicating copy to clipboard operation
go-smb2 copied to clipboard

feature request: add server version detection

Open ilyapashuk opened this issue 4 years ago • 5 comments

please add an option to retrieve an operating system and server soft version of the session, like in nmap.

ilyapashuk avatar Aug 26 '20 17:08 ilyapashuk

I don't know how to detect OS in smb2. I just googled it, and it seems to me that nmap currently doesn't support OS detection in smb2.

It has get_os function for smb1. https://github.com/nmap/nmap/blob/ccdb81655208383fe5144bffcd77edf4f47c4bd0/nselib/smb.lua#L3383

But I couldn't find similar functionality for smb2. https://github.com/nmap/nmap/blob/ccdb81655208383fe5144bffcd77edf4f47c4bd0/nselib/smb2.lua

hirochachacha avatar Aug 26 '20 23:08 hirochachacha

I think it's possible. At https://github.com/stacktitan/smb/blob/da9a425dceb89b24a6e823c9069349b165b3b6de/smb/session.go#L191 , I can use this to get any winodws OS , it's a part of smb interaction before authentication, but I'm not sure about its version,I think it's smb v2 @hirochachacha

PassingFoam avatar May 22 '21 03:05 PassingFoam

really? I can't see any os information on wireshark.

image

hirochachacha avatar May 22 '21 04:05 hirochachacha

it's in the next field after Target Info image @hirochachacha

PassingFoam avatar May 22 '21 15:05 PassingFoam

As far as I can tell, that's is more like NTLM version. We can't detect os itself like linux, macos because there're no constants for third party's implementations.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/b1a6ceb2-f8ad-462b-b5af-f18527c48175 https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/a211d894-21bc-4b8b-86ba-b83d0c167b00#Appendix_A_31

On the other hand, nmap's smb implementation can detect samba on unix, so it's different.

https://github.com/nmap/nmap/blob/ccdb81655208383fe5144bffcd77edf4f47c4bd0/nselib/smb.lua#L1223-L1239

hirochachacha avatar May 24 '21 00:05 hirochachacha