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

34
genRange.py Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env python2
#
#simple range generator
#august 2015, dash
import os
import sys
import struct
import socket
import netaddr
def usage():
print 'generate ip list from range'
print '<startip> <endip>'
print 'example: ./%s 1.1.1.1 1.1.1.255'
print
if len(sys.argv)<3:
usage()
exit()
s = sys.argv[1]
e = sys.argv[2]
i=netaddr.IPRange(s,e)
ss = i.first
se = i.last
o=0
res = se-ss
while o != res + 1:
conv_ip = ss + o
print socket.inet_ntoa(struct.pack('!L', conv_ip))
o+=1