zmap / zgrab2

Fast Go Application Scanner
Other
1.75k stars 307 forks source link

Application Option --source-ip does not work for all protocol except http #310

Closed neciptomurcuk-biz closed 2 years ago

neciptomurcuk-biz commented 3 years ago

We have tried zgrab2 with source-ip options. We have some ip address on host. When we have tried "zgrab2 --source-ip=ip_1 smtp --input-file input_file_name --output-file output_file_name" and have got tcpdump for that interface having multiple ips. We saw that only first ip not ip_1. I have also tested zgrab2 on windows and ubuntu both of them not put source-ip correctly for most module like smtp, pop3, ssh etc. except http module work correctly. There is no OS related issues because I have tested source-ips with curl or ping with -interface/source kinds of options and got tcpdump/wireshark I saw that source-ip are correctly matched. But zgrab2 does not work except http module. Thanks.

sippejw commented 2 years ago

I realize this issue is over a year old, however, I ran into this same issue and have done a bit of digging. I also believe it is loosely related to #12. I have been trying to better understand why this is occurring, my use case is TLS, and it looks like the HTTP module creates its own Dialer and applies the local address before creating the TCP connection. TLS, SMTP, and SSH all ultimately rely on the standard Go net module to create the TCP connection which abstracts away the dialer.

If you are still looking for a quick hack, you can modify DialTimeout in net/dial.go to create a Dialer with the LocalAddr field hard coded. Once I get a better grasp on why the HTTP module uses the custom connection and others don't, I may be able to create a PR for this issue.

dadrian commented 2 years ago

As discussed in other issues, for Go related reasons, you're best off using network namespaces to make this happen.

356 removes the option, because it does not work, and cannot work well in the general case.