-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathipgenerator.py
268 lines (249 loc) · 11 KB
/
ipgenerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import sys
print "\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
print " |.|/|i|p|g|e|n|e|r|a|t|o|r|.|p|y|"
print " +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
if (len(sys.argv) > 2):
print "\nUsage: ipgenerator.py [OPTIONS] \n\n--safeips All public IP Addresses, excluding those which are reserved\n for specific purposes. (This option can be used to scan the \n whole internet following safe practices). \n--unsafeIPs All public IP Addresses, including those which are reserved\n for specific purposes. All reserved IP Addresses. \n--allprivate All the Private IP Addresses including APIPA and Loopback IPs. \n--allprivaten All the Private IP Addresses excluding APIPA and Loopback IPs. \n--loopback The whole 127.0.0.0/24 series. \n--apipa IPs belonging to APIPA series (169.254.X.X). \n--a10 IPs belonging to 10.X.X.X series. \n--b172 IPs belonging to 172.16.X.X series. \n--c192 IPs belonging to 192.168.X.X series\n--classA All Class A Ip Addresses\n--classB All class B IP Addresses\n--classC All Class C IP addresses.\n--classD All Class D IP addresses.\n--classE All Class E IP addresses.\n--help This awesome help in more detailed manner."
elif (len(sys.argv) <2):
print "\nUsage: ipgenerator.py [OPTIONS] \n\n--safeips All public IP Addresses, excluding those which are reserved\n for specific purposes. (This option can be used to scan the \n whole internet following safe practices). \n--unsafeIPs All public IP Addresses, including those which are reserved\n for specific purposes. All reserved IP Addresses. \n--allprivate All the Private IP Addresses including APIPA and Loopback IPs. \n--allprivaten All the Private IP Addresses excluding APIPA and Loopback IPs. \n--loopback The whole 127.0.0.0/24 series. \n--apipa IPs belonging to APIPA series (169.254.X.X). \n--a10 IPs belonging to 10.X.X.X series. \n--b172 IPs belonging to 172.16.X.X series. \n--c192 IPs belonging to 192.168.X.X series\n--classA All Class A Ip Addresses\n--classB All class B IP Addresses\n--classC All Class C IP addresses.\n--classD All Class D IP addresses.\n--classE All Class E IP addresses.\n--help This awesome help in more detailed manner."
else:
if (sys.argv[1] == "--reserved"):
for q in range(0,255):
for r in range(0,255):
for s in range(0,255):
ip = "10." + str(q) + "." + str(r) + "." + str(s)
print ip
for q in range(0,255):
for r in range(0,255):
for s in range(0,255):
ip = "127." + str(q) + "." + str(r) + "." + str(s)
print ip
for q in range(64,127):
for r in range(0,255):
for s in range(0,255):
ip = "100." + str(q) + "." + str(r) + "." + str(s)
print ip
for r in range(0,255):
for s in range(0,255):
ip = "169.254." + str(r) + "." + str(s)
print ip
for q in range(16,31):
for r in range(0,255):
for s in range(0,255):
ip = "172." + str(q) + "." + str(r) + "." + str(s)
print ip
for s in range(0,255):
ip = "192.0.0." + str(s)
print ip
for s in range(0,255):
ip = "192.0.2." + str(s)
print ip
for s in range(0,255):
ip = "192.88.99." + str(s)
print ip
for r in range(0,255):
for s in range(0,255):
ip = "192.168." + str(r) + "." + str(s)
print ip
for r in range(0,255):
for s in range(0,255):
ip = "192.18." + str(r) + "." + str(s)
print ip
for r in range(0,255):
for s in range(0,255):
ip = "192.19." + str(r) + "." + str(s)
print ip
for s in range(0,255):
ip = "192.51.100" + str(s)
print ip
for r in range(0,255):
for s in range(0,255):
ip = "203.113." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--allprivate"):
for q in range(0,255):
for r in range(0,255):
for s in range(0,255):
ip = "10." + str(q) + "." + str(r) + "." + str(s)
print ip
for q in range(16,31):
for r in range(0,255):
for s in range(0,255):
ip = "172." + str(q) + "." + str(r) + "." + str(s)
print ip
for r in range(0,255):
for s in range(0,255):
ip = "192.168." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--allprivaten"):
for q in range(0,255):
for r in range(0,255):
for s in range(0,255):
ip = "10." + str(q) + "." + str(r) + "." + str(s)
print ip
for q in range(16,31):
for r in range(0,255):
for s in range(0,255):
ip = "172." + str(q) + "." + str(r) + "." + str(s)
print ip
for r in range(0,255):
for s in range(0,255):
ip = "192.168." + str(r) + "." + str(s)
print ip
for r in range(0,255):
for s in range(0,255):
ip = "169.254." + str(r) + "." + str(s)
print ip
for q in range(0,255):
for r in range(0,255):
for s in range(0,255):
ip = "127." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--safeips"):
for p in xrange(1,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for q in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for r in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for s in xrange(0,255):
ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
if (p==10 or p==127):
#Private IP and Loopback IP
ip = "null"
elif (p == 100 and q >= 64 and q <= 127):
#Shared Address Space
ip = "null"
elif (p == 169 and q == 254):
# APIPA
ip = "null"
elif (p == 172 and q >= 16 and q <= 31):
#Private IP 172.16.0.0 - 172.31.255.255
ip = "null"
elif (p == 192 and q == 0 and r == 0):
#192.0.0.0/24 # RFC6890: IETF Protocol Assignments
ip = "null"
elif (p == 192 and q == 0 and r == 2):
#192.0.2.0/24 # RFC5737: Documentation (TEST-NET-1)
ip = "null"
elif (p == 192 and q == 88 and r == 99):
#192.88.99.0/24 # RFC3068: 6to4 Relay Anycast
ip = "null"
elif (p == 192 and q == 168):
#RFC1918: Private-Use
ip = "null"
elif (p == 192 and q == 18):
# RFC2544: Benchmarking
ip = "null"
elif (p == 192 and q == 19):
# RFC2544: Benchmarking
ip = "null"
elif (p == 192 and q == 51 and r == 100):
# RFC5737: Documentation (TEST-NET-2)
ip = "null"
elif (p == 203 and r == 113):
# RFC5737: Documentation (TEST-NET-2)
ip = "null"
elif (p >= 224):
# RFC5737: Reserved D & E
ip = "null"
if (ip != "null"):
print ip
if (sys.argv[1] == "--a10"):
for q in range(0,255):
for r in range(0,255):
for s in range(0,255):
ip = "10." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--b172"):
for q in range(16,31):
for r in range(0,255):
for s in range(0,255):
ip = "172." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--c192"):
for r in range(0,255):
for s in range(0,255):
ip = "192.168." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--loopback"):
for q in range(0,255):
for r in range(0,255):
for s in range(0,255):
ip = "127." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--apipa"):
for r in range(0,255):
for s in range(0,255):
ip = "169.254." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--unsafeips"):
for p in xrange(1,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for q in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for r in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for s in xrange(0,255):
ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
if (p==10 or p==127):
#Private IP and Loopback IP
ip = "null"
elif (p == 169 and q == 254):
# APIPA
ip = "null"
elif (p == 172 and q >= 16 and q <= 31):
#Private IP 172.16.0.0 - 172.31.255.255
ip = "null"
elif (p == 192 and q == 168):
#RFC1918: Private-Use
ip = "null"
if (ip != "null"):
print ip
if (sys.argv[1] == "--classA"):
for p in xrange(1,126):
for q in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for r in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for s in xrange(0,255):
ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--classB"):
for p in xrange(128,191):
for q in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for r in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for s in xrange(0,255):
ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--classC"):
for p in xrange(192,223):
for q in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for r in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for s in xrange(0,255):
ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--classD"):
for p in xrange(223,239):
for q in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for r in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for s in xrange(0,255):
ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] == "--classE"):
for p in xrange(239,255):
for q in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for r in xrange(0,255):
#print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
for s in xrange(0,255):
ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
print ip
if (sys.argv[1] != "--safeips" and sys.argv[1] != "--unsafeips" and sys.argv[1] != "--allprivaten" and sys.argv[1] != "--allprivate" and sys.argv[1] != "--classA" and sys.argv[1] != "--classB" and sys.argv[1] != "--classC" and sys.argv[1] != "--classD" and sys.argv[1] != "--classE" and sys.argv[1] != "--a10" and sys.argv[1] != "--b172" and sys.argv[1] != "--c192" and sys.argv[1] != "--apipa" and sys.argv[1] != "--loopback" or sys.argv[1]=="-h"):
print "\nUsage: ipgenerator.py [OPTIONS] \n\n--safeips All public IP Addresses, excluding those which are reserved\n for specific purposes. (This option can be used to scan the \n whole internet following safe practices). \n--unsafeIPs All public IP Addresses, including those which are reserved\n for specific purposes. All reserved IP Addresses. \n--allprivate All the Private IP Addresses including APIPA and Loopback IPs. \n--allprivaten All the Private IP Addresses excluding APIPA and Loopback IPs. \n--loopback The whole 127.0.0.0/24 series. \n--apipa IPs belonging to APIPA series (169.254.X.X). \n--a10 IPs belonging to 10.X.X.X series. \n--b172 IPs belonging to 172.16.X.X series. \n--c192 IPs belonging to 192.168.X.X series\n--classA All Class A Ip Addresses\n--classB All class B IP Addresses\n--classC All Class C IP addresses.\n--classD All Class D IP addresses.\n--classE All Class E IP addresses.\n--help This awesome help in more detailed manner.\n\n Read more at http://google.com"