Every hacker must know many tools with which he can launch his attacks, in addition to that he must also develop them.

Here we have a very dry tool written in python to which you can add many features such as sending mail or generating alerts in case you find something desired.

The code is as follows we will explain line by line so you can understand it better:

from subprocess import Popen, PIPE

for ip in range(50,100):
     IP = '192.168.1.'+str(ip)
     subprocess = Popen(['/bin/ping', '-c 1 ', IP], stdin=PIPE, stdout=PIPE, stderr=PIPE)
     stdout, stderr= subprocess.communicate(input=None)
     DATA= stdout.decode('UTF-8')
     if "1 received" in DATA:
           print("The Ip Address %s has responded with a ECHO_REPLY!" %(DATA.split()[1]))

You can customize this dependent code that you want to do.

1. from subprocess import Popen, PIPE

In this first line of code we are importing the python module that we will use.

2. for ip in range(50,100):

here we have created a cycle with a range of 50 to 100 this range can be modified depending on your interest

3. IP = '192.168.1.'+str(ip)

In this line of code we define the first 3 octets.

4. subprocess = Popen(['/bin/ping', '-c 1 ', IP], stdin=PIPE, stdout=PIPE, stderr=PIPE)
5. stdout, stderr= subprocess.communicate(input=None)

In these last two lines of code we make use of the modules that we import.

6. DATA= stdout.decode('UTF-8')

Here we pass the DATA from binary to string.

7. if "1 received" in DATA:

We have asked if within that string or string there is something equal to “1 received”

8. print("The Ip Address %s has responded with a ECHO_REPLY!" %(DATA.split()[1]))

This last part must be designed with the previous line and if the condition is fulfilled which tells us that this connected device shows us a message on the screen.

You can have an email sent or sound an alarm if a device connected to a specific address is found.

Finally we have a console message of the result of our code.

If you are interested in learning more, we invite you to review this course.