hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
713 stars 180 forks source link

How to get folder path using share name? #567

Closed kvk484 closed 3 years ago

kvk484 commented 4 years ago

Hi Can you plz let me know how can I get the physical location of a share , like (C:\abc\xyz...) given a sharename or sharerelative path. I searched all the info in FIleALLinformation to noavail.

hierynomus commented 4 years ago

I don't think you can get this. I think the SMB system is shielded from this. The only way to know would be to browse the Administrative Shares (C$).

pepijnve commented 4 years ago

You can get this using MS-SRVS RPC calls (https://github.com/rapid7/smbj-rpc/blob/master/src/main/java/com/rapid7/client/dcerpc/mssrvs/ServerService.java), provided the SMB server in question supports this. Info level 2 (https://github.com/rapid7/smbj-rpc/blob/master/src/main/java/com/rapid7/client/dcerpc/mssrvs/dto/NetShareInfo2.java) for instance provides the path you're looking for.

Note that this will almost always be a Windows style path even if you're talking to a UNIX based SMB server. Most systems I've seen so far take the Unix path, change all /s to \ and stick C:\ in front of the path.

hierynomus commented 3 years ago

@kvk484 I think @pepijnve's answer should solve your question. As such I'm closing this issue. If you have any additional questions, feel free to reopen.