Protecting the router from the user using dd-wrt

    The provider from whom I am leaving the working duty gives out routers to subscribers for free for the period of conclusion of the contract. When issuing a router, mechanics flash it by entering a username, password, ip and setting up wifi. And all would be fine, but especially smart users come across who like to configure the device, and the routers also have a reset button to the factory settings, after which either the subscriber went to the office or the mechanic went to the subscriber to reconfigure the device. The patience was full and the last straw was the TL-WR841N, which the provider purchased a large batch.
    Not only that, the reset pedal is not recessed (but rather located so that it can be pressed with a twisted cable and just trash in which subscriber devices sometimes appear), the manufacturer also combined WPS and RESET on one button, which, to put it mildly, is a wonderful solution.
    image
    There was another painful moment - with the native TP-Link firmware, the router did not always restore the connection after a disconnection.
    Of course, our solution also has its drawbacks, such as the impossibility of changing passwords, but we are ready to put up with this.
    Well then ... We begin the "treatment".

    I don’t have a lot of love for Linux, but I couldn’t get all the necessary tools under FreeBSD on the fly, and I didn’t want to experiment much on the flash drive in the run-up to the firmware source for Linux, so everything described below is done under
    # uname -a
    Linux debian64 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u1 x86_64 GNU/Linux
    

    An important nuance is x86_64 , but about it later.
    Our ultimate task is to fill in the firmware in the default router containing user data, which will be restored after a reset to the factory settings. Along the way, we solve the problem of reconnecting after disconnecting. The latter problem does not occur on dd-wrt , and the availability of source codes makes it especially attractive.
    To get started, simply select the firmware for our revision. Pour into the router, make test settings and look for where they are stored. A little bit
    root@DD-WRT:~# grep -rn test00 /etc
    /etc/defaults.bin:160:
    ppp_usernametest001
    root@DD-WRT:~#
    

    we find out what they are stored in the /etc/defaults.bin file, which we will edit. It is from it that the default settings twitch. A little google we find the editing options for it with a hex editor, but having the source code is not our method to distort with a hex editor. We have three ways:
    - to collect all the firmware from the source;
    - compile from source only defaults.bin and disassembling the original firmware to replace it;
    - create defaults.bin yourself and again replace it in the original firmware.
    All options are viable, and although we will go along the 3rd path, we will touch on the first two as well. In order to make firmware from source you need to remember that you need to assemble it for the processor architecture, in our case MIPS, and we automatically get to hemorrhoids with cross-compilation. For this, there are prepared toolchains on the dd-wrt website, but all links to them answer "404 Not Found." They managed to find them - ftp.dd-wrt.com/toolchains/toolchains.tar.xz .
    NB : all toolchains are built under x86_64, which is why it is better to set the x86_64 system for experiments initially We will not dwell
    on cross-compilation, this topic is covered in the wiki dd-wrt

    But let's go our own way. We start by disassembling the firmware.
    Download Firmware Modification Kit
    # git clone https://code.google.com/p/firmware-mod-kit/
    

    We disassemble our firmware
    # firmware-mod-kit/extract-firmware.sh tl-wr841nd-webflash.bin ./working_directory/
    

    Now let's get down to preparing our defaults.bin.
    Get the source for dd-wrt
    # svn co svn://svn.dd-wrt.com/DD-WRT
    

    Actually, from all source codes we need only 2 files
    # find ./src/router/services/ -name defaults.c
    ./src/router/services/sysinit/defaults.c
    ./src/router/services/bin/defaults.c
    

    The first of which contains the filled srouter_defaults structure, and the second drives it into defaults.bin.
    We modify these files for ourselves:
    Structure:
    defaults.c
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    struct nvram_tuple srouter_defaults[] = {
    {"nvram_ver", "3", 0},
    {"router_style", "elegant", 0},
    {"os_name", "", 0},
    {"os_version", "4.150.10.5", 0},
    {"os_date", "Jul  9 2014", 0},
    {"ct_modules", "", 0},
    {"wait_time", "5", 0},
    {"timer_interval", "3600", 0},
    {"time_zone", "Europe/Minsk", 0},
    {"ntp_server", "", 0},
    {"refresh_time", "3", 0},
    {"auth_limit", "180", 0},
    {"log_level", "0", 0},
    {"ezc_enable", "1", 0},
    {"ezc_version", "2", 0},
    {"is_default", "1", 0},
    {"os_server", "", 0},
    {"stats_server", "", 0},
    {"console_loglevel", "7", 0},
    {"fw_disable", "0", 0},
    {"log_enable", "0", 0},
    {"log_ipaddr", "0", 0},
    {"lan_ifname", "", 0},
    {"lan_ifnames", "", 0},
    {"lan_hwnames", "", 0},
    {"lan_hwaddr", "", 0},
    {"wl0_ifname", "eth1", 0},
    {"lan_proto", "dhcp", 0},
    {"lan_ipaddr", "192.168.1.1", 0},
    {"lan_netmask", "255.255.255.0", 0},
    {"lan_gateway", "0.0.0.0", 0},
    {"sv_localdns", "0.0.0.0", 0},
    {"lan_stp", "0", 0},
    {"lan_wins", "", 0},
    {"lan_domain", "", 0},
    {"lan_lease", "86400", 0},
    {"wan_dial", "0", 0},
    {"wan_ifname", "", 0},
    {"wan_ifname2", "", 0},
    {"wan_ifnames", "", 0},
    {"wan_default", "", 0},
    {"wan_hwname", "", 0},
    {"wan_hwaddr", "", 0},
    {"wan_vdsl", "0", 0},
    {"dtag_vlan8", "0", 0},
    {"wan_proto", "pptp", 0},
    {"wan_ipaddr", "10.34.1.231", 0},
    {"wan_netmask", "255.255.240.0", 0},
    {"wan_gateway", "10.34.1.1", 0},
    {"pptp_wan_gateway", "10.34.1.1", 0},
    {"l2tp_wan_gateway", "0.0.0.0", 0},
    {"wan_dns", "77.88.8.8 8.8.8.8 8.8.4.4", 0},
    {"wan_wins", "0.0.0.0", 0},
    {"wan_dualaccess", "1", 0},
    {"wan_hostname", "", 0},
    {"wan_domain", "", 0},
    {"wan_lease", "86400", 0},
    {"static_route", "", 0},
    {"static_route_name", "", 0},
    {"ses_enable", "1", 0},
    {"ses_event", "2", 0},
    {"ses_button", "0", 0},
    {"ses_script", "", 0},
    {"wan_primary", "1", 0},
    {"wan_unit", "0", 0},
    {"filter_maclist", "", 0},
    {"filter_macmode", "deny", 0},
    {"filter_client0", "", 0},
    {"filter_port", "", 0},
    {"filter_rule1", "", 0},
    {"filter_rule2", "", 0},
    {"filter_rule3", "", 0},
    {"filter_rule4", "", 0},
    {"filter_rule5", "", 0},
    {"filter_rule6", "", 0},
    {"filter_rule7", "", 0},
    {"filter_rule8", "", 0},
    {"filter_rule9", "", 0},
    {"filter_rule10", "", 0},
    {"filter_tod1", "", 0},
    {"filter_tod2", "", 0},
    {"filter_tod3", "", 0},
    {"filter_tod4", "", 0},
    {"filter_tod5", "", 0},
    {"filter_tod6", "", 0},
    {"filter_tod7", "", 0},
    {"filter_tod8", "", 0},
    {"filter_tod9", "", 0},
    {"filter_tod10", "", 0},
    {"filter_tod_buf1", "", 0},
    {"filter_tod_buf2", "", 0},
    {"filter_tod_buf3", "", 0},
    {"filter_tod_buf4", "", 0},
    {"filter_tod_buf5", "", 0},
    {"filter_tod_buf6", "", 0},
    {"filter_tod_buf7", "", 0},
    {"filter_tod_buf8", "", 0},
    {"filter_tod_buf9", "", 0},
    {"filter_tod_buf10", "", 0},
    {"filter_ip_grp1", "", 0},
    {"filter_ip_grp2", "", 0},
    {"filter_ip_grp3", "", 0},
    {"filter_ip_grp4", "", 0},
    {"filter_ip_grp5", "", 0},
    {"filter_ip_grp6", "", 0},
    {"filter_ip_grp7", "", 0},
    {"filter_ip_grp8", "", 0},
    {"filter_ip_grp9", "", 0},
    {"filter_ip_grp10", "", 0},
    {"filter_mac_grp1", "", 0},
    {"filter_mac_grp2", "", 0},
    {"filter_mac_grp3", "", 0},
    {"filter_mac_grp4", "", 0},
    {"filter_mac_grp5", "", 0},
    {"filter_mac_grp6", "", 0},
    {"filter_mac_grp7", "", 0},
    {"filter_mac_grp8", "", 0},
    {"filter_mac_grp9", "", 0},
    {"filter_mac_grp10", "", 0},
    {"filter_web_host1", "", 0},
    {"filter_web_host2", "", 0},
    {"filter_web_host3", "", 0},
    {"filter_web_host4", "", 0},
    {"filter_web_host5", "", 0},
    {"filter_web_host6", "", 0},
    {"filter_web_host7", "", 0},
    {"filter_web_host8", "", 0},
    {"filter_web_host9", "", 0},
    {"filter_web_host10", "", 0},
    {"filter_web_host11", "", 0},
    {"filter_web_host12", "", 0},
    {"filter_web_host13", "", 0},
    {"filter_web_host14", "", 0},
    {"filter_web_url1", "", 0},
    {"filter_web_url2", "", 0},
    {"filter_web_url3", "", 0},
    {"filter_web_url4", "", 0},
    {"filter_web_url5", "", 0},
    {"filter_web_url6", "", 0},
    {"filter_web_url7", "", 0},
    {"filter_web_url8", "", 0},
    {"filter_web_url9", "", 0},
    {"filter_web_url10", "", 0},
    {"filter_web_url11", "", 0},
    {"filter_web_url12", "", 0},
    {"filter_web_url13", "", 0},
    {"filter_web_url14", "", 0},
    {"filter_web_url15", "", 0},
    {"filter_port_grp1", "", 0},
    {"filter_port_grp2", "", 0},
    {"filter_port_grp3", "", 0},
    {"filter_port_grp4", "", 0},
    {"filter_port_grp5", "", 0},
    {"filter_port_grp6", "", 0},
    {"filter_port_grp7", "", 0},
    {"filter_port_grp8", "", 0},
    {"filter_port_grp9", "", 0},
    {"filter_port_grp10", "", 0},
    {"filter_dport_grp1", "", 0},
    {"filter_dport_grp2", "", 0},
    {"filter_dport_grp3", "", 0},
    {"filter_dport_grp4", "", 0},
    {"filter_dport_grp5", "", 0},
    {"filter_dport_grp6", "", 0},
    {"filter_dport_grp7", "", 0},
    {"filter_dport_grp8", "", 0},
    {"filter_dport_grp9", "", 0},
    {"filter_dport_grp10", "", 0},
    {"filter_services", "", 0},
    {"filter_services_1", "", 0},
    {"dmz_enable", "0", 0},
    {"dmz_ipaddr", "0", 0},
    {"autofw_port0", "", 0},
    {"dhcp_start", "100", 0},
    {"dhcp_num", "50", 0},
    {"dhcp_lease", "1440", 0},
    {"dhcp_domain", "wan", 0},
    {"dhcp_wins", "wan", 0},
    {"wan_get_dns", "", 0},
    {"remote_ip_any", "0", 0},
    {"remote_ip", "123.123.123.1 254", 0},
    {"http_wanport", "8080", 0},
    {"http_lanport", "80", 0},
    {"http_enable", "1", 0},
    {"http_method", "post", 0},
    {"wl0_web_filter", "0", 0},
    {"wl1_web_filter", "0", 0},
    {"pppoe_ifname", "", 0},
    {"ppp_username", "test001", 0},
    {"ppp_passwd", "pass001", 0},
    {"ppp_idletime", "5", 0},
    {"ppp_keepalive", "0", 0},
    {"ppp_demand", "0", 0},
    {"ppp_redialperiod", "30", 0},
    {"ppp_service", "", 0},
    {"ppp_ac", "", 0},
    {"ppp_static", "0", 0},
    {"ppp_static_ip", "", 0},
    {"ppp_get_ac", "", 0},
    {"ppp_get_srv", "", 0},
    {"ppp_compression", "0", 0},
    {"ppp_mppe", "", 0},
    {"ppp_mlppp", "0", 0},
    {"wl0_nbw_cap", "1", 0},
    {"wl1_nbw_cap", "1", 0},
    {"wl0_nbw", "20", 0},
    {"wl1_nbw", "20", 0},
    {"wl0_bw_cap", "255", 0},
    {"wl1_bw_cap", "255", 0},
    {"wl0_nctrlsb", "lower", 0},
    {"wl1_nctrlsb", "lower", 0},
    {"wl0_nband", "0", 0},
    {"wl1_nband", "0", 0},
    {"wl0_nmcsidx", "-1", 0},
    {"wl1_nmcsidx", "-1", 0},
    {"wl0_nmode", "-1", 0},
    {"wl1_nmode", "-1", 0},
    {"wl0_nreqd", "0", 0},
    {"wl1_nreqd", "0", 0},
    {"wl0_vlan_prio_mode", "off", 0},
    {"wl1_vlan_prio_mode", "off", 0},
    {"wl0_leddc", "0x640000", 0},
    {"wl_rxstreams", "0", 0},
    {"wl_txstreams", "0", 0},
    {"wl0_sta_retry_time", "5", 0},
    {"wl_distance", "2000", 0},
    {"wl_ifname", "", 0},
    {"wl_hwaddr", "", 0},
    {"wl_phytype", "g", 0},
    {"wl_corerev", "", 0},
    {"wl_phytypes", "", 0},
    {"wl_radioids", "", 0},
    {"wl_shortslot", "auto", 0},
    {"wl1_shortslot", "auto", 0},
    {"wl_ssid", "Nord dd-wrt", 0},
    {"wl0_ssid", "Nord dd-wrt", 0},
    {"wl1_ssid", "Nord dd-wrt", 0},
    {"wl0.1_ssid", "", 0},
    {"wl0.2_ssid", "", 0},
    {"wl0.3_ssid", "", 0},
    {"wl0_bridged", "1", 0},
    {"wl0.1_bridged", "1", 0},
    {"wl0.2_bridged", "1", 0},
    {"wl0.3_bridged", "1", 0},
    {"wl0_ipaddr", "0.0.0.0", 0},
    {"wl0.1_ipaddr", "0.0.0.0", 0},
    {"wl0.2_ipaddr", "0.0.0.0", 0},
    {"wl0.3_ipaddr", "0.0.0.0", 0},
    {"wl0_netmask", "0.0.0.0", 0},
    {"wl0.1_netmask", "0.0.0.0", 0},
    {"wl0.2_netmask", "0.0.0.0", 0},
    {"wl0.3_netmask", "0.0.0.0", 0},
    {"wl_radio", "1", 0},
    {"wl0_radio", "1", 0},
    {"wl0_closed", "0", 0},
    {"wl0.1_closed", "0", 0},
    {"wl0.2_closed", "0", 0},
    {"wl0.3_closed", "0", 0},
    {"wl_ap_isolate", "0", 0},
    {"wl1_ap_isolate", "0", 0},
    {"wl_mode", "ap", 0},
    {"wl0_mode", "ap", 0},
    {"wl1_mode", "ap", 0},
    {"wl_lazywds", "0", 0},
    {"wl_wds", "", 0},
    {"wl_wep", "disabled", 0},
    {"wl_crypto", "off", 0},
    {"wl_auth", "0", 0},
    {"wl0_crypto", "tkip+aes", 0},
    {"ath0_crypto", "tkip+aes", 0},
    {"wl0_auth", "0", 0},
    {"wl1_auth", "0", 0},
    {"wl0_key", "1", 0},
    {"wl0_key1", "", 0},
    {"wl0_key2", "", 0},
    {"wl0_key3", "", 0},
    {"wl0_key4", "", 0},
    {"wl0.1_crypto", "off", 0},
    {"wl0.1_auth", "0", 0},
    {"wl0.1_key", "1", 0},
    {"wl0.1_key1", "", 0},
    {"wl0.1_key2", "", 0},
    {"wl0.1_key3", "", 0},
    {"wl0.1_key4", "", 0},
    {"wl0.2_crypto", "off", 0},
    {"wl0.2_auth", "0", 0},
    {"wl0.2_key", "1", 0},
    {"wl0.2_key1", "", 0},
    {"wl0.2_key2", "", 0},
    {"wl0.2_key3", "", 0},
    {"wl0.2_key4", "", 0},
    {"wl0.3_crypto", "off", 0},
    {"wl0.3_auth", "0", 0},
    {"wl0.3_key", "1", 0},
    {"wl0.3_key1", "", 0},
    {"wl0.3_key2", "", 0},
    {"wl0.3_key3", "", 0},
    {"wl0.3_key4", "", 0},
    {"wl_macmode", "disabled", 0},
    {"wl_macmode1", "disabled", 0},
    {"wl0_channel", "6", 0},
    {"wl_reg_mode", "off", 0},
    {"wl_dfs_preism", "60", 0},
    {"wl_dfs_postism", "60", 0},
    {"wl_rate", "0", 0},
    {"wl1_rate", "0", 0},
    {"wl_mrate", "0", 0},
    {"wl_rateset", "default", 0},
    {"wl1_rateset", "default", 0},
    {"wl_frag", "2346", 0},
    {"wl1_frag", "2346", 0},
    {"wl_rts", "2347", 0},
    {"wl1_rts", "2347", 0},
    {"wl_dtim", "1", 0},
    {"wl1_dtim", "1", 0},
    {"wl_bcn", "100", 0},
    {"wl1_bcn", "100", 0},
    {"wl_plcphdr", "long", 0},
    {"wl1_plcphdr", "long", 0},
    {"wl_net_mode", "mixed", 0},
    {"wl0_net_mode", "mixed", 0},
    {"wl1_net_mode", "mixed", 0},
    {"wl0_gmode", "1", 0},
    {"wl_gmode_protection", "auto", 0},
    {"wl1_gmode_protection", "auto", 0},
    {"wl_nmode_protection", "auto", 0},
    {"wl_frameburst", "off", 0},
    {"wl1_frameburst", "off", 0},
    {"wl_infra", "1", 0},
    {"wl_passphrase", "", 0},
    {"wl_wep_bit", "64", 0},
    {"wl_wep_buf", "", 0},
    {"wl_wep_gen", "", 0},
    {"wl_wep_last", "", 0},
    {"wl_active_mac", "", 0},
    {"wl_mac_list", "", 0},
    {"wl_mac_deny", "", 0},
    {"security_mode", "disabled", 0},
    {"security_mode_last", "", 0},
    {"wl0_auth_mode", "disabled", 0},
    //{"wl0_akm", "disabled", 0},
    {"wl0_akm", "psk psk2", 0},
    {"ath0_akm", "psk psk2", 0},
    {"wl0_wpa_psk", "1234567890", 0},
    {"ath0_wpa_psk", "1234567890", 0},
    {"wl0_wpa_gtk_rekey", "3600", 0},
    {"wl0_radius_port", "1812", 0},
    {"wl0_radius_ipaddr", "", 0},
    {"wl0_radius_key", "", 0},
    {"wl0_security_mode", "psk2", 0},
    {"ath0_security_mode", "psk2", 0},
    {"wl0.1_auth_mode", "disabled", 0},
    {"wl0.1_akm", "disabled", 0},
    {"wl0.1_wpa_psk", "", 0},
    {"wl0.1_wpa_gtk_rekey", "3600", 0},
    {"wl0.1_radius_port", "1812", 0},
    {"wl0.1_radius_ipaddr", "", 0},
    {"wl0.1_radius_key", "", 0},
    {"wl0.2_auth_mode", "disabled", 0},
    {"wl0.2_akm", "disabled", 0},
    {"wl0.2_wpa_psk", "", 0},
    {"wl0.2_wpa_gtk_rekey", "3600", 0},
    {"wl0.2_radius_port", "1812", 0},
    {"wl0.2_radius_ipaddr", "", 0},
    {"wl0.2_radius_key", "", 0},
    {"wl0.3_auth_mode", "disabled", 0},
    {"wl0.3_akm", "disabled", 0},
    {"wl0.3_wpa_psk", "", 0},
    {"wl0.3_wpa_gtk_rekey", "3600", 0},
    {"wl0.3_radius_port", "1812", 0},
    {"wl0.3_radius_ipaddr", "", 0},
    {"wl0.3_radius_key", "", 0},
    {"wl0_radius_override", "1", 0},
    {"wl0_max_unauth_users", "0", 0},
    {"wl0_radmacpassword", "0", 0},
    {"wl_afterburner", "off", 0},
    {"wl1_afterburner", "off", 0},
    {"wl_unit", "0", 0},
    {"restore_defaults", "0", 0},
    {"router_name", "DD-WRT", 0},
    {"ntp_mode", "auto", 0},
    {"pptp_server_ip", "", 0},
    {"pptp_get_ip", "", 0},
    {"filter", "on", 0},
    {"block_wan", "1", 0},
    {"block_ident", "1", 0},
    {"block_proxy", "0", 0},
    {"block_java", "0", 0},
    {"block_activex", "0", 0},
    {"block_cookie", "0", 0},
    {"block_multicast", "1", 0},
    {"block_loopback", "0", 0},
    {"block_snmp", "1", 0},
    {"ipsec_pass", "1", 0},
    {"pptp_pass", "1", 0},
    {"l2tp_pass", "1", 0},
    {"limit_ssh", "0", 0},
    {"limit_telnet", "0", 0},
    {"limit_pptp", "0", 0},
    {"remote_management", "1", 0},
    {"mtu_enable", "0", 0},
    {"wan_mtu", "1500", 0},
    {"forward_port", "", 0},
    {"forward_spec", "", 0},
    {"port_trigger", "", 0},
    {"wk_mode", "gateway", 0},
    {"dr_setting", "0", 0},
    {"dr_lan_tx", "0", 0},
    {"dr_lan_rx", "0", 0},
    {"dr_wan_tx", "0", 0},
    {"dr_wan_rx", "0", 0},
    {"mac_clone_enable", "0", 0},
    {"def_hwaddr", "00:00:00:00:00:00", 0},
    {"port_swap", "0", 0},
    {"ddns_enable", "0", 0},
    {"ddns_wan_ip", "1", 0},
    {"ddns_username", "", 0},
    {"ddns_passwd", "", 0},
    {"ddns_hostname", "", 0},
    {"ddns_dyndnstype", "", 0},
    {"ddns_wildcard", "", 0},
    {"ddns_username_2", "", 0},
    {"ddns_passwd_2", "", 0},
    {"ddns_hostname_2", "", 0},
    {"ddns_username_3", "", 0},
    {"ddns_passwd_3", "", 0},
    {"ddns_hostname_3", "", 0},
    {"ddns_username_4", "", 0},
    {"ddns_passwd_4", "", 0},
    {"ddns_hostname_4", "", 0},
    {"ddns_username_5", "", 0},
    {"ddns_passwd_5", "", 0},
    {"ddns_hostname_5", "", 0},
    {"ddns_custom_5", "", 0},
    {"ddns_conf", "", 0},
    {"ddns_url", "", 0},
    {"ddns_username_6", "", 0},
    {"ddns_passwd_6", "", 0},
    {"ddns_hostname_6", "", 0},
    {"ddns_dyndnstype_6", "", 0},
    {"ddns_wildcard_6", "", 0},
    {"ddns_username_7", "", 0},
    {"ddns_passwd_7", "", 0},
    {"ddns_hostname_7", "", 0},
    {"ddns_wildcard_7", "", 0},
    {"ddns_username_8", "", 0},
    {"ddns_passwd_8", "", 0},
    {"ddns_hostname_8", "", 0},
    {"ddns_enable_buf", "", 0},
    {"ddns_username_buf", "", 0},
    {"ddns_passwd_buf", "", 0},
    {"ddns_hostname_buf", "", 0},
    {"ddns_force", "10", 0},
    {"ddns_cache", "", 0},
    {"ddns_time", "", 0},
    {"skip_amd_check", "0", 0},
    {"skip_intel_check", "0", 0},
    {"l2tp_use_dhcp", "1", 0},
    {"l2tp_server_ip", "", 0},
    {"l2tp_server_name", "", 0},
    {"l2tp_get_ip", "", 0},
    {"l2tp_req_chap", "yes", 0},
    {"l2tp_ref_pap", "yes", 0},
    {"l2tp_req_auth", "yes", 0},
    {"wan_gateway_buf", "0.0.0.0", 0},
    {"hb_server_ip", "", 0},
    {"hb_server_domain", "", 0},
    {"samba_mount", "0", 0},
    {"rflow_enable", "0", 0},
    {"info_passwd", "0", 0},
    {"macupd_enable", "0", 0},
    {"wl_radauth", "0", 0},
    {"rc_startup", "", 0},
    {"rc_firewall", "", 0},
    {"rc_custom", "", 0},
    {"rc_shutdown", "", 0},
    {"wl0_txpwr", "71", 0},
    {"wl1_txpwr", "71", 0},
    {"wl0_txant", "3", 0},
    {"wl0_antdiv", "3", 0},
    {"wl1_txant", "3", 0},
    {"wl1_antdiv", "3", 0},
    {"apwatchdog_enable", "0", 0},
    {"apwatchdog_interval", "15", 0},
    {"boot_wait", "on", 0},
    {"cron_enable", "1", 0},
    {"cron_jobs", "", 0},
    {"dhcpd_options", "", 0},
    {"dhcpd_usenvram", "0", 0},
    {"local_dns", "0", 0},
    {"dnsmasq_no_dns_rebind", "1", 0},
    {"dnsmasq_enable", "1", 0},
    {"dnsmasq_options", "", 0},
    {"nas_enable", "1", 0},
    {"ntp_enable", "1", 0},
    {"pptpd_enable", "0", 0},
    {"pptpd_forcemppe", "1", 0},
    {"pptpd_bcrelay", "0", 0},
    {"pptpd_lip", "", 0},
    {"pptpd_rip", "", 0},
    {"pptpd_auth", "", 0},
    {"pptpd_radius", "0", 0},
    {"pptpd_radserver", "0.0.0.0", 0},
    {"pptpd_radport", "1812", 0},
    {"pptpd_acctport", "1813", 0},
    {"pptpd_radpass", "", 0},
    {"pptpd_conn", "64", 0},
    {"pptp_reorder", "0", 0},
    {"pptp_iptv", "0", 0},
    {"pptp_extraoptions", "", 0},
    {"pptpd_mtu", "1436", 0},
    {"pptpd_mru", "1436", 0},
    {"pptp_encrypt", "0", 0},
    {"resetbutton_enable", "1", 0},
    {"telnetd_enable", "1", 0},
    {"ipv6_enable", "0", 0},
    {"radvd_enable", "0", 0},
    {"radvd_conf", "", 0},
    {"remote_mgt_telnet", "1", 0},
    {"telnet_wanport", "23", 0},
    {"syslogd_enable", "0", 0},
    {"syslogd_rem_ip", "", 0},
    {"wl0_wds1_enable", "0", 0},
    {"wl0_wds2_enable", "0", 0},
    {"wl0_wds3_enable", "0", 0},
    {"wl0_wds4_enable", "0", 0},
    {"wl0_wds5_enable", "0", 0},
    {"wl0_wds6_enable", "0", 0},
    {"wl0_wds7_enable", "0", 0},
    {"wl0_wds8_enable", "0", 0},
    {"wl0_wds9_enable", "0", 0},
    {"wl0_wds10_enable", "0", 0},
    {"wl0_wds1_hwaddr", "", 0},
    {"wl0_wds2_hwaddr", "", 0},
    {"wl0_wds3_hwaddr", "", 0},
    {"wl0_wds4_hwaddr", "", 0},
    {"wl0_wds5_hwaddr", "", 0},
    {"wl0_wds6_hwaddr", "", 0},
    {"wl0_wds7_hwaddr", "", 0},
    {"wl0_wds8_hwaddr", "", 0},
    {"wl0_wds9_hwaddr", "", 0},
    {"wl0_wds10_hwaddr", "", 0},
    {"wl0_wds1_ipaddr", "", 0},
    {"wl0_wds2_ipaddr", "", 0},
    {"wl0_wds3_ipaddr", "", 0},
    {"wl0_wds4_ipaddr", "", 0},
    {"wl0_wds5_ipaddr", "", 0},
    {"wl0_wds6_ipaddr", "", 0},
    {"wl0_wds7_ipaddr", "", 0},
    {"wl0_wds8_ipaddr", "", 0},
    {"wl0_wds9_ipaddr", "", 0},
    {"wl0_wds10_ipaddr", "", 0},
    {"wl0_wds1_netmask", "", 0},
    {"wl0_wds2_netmask", "", 0},
    {"wl0_wds3_netmask", "", 0},
    {"wl0_wds4_netmask", "", 0},
    {"wl0_wds5_netmask", "", 0},
    {"wl0_wds6_netmask", "", 0},
    {"wl0_wds7_netmask", "", 0},
    {"wl0_wds8_netmask", "", 0},
    {"wl0_wds9_netmask", "", 0},
    {"wl0_wds10_netmask", "", 0},
    {"wl0_wds1_desc", "", 0},
    {"wl0_wds2_desc", "", 0},
    {"wl0_wds3_desc", "", 0},
    {"wl0_wds4_desc", "", 0},
    {"wl0_wds5_desc", "", 0},
    {"wl0_wds6_desc", "", 0},
    {"wl0_wds7_desc", "", 0},
    {"wl0_wds8_desc", "", 0},
    {"wl0_wds9_desc", "", 0},
    {"wl0_wds10_desc", "", 0},
    {"wl0_wds1_ospf", "", 0},
    {"wl0_wds2_ospf", "", 0},
    {"wl0_wds3_ospf", "", 0},
    {"wl0_wds4_ospf", "", 0},
    {"wl0_wds5_ospf", "", 0},
    {"wl0_wds6_ospf", "", 0},
    {"wl0_wds7_ospf", "", 0},
    {"wl0_wds8_ospf", "", 0},
    {"wl0_wds9_ospf", "", 0},
    {"wl0_wds10_ospf", "", 0},
    {"wl1_wds1_enable", "0", 0},
    {"wl1_wds2_enable", "0", 0},
    {"wl1_wds3_enable", "0", 0},
    {"wl1_wds4_enable", "0", 0},
    {"wl1_wds5_enable", "0", 0},
    {"wl1_wds6_enable", "0", 0},
    {"wl1_wds7_enable", "0", 0},
    {"wl1_wds8_enable", "0", 0},
    {"wl1_wds9_enable", "0", 0},
    {"wl1_wds10_enable", "0", 0},
    {"wl1_wds1_hwaddr", "", 0},
    {"wl1_wds2_hwaddr", "", 0},
    {"wl1_wds3_hwaddr", "", 0},
    {"wl1_wds4_hwaddr", "", 0},
    {"wl1_wds5_hwaddr", "", 0},
    {"wl1_wds6_hwaddr", "", 0},
    {"wl1_wds7_hwaddr", "", 0},
    {"wl1_wds8_hwaddr", "", 0},
    {"wl1_wds9_hwaddr", "", 0},
    {"wl1_wds10_hwaddr", "", 0},
    {"wl1_wds1_ipaddr", "", 0},
    {"wl1_wds2_ipaddr", "", 0},
    {"wl1_wds3_ipaddr", "", 0},
    {"wl1_wds4_ipaddr", "", 0},
    {"wl1_wds5_ipaddr", "", 0},
    {"wl1_wds6_ipaddr", "", 0},
    {"wl1_wds7_ipaddr", "", 0},
    {"wl1_wds8_ipaddr", "", 0},
    {"wl1_wds9_ipaddr", "", 0},
    {"wl1_wds10_ipaddr", "", 0},
    {"wl1_wds1_netmask", "", 0},
    {"wl1_wds2_netmask", "", 0},
    {"wl1_wds3_netmask", "", 0},
    {"wl1_wds4_netmask", "", 0},
    {"wl1_wds5_netmask", "", 0},
    {"wl1_wds6_netmask", "", 0},
    {"wl1_wds7_netmask", "", 0},
    {"wl1_wds8_netmask", "", 0},
    {"wl1_wds9_netmask", "", 0},
    {"wl1_wds10_netmask", "", 0},
    {"wl1_wds1_desc", "", 0},
    {"wl1_wds2_desc", "", 0},
    {"wl1_wds3_desc", "", 0},
    {"wl1_wds4_desc", "", 0},
    {"wl1_wds5_desc", "", 0},
    {"wl1_wds6_desc", "", 0},
    {"wl1_wds7_desc", "", 0},
    {"wl1_wds8_desc", "", 0},
    {"wl1_wds9_desc", "", 0},
    {"wl1_wds10_desc", "", 0},
    {"wl1_wds1_ospf", "", 0},
    {"wl1_wds2_ospf", "", 0},
    {"wl1_wds3_ospf", "", 0},
    {"wl1_wds4_ospf", "", 0},
    {"wl1_wds5_ospf", "", 0},
    {"wl1_wds6_ospf", "", 0},
    {"wl1_wds7_ospf", "", 0},
    {"wl1_wds8_ospf", "", 0},
    {"wl1_wds9_ospf", "", 0},
    {"wl1_wds10_ospf", "", 0},
    {"wl0_br1_enable", "0", 0},
    {"wl0_br1_nat", "0", 0},
    {"wl1_br1_enable", "0", 0},
    {"wl1_br1_nat", "0", 0},
    {"wl0_wds", "", 0},
    {"wl0_wds0", "", 0},
    {"wl0_wds1", "", 0},
    {"wl0_wds2", "", 0},
    {"wl0_wds3", "", 0},
    {"wl0_wds4", "", 0},
    {"wl0_wds5", "", 0},
    {"wl0_wds6", "", 0},
    {"wl0_wds7", "", 0},
    {"wl0_wds8", "", 0},
    {"wl0_wds9", "", 0},
    {"wl1_wds", "", 0},
    {"wl1_wds0", "", 0},
    {"wl1_wds1", "", 0},
    {"wl1_wds2", "", 0},
    {"wl1_wds3", "", 0},
    {"wl1_wds4", "", 0},
    {"wl1_wds5", "", 0},
    {"wl1_wds6", "", 0},
    {"wl1_wds7", "", 0},
    {"wl1_wds8", "", 0},
    {"wl1_wds9", "", 0},
    {"wl0_wds0_if", "", 0},
    {"wl0_wds1_if", "", 0},
    {"wl0_wds2_if", "", 0},
    {"wl0_wds3_if", "", 0},
    {"wl0_wds4_if", "", 0},
    {"wl0_wds5_if", "", 0},
    {"wl0_wds6_if", "", 0},
    {"wl0_wds7_if", "", 0},
    {"wl0_wds8_if", "", 0},
    {"wl0_wds9_if", "", 0},
    {"wl0_wds10_if", "", 0},
    {"wl1_wds0_if", "", 0},
    {"wl1_wds1_if", "", 0},
    {"wl1_wds2_if", "", 0},
    {"wl1_wds3_if", "", 0},
    {"wl1_wds4_if", "", 0},
    {"wl1_wds5_if", "", 0},
    {"wl1_wds6_if", "", 0},
    {"wl1_wds7_if", "", 0},
    {"wl1_wds8_if", "", 0},
    {"wl1_wds9_if", "", 0},
    {"wl1_wds10_if", "", 0},
    {"wds0.1", "", 0},
    {"wds0.2", "", 0},
    {"wds0.3", "", 0},
    {"wds0.4", "", 0},
    {"wds0.5", "", 0},
    {"wds0.6", "", 0},
    {"wds0.7", "", 0},
    {"wds0.8", "", 0},
    {"wds0.9", "", 0},
    {"wds0.10", "", 0},
    {"wds0.11", "", 0},
    {"wds0.12", "", 0},
    {"wds0.13", "", 0},
    {"wds0.14", "", 0},
    {"wds0.15", "", 0},
    {"wds0.16", "", 0},
    {"wds1.1", "", 0},
    {"wds1.2", "", 0},
    {"wds1.3", "", 0},
    {"wds1.4", "", 0},
    {"wds1.5", "", 0},
    {"wds1.6", "", 0},
    {"wds1.7", "", 0},
    {"wds1.8", "", 0},
    {"wds1.9", "", 0},
    {"wds1.10", "", 0},
    {"wds1.11", "", 0},
    {"wds1.12", "", 0},
    {"wds1.13", "", 0},
    {"wds1.14", "", 0},
    {"wds1.15", "", 0},
    {"wds1.16", "", 0},
    {"wshaper_enable", "0", 0},
    {"wshaper_dev", "WAN", 0},
    {"wshaper_downlink", "0", 0},
    {"wshaper_uplink", "0", 0},
    {"wshaper_nopriohostsrc", "", 0},
    {"wshaper_nopriohostdst", "", 0},
    {"wshaper_noprioportsrc", "", 0},
    {"wshaper_noprioportdst", "", 0},
    {"zebra_enable", "1", 0},
    {"qos_type", "0", 0},
    {"svqos_svcs", "", 0},
    {"svqos_ips", "", 0},
    {"svqos_macs", "", 0},
    {"svqos_port1bw", "FULL", 0},
    {"svqos_port2bw", "FULL", 0},
    {"svqos_port3bw", "FULL", 0},
    {"svqos_port4bw", "FULL", 0},
    {"svqos_port1prio", "10", 0},
    {"svqos_port2prio", "10", 0},
    {"svqos_port3prio", "10", 0},
    {"svqos_port4prio", "10", 0},
    {"wol_enable", "0", 0},
    {"wol_interval", "86400", 0},
    {"wol_hostname", "", 0},
    {"wol_macs", "", 0},
    {"wol_passwd", "", 0},
    {"hs_enable", "", 0},
    {"hs_exempt", "", 0},
    {"hs_urls", "", 0},
    {"hs_redirect", "", 0},
    {"hs_html", "", 0},
    {"hs_image", "", 0},
    {"def_whwaddr", "00:00:00:00:00:00", 0},
    {"sv_restore_defaults", "0", 0},
    {"ospfd_conf", "", 0},
    {"zebra_conf", "", 0},
    {"ospfd_copt", "0", 0},
    {"zebra_copt", "0", 0},
    {"zebra_log", "0", 0},
    {"dyn_default", "0", 0},
    {"altdns1", "", 0},
    {"altdns2", "", 0},
    {"altdns3", "", 0},
    {"log_accepted", "0", 0},
    {"log_dropped", "0", 0},
    {"log_rejected", "0", 0},
    {"port0vlans", "1", 0},
    {"port1vlans", "0", 0},
    {"port2vlans", "0", 0},
    {"port3vlans", "0", 0},
    {"port4vlans", "0", 0},
    {"port5vlans", "0 1 16", 0},
    {"vlans", "0", 0},
    {"trunking", "0", 0},
    {"manual_boot_nv", "0", 0},
    {"status_auth", "1", 0},
    {"ipv6_enable", "0", 0},
    {"enable_jffs2", "0", 0},
    {"clean_jffs2", "0", 0},
    {"sys_enable_jffs2", "0", 0},
    {"language", "russian", 0},
    {"macupd_ip", "0.0.0.0", 0},
    {"macupd_port", "2056", 0},
    {"macupd_interval", "10", 0},
    {"mmc_enable", "0", 0},
    {"mmc_enable0", "0", 0},
    {"ip_conntrack_max", "4096", 0},
    {"ip_conntrack_tcp_timeouts", "3600", 0},
    {"ip_conntrack_udp_timeouts", "120", 0},
    {"rflow_ip", "0.0.0.0", 0},
    {"rflow_port", "2055", 0},
    {"rflow_if", "br0", 0},
    {"schedule_enable", "0", 0},
    {"schedule_time", "3600", 0},
    {"schedule_hour_time", "1", 0},
    {"schedule_minutes", "0", 0},
    {"schedule_hours", "0", 0},
    {"schedule_weekdays", "00", 0},
    {"smtp_redirect_enable", "0", 0},
    {"smtp_redirect_destination", "0.0.0.0", 0},
    {"smtp_source_network", "0.0.0.0", 0},
    {"wds_watchdog_enable", "0", 0},
    {"wds_watchdog_interval_sec", "1000", 0},
    {"wds_watchdog_ips", "", 0},
    {"dhcpfwd_enable", "0", 0},
    {"dhcpfwd_ip", "0.0.0.0", 0},
    {"NC_enable", "0", 0},
    {"NC_GatewayName", "DD-WRT", 0},
    {"NC_HomePage", "http://www.dd-wrt.com", 0},
    {"NC_ExcludePorts", "25", 0},
    {"NC_IncludePorts", "", 0},
    {"NC_Verbosity", "2", 0},
    {"NC_LoginTimeout", "86400", 0},
    {"NC_AllowedWebHosts", "", 0},
    {"NC_RouteOnly", "0", 0},
    {"NC_DocumentRoot", "/www", 0},
    {"NC_SplashURL", "", 0},
    {"NC_SplashURLTimeout", "21600", 0},
    {"NC_MACWhiteList", "", 0},
    {"NC_GatewayPort", "5280", 0},
    {"NC_GatewayMode", "Open", 0},
    {"NC_extifname", "auto", 0},
    {"NC_ForcedRedirect", "0", 0},
    {"NC_IdleTimeout", "0", 0},
    {"NC_MaxMissedARP", "5", 0},
    {"NC_RenewTimeout", "0", 0},
    {"wl_wme", "on", 0},
    {"wl1_wme", "on", 0},
    {"wl_wme_sta_bk", "15 1023 7 0 0 off", 0},
    {"wl_wme_sta_be", "15 1023 3 0 0 off", 0},
    {"wl_wme_sta_vi", "7 15 2 6016 3008 off", 0},
    {"wl_wme_sta_vo", "3 7 2 3264 1504 off", 0},
    {"wl_wme_ap_bk", "15 1023 7 0 0 off", 0},
    {"wl_wme_ap_be", "15 63 3 0 0 off", 0},
    {"wl_wme_ap_vi", "7 15 1 6016 3008 off", 0},
    {"wl_wme_ap_vo", "3 7 1 3264 1504 off", 0},
    {"wl_wme_no_ack", "off", 0},
    {"wl_wme_apsd", "on", 0},
    {"wl1_wme_sta_bk", "15 1023 7 0 0 off", 0},
    {"wl1_wme_sta_be", "15 1023 3 0 0 off", 0},
    {"wl1_wme_sta_vi", "7 15 2 6016 3008 off", 0},
    {"wl1_wme_sta_vo", "3 7 2 3264 1504 off", 0},
    {"wl1_wme_ap_bk", "15 1023 7 0 0 off", 0},
    {"wl1_wme_ap_be", "15 63 3 0 0 off", 0},
    {"wl1_wme_ap_vi", "7 15 1 6016 3008 off", 0},
    {"wl1_wme_ap_vo", "3 7 1 3264 1504 off", 0},
    {"wl1_wme_no_ack", "off", 0},
    {"wl1_wme_apsd", "on", 0},
    {"wl_maxassoc", "128", 0},
    {"wl1_maxassoc", "128", 0},
    {"wl_wme_txp_be", "7 3 4 2 0", 0},
    {"wl_wme_txp_bk", "7 3 4 2 0", 0},
    {"wl_wme_txp_vi", "7 3 4 2 0", 0},
    {"wl_wme_txp_vo", "7 3 4 2 0", 0},
    {"wl1_wme_txp_be", "7 3 4 2 0", 0},
    {"wl1_wme_txp_bk", "7 3 4 2 0", 0},
    {"wl1_wme_txp_vi", "7 3 4 2 0", 0},
    {"wl1_wme_txp_vo", "7 3 4 2 0", 0},
    {"dhcp_dnsmasq", "1", 0},
    {"dns_dnsmasq", "1", 0},
    {"auth_dnsmasq", "1", 0},
    {"pptp_use_dhcp", "0", 0},
    {"pptp_server_name", "10.10.10.22", 0},
    {"forward_entries", "0", 0},
    {"forwardspec_entries", "0", 0},
    {"trigger_entries", "0", 0},
    {"sip_port", "5060", 0},
    {"sip_domain", "192.168.1.1", 0},
    {"static_leases", "", 0},
    {"static_leasenum", "0", 0},
    {"dhcpc_vendorclass", "", 0},
    {"dhcpc_requestip", "", 0},
    {"maskmac", "1", 0},
    {"fullswitch", "0", 0},
    {"upgrade_delay", "300", 0},
    {"fon_enable", "0", 0},
    {"pptpd_client_enable", "", 0},
    {"pptpd_client_srvip", "", 0},
    {"pptpd_client_srvsub", "", 0},
    {"pptpd_client_srvsubmsk", "", 0},
    {"pptpd_client_srvuser", "", 0},
    {"pptpd_client_srvpass", "", 0},
    {"pptpd_client_ipparam", "", 0},
    {"pptpd_client_mtu", "1436", 0},
    {"pptpd_client_mru", "1436", 0},
    {"radio0_on_time", "111111111111111111111111", 0},
    {"radio0_timer_enable", "0", 0},
    {"radio1_on_time", "111111111111111111111111", 0},
    {"radio1_timer_enable", "0", 0},
    {"wifi_bonding", "0", 0},
    {"wifi_display", "wl0", 0},
    {"ttraff_enable", "1", 0},
    {"ttraff_iface", "", 0},
    {"reconnect_enable", "0", 0},
    {"reconnect_hours", "0", 0},
    {"reconnect_minutes", "0", 0},
    {"warn_enabled", "0", 0},
    {"warn_connlimit", "500", 0},
    {"ptoken", "0", 0}
    };
    


    The structure is quite clear, the missing elements are intuitively thought out, but the most incomprehensible can be found in a roundabout way. Almost all the names of the elements of the web-interface pages coincide with the names of the parameters of our structure, for example, let's see the code of the element in chrome.
    image
    I think the comments are superfluous.

    Shaper itself
    bin_defaults.c
    #include 
    #include 
    #include 
    #include 
    #include "./defaults.c"
    static void
    usage(void)
    {
    	const char *cmd = "make_defaults";
    	fprintf(stderr,
    		"Usage:\n"
    		"%s arguments\n"
    		"\t-u username		pptp username\n"
    		"\t-p password		pptp user password\n"
    		"\t-i ip\t		user LAN ip-assress\n"
    		"\t-P password		WI-FI user password\n"
    		"",
    		cmd);
    	exit(0);
    }
    //-----------------------------------------------------------------------------
    int main(int argc, char *argv[])
    {
    	int ch;
    	char username[32], password[32], ip[32], wifi_password[64];
    	if(argc != 9) usage();
    	while ( (ch = getopt(argc, argv, "u:p:i:P:")) != -1) {
    		switch(ch) {
    		default:
    			printf("bad option %c %s\n", ch, optarg);
    			usage();
    			break;
    		case 'u':
    			strcpy(username, optarg);
    			break;
    		case 'p':
    			strcpy(password, optarg);
    			break;
    		case 'i':
    			strcpy(ip, optarg);
    			break;
    		case 'P':
    			strcpy(wifi_password, optarg);
    			break;
    		}
    	}
    	FILE *out;
    	out = fopen("defaults.bin", "wb");
    	int i;
    	int len = sizeof(srouter_defaults) / sizeof(struct nvram_tuple);
    	fwrite(&len, 4, 1, out);
    	int iSize = sizeof(srouter_defaults) / sizeof(struct nvram_tuple);
    	for (i = 0; i < iSize; i++) {
    		if (srouter_defaults[i].name) {
    			if (strcmp(srouter_defaults[i].name, "ppp_username") == 0) 	srouter_defaults[i].value = username;
    			if (strcmp(srouter_defaults[i].name, "ppp_passwd") == 0) 	srouter_defaults[i].value = password;
    			if (strcmp(srouter_defaults[i].name, "wan_ipaddr") == 0) 	srouter_defaults[i].value = ip;
    			if (strcmp(srouter_defaults[i].name, "ath0_wpa_psk") == 0) 	srouter_defaults[i].value = wifi_password;
    			if (strcmp(srouter_defaults[i].name, "wl0_wpa_psk") == 0) 	srouter_defaults[i].value = wifi_password;
    			//  /usr/bin/gcc /root/scripts/dd-wrt/c/bin_defaults.c -I/root/scripts/dd-wrt/DD-WRT/src/include.v24 -I /root/scripts/dd-wrt/DD-WRT/src/router/shared
    			printf("{\"%s\", \"%s\", 0}", srouter_defaults[i].name, srouter_defaults[i].value);
    			if(i+2 < iSize) printf(",");
    			printf("\n");
    			putc(strlen(srouter_defaults[i].name), out);
    			fwrite(srouter_defaults[i].name,
    			       strlen(srouter_defaults[i].name), 1, out);
    			len = strlen(srouter_defaults[i].value);
    			if (len > 127) {
    				len |= 128;
    				putc(len & 0xff, out);
    				putc(strlen(srouter_defaults[i].value) >> 7,
    				     out);
    			} else {
    				putc(len, out);
    			}
    			fwrite(srouter_defaults[i].value,
    			       strlen(srouter_defaults[i].value), 1, out);
    		} else {
    			putc(0, out);
    			putc(0, out);
    		}
    	}
    	fclose(out);
    	return 0;
    }
    



    Compile
    # gcc /root/scripts/dd-wrt/c/bin_defaults.c -I/root/scripts/dd-wrt/DD-WRT/src/include.v24 -I /root/scripts/dd-wrt/DD-WRT/src/router/shared
    

    We launch
    # a.out  -u test001 -p 0123456 -i 10.34.1.231 -P 01234567890123456
    

    Copy the resulting defaults.bin to our disassembled firmware
    # /bin/cp dd-wrt/c/defaults.bin dd-wrt/841/working_directory/rootfs/etc/defaults.bin
    

    AND
    collect it back
    # dd-wrt/firmware-mod-kit/build-firmware.sh ./working_directory/
    Firmware Mod Kit (build) 0.99, (c)2011-2013 Craig Heffner, Jeremy Collake
    Building new squashfs file system... (this may take several minutes!)
    Squashfs block size is 128 Kb
    Creating big endian 3.0 filesystem on /root/scripts/dd-wrt/841/working_directory/new-filesystem.squashfs, block size 131072.
    Big endian filesystem, data block size 131072, compressed data, compressed metadata, compressed fragments
    Filesystem size 2753.71 Kbytes (2.69 Mbytes)
            34.09% of uncompressed filesystem size (8077.26 Kbytes)
    Inode table size 4920 bytes (4.80 Kbytes)
            22.78% of uncompressed inode table size (21599 bytes)
    Directory table size 6275 bytes (6.13 Kbytes)
            57.61% of uncompressed directory table size (10892 bytes)
    Number of duplicate files found 0
    Number of inodes 700
    Number of files 446
    Number of fragments 24
    Number of symbolic links  189
    Number of device nodes 0
    Number of fifo nodes 0
    Number of socket nodes 0
    Number of directories 65
    Number of uids 1
            root (0)
    Number of gids 0
    Remaining free bytes in firmware image: 126976
    Processing 1 header(s) from /root/scripts/dd-wrt/841/working_directory/new-firmware.bin...
    Processing header at offset 0...checksum(s) updated OK.
    CRC(s) updated successfully.
    Finished!
    New firmware image has been saved to: /root/scripts/dd-wrt/841/working_directory/new-firmware.bin
    



    Voila ... It remains to fill the firmware into the router.

    UPD : This add-on has appeared for those who write comments in the style of "did not read, but condemn." With this decision, the user was not hurt at all. It has no restrictions in terms of settings. He only got the opportunity to mop up with impunity and if he mopped up, then dropping the router to zero he gets access to the network without any settings.

    Also popular now: