add range and random script snippets

This commit is contained in:
your-favorite-hacker
2015-08-15 23:01:45 +02:00
parent ef80a7cec4
commit 1c8f92637b
2 changed files with 74 additions and 0 deletions

40
genRandom.py Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python2
#
# important part ripped off shamelessly here:
# http://www.codingwithcody.com/2010/05/generate-random-ip-with-python/
#
import os
import sys
from random import randrange
def usage():
print 'random ip generator in python'
print 'august 2015, dash'
print '<ip cnt>'
print
def generateIP():
blockOne = randrange(0, 255, 1)
blockTwo = randrange(0, 255, 1)
blockThree = randrange(0, 255, 1)
blockFour = randrange(0, 255, 1)
if blockOne == 10:
return generateIP()
elif blockOne == 172:
return generateIP()
elif blockOne == 192:
return generateIP()
else:
print str(blockOne) + '.' + str(blockTwo) + '.' + str(blockThree) + '.' + str(blockFour)
if len(sys.argv)<2:
usage()
exit()
ipcnt = int(sys.argv[1])
i=0
while i!=ipcnt:
generateIP()
i+=1