LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Is there a service that binds and listens to unused ports? (https://www.linuxquestions.org/questions/linux-newbie-8/is-there-a-service-that-binds-and-listens-to-unused-ports-818614/)

unraisedarc 07-07-2010 10:47 PM

Is there a service that binds and listens to unused ports?
 
Hello, I have a server that is behind a network firewall. I wish to know what ports the firewall lets through to this server. The only way I can think of testing this would be to run a bunch of services and make them listen on a bunch of ports on the server and then run nmap and scan the server. Does anyone know of some all-in-one service that will bind to unused ports in a specific range and listen on them so that I can scan with nmap?

Thanks!

Tinkster 07-07-2010 11:21 PM

Hi,

You could conceivably use the "swiss army knife" of networking
for this ... have a look at netcat (nc for short).


Cheers,
Tink

vikas027 07-07-2010 11:36 PM

Yeah Tinkster pointed it right, see this example.

Code:

bash $ nc -zuvv 192.168.1.27 30118-30121
airtelussd1 [10.2.45.197] 30121 (?) open
airtelussd1 [10.2.45.197] 30120 (?) open
airtelussd1 [10.2.45.197] 30119 (?) open
airtelussd1 [10.2.45.197] 30118 (?) : Connection refused


unraisedarc 07-08-2010 12:04 AM

Thanks guys. I am beginning to mess around with netcat, but I'm not getting very far. For instance, I run the following command and nothing seems to happen:


Code:

me@me$ nc -l -p 1234 < /etc/resolv.conf
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]
          [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]
          [-x proxy_address[:port]] [hostname] [port[s]]


From what I've read, I expect it to wait for a connection on 1234 then dump the file to that port. Unfortunately, it seems like I have a usage problem. The -l is supposed to be for "listen" and the -p is supposed to be for "on port."

Same thing happens with the following command:

Code:

me@me$ nc -vv -z -w2 192.168.31.129
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]
          [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]
          [-x proxy_address[:port]] [hostname] [port[s]]

Thanks again.

vikas027 07-08-2010 01:50 AM

Did you tried my example.

Usage is
Code:

nc -zuvv IP 'range of ports separated by -'
Example
Code:

nc -zuvv 192.168.1.27 30118-30121


All times are GMT -5. The time now is 12:09 AM.