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

Fixing -P option being ignored #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

r3nt0n
Copy link

@r3nt0n r3nt0n commented Jul 9, 2024

Seems that smbmap ignores the custom port passed via -P, still tries to connect to 445/tcp. This PR should fix it. I didn't test all functionalities, just basic use cases: connect and enumerate all shares content recursively.

Bear in mind that this is more a quick dirty patch than a long-term solution. There is probably a better way to do it than using a global variable, but I didn't have time to mess with the map calls.

Also, there are two reasons to explain the changes in line 1233:

  • host['ip'] instead of host['host'] because it was throwing a missing key exception regarding 'host'
  • This line was also causing a connection error because it was trying to connect to NetBIOS port. Since one of the most common scenarios to provide a custom port would be when you are connecting to the target via some pivot point (e.g. port forwarding on an intermediate host), this wouldn't be always possible. So I dipped my toe into impacket SmbConnection class and seems that the change from '*SMBSERVER' to 'host['ip'] was the way to avoid this behavior.
  • This change renders the if-else there redundant, I just keep it in case is needed for other features that I didn't test. If not, it can be removed.

Anyway, still feels hacky and probably need some improvements, but at least it works :)

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

Successfully merging this pull request may close these issues.

1 participant