Netstat command for multiple ports under windows and unix - windows

How can I determine the services which are listening on a port bigger than 8000 using the netstat command under windows and unix?
Could you help me out, please?

On Windows you need to run a command console as administrator. Then execute
netstat -ab
The b lists the executable program that is doing the listening. you should be able to match that to the services.
I don't think netstat is selective on the ports, if you are not seeing any beyond 8000 then there is no activity or listening there.
This works on windows. Not sure if this is also the case on unix.

Related

How can I use the telnet server service, that comes with windows, to listen for a port?

Is there an easy way to use the telnet server from command line?
I can connect with telnet [ip/domain] [port] but is there a telnet equivalent of nc -l -p [port]?
I've tried using netcat for windows but it didn't support ANSI.
I've tried telnet-server but that didn't work.
Is there a native Win7 way of making a telnet server? And if so, how?
The partial answer is net start telnet, though there's no easy way to emulate netcat -e.
EDIT: Just use netcat, it can transmit ansi art, but only telnet can display it.

Passing additional "arguments" to a telnet connection command

I have a server that takes whatever data is sent to it and sends it back. With netcat on linux I am able to exectue the nc ip port command with an additional "argument" in a single line:
python -c print("Hello!") | nc ip port
This is equivalent to first running nc ip port to connect to the server, and later typing Hello! in the opened prompt to send the data.
While I know how to pass an output from a script to another script in windows (ex. here), I am fairly unsure how to achieve a similar result using telnet, as telnet ip port opens its own prompt (which means disabling windows commands).
I would like to know if it is at all possible with telnet to achieve what piping in linux does, or if there is a similar, minimalistic software that I could use on windows.

Can still do POST and GET, although nothing running on server

On my server machine, I have an application that responds to port 9876.
I've closed the application with kill.
If I do netstat | grep 9876, no process is shown.
However, I can still do POST and GET request to the server machine (from both Postman and Chrome) on port 9876.
How is that possible?
Just netstat doesn't show you listening sockets/process
Issue sudo netstat -lp | grep 9876, as Payalord mentioned, if you don't sudo you'll only list sockets controlled by your user. The last column will be PID/Program name which will help you find out who's keeping this socket open.
man pages are your friends:
-p, --program
Show the PID and name of the program to which each socket belongs.
-l, --listening
Show only listening sockets. (These are omitted by default.)
As for avoiding the application from spawning a subprocess, you'll need to investigate this as there's not enough information here to know why it happens and how to avoid it.
Make sure you are running commands on the right user, usually the best to run the commands on root user.
Also maybe better to run netstat like this: netstat -tulpn | grep :9876
Hope this helps to clarify the problem.

FTP - `Name or service not know`

I have an app, on my iphone, which allows me to transfer songs too and from my linux desktop via ftp. The app indicates that the host address is 192.168.0.4 and the port to be used is 5021. I can connect fine to the device from filezilla but when I try to connect via the command line it fails with the error mentioned in the title.
The command i'm using is ftp 192.168.0.4:5021 but it fails. I'm totally stumped. When I search for help on the internet the answer is to simply do what I've done already.
Does anyone have an any idea on what to do?
The ftp command does not support the :5021 syntax for port numbers. Instead, there must be another way.
With some FTP clients, you can use a -P command line option:
ftp -P 5021 192.168.0.4
With others, you need to put the port number after the host address with a space:
ftp 192.168.0.4 5021
Use man ftp to see which yours supports.
add domain and ip to hosts file of you computer.

Windows BAT or CMD: send some data to a localhost udp port

I have an app that listens on a localhost port. I want a minimal launcher to bring that app's to the front.
My app is in Java. I don't know how to write any exe files, but I can write bat files, and then make a shortcut that launches the bat file without showing the terminal. I would like to have the bat file send some data to a port (preferably UDP so there will not be any stream overhead).
How can I send data to a UDP port?
One of the things I thought of was nslookup, but that will only connect to port 53 as far as I know.
This only needs to work on Windows. Would like it to work on XP and up, but I can make a workaround if necessary.
This is a job for netcat.
http://nc110.sourceforge.net/
After installing you can easily launch it from the command line or write a BAT script to execute it for you.
To send date through UDP rather than TCP, use the "-u" switch.
For example, to send the data to UPD port 2345 on localhost execute:
nc -u localhost 2345
Then type the data you want to send.
I was having quite a few problems sending a UDP command to a Brightsign digital sign with netcat. I ended up using Swiss File Knife. It is possible I had the syntex wrong with my netcat statement. (If anyone could suggest the correct syntax based on my working SFK statement, I would love to know)
I just wanted to send a few asci key words to my sign from a batch file.
My sign was 192.168.1.22 and listening on port 5000
Here are my working steps:
Download Swiss File Knife SKF: http://swissfileknife.sourceforge.net/
Copied the file to C:\tools and renamed the sfk174.exe file to skf.exe(to make is shorter) and used the bellow syntax to send the UDP command Special
C:\tools\sfk udpsend 192.168.1.22 5000 “Special” (make sure you put your asci word in quotes. it will work without but not for words with spaces between)
I put the commands in a batch file and created a windows icon for the customer and they worked great.
You can send an udp packet like this :
c:\nemesis\nemesis.exe udp -P do7on.txt -D 192.168.0.10 -y 1025
Nemesis : http://nemesis.sourceforge.net/

Resources