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

adds ability to specify bind address #303

Merged

Conversation

audibleblink
Copy link

@audibleblink audibleblink commented Apr 29, 2020

Attempt at implementing #302

@audibleblink audibleblink marked this pull request as ready for review June 15, 2020 15:37
@urbanadventurer
Copy link
Owner

@audibleblink first of all, thanks 🙇 for this pull request. It's a good idea 💡

Before I'm ready to merge it, I want to discuss some options with you and @bcoles.

Do we want to let the user select the bind address, the hostname, the interface, or all three?

@audibleblink 's pull request lets someone select the IP address.

I'm in favour of interface or bind address, assuming the former will be more popular.

Some examples from other popular tools are:

  • curl
    --interface <name> Use network INTERFACE (or address)

  • nmap
    -e <iface>: Use specified interface

  • ncat
    -p, --source-port port Specify source port to use -s, --source addr Specify source address to use (doesn't affect -l)

  • wget
    --bind-address=ADDRESS bind to ADDRESS (hostname or IP) on local host

The local port

The $local_port gets set to 61000. Why did you set this and did it cause problems if left as nil?
The ideal situation would be for the local port to be whatever the OS chooses, even when selecting an interface or bind IP address.

    when '-b', '--bind'
      $local_host = arg
      $local_port = 61000

Should we allow the user to select the local port?

This could be useful for bypassing mis-configured firewalls.

nmap
-g/--source-port <portnum>: Use given port number

ncat
-p, --source-port port Specify source port to use

Note -- to get interfaces and IP addresses

require 'socket'
Socket.ip_address_list

@bcoles
Copy link
Collaborator

bcoles commented Aug 3, 2020

I like this idea.

Before I'm ready to merge it, I want to discuss some options with you and @bcoles.

In regards to command line convention, I'm in favor of -I / --interface if the interfacecan be specified by name (ie, eth0).

If using the adapter name isn't easy/possible, then --bind or --source seem more appropriate, as these imply an address.

The $local_port gets set to 61000. Why did you set this and did it cause problems if left as nil?

I, too, would like to see the hard-coded port removed, if possible.

@urbanadventurer urbanadventurer changed the base branch from master to bind-interface August 4, 2020 12:07
@urbanadventurer urbanadventurer merged commit 73520a7 into urbanadventurer:bind-interface Aug 4, 2020
@urbanadventurer
Copy link
Owner

@bcoles and @audibleblink I'm working on it on the bind-interface branch.

Currently working on the interface validation

@urbanadventurer
Copy link
Owner

Hi @audibleblink, did this patch work for you, and if so what OS are you using?

@audibleblink
Copy link
Author

hey all. thanks for looking at this. currently dealing with a 3 day power outage, a newborn, and in-laws. will be a bit before I can add anything here.

@urbanadventurer
Copy link
Owner

urbanadventurer commented Aug 6, 2020

image

--interface tests under Linux successfully send the traffic through the correct network interface.

@urbanadventurer
Copy link
Owner

urbanadventurer commented Aug 6, 2020

image

--interface tests under macOS fail. Everything "just works"

@urbanadventurer
Copy link
Owner

urbanadventurer commented Aug 6, 2020

image

--source-port under Linux with 1 thread, fails with source port reuse problems.

@urbanadventurer
Copy link
Owner

urbanadventurer commented Aug 6, 2020

image

--source-port under Linux even fails with source port reuse problems, even when using --wait

@urbanadventurer
Copy link
Owner

image

--source-port under macOS fails with source port reuse problems.

@urbanadventurer
Copy link
Owner

image

image

--source-port under Linux only works when --source-address (or --interface) is also specified.

@CylicAmp
Copy link

does the firmware in devies prevent this

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.

4 participants