Skip to content

Instantly share code, notes, and snippets.

@mdornseif
Created September 24, 2013 09:41
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 mdornseif/6682539 to your computer and use it in GitHub Desktop.
Save mdornseif/6682539 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# encoding: utf-8
import sys
def main():
if len(sys.argv) < 2:
sys.stderr.write('Usage: %s filename\n' % sys.argv[1])
sys.exit()
f = open('dos.yaml', 'w')
f.write("blacklist:\n")
infile = open(sys.argv[1])
count = 0
for line in infile:
# remove comment only lines
if line.startswith('#'):
continue
# remove trailing comments
line = line.split('#', 1)[0].strip()
if line:
f.write("- subnet: %s\n description: DDoS\n" % line)
count += 1
if count >= 100:
print "Maximale Anzahl von Zeilen erreicht: 100 Zeilen"
break
f.close()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment