Skip to content

Fixing -P option being ignored#105

Open
r3nt0n wants to merge 1 commit into
ShawnDEvans:masterfrom
r3nt0n:master
Open

Fixing -P option being ignored#105
r3nt0n wants to merge 1 commit into
ShawnDEvans:masterfrom
r3nt0n:master

Conversation

@r3nt0n

@r3nt0n r3nt0n commented Jul 9, 2024

Copy link
Copy Markdown

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