Skip to content

Instantly share code, notes, and snippets.

@jgamblin
Created May 20, 2015 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgamblin/7872c70fa93018f751fc to your computer and use it in GitHub Desktop.
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.
#!/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