Skip to content
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

Option to set the destination IP of an SMB server #305

Open
ellasev opened this issue Dec 3, 2024 · 3 comments
Open

Option to set the destination IP of an SMB server #305

ellasev opened this issue Dec 3, 2024 · 3 comments

Comments

@ellasev
Copy link

ellasev commented Dec 3, 2024

Hey :)
Im trying to switch from using the linux smbclient binary to the smbprotocol repo in one of my projects.

Since I'm using a locally running tunnel, I set the --ip-address flag to localhost. setting the server to localhost doesn't work since this field also affects what shares we will be able to access.
Example: smbclient -U <user name> -c "dir" //shareServer/shareName --password <password> -W <domain name> -I 127.0.0.1 -p 1234

I've noticed there isn't a similar option in this repo.

@jborean93
Copy link
Owner

jborean93 commented Dec 3, 2024

There is no analogue here, this library will use the server specified in the UNC path so in this case you would do r'\\127.0.0.1\share\…' as the path. There is no reason that I’m aware where you want a different server name in the requested path vs what you are connecting to. The port is a bit more difficult though, you have to specify it always through the port kwarg.

@ellasev
Copy link
Author

ellasev commented Dec 3, 2024

Ive seen in multiple places so far I'm accessible to different shares when accessing \\127.0.0.1\share\… vs \\server\share\…
I would be happy to help write this feature if it's a possibility

@jborean93
Copy link
Owner

jborean93 commented Dec 3, 2024

Do you have an example of the SMB server you are using and how it is configured. I've never seen a server change it's behaviour based on the path requested to it. Technically SMB has added a dialect extension in the first negotiate request called SMB2_NETNAME_NEGOTIATE_CONTEXT_ID since 2019-ish but no SMB implementation that I know off use that in any way and is mostly just a marker for network inspection tools. If \\127.0.0.1\share vs \\server\share is showing different shares then the logical explanation is that server does not resolve to localhost/127.0.0.1 and thus you are talking to different servers.

If I am wrong and you have an example where the value in SMB2_NETNAME_NEGOTIATE_CONTEXT_ID is changing how the server is responding or the actual tree request name changes the target share based on the server name then I'm happy to look at introducing an API to expose the value but I would need to see it happening first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants