Oscam server on DD-Wrt Router
The Netgear server Emu project is a personal project! It's about installing
an Oscam Emu on a Netgear WNDR4500 K26MIPS router! It's not terribly
original, I did this about 15 years ago! But the experience itself is worth
telling ... I think we'll all have something to learn from it!

The planning
- The test router "lived" on the table, powered and not connected to the Internet !!!
- nearby, also on the table, is the monitor and the target uClan receiver connected
to the test router with a patch cord
- also on the table is a Desktop PC ... in which I planted a Wi-Fi adapter
- The PC is connected to the home router, with Internet access, through a patch cord
- The PC is connected through the Wi-Fi adapter and to the test router !!!

On the PC I have the two key utilities ... Telnet and WinSCP! through which I perform
file transfer (scp) and command interface (ssh) with the test router whose address is
192.198.1.1 ! From the PC, this time through Edge, I can launch WebIF to the test
Router by command http://192.168.1.1 !

The Telnet and WinSCP interfaces are already well known to you !!!

Like the Oscam Emu ... which ate my days until I saw it !!!

The only big inconvenience encountered is the huge Reboot time of
the NetGear WNDR4500 Router !!! 2-3 minutes !!! which has 128 Mb Flash
and which is extremely slow !!!
Why Squashfs?
Routers are notorious targets for hackers! Among them are "masters", against
whom it is difficult to defend yourself, but also "newcomers" who try their luck !
In the way of all the "curious", router manufacturers adopt a lot of measures
to make access difficult and taking control of the router as difficult as possible!
you have already seen them in the router interface! Another main goal of
Squashfs was Flash space economy ... Flash was scarce at the time !
Squashfs is protection at a lower level! that of the operating system!
- SFS is "read only"! the flash partition where "Rootfs" is located is RO !!!
- the system works by maintaining two RW directories ... /etc and /tmp
which are volatile from there everything disappears on a reboot
- the system saves flash space by adopting small allocation blocks! it is
compact and faster to load
- the system is more secure because it prohibits the ordinary user from
writing and automatically launching his applications in it
- Volatile folders are precisely the ones where writing is frequent so
by allocating them in RAM it protects the Flash which was expensive,
slow and unreliable
In essence ... Squashfs screwed us ! Alternative firmware DD-WRT or FreshTomato
open some gates to the system, expand the freedoms of smart guys ... but
Squashfs is insurmountable ! What do alternative FWs bring in addition? root
access for Telnet and SSH access for WinSCP! and very important access to RW
in the rest of the Flash! it is not at all a small thing! but look, we haven't reached it yet!
Another major obstacle is the fact that almost no one builds Oscam for MIPS
routers anymore... they are old, servers on routers are out of fashion, MIPS build
toolchains have been abandoned! so it is not really good news! What is special
about an Oscam for routers? - it must be with static libraries! because it is not
expected that the operating system will contain the necessary ones and referenced
by the executable and compatible ones as a version - it may be one without DVB-API
support but it will not know iCAM and PVU! but that was expected... Linux on Router
does not have DVB "hook" - it may exclude some "historical" encoding systems - and
if the user wants even card readers
Why JFFS ?
JFFS is a journaled File System organization, with small block allocation to minimize
space losses. If Squashfs is the RO partition where the classic Linux Rootfs is hosted
and protected as Read Only, creating JFFS appears as an action in the Advanced menu
of WebIF, both on DD-WRT and Tomato, you can select and request the formatting of
the partition allocated after Squashfs and which will be mounted at Boot in the JFSS
directory existing in Rootfs!
The JFSS directory is a RW type that can be written permanently! and where the user
can install his own applications ... for example an Oscam ! The problems arise when
Oscam makes its external references ... usually located in /lib of Rootfs! ideally, all the
necessary ones should be included in Oscam! because there is little chance that the
libraries in /lib system will be all the necessary ones and will be compatible!
Here is the demonstration ...

- after I activated JFFS from WebIF and formatted its partition
- I transferred something to /JFFS and as you can see I can find it
How to do it ?
- DD-WRT and FreshTomato offer Squashfs type images ... whether you should or not !
This is the case of NegEear WRTN4500 which has 128 Mb Flash of which Roots only
takes up 32 Mb ! This is a partial impediment to installing an Oscam !
- the two images allow the activation of a JFFS type partition from the end of the
Squashfs partition and to the end of the Flash ... this becomes a user space ... where
you can transfer your Oscam and the necessary (config) this is done from WebIF Router !
- the JFFS partition will be automatically mounted at Reboot in /jffs so you can
refer to it through this directory
- for ease of maneuvering, activate the SCP service on the Router and you will
be able to use WinSCP as an SCP type client ... like FTP !
- I transferred the Ocam executable and the configuration files there
- after which I launched it by hand ... and it started!
The big problem is finding the executable suitable for the purpose! You need
an Oscam built for that chipset and Linux version and which includes all the
execution libraries (static). I found one for MIPSEL! grace to samur !!!
Download :
https://mega.nz/file/axtkDKyK#CZn8Xr1ydxp0ZyuIxotRR0c4_ZykFV7qdjRegpcfzVo
OSCam-11878-802 (OpenWRT 23.05.05 mipsel mt7620 libusb) ( samur)
the executable is functional but does not cover my special case !!! With the
automatic launch of the executable it is another story !!! We must replace the
system loader with one capable to launch the execution of Samur's Oscam !!!
Because Rootfs is RO as part of the Squashfs partition ... you will not be able
to simply plan the execution of Oscam! but FrehTomato, I think like DD-WRT,
offers you the possibility to launch it after mounting the JFFS partition in /jffs
executing a command line! in my case ...
This is the command that the router executes at Startup !!!
/jffs/config contains the configuration files of Oscam!


This is how the CCCam (Emu) server is created and the client is declared!!!



The secret to launch Oscam execution is in WebIF ... to enable and instruct Cron !!!
I just found out that the Cron syntax in DD-Wrt is different from that in Enigma2 !
... "root" is the new thing! With the correct Cron syntax ... oscam-test is launched !!!
If Oscam is not running, it has not created the file /tmp/.oscam/oscam.pid ,
and it is necessary to launch it! In a later version the script will check if only Oscam
died and the PID file remained orphaned! destroying it in order to launch a new
execution! The current script is launched at Boot and starts Oscam after 1 minute,
and at the next launches by Cron, from minute to minute, it will only test that
Oscam is running and will exit!
This Cron programming line is written from WebIF from "Administration",
the Cron support is activated, the line is written after which "Save and apply"
is given ... the router restarts and schedules Cron to execute!
If Oscam is not running, it has not created the file /tmp/.oscam/oscam.pid,
and it is necessary to launch it! In a later version the script will check if only
Oscam died and the PID file remained orphaned! destroying it in order to launch
a new execution! The current script is launched at Boot and starts Oscam after
1 minute, and at the next launches by Cron, from minute to minute, it will only
test that Oscam is running and will exit !
