Created
September 11, 2021 16:25
-
-
Save fagci/74045f280991312592068a34c8a13224 to your computer and use it in GitHub Desktop.
Fastest global (WAN) random IP generator written in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Global (WAN) IP generator""" | |
from random import randint | |
from socket import inet_ntoa | |
from struct import pack | |
__author__ = 'Mikhail Yudin aka fagci' | |
def global_ip_generator(count=10): | |
while count: | |
intip = randint(0x1000000, 0xE0000000) | |
if (0xa000000 <= intip <= 0xaffffff | |
or 0x64400000 <= intip <= 0x647fffff | |
or 0x7f000000 <= intip <= 0x7fffffff | |
or 0xa9fe0000 <= intip <= 0xa9feffff | |
or 0xac100000 <= intip <= 0xac1fffff | |
or 0xc0000000 <= intip <= 0xc0000007 | |
or 0xc00000aa <= intip <= 0xc00000ab | |
or 0xc0000200 <= intip <= 0xc00002ff | |
or 0xc0a80000 <= intip <= 0xc0a8ffff | |
or 0xc6120000 <= intip <= 0xc613ffff | |
or 0xc6336400 <= intip <= 0xc63364ff | |
or 0xcb007100 <= intip <= 0xcb0071ff | |
or 0xf0000000 <= intip <= 0xffffffff): | |
continue | |
count -= 1 | |
yield inet_ntoa(pack('>I', intip)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment