Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv4 in IPv6 and various improvements #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 38 additions & 27 deletions ipfuscator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ def get_args():
return parser.parse_args()

def banner():
print "IPFuscator"
print "Author: Vincent Yiu (@vysecurity)"
print "https://www.github.com/vysec/IPFuscator"
print "Version: {}".format(__version__)
print ""
print(
'''
IPFuscator
Author: Vincent Yiu (@vysecurity)
https://www.github.com/vysec/IPFuscator
Version: {}

'''.format(__version__))

def checkIP(ip):
m = re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\Z',ip)
Expand All @@ -42,16 +45,21 @@ def printOutput(ip):
parts = ip.split('.')

decimal = int(parts[0]) * 16777216 + int(parts[1]) * 65536 + int(parts[2]) * 256 + int(parts[3])
print ""

print "Decimal:\t{}".format(decimal)
#hexadecimal = "0x%02X%02X%02X%02X" % (int(parts[0]), int(parts[1]), int(parts[2]), int(parts[3]))
print "Hexadecimal:\t{}".format(hex(decimal))

#octal = oct(decimal)
print "Octal:\t\t{}".format(oct(decimal))

print ""
print(
'''
Decimal:\t{}
Hexadecimal:\t{}
Octal:\t\t{}

IPv4 in IPv6: [::ffff:{}]
IPv4 in IPv6: [0:0:0:0:0:ffff:{}]
'''.format(decimal,
hex(decimal),
oct(decimal),
ip,
ip))

hexparts = []
octparts = []
Expand All @@ -60,30 +68,33 @@ def printOutput(ip):
hexparts.append(hex(int(i)))
octparts.append(oct(int(i)))

print "Full Hex:\t{}".format('.'.join(hexparts))
print "Full Oct:\t{}".format('.'.join(octparts))
print(
'''
Full Hex:\t{}
Full Oct:\t{}
'''.format('.'.join(hexparts),
('.'.join(octparts))))

print ""
print "Random Padding: "
print("Random Padding: ")

randhex = ""

for i in hexparts:
randhex += i.replace('0x','0x' + '0' * random.randint(1,30)) + '.'

randhex = randhex[:-1]
print "Hex:\t{}".format(randhex)
print("Hex:\t{}".format(randhex))

randoct = ""
for i in octparts:
randoct += '0' * random.randint(1,30) + i + '.'

randoct = randoct[:-1]

print "Oct:\t{}".format(randoct)
print("Oct:\t{}".format(randoct))

print ""
print "Random base:"
print("")
print("Radom base:")

randbase = []

Expand All @@ -102,11 +113,11 @@ def printOutput(ip):
randbaseval += octparts[i] + '.'
# oct
randbase.append(randbaseval[:-1])
print "#{}:\t{}".format(count+1, randbase[count])
print("#{}:\t{}".format(count+1, randbase[count]))
count += 1

print ""
print "Random base with random padding:"
print("")
print("Random base with random padding:")

randbase = []

Expand All @@ -125,7 +136,7 @@ def printOutput(ip):
randbaseval += '0' * random.randint(1,30) + octparts[i] + '.'
# oct
randbase.append(randbaseval[:-1])
print "#{}:\t{}".format(count+1, randbase[count])
print("#{}:\t{}".format(count+1, randbase[count]))
count += 1


Expand All @@ -135,10 +146,10 @@ def main():
args = get_args()

if checkIP(args.ip):
print "IP Address:\t{}".format(args.ip)
print("IP Address:\t{}".format(args.ip))
printOutput(args.ip)
else:
print "[!] Invalid IP format: {}".format(args.ip)
print("[!] Invalid IP format: {}".format(args.ip))


if __name__ == '__main__':
Expand Down