Linux router help needed

hi guys.
I have an Kaon router wich runs "Linux version 3.10.24-svn1480 (jskim@jake-205) (gcc version 4.4.7 (Realtek MSDK-4.4.7 Build 1459".
The problem I have it is that its firmware is in early stages and has alot of things messed up.
Wake on lan doesn't work without arp binding and that can be done only via telnet as it's webinterface doesn't have that option.
Its a workaround that works , unfortunately it only lasts untill I reboot the router.
What I was trying to accomplish is creating a script in /etc/init.d that runs the arp bind command.
That's where my troubles really began. I can't create or edit files in /etc/init.d (or /etc for that matter). The filesystem is Ready-only.

I have tried "mount -o remount, rw /" command and the / is still "ro"

here are my mounts. I managed to create a file inside /apps (though that doesn't help much as, as I need it in /etc/init.d

# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro,relatime)
proc on /proc type proc (rw,relatime)
ramfs on /var type ramfs (rw,relatime)
/dev/mtdblock5 on /apps type jffs2 (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)

any ideeas?
thanks in advance.

This is wrong: mount -o remount, rw /

There's a very important space which shouldn't be there.

mount -o remount,rw /

Actually, though - your mount command says that / is rw now.

What user are you logged in as when you try to edit these files?

Oh, now I see.

/dev/root on / type squashfs (ro,relatime)

You aren't going to be able to write to this. It's an unwritable compressed filesystem which is stuck the way it's made.

You'll have to copy it elsewhere, extract it all, edit it, and create a new squashfs to replace it with.

If you don't get it exactly, perfectly right, things may go badly. I suggest finding newer firmware instead of hand-editing things yourself.

1 Like

Hi , apoklyps3

Your linux is embedded ( for that Your "rootfs" ( "/") is in like RAM drive/disk ( as temp/pivot root ) -> then you cannot remount for r/w and this only r/w only at runtime ). )

( Your firmware in the flash ( mostly ) loaded to the RAM at the boot stages by bootloader ( like u-boot ).. )

Your "/dev/root" device is mounted to (/) point that is "read-only fs" with squashfs ( compressed ) that located in the flash ( or sometimes sdcard ? )
it should contains all binaries , startup files , default config files and the others....

  • Your mount command is wrong as already @Corona688 said this.
  • And you cannot re-mount the squahfs for r/w ( try with "/dev/root" lets see what happen or not )

Your device ( /dev/mtdblock5 is read/writable block device ( Flash or disk-on-chip ) with "rootfstype=jffs2" and
then you can read the some configs or other related files from it.
But also you can write via "/dev/mtd5" ( safe way ) char device to flash partiton which is writable side.
Shortly , mount command works via block device and must used via the char device for i/o operations..
Your ( /apps ) mount point is writable and has contains user apps/data/configs ( already i said above ) and these are permanent.
Look at the some details..
Managing flash storage with Linux

( the others are Kernel partitions from RAM or other memory chips ( ssd ? ) .. )

  • You can look for the details of the flash partitions ( "cat /proc/mtd" )

Now i m not sure is there a easy way ? , ( because i have no knowlodge about the routers and firmware )
But i can say , you have to create the customized firmware and you must flash it to router for permanent solution.. ( if it has not nvram settings for non-squash filesystem support )
( or you must unsquashfs to extract the contents to writable partition then mksquashfs to create new image from thises and write it to the target mtd device ( like "writemtd.c" codes or image dump tools )

Another try , you maybe update the router firmware with ( open-source ) alternatives like dd-wrt , open-wrt .. ( if your product ( Kaon media ) vendor does not the new firmware..)

But best way as @Corona688 said , you must update the new firmware from original Kaon hardware vendor if there is..

Good lucks
regards
ygemici

1 Like

thanks guys.
I have managed to unpack the firmware , though it seems kinda risky to pack it back and try to flash it.
any other way I could make squashfs read /etc from another location (ex usb) instead of the default one?

Depends a lot on the drivers available and when they get loaded in the boot procedure. It's the exact same risk for the exact same reason anyway - the slightest mistake will brick it.

There's presumably a sane way to update it but we don't know what it is, being we don't know what distrubution it is. "Linux" is just the name of the 3 megabyte file which loads when you turn it on, everything else is down to the distro. Check for a file like /etc/release which states what it is

Hi apoklyps3

  • we have needed some inputs/outputs :slight_smile:
  • could you write what you did ( commands and outputs ) ?
    where did you extract to unpack the firmware ? ( external stroage ? )
    can you see the images/files as separately ( bootloader/kernel/rootfs and the others.. )
  • do you have the orginal firmware image outside the flash ?
  • i can try search your hardware but i cannot find any usefull infos.

so i have to learn this :

  1. your device chip details
  2. your flash chip details
  3. cat /proc/mounts ( and fstab ? )
  4. cat /proc/mtd
  5. have you any tools ? ( flash_erase / nandwrite ... )
    ( can you list the your binaries related flash that you have .. )
  6. what is your boot-loader ? any screen output releated booting ?
  7. can you execute the boot-loader commands ( so is there any prompt ? )
  8. can you paste the dmesg or /var/log/messages files ?
  9. did you try the plug in the usb drive and kernel see it ? ( like /dev/sdaX )
  10. are there any kernel configs ( /proc/configXX , /boot/config* )

I do not recommend to change the firmware yourself without prior experience in this area. Chances to brick your device immediately are very high.

As of now it seems a good place to create your custom scripts within the /apps folder, which is writable and likely durable across reboots.

What's left is to figure out what mechanism your router-linux-distribution provides to call your scripts.

Since it's highly likely that some open source distribution is used, the first thing is to figure out which one it is(google, vendor homepage, product specifications, ...) and when the distribution name/type is found look/read for the possibillities for calling individual startup scripts.

@Corona688 - no ""/etc/release" file only version:

RTL819xD v1.0 --  2017. 04. 13. () 20:01:43 KST
The SDK version is: Realtek SDK v3.4.9.4-r34739
Ethernet driver version is: 21743-21743
Wireless driver version is: 34739-34739
Fastpath source version is: -
Feature support version is: -

and
motd

RLX Linux version 2.0
         _           _  _
        | |         | ||_|                 
   _  _ | | _  _    | | _ ____  _   _  _  _ 
  | |/ || |\ \/ /   | || |  _ \| | | |\ \/ /
  | |_/ | |/    \   | || | | | | |_| |/    \
  |_|   |_|\_/\_/   |_||_|_| |_|\____|\_/\_/

For further information check:
http://processor.realtek.com/

@ygemici

  1. Realtek of some kind as previous info sugests
  2. no ideea :frowning:
  3. fstab doesnt seem to exist
cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / squashfs ro,relatime 0 0
proc /proc proc rw,relatime 0 0
ramfs /var ramfs rw,relatime 0 0
/dev/mtdblock5 /apps jffs2 rw,relatime 0 0
/dev/sda1 /var/tmp/usb/sda1 fuseblk rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096 0 0
sysfs /sys sysfs rw,relatime 0 0
cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00001000 "boot+cfg"
mtd1: 00200000 00001000 "linux(bank1)"
mtd2: 00800000 00001000 "root fs(bank1)"
mtd3: 00200000 00001000 "linux(bank2)"
mtd4: 00800000 00001000 "root fs(bank2)"
mtd5: 009c0000 00001000 "apps"
mtd6: 00200000 00001000 "tr069"
 cd /bin
# ls
UDPserver                    lsmod
[                            md5sum
[[                           minidlna
acltd                        miniigd
adduser                      mkdir
aipc_util                    mknod
arp                          mmd_cmdr
ash                          mmd_cmdw
autocfg.sh                   mount
awk                          mp.sh
boa                          mp_98c.sh
boot_rcs.bin                 mp_factory.sh
brctl                        mtd
bunzip2                      multi_wan_test.sh
busybox                      mv
bzcat                        netcat
caller_id                    netstat
cat                          nmbd
check_link                   ntfs-3g
chgrp                        ntp_inet
chmod                        ntpclient
chown                        ob
conference                   ob1
config-dhcpd.sh              od
config_again_tr069.sh        od1
connect.sh                   openssl
connect6.sh                  orf
cp                           orf1
cp3_measure                  ow
crash                        ow1
crc                          passwd
crc1                         pcm_dump
create_multi_wan.sh          phyr
cut                          phyw
cwmpClient                   ping
date                         ping6
dbg                          poweroff
dd                           ppp8_solar.sh
ddns_inet                    ppp_inet
depmod                       pppd
detbuf2_dump                 pppoe.sh
df                           pppoe_conn_patch.sh
dhcp6c                       pppoe_disc_patch.sh
dhcp6cRcv.sh                 pptp
dhcp6ctl                     pptp.sh
dhcp6s                       printenv
dhcp6s.sh                    proslic_set
disconnect.sh                ps
dmesg                        pulse_dial
dnrd                         pwd
dns6.sh                      radvd
dns_task                     radvdump
dnsmasq                      ram
dtmf_det_cfg                 rdate
dtmf_det_test                reboot
dtmfdet_dump                 reboot.sh
dual_dhcp_test.sh            reg
dummy_ar4010                 reload
dw                           remove_multi_wan.sh
echo                         renice
ecmh                         rm
eth8_non_dhcp.sh             rmmod
eth8_rp_again.sh             route
ew                           routed
expr                         rssi
factory_check                rssi1
factorysw                    rtcp_logger
false                        rtcp_statistic
find                         rtk_cmd
firewall.sh                  rtp
flash                        rtp2
free                         script_check_l2tp_status.sh
fskgen                       sed
ftpget                       send_2833
ftpput                       setmib
fwd                          setmib1
fwdownload.sh                sh
fwup_check.sh                show
fwupdate                     sleep
fwupg                        slic_reset
fxo                          smbd
fxo_int                      smbpasswd
fxs                          snmpd.sh
fxs_int                      solar
getmib                       solar_monitor
getmib1                      startup.sh
gpio_init                    static_restart_tr069.sh
gpio_read                    stty
gpio_write                   sysconf
grep                         syslogd
halt                         systemInfo.sh
hdpw.sh                      tagged_eth1_test.sh
head                         tail
hexdump                      tc
hostname                     tcp2dev
iapp                         telnet
ib                           telnetd
ib1                          test
id1                          test_ivr_g711
idd                          test_ivr_g722
idd1                         test_ivr_g723
ifconfig                     test_ivr_g729
igmpproxy                    tftp
init                         tftpd
init.sh                      timelycheck
inotifyd                     timelymacfilter
insmod                       tone
ip                           top
ip_qos.sh                    touch
iptables                     tr
irf                          true
irf1                         udhcpc
ivr_text_play                udhcpd
iw                           umount
iw1                          up_usbStorage_apps
iwconfig                     updatedd
iwcontrol                    uptime
iwpriv                       usbStorageAppController
kill                         usbmount
kill_usbStorage_apps         vconfig
killall                      vmwigen
killsh.sh                    vnifdownup.sh
klogd                        voip_event
l2tp.sh                      voipbox
l2tpd                        voipcli
lb_test                      wait_dsp
led_ctrl                     watchdog
lld2d                        wc
ln                           wget
login                        wlanapp.sh
ls                           wscd

for 6-10 I will answer tomorrow when I will redo the dump. I think I didn't perform it the right way and only got the squashfs out if.

---------- Post updated 04-22-17 at 04:07 PM ---------- Previous update was 04-21-17 at 07:51 PM ----------

  1. I think I saw Uboot mention while analyzing the dump of an older firmware. The newer firmware only dumps the squashfs, no longer bootloader or kernel
  2. no ideea how to do that, sorry
    8
dmesg
wlan1: Open and authenticated
wlan1: A wireless client is associated - E8:93:09:8B:0B:CD
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - E8:93:09:8B:0B:CD
wlan1: Open and authenticated
wlan1: A wireless client is disassociated - 9C:B7:0D:86:19:C5
wlan1: A wireless client is associated - E8:93:09:8B:0B:CD
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - E8:93:09:8B:0B:CD
wlan1: Open and authenticated
wlan1: A STA is expired - 0C:D7:46:91:61:CB
wlan1: A STA is expired - E8:93:09:8B:0B:CD
wlan1: A expired STA is resumed - 0C:D7:46:91:61:CB
wlan1: A STA is expired - 0C:D7:46:91:61:CB
wlan1: A wireless client is associated - E8:93:09:8B:0B:CD
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - E8:93:09:8B:0B:CD
wlan1: Open and authenticated
wlan1: A wireless client is associated - E8:93:09:8B:0B:CD
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - E8:93:09:8B:0B:CD
wlan1: Open and authenticated
wlan1: A wireless client is associated - 0C:D7:46:91:61:CB
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - 0C:D7:46:91:61:CB
wlan1: Open and authenticated
wlan1: A wireless client is disassociated - 0C:D7:46:91:61:CB
wlan1: A wireless client is associated - 0C:D7:46:91:61:CB
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - 0C:D7:46:91:61:CB
wlan1: Open and authenticated
wlan1: A wireless client is disassociated - 0C:D7:46:91:61:CB
wlan0: A wireless client is associated - 0C:D7:46:91:61:CB
wlan0: WPA2-AES PSK authentication in progress...
wlan0: A wireless client is associated - 0C:D7:46:91:61:CB
wlan0: Open and authenticated
wlan0: A wireless client is associated - 48:5A:3F:89:EA:F4
wlan0: WPA2-AES PSK authentication in progress...
wlan0: A wireless client is associated - 48:5A:3F:89:EA:F4
wlan0: Open and authenticated
wlan1: A wireless client is associated - 9C:B7:0D:86:19:C5
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - 9C:B7:0D:86:19:C5
wlan1: Open and authenticated
wlan0: A wireless client is disassociated - 48:5A:3F:89:EA:F4
wlan1: A wireless client is disassociated - 9C:B7:0D:86:19:C5
wlan1: A wireless client is associated - 9C:B7:0D:86:19:C5
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - 9C:B7:0D:86:19:C5
wlan1: Open and authenticated
ODM_TXPowerTrackingCallback_ThermalMeter_JaguarSeries2(437)
wlan1: A wireless client is associated - 9C:B7:0D:86:19:C5
wlan1: WPA2-AES PSK authentication in progress...
wlan1: A wireless client is associated - 9C:B7:0D:86:19:C5
wlan1: Open and authenticated
wlan1: A STA is expired - E8:93:09:8B:0B:CD
  1. yes, usb is automounted as /dev/sda1
  2. no

ok.. i think test / try and lets see way is difficult and time consuming and also risky..
therefore can you execute the below commands and attachment the output files to me ? ( thanks. )

dd if=/dev/mtd0 of=/var/tmp/usb/sda1/bootl.bin
dd if=/dev/mtd1 of=/var/tmp/usb/sda1/linux1.bin

there wasn't any /dev/mtd0 or 1 , but I think you meant /dev/mtdblock0 & 1
here are the files:

thanks

I'm not sure I'm going to be able to accomplish anything here.
I have made the modifications, but unfortunately the router is branded by the internet provider and there is no official support or any way to download the firmware.
the provider pushes new firmware and can't think of any way I could intercept it
i guess what I was dumping the squashfs only using cat /dev/mtd5 > /var/tmp/usb/sda1/backup1.bin command.

Is it a router or actually a DSL modem? Reflashing a modem is something they're liable to notice and not appreciate.

If your model is compatible with OpenWRT, you can replace it outright by installing that. If there's no install procedure for it, it probably isn't.

it's a router. couldn't care less if they apreciate it or not, I might just even disable their remote connection to it if I get my way.
Hopefuly I will intercept de next firmware and get what I need.
it's not openwrt compatible yet and I wouldn't flash it to that anyway , because it's a gigabit router and being closed source openwrt would come without hardware NAT , wich means only 100MBps speed limit.

100MBps speed limit? How fast is your ISP?

1GBps the highest plan, 500Mbps mid-range...and 300MBps for low-end.
I got the highest plan. It's also very cheap - only 10$

Hi apoklyps3 ,
Sorry for late response beceause of im very busy with some jobs and a lot of works :rolleyes:

I could see for a few hours at the images..
It takes a lot of time to study it in depth but i see some files in the images so it look MIPS arch executable ( kernel code ) and
other kernel data ( but i m not sure consistency of this data , i could not test it due to limited time ) and the other one contains two boot data ( i guess binary bootloader and configs )..
as I understand it we must the update the rootfs that contains ( /etc/ and others dirs ) ..
so i will continue to examine ( when i have time )

now if you have the firmware image ( one-piece ) , can you attach here it ?
and can you attach the other mtd ( ( 2-3-4-5-6) especially rootfses ) parts ( thanks )

unfortunately the firmare image is not public. the router is branded by the ISP and automaticaly updates the firmware.
My guess is that they put the firmware somewhere and it gets updated on a reboot.
Hopefuly I'll be able to intercept it next time there will be an update.
I have probed /bin/busybox myself and it seems to be an ELF-64 kind of executable...not sure what to make of that ...
the files I attached before were from mtdblock0 and 1 , because when trying to do it on mtd0 and 1 i got "dd: can't open '/dev/mtd0': No such file or directory",wich is weird because they are mentioned in "cat /proc/mnt"
In /dev I have mtd from 5 to 7 and mtdblock from 0 to 7. which of them do you want me to post?

mtdblock ( 2-5-6 ) is enough .
thanks :slight_smile:

1 Like

here you go
mtdblock.rar - Google Drive

thanks