Created
May 20, 2015 20:12
-
-
Save jgamblin/7872c70fa93018f751fc to your computer and use it in GitHub Desktop.
Python script to grep homepages on a subnet and will report if text is found.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Name: grepips | |
# Purpose: #!/usr/bin/env python | |
# Name: grepips | |
# Purpose: grep a subnet and report if text is found. | |
# By: Jerry Gamblin | |
# Date: 20.05.15 | |
# Modified 20.05.15 | |
# Rev Level 0.1 | |
## ----------------------------------------------- | |
import os | |
import sys | |
import commands | |
from netaddr import IPNetwork | |
if len(sys.argv) != 3: | |
print("quickgrep subnet/24 string") | |
exit(0) | |
subnet = sys.argv[1] | |
s2g = sys.argv[2] | |
for ip in IPNetwork(subnet): | |
command = ("{0}{1}{2}{3}").format("lynx --source http://",ip," | grep -ci ",s2g) | |
bad = commands.getoutput(command) | |
if bad is '1': | |
print ip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment