Posts by supermariocs

    Oscam has very good caching system. No need for CSP at all!
    Why would I want to keep ECM's older then one minute? They change anyway. CPS is caching ECM's for days and weeks. What for??

    My script has nothing to do with size of Oscam.log!! It is only reading the log and not writing to it.
    However, there is simple solution for your problem. Edit your oscam.conf file and limit the maximum size of the log:

    Code
    maxlogsize = kbytes


    So if you want to limit maximum size of the log to 512 Kilobytes, you should write this line to oscam.conf:

    Code
    maxlogsize = 512


    Enjoy!

    OK
    Here is the plan:
    - Record last 10 minutes of debug file in intervals of 6 hours (can be changed to 3 hours).
    - Rotate always latest 2 files and erase older ones.Use filter to extract only user data (username and sid).
    - Compare two files and see if last watched channel (sid) is exactly the same in both files (for each user separately).
    - If lines are exactly the same, this means user has been watching the same channel for at least 6 hours.
    - For users that have been watching the same channel, find their IP and send it to iptables (DROP).
    (iptables need to be flushed 2-3 minutes before we execute the compare&ban script. So we can test again those users that have been previously banned)


    Possible problems:
    - Need to find a simplest way to extract IP address from user name. CCcam debug contain this data, but it can be very old and buried deep inside the log. For example, if user connected on 18.8.2011 and stayed online till 20.8.2011 without disconnecting, then this could be problematic to find.
    I was thinking to use web interface (16001) and get the IP from there.
    - If the user watched channel 1 when we first save the log, and then changed to other channels but again returned to channel 1 on next sampling time, he will get banned although he did changed channels in the middle.


    Any ideas, help or improvements are WELCOME!!
    :30_002:

    Well... we can make it work if you really want. Even this 3 hours zapping request. It will require to join forces and start writing the script since I dont have enough time to write it alone.
    We can monitor debug file and extract data from there. If user is watching the same channel for 3 hours, we ban him on IP tables.
    And then release him for 10 minutes and if he's still on the same channel, ban again. Something like fail2ban script.

    Hello Linux lovers


    I decided to write a small tutorial and show you my method of starting and stopping the Oscam in my Linux. And also a script that will keep it alive in case it crashes or shows one of 2 known errors (ins_40 and deadlock).
    You are free to change the script and improve it. I would be glad to implement some new stuff to it. I am using this method for long time and it works great for me!!
    Paths and file names are used as sample only. You can change it.
    This was tested on Debian Linux, but it should work on others too.



    Step 1:


    Put your oscam binary to this path and name it like this:

    Code
    /emu/oscam/oscam.x86


    And put your all config files to this same folder:

    Code
    /emu/oscam


    Don't forget to give 755 permissions to oscam.x86:

    Code
    chmod 755 /emu/oscam/oscam.x86



    Step 2:


    Create a script that will easily control start/stop of your oscam and name it oscript. I am using vi as editor. You can use any editor you wish:

    Code
    vi /emu/oscam/oscript


    and then paste this text to the file:


    * I prefer to run kill command before starting the oscam. Just in case oscam is already running when you execute start command.


    Don't forget to give 755 permissions to oscript:

    Code
    chmod 755 /emu/oscam/oscript


    Create symbolic link so you can easily use this script from any location:

    Code
    ln /emu/oscam/oscript /bin/oscript


    Now you can simply start, stop or restart oscam from any directory by simply typing:

    Code
    oscript start
    oscript stop
    oscript restart



    Step 3:


    Now you need a script that will control your Oscam and keep it running all the time. Create the script and name it check_os:

    Code
    vi /emu/oscam/check_os


    Don't forget to give 755 permissions to check_os script:

    Code
    chmod 755 /emu/oscam/check_os


    and then paste this text to the file:


    As you can see in the text, my oscam log is located in /var/log directory.
    This means that you need this line in your "oscam.config" file:

    Code
    logfile = /var/log/oscam.log


    Also, every restart by this script will be recorded in this file:

    Code
    /var/log/oscam_restart_log


    It will include time stamp and reason for restart so you can have trace of it.



    Step 4:


    Now you need a crontab entry that will run all the time in the background and check your oscam status. I prefer to run it every 15 minutes, but you can change it of course:


    Code
    vi /etc/crontab


    and add this line:

    Code
    */15 * * * * root /emu/oscam/check_os >/dev/null



    Step 5:


    Add this line to your startup file. In Debian it is "/etc/rc.local"

    Code
    /bin/oscript start &


    Step 6:


    ENJOY!!!

    Just note that this will disconnect and then reconnect all your existing peers and lines.
    The best is to make offline changes to your CCcam.cfg in PC and upload this file to some other folder (for example /var/etc/temp) and then once a day (few minutes before your daily reboot), run the script that will replace the working CCcam.cfg with this one from temp. Same script will move the file from temp to some other location and rename it for future reference and backup (for example CCcam.cfg-18.8.2011).
    Enjoy!

    You can write your own script to make it work even in Cccam.
    I think I have it somewhere. Will post when I find. But this is the procedure:
    - run wget in crontab to download activeclients list from 16001 and save the list (filename1)
    - run again the same thing after x period of time you wish and save it as (filename 2).
    - repeat those actions in rotation so you will delete the oldest file and create new one all the time.
    - clean the files from unnecessary fields and leave only client name, IP and channels he's watching
    - compare the files and look for clients that have identical lines (watching same channels).
    - cut their IP and send it to Iptables for a ban. Just make sure you flush the IP tables at least once a day.
    - you can also cut the sid and ban from him only the specific channel through CCcam.cfg but this demands much more work since you need to find his F line and add this SID in specific location in CCcam.cfg. I wouldnt mess with this thing. Simple IP ban for limited time would do the job.
    CHEERS

    Not much you can do with regular tools like Oscam,CCcam...Some special data needs to be extracted and very few servers in the world have it.Meanwhile, enjoy your SD! :>