This document outlines the system information, filesystem structure, available commands, and network interfaces of the target router.
- OS: GNU/Linux
- Hostname:
RTKGW - Kernel Version:
4.4.140 - Architecture:
mips - System Time:
Wed Apr 3 09:23:56 CST 2024 - Core Utilities:
BusyBox v1.22.1provides the main set of shell commands.
The filesystem is characteristic of an embedded device, with a small, read-only root partition and several writable partitions for configuration and temporary data.
| Filesystem | Size (1K-blocks) | Used | Available | Capacity | Mounted on |
|---|---|---|---|---|---|
/dev/root |
12160 | 12160 | 0 | 100% | / |
devtmpfs |
55544 | 0 | 55544 | 0% | /dev |
tmpfs |
55660 | 0 | 55660 | 0% | /run |
ubi0:ubi_Config |
8140 | 252 | 7436 | 3% | /var/config |
ubi0:ubi_misc |
25688 | 24 | 24316 | 0% | /var/misc |
The root directory contains standard Linux folders. Several directories are symlinked to the writable /var partition to allow for dynamic data storage.
/bin: Core system binaries./config: ->./var/config//dev: Device files./etc: System configuration files./lib: Shared libraries./mnt: ->/var/mnt/proc: Kernel process information./run: Runtime data./sbin: ->/bin(symlink)/sys: Kernel object information./tmp: ->/var/tmp/usr: User binaries and libraries./var: Writable partition for variable data.
The available commands are located in directories specified by the $PATH environment variable.
- $PATH:
/sbin:/usr/sbin:/bin:/usr/bin:/etc/scripts
- /bin: Contains the
busyboxexecutable and numerous symlinks to it for common commands (e.g.,ls,cat,vi). It also contains other standalone binaries related to networking (udhcpd), VoIP, and system utilities. - /usr/bin, /usr/sbin: These directories are in the
$PATHbut do not exist on the filesystem. - /etc/scripts: Contains various shell scripts (
.sh) for managing system functions, including networking (udhcpc.sh), hardware (rps.sh), and VoIP services.
This indicates that most functionality is provided by busybox and specialized scripts, rather than a full set of standard GNU utilities.
The router has a complex network configuration with multiple bridge, Ethernet, and wireless interfaces.
- lo: The local loopback interface.
- br0: A bridge interface, likely for the main LAN, grouping together Ethernet and wireless clients.
- eth0, eth1, eth2, eth3, eth4: Physical Ethernet ports.
- p-ppp: A PPP (Point-to-Point Protocol) interface, almost certainly for the WAN (Internet) connection.
- wlan0, wlan1: Physical wireless interfaces.
- wlan0-vap0, wlan0-vap1, etc.: Virtual Access Points (VAPs) for creating multiple SSIDs (e.g., guest networks) on the physical wireless interfaces.
- wlan0-vxd, wlan1-vxd: Likely a virtual interface for WDS (Wireless Distribution System) or a similar mesh/bridging technology.
This setup allows the router to manage multiple LAN clients (wired and wireless), guest networks, and connect to the internet via PPP.
The router utilizes a classic BusyBox-based init process, starting with /etc/inittab and dispatching a series of numbered scripts.
This is the main configuration file for the init process. The most important line is:
::sysinit:/etc/init.d/rcS
This command specifies that the /etc/init.d/rcS script is the first script to be executed on system boot.
This is the primary system initialization script. Its main function is to loop through numbers 0 to 63 and execute any script in /etc/init.d/ that follows the pattern rc<number> (e.g., rc2, rc3, etc.).
A key feature is the conditional execution of /var/tmp/custom_cmds.sh when the loop counter reaches 32.
The boot sequence is determined by the following scripts, executed in numerical order:
-
rc2: Performs critical early-boot tasks:- Mounts
/varas a RAM filesystem. - Initializes
mdevfor device hotplugging. - Mounts UBI filesystems for configuration (
/var/config) and other data (/var/misc). - Initializes the loopback network interface (
lo).
- Mounts
-
rc3: Starts core services and loads drivers:- Starts the
configddaemon. - Executes multiple scripts for custom configuration, VoIP, and driver loading (
insdrv.sh). - Launches the main Realtek SDK process (
runsdk.sh) with high priority.
- Starts the
-
rc6: Prepares for Samba file sharing by creating the/var/samba/directory. -
rc10: Tunes the IPv4 network stack by setting various kernel parameters in/proc/sys/net/ipv4/, including connection tracking timeouts and enabling IP forwarding. -
rc14: Tunes the IPv6 network stack, configuring forwarding, autoconfiguration, and duplicate address detection. -
rc18: Starts a background process named/bin/systemd. This is highly unconventional and is likely a custom binary, not the standard Linux init system. -
rc20: Starts the/bin/ramonitorbackground process. -
rc32:- Starts a generic
startupbackground process. - Creates directories for the CUPS printing service, indicating print server functionality.
- Runs
rtkbosa, a Realtek-specific hardware initialization utility. - Calls
/var/tmp/custom_cmds.sh(see below).
- Starts a generic
-
rc34:- Starts VoIP services (
rcm_voip). - Enables the
luna_watchdoghardware watchdog.
- Starts VoIP services (
-
rc35: Performs hardware and performance tuning:- Initializes the board and firmware (
fw_loaded.sh,board_init.sh). - Activates the fiber optic laser (
laser_force_on_detect), confirming this is a fiber router. - Enables Receive Packet Steering (
rps.sh) for network performance. - Starts another watchdog timer (
cdt_wdt).
- Initializes the board and firmware (
-
rc36: Starts the/etc/init.d/asod_monitorbackground process.
This script is executed during the rc32 step and performs critical, device-specific configurations:
- MIB Configuration: Sets several Management Information Base (MIB) variables for services like CWMP (TR-069 remote management) and sets the PPP credentials for the
excitel_sysuser. - U-Boot Bootloader Update: Contains a dangerous but critical function that checks the U-Boot version. If the version does not match a specific string, it erases and re-flashes the bootloader (
/dev/mtd0) with a new image (/etc/encode_uboot.img) and reboots the device. This is a powerful and potentially risky automated update mechanism.
The router's PPP connection process for Excitel is distinct and involves a combination of default scripting and provisioned credentials.
- PPP Daemon: The system uses a custom daemon,
/bin/spppd, and a control utility,/bin/spppctl. - Configuration Directory:
/etc/pppis a symbolic link to the writable/var/ppp/directory.
-
Default Credential Injection: During the boot process, the
/var/tmp/custom_cmds.shscript sets a default, hard-coded PPP username and password (excitel_sys/11223344) into the router's MIB (Management Information Base) configuration. This appears to be a fallback or initial setup step. -
Provisioned Credentials: The actual credentials used for the live connection are stored in
/var/ppp/ppp.conf. This file contains the real username and password (e.g.,ccc/cccc) that are likely provisioned by Excitel's backend systems, overriding the defaultexcitel_sysuser. -
Configuration Management: The
/etc/scripts/flashscript contains references to PPP settings (pppUser,pppPasswd, etc.), indicating it is the utility responsible for reading and writing these configurations to the device's persistent flash storage. -
Session Status: Once the connection is active, its status, including the session MAC addresses and uptime, is reflected in the
/var/ppp/pppoe.conffile.
In summary, while the router has hard-coded default credentials for Excitel, the live connection relies on credentials that are provisioned separately and stored in a dynamically generated configuration file. This process is managed by custom PPP binaries and scripts.
This section provides a detailed analysis of individual shell scripts found in the /etc/scripts/ directory, beyond those directly involved in the main rcS boot sequence.
Status: This script was called from /etc/init.d/rc35 but was not found on the filesystem during analysis. It is possible it is dynamically created, removed after execution, or its presence is conditional.
Function: This is a standard Linux script responsible for checking and mounting the root filesystem.
- Reads
/etc/fstabto determine root filesystem properties. - Activates swap partitions.
- Performs a filesystem check (
fsck) on the root filesystem. - If
fsckfails, it drops into a single-user shell for manual repair. - Remounts the root filesystem with appropriate read/write permissions.
Function: Sets up the devpts filesystem, essential for pseudo-terminals.
- Checks for
devptskernel support. - Creates
/dev/ptmxdevice node if missing. - Mounts
devptsat/dev/pts.
Function: Controls the kernel's logging verbosity.
- Reads the
PRINTK_DISABLEMIB variable. - Sets
/proc/sys/kernel/printkto1(disables most messages) or7(enables all messages) based onPRINTK_DISABLEand script arguments.
Status: Identified as a binary executable, not a shell script. It is used by other scripts (e.g., rcm_voip, update_ver_normal.sh) to interact with the device's persistent flash memory, likely for reading and writing configuration parameters like PON_MODE and software versions, and potentially for managing PPP settings.
Function: Manages firmware update states and image commitment.
- Determines the active (
sw_active) and backup firmware images. - If an update was performed by a non-OMCI updater (
sw_updateris set), it ensures thesw_commitflag matches thesw_activeimage, marking the new firmware as committed. - Clears the
sw_updaterenvironment variable.
Function: Loads the Realtek IGMP/MLD snooping kernel module.
- Identifies the current kernel version.
- Constructs the path to
rtk_igmp_hook.ko. - Loads the module using
insmodif found, crucial for optimizing multicast traffic (e.g., IPTV).
Function: Reads RF (Radio Frequency) parameters from the wlan0 wireless interface.
- Takes
<path>and<offset>as arguments. - Uses
iwpriv wlan0 read_rfto query specific RF parameters.
Function: Reads RF parameters from the wlan1 wireless interface.
- Identical to
irf, but targetswlan1.
Function: Reads a register from the wlan0 wireless interface.
- Takes
<offset>as an argument. - Uses
iwpriv wlan0 read_reg w,<offset>for low-level hardware debugging/configuration.
Function: Reads a register from the wlan1 wireless interface.
- Identical to
iw, but targetswlan1.
Function: Mounts configuration filesystems, particularly UBI volumes.
- Takes mount parameters, MTD name, and mount directory as arguments.
- Validates arguments, creates mount point if needed.
- Identifies MTD ID from
/proc/mtd. - Attempts to mount the MTD block device.
- If mounting fails, it attempts to
flash_erasethe partition (e.g., foryaffs2filesystems) and retries the mount, ensuring persistent configuration storage is available.
Function: Comprehensive script for loading various kernel modules, especially Realtek-specific drivers.
- PON Configuration: Contains functions (
ca_rtk_pon_set_scfg,rtk_pon_set_scfg) to configure Passive Optical Network (PON) settings, including MAC addresses, by interacting with ascfgfile. - Module Dependency: Runs
depmod -Aeif module dependencies are not found. - Generic Module Loading: Processes
/etc/modulesand/etc/modules-load.d/*.confto load specified modules. - Realtek-Specific Drivers: Explicitly loads numerous Realtek kernel modules for Ethernet (
fc_mgr,fc_8198f,rg,rtl8226b,rtl8367,rtl8261), wireless (rtl8192cd,8852ae), and other functionalities (ext_phy_polling).
Function: Writes a byte to a register on the wlan0 wireless interface.
- Takes
<offset>and<data>as arguments. - Uses
iwpriv wlan0 write_reg b,<offset>,<data>for low-level wireless hardware configuration.
Function: Writes a byte to a register on the wlan1 wireless interface.
- Identical to
ob, but targetswlan1.
Function: Writes a double word (32-bit) to a register on the wlan0 wireless interface.
- Takes
<offset>and<data>as arguments. - Uses
iwpriv wlan0 write_reg dw,<offset>,<data>for low-level wireless hardware configuration.
Function: Writes a double word (32-bit) to a register on the wlan1 wireless interface.
- Identical to
od, but targetswlan1.
Function: Writes RF (Radio Frequency) parameters to the wlan0 wireless interface.
- Takes
<path>,<offset>, and<data>as arguments. - Uses
iwpriv wlan0 write_rfto configure specific RF parameters.
Function: Writes RF parameters to the wlan1 wireless interface.
- Identical to
orf, but targetswlan1.
Function: Writes a word (16-bit) to a register on the wlan0 wireless interface.
- Takes
<offset>and<data>as arguments. - Uses
iwpriv wlan0 write_reg w,<offset>,<data>for low-level wireless hardware configuration.
Function: Writes a word (16-bit) to a register on the wlan1 wireless interface.
- Identical to
ow, but targetswlan1.
Function: Creates device nodes for VoIP (Voice over IP) functionality.
- Determines the major device number for VoIP from
/proc/devices. - Creates
/dev/voipdirectory. - Uses
mknodto create character device nodes for DTMF detectors, IVR, PCM channels, and a manager interface, essential for VoIP operations.
Function: Initializes and manages VoIP-related modules and processes.
- Retrieves
PON_MODEfrom flash memory using theflash getcommand. - Conditionally executes
aipc_util -E 0x0based onPON_MODE. - Executes
/etc/rc_voip_moduleand/bin/voip_def_initif they are executable. - Starts a VoIP watchdog daemon (
/bin/voip_gwdt) in the background.
Function: Resets the router to its default configuration.
- Checks for
rst2dfl=1in the kernel command line. - If present, it removes
/etc/config/lastgood.xmlto trigger a reset.
Function: Configures Receive Packet Steering (RPS) for network performance optimization.
- Takes
onoroffas an argument. - Sets
RPS_cpusandRPS_flow_cntbased on CPU core count. - Applies RPS settings to specific network interfaces (e.g.,
eth0.2,nas0).
Function: Sets a MIB variable for RSSI (Received Signal Strength Indicator) dumping on the wlan0 interface.
- Takes an argument to set the
rssi_dumpMIB variable usingiwpriv wlan0 set_mib.
Function: Sets a MIB variable for RSSI dumping on the wlan1 wireless interface.
- Identical to
rssi, but targetswlan1.
Function: Generic utility to set MIB variables on the wlan0 wireless interface.
- Takes a MIB variable name and a value as arguments.
- Uses
iwpriv wlan0 set_mibto apply the setting.
Function: Generic utility to set MIB variables on the wlan1 wireless interface.
- Identical to
setmib, but targetswlan1.
Function: Synchronizes log files.
- Compares modification times of two provided file paths.
- Copies the first file to the second if the first is newer.
Function: Mounts various kernel virtual filesystems.
- Mounts
procfs,sysfs,debugfs,devtmpfs, andtmpfsat their respective locations, making kernel information and device files accessible.
Function: udhcpc (DHCP client) hook script for deconfiguration.
- Deconfigures the network interface by setting its IP address to
0.0.0.0when a DHCP lease is released.
Function: Main udhcpc (DHCP client) hook script.
- Executes at different stages of the DHCP lease process (
bound,renew,deconfig,nak). - Configures the network interface, interacts with UPNP, calls
updateddctrl, and manages routes. - Signals the
udhcpd(DHCP server) if running.
Function: Manages software version information, particularly for province-specific configurations and OMCI.
- Retrieves active software image and hardware province name.
- Extracts
PROVINCE_SW_VERSIONfrom XML configuration files. - Uses the
flashutility andmibcommand to updatePROVINCE_SW_VERSIONand OMCI software versions.
Function: Tunes virtual memory parameters for system performance.
- Adjusts
min_free_kbytesto prevent memory deadlocks. - Configures
lowmem_reserve_ratio,vfs_cache_pressure, and dirty page writeback parameters (dirty_bytes,dirty_background_bytes,dirty_writeback_centisecs,dirty_expire_centisecs).
8. Hidden 2.4GHz SSID Configuration (www.excitel.com)
The configuration of the hidden 2.4GHz SSID named "www.excitel.com" is primarily managed through the flash binary, which interacts with the router's persistent configuration storage.
flashBinary: This executable is central to setting wireless parameters, including SSID and its hidden status. It likely interacts with MIB variables or directly with flash memory to store these settings.- Wireless Interfaces: The 2.4GHz SSID would be configured on one of the wireless interfaces, typically
wlan0orwlan1.
Based on the analysis of scripts and the grep output for "ssid" and "hidden" within /etc/scripts/flash, the following MIB-like parameters are likely used:
WLAN_SSID: To set the SSID name (e.g., "www.excitel.com").WLAN_HIDDEN_SSID: To enable or disable the hidden status of the SSID (e.g.,1for hidden,0for broadcast).- Similar parameters exist for the second wireless interface, such as
WLAN1_SSIDandWLAN1_HIDDEN_SSID.
While custom_cmds.sh sets various MIBs, it does not directly configure the SSID or its hidden status. Therefore, these settings are either pre-configured in the firmware, set by a different provisioning mechanism, or configured via the router's web interface, which then uses the flash binary to persist the changes.
To set the hidden 2.4GHz SSID "www.excitel.com", the flash binary would be invoked with commands similar to:
flash set WLAN_SSID "www.excitel.com"
flash set WLAN_HIDDEN_SSID 1(Note: The exact syntax for flash set and the MIB names might vary slightly, but the identified strings strongly suggest this mechanism.)