Monday, June 2, 2014

network sweeping with python

Well as of late i have decided to ditch bash and go directly with using python for all scripting tasks and so far so good :). I think python is such an awesome language and should be used instead of bash all together. I'm currently preparing for my OSCP certification exam os this is one of many tools that i will write and post for your enjoyment.  Well enough babbling from me  he goes. This tool that ive written in python is a network ping sweeper.


 #!/usr/bin/python

import subprocess
import os
with open(os.devnull, "wb") as limbo:
    for n in xrange(1, 10):
        ip="192.168.18.{0}".format(n)
        result=subprocess.Popen(["ping", "-c", "1", "-n", "-W", "2", ip],
            stdout=limbo, stderr=limbo).wait()
        if result:
            print ip, "inactive"

        else:

           log = open("active_hosts", "a")
                print >>log,  ip


When running my script you will receive  the following output 


root@kali:/home/cyclonis/scripts/python# ./laserbeak.py
192.168.18.1 active
192.168.18.2 inactive
192.168.18.3 inactive
192.168.18.4 inactive
192.168.18.5 inactive
192.168.18.6 inactive
192.168.18.7 inactive
192.168.18.8 inactive
192.168.18.9 active


Well i hope whoever reads this blog post gets something from it. I really enjoy sharing information with others so if you like it please feel free to use it. 




No comments:

Post a Comment

Cracking Kerberos Service Tickets (TGS) Using Kerberoasting

As of late I've been spending a lot of time researching and learning different techniques when it comes to attacking Active Directory En...