From 43b4a2bde34a377b9d4f54e781beed8a7742e1f2 Mon Sep 17 00:00:00 2001 From: Tj Date: Tue, 29 Mar 2016 17:42:54 +0100 Subject: [PATCH] convert descriptive comments into printable C strings Signed-off-by: Tj --- cfe_generate_password.c | 96 ++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 55 deletions(-) diff --git a/cfe_generate_password.c b/cfe_generate_password.c index dd5beb4..6331dbd 100644 --- a/cfe_generate_password.c +++ b/cfe_generate_password.c @@ -1,79 +1,65 @@ -/* - Generate Broadcom CFE seeds and passwords for many popular modem/router devices +static const char *title = \ +"Generate Broadcom CFE seeds and passwords for many popular modem/router devices\n" +; - Copyright 2015 TJ - Licenced on the terms of the GNU General Public Licence version 3 +static const char *copyright = \ +"Copyright 2015 TJ \n" +"Licenced on the terms of the GNU General Public Licence version 3\n" +; - To build: +static const char *help = \ +"This tool can generate passwords for use with many devices that contain Broadcom Common Firmware Environment (CFE) bootbase which has a debug mode that is enabled using the 'ATEN 1 XXXXXXXX' command, where XXXXXXXX is an eight digit hexadecimal 'password'.\n\n" - gcc -o cfe_gen_pass cfe_generate_password.c +"It is NOT necessary to have the device generate a 'seed' using 'ATSE [MODEL-ID]' because this tool can generate the seed from the device's first (base) MAC address.\n\n" - Or: +"When the device generates a seed it combines the number of seconds since 1970-01-01 00:00:00 with the router MAC address. Both are encoded in a single 6-byte hexadecimal number\n\n" - make +"Each value is truncated to its 3 least significant bytes so, for example:\n\n" - To use: +" $ date +%F.%T; echo \"obase=16;$(date +%s)\" | bc\n" +" 2016-03-26.23:06:32\n" +" 56F715F8\n\n" - ./cfe_gen_pass [options] +"and MAC Address: EC:43:F6:46:C0:80\n\n" - This tool can generate passwords for use with many devices that contain - Broadcom Common Firmware Environment (CFE) bootbase which has a debug mode - that is enabled using the "ATEN 1 XXXXXXXX" command, where XXXXXXXX is an - eight digit hexadecimal 'password'. +"becomes F715F8 concatenated with 46C080\n\n" - It is NOT necessary to have the device generate a 'seed' using "ATSE [MODEL-ID]" - because this tool can generate the seed from the device's first (base) MAC address. +" CFE> ATSE DSL-2492GNAU-B1BC\n" +" F715F846C080 <<<< last 3 bytes of MAC address\n" +" ^^^^^^\n" +" seconds since 1970-01-01 00:00:00 (2016-03-26 23:06:32)\n\n" - When the device generates a seed it combines the number of seconds since 1970-01-01 00:00:00 - with the router MAC address. Both are encoded in a single 6-byte hexadecimal +"*NOTE: the default seed after power-up is 000000 so no time value needs to be specifed if 'ATSE ' has not been executed on the device.\n\n" - Each value is truncated to its 3 least significant bytes so, for example: +"Access to the device's console via a serial UART port, or a network telnet/ssh session, is required to enter the password.\n\n" - $ date +%F.%T; echo "obase=16;$(date +%s)" | bc - 2016-03-26.23:06:32 - 56F715F8 - # MAC Address: EC:43:F6:46:C0:80 +"So, for a device with base MAC address (reported by the CFE during boot) E.g:\n\n" - becomes F715F8 concatenated with 46C080 +" CFE version 1.0.38-112.118 for BCM963268 (32bit,SP,BE)\n" +" ...\n" +" Base MAC Address : ec:43:f6:46:c0:80\n" +" ...\n" +" *** Press any key to stop auto run (1 seconds) ***\n" +" CFE>\n\n" - CFE> ATSE DSL-2492GNAU-B1BC - F715F846C080 <<<< last 3 bytes of MAC address - ^^^^^^ - seconds since 1970-01-01 00:00:00 (2016-03-26 23:06:32) +"Using this tool do:\n\n" - *NOTE: the default seed after power-up is 000000 so no time value needs to be specifed - if "ATSE " has not been executed on the device. +" ./cfe_gen_pass -s ec:43:f6:46:c0:80 -p\n\n" - Access to the device's console via a serial UART port, or a network telnet/ssh session, - is required to enter the password. +" MAC address: ec:43:f6:46:c0:80 Timestamp: 000000 Seed: 00000046c080 Password: 10f0a563\n\n" - So, for a device with base MAC address (reported by the CFE during boot) E.g: +"And on the device do:\n\n" - CFE version 1.0.38-112.118 for BCM963268 (32bit,SP,BE) - ... - Base MAC Address : ec:43:f6:46:c0:80 - ... - *** Press any key to stop auto run (1 seconds) *** - CFE> +" CFE> ATEN 1 10f0a563\n" +" OK\n" +" *** command status = 0\n\n" - Using this tool do: +"The tool can accept a timestamp as 8 hexadecimal characters (useful for testing the algorithm):\n\n" - ./cfe_gen_pass -s ec:43:f6:46:c0:80 -p +" ./cfe_gen_pass -t 0FF020 -s ec:43:f6:46:c0:80 -p\n\n" - MAC address: ec:43:f6:46:c0:80 Timestamp: 000000 Seed: 00000046c080 Password: 10f0a563 - - And on the device do: - - CFE> ATEN 1 10f0a563 - OK - *** command status = 0 - - The tool can accept a timestamp as 8 hexadecimal characters (useful for testing the algorithm): - - ./cfe_gen_pass -t 0FF020 -s ec:43:f6:46:c0:80 -p - - MAC address: ec:43:f6:46:c0:80 Timestamp: 0FF020 Seed: 0FF02046c080 Password: 110f65a3 - */ +"MAC address: ec:43:f6:46:c0:80 Timestamp: 0FF020 Seed: 0FF02046c080 Password: 110f65a3\n\n" +; #include #include -- 2.17.1