How do i verify that port 5555 is open? - windows

I have a task in a lab for my cyber-security class where I have to verify that the port 5555 is open and not in use via Command Prompt. I have tried the following command with these flags:
command used to check port 5555

You can do a nmap scan on that port to see if its open or close; also you can get more information about the port if its open this way.
nmap -vvv <ip> -p 5555
if you are looking for a fast way you can try to connect to that port and see using netcat or telnet
nc localhost 5555
telnet localhost 5555
if the port is close your connection will drop if its open the connection wont close if the application running on port 5555 has a header you can also see that.
in case you looking for open ports in your own computer you can do ss -lnpt which will show all open ports. then you can grep for port 5555

You can either use netstat or sudo lsof -i tcp:5555.
If you don't get a response on your terminal, it means that there's nothing running on port 5555.

Related

How to get messages sent to http://localhost:7777/ through a Linux command line?

I would like to check messages sent to my 7777 port, namely, http://localhost:7777/. I am on Linux and want to do it through command line. Which command line should I use?
How about use the tool netcat? Try nc localhost 7777. Does it work?
Simple command :- nc -vz www.google.com 7777
nc -vz (website) (port number)

How to find the application running on a specific port in MAC

I need to find if there is any application running on port 9000 on my mac.
sudo lsof -i :9000
-i will list the applications using the mentioned port
In order to find if there is any process running on port 9000, use following command in terminal>> netstat -vanp tcp | grep 9000

On mac, lsof says a port is not in use, but I can telnet to the port

If I run lsof, it says that this port is not in use. Yet, I can telnet into it and something is listening on that port.
Am I using the wrong command to see what ports are in use? I'd like to kill the process listening on 3306.
± |master ✓| → lsof -i :3306
|2.3.1| montana in ~/workspace
± |master ✓| → telnet localhost 3306
Trying ::1...
Connected to localhost.
Escape character is '^]'.
J
5.6.39|=X%N9r�&a;AtF>E!r>{mysql_native_passwordConnection closed by foreign host.
To check which process is running on 3306 port
sudo lsof -i tcp:3306
and if you get the process id
kill -9

Change ssh tunnel direction with the same port?

I'm using an ssh tunnel to forward a port to a db server.
Let's say I'm using mysql, so my ssh command would be something along the lines of
ssh -fqTN -L 12345:127.0.0.1:3306 user#server.com
based on the method of transfer (sync from or sync to) I want to use either the -L or -R flags.
I do need the -L flag at first though, so I open the tunnel above anyway.
My question is though -
If after now run
ssh -fqTN -R 12345:127.0.0.1:3306 user#server.com
Will it replace the above command and make a reverse tunnel on the same port?
The second command will not "replace" the first command, but it will work just fine.
You started with:
ssh -fqTN -L 12345:127.0.0.1:3306 user#server.com
This opens port 12345 on your local system and forwards it to 127.0.0.1:3306 from the perspective of the remote system, so that you can access the mysql server on the remote system using local port 12345.
The second command...
ssh -fqTN -R 12345:127.0.0.1:3306 user#server.com
...opens port 12345 on the remote system and forwards it to 127.0.0.1:3306 from the perspective of your local system, allowing the remote system to access a mysql server on your local host via port 12345.
This doesn't conflict with the original command, so these can both be run at the same time.
Update
Responding to your comment here, because I want to quote some command output:
If I run:
ssh -R 12345:127.0.0.1:3306 remote_system
Then on remote_system I run lsof -i -n, I see:
sshd 23280 lars 10u IPv6 37263762 0t0 TCP [::1]:italk (LISTEN)
sshd 23280 lars 11u IPv4 37263763 0t0 TCP 127.0.0.1:italk (LISTEN)
And from /etc/services, we see that italk is port 12345. If you add -P to your lsof command line it will not try to translate port numbers to service names:
# lsof -i -n -P | grep 12345
sshd 23280 lars 10u IPv6 37263762 0t0 TCP [::1]:12345 (LISTEN)
sshd 23280 lars 11u IPv4 37263763 0t0 TCP 127.0.0.1:12345 (LISTEN)

telnet output save it to file using .bat file

telnet 10.0.0.22 3389 ( for checking rdp port )
I want to create a batch file, for checking two or three port, so i create a .bat file in that i have written
telnet 10.0.0.22 1158 >> C:\result\telnetresult.txt
telnet 10.0.0.22 3389 >> C:\result\telnetresult.txt
telnet 10.0.0.22 1159 >> C:\result\telnetresult.txt
but it didn't work. Can you suggest where i am doing mistake or if there is some other alternative / Workaround.
I also tried to create another .bat file with the following command.
Telnet
set logfile c:\log.txt
Open 10.0.0.22 80
open 10.0.0.22 1158
open 10.0.0.22 3389
but it also didn't work.
You could try telnet “IP Address” -f “file location". Found the solution here.
try this:
for port in 1158 3389 1159
do
echo "telnet 10.0.0.22 $port"
echo $port |xargs telnet 10.0.0.22 >> C:\result\telnetresult.txt
done
some similar output
telnet 10.0.0.22 1158
Trying 10.0.0.22...
telnet: Unable to connect to remote host: Connection refused
telnet 10.0.0.22 3389
Trying 10.0.0.22...
telnet: Unable to connect to remote host: Connection refused
telnet 10.0.0.22 1159
Trying 10.0.0.22...
Connected to 10.0.0.22.
Escape character is '^]'.
Connection closed by foreign host.

Resources