Skip to main content

Posts

Showing posts from July, 2023

PowerShell Port Scanning one liner - check range of port

Netcat is one of the best tools to check if port is open or not, and Netcat does offer also a lot of features other than port scanning. However, if netcat is not available on the system or it's not allowed to be installed. In Windows environment PowerShell will come in handy. Example one-liner code below uses PowerShell to scan a specified Target IP and also a range of ports to be scanned. To test the code, change the target IP as desired and also the range of port to be tested.  1..65535 | % {Test-NetConnection  127.0.0.1-Port $_ } 442..443 | % {Test-NetConnection  8.8.8.8 -Port $_ } Sample Output of the above commands:  1..10 | % {Test-NetConnection  127.0.0.1-Port $_ } 442..443 | % {Test-NetConnection  8.8.8.8 -Port $_ } Cheers! Take care. Till next Time. Enjoy exploring the world of PowerShell and enjoy the journey of learning.. Stay safe! and Keep things up!  Do ASAP,  A lways  S ay  A   P rayer ... Practice O.T.G. =  O bedience  T o  G od Make time for Prayer and Meditation.

How to automate Python to use Telnet to check ports

 Checking ports automatically can be stressful if there are quite a few addresses and ports to be checked. And typing manually is prone to error by mistyping the IP Address and Port. This is where automation comes into play. Prepare the IP Address and Port on  a text file, and once all is prepared. Let Python do the job or the task to Telnet and check the port whether the system can successfully connect or not. The tester just need to watch or monitor the terminal or do some other task, while waiting for the Python to do its job. Simple code below shows, how to do this task. #===================================== import sys import telnetlib def get_all_ips(filename_to_check):   with open(filename_to_check, 'r') as entries:     for ip_entries in entries:       ip_and_port=ip_entries.split(" ")                 the_ip=ip_and_port[0]       the_port_num=ip_and_port[1]       the_ip=the_ip.strip()       the_port_num=the_port_num.strip()       print("IP Address is: "

Linux sudo revoke permissions

 sudo is quite a good tool in Linux world in which you can specify commands with full access without giving root permissions to everything on the system.   However, sudo can also be used to have access or root permissions to everything on the system.   Why use sudo, when it can access everything? Why not just use or switch to root?   When entering or executing a command, sudo is a safe haven to make sure you know exactly what you are doing or it can provide you a second chance to abort the command. If the command being entered isn't the right one, before entering the password or pressing enter "Ctrl + C" can be used to abort the command and stop the execution. When running on a root session, any commands executer after pressing enter. There's no way to cancel or abort the command. That's why sudo is a good practice to use, so any of change of mind before pressing enter can is still possible to cancel. And running in a non-root session, if the command is