Scripts for oscam powervu autoroll extension for Dreambox

kebien

Registered
Messages
1,329
Ok,since nobody have done it,here we are.

Let's take this as a learning experience for those new to dreambox and who want to learn something about thier boxes.
Scripts can be done for most everything you want to do.

In this case,we need to start editing softcam.key file so all channels in the trasponder can get the keys.
For the moment,only one channel in the trasponder gets updated,the one noted in the EMM key string.

Let's start by laying out what the script should be doing
It must copy the key and write new lines for each channel in the trasponder with this key.
Seem simple enough.

let's try all to collaborate,with ideas or with code.
I know there are very smart people and can come up with a single line to do it all,but the work should be oriented for those that never wrote code,or never knew about this.So,be patience with them,hint without forgetting they are learning,do not spoonfeed.
Let's make it fun.
Is going to be horrible at the beginning and maybe also at the end,but if is working as intended,later on it can be perfected.

So,let's make it fun.(gonna be boring for advanced coders,of course,but for the rest).

We have to begin by selecting exactly what we are going to copy and from where.
The line offered by oscam is
Code:
P 006D 00 XXXXXXXXXXXXXXXX ; added by OSEmu Mon Dec 14 15:46:01 2015 UA: 00UAUAUA
We need first to locate the P lines,not another,since oscam also work with other encryptions,and in order to not screw up other lines,we must make sure only the P lines are the ones that are going to be copied.
Then we need to match the UA (at the end of the comment) with all sid's present in the trasponder,making a list.
I doubt we could find a similar UA in another encryption,but just in case,we should test for UA and P as starting line.

We need to copy the 3rd and 4th column (key type and key value).

With this information we need to write new lines with fixed values and variables

P is fixed
SID is variable,taken from each SID in the list
Key type and key value is pasted here
; is fixed and any comment can be added here.

Keep in mind Dreambox use busybox instruction set

So,who wants to try the first shot?
Single UA example first,then we move on.

Should we define what we are looking for for first?
If we do,we compare the UA from the list (we can write a different file with all our UA's),and look at the beginning of the line if starts with "P" or "P 00" (to avoid writing keys for other encryptions)
Anybody knows how to do this?

Lets use grep to get a UA from "Unique" file,where we list all our UA one per line as
UA: XXXXXXXX
if we use
Code:
grep UA: Unique
we get a list of every line that starts with UA:
You can test this right now in your dreambox by making a new file in /tmp called Unique,with line UA: 0011223344
The use telnet and type
Code:
grep UA: /tmp/Unique
With this information,we can keep all UA values in memory,and compare those to those in softcam.key,if found,we procede to make multiple lines for each sid the UA is associated with (in the Unique file we can do this,for example)

let's see who wants to give it a shot to continue

I know is all basic,and might take only 5 minutes to produce a working script,but this way could be educative for some
 
Last edited:

kebien

Registered
Messages
1,329
I think we can lay out the Unique file as
UA: xxxxxxxx
SID: aaaa,bbbb,cccc,dddd..............
UA: xxxxxxxx
SID: ffff,gggg,hhhh,.......

In this way,we can associate the SID's the UA and make a line for any SID present in the very next following line.

A way of NOT TO USE a different file,would be to write all SID's right after the EMM key in the very same softcam.key file,we can read the UA from there and do the rest.
But for information purposes,we better not to mess up softcam.key file at the moment.
 
Last edited:

percivjr

Registered
Messages
461
Thanks for starting this thread.

I think the trouble with the list you propose is that SIDs are not unique, e.g.

P 0002 xx xxxxxxxxxxxxxx ;AFN Atlantic,9.0E
P 0002 xx xxxxxxxxxxxxxx ;DISCOVERY NET TLC Balkans, 0.8W

which is why I originally suggested the invention of an 'auto-roll group' to tag the P line to distinguish which provider the auto-rolled key applies to.

I believe that at some point you mentioned using the UA instead which I think makes better sense than some arbitrary 'auto-roll group'. But can there be more than one UA per provider?

I see that joeuser has already implemented a 'groupId' (I presume in OSEmu).
 

Felli71

Registered
Messages
351
Notice: Expired EMM from provider "x" are valid on provider "y + z" ... on the same satellite position

...or otherwise
Code:
P 004xxxxC 00 FxxxxADBExxxx6 # EMM Key [Arqiva 4.8°E] [Expired Discovery-Europe 4.8°E + Discovery-Networks 0.8°W/4.8°E + TLC,UNI CZSK 0.8°W]
 
Last edited:

kebien

Registered
Messages
1,329
Thanks for starting this thread.

I think the trouble with the list you propose is that SIDs are not unique, e.g.

P 0002 xx xxxxxxxxxxxxxx ;AFN Atlantic,9.0E
P 0002 xx xxxxxxxxxxxxxx ;DISCOVERY NET TLC Balkans, 0.8W

which is why I originally suggested the invention of an 'auto-roll group' to tag the P line to distinguish which provider the auto-rolled key applies to.

I believe that at some point you mentioned using the UA instead which I think makes better sense than some arbitrary 'auto-roll group'. But can there be more than one UA per provider?

I see that joeuser has already implemented a 'groupId' (I presume in OSEmu).

Oscam do not worry anymore when there are two keys using the same SID,didn;t you notice?
Read oscam readme,it just jump to the other SID to check if it works.
This is not a problem.
And we are not discusing this here.
This is just an exercise with the hope it become useful.

You can have as many emm keys you want for a single SID,oscam just going to use one.
The smart thing,if you have more than one UA emm key for the service,is to add it with another SID,so will autoroll in this other channel also.
For the moment,oscam only autoroll in the channel that has the emm key,which is not what we are discussing.
 

kebien

Registered
Messages
1,329
Notice: Expired EMM from provider "x" are valid on provider "y + z" ... on the same satellite position

...or otherwise
Code:
P 004xxxxC 00 FxxxxADBExxxx6 # EMM Key [Arqiva 4.8°E] [Expired Discovery-Europe 4.8°E + Discovery-Networks 0.8°W/4.8°E + TLC,UNI CZSK 0.8°W]

We know that,it was posted in another thread a while ago.
Not really the case to discuss this.
I will wait until tomorrow to see if there is interest to continue.
Feel free to collaborate,all input is welcomed.
 

joeuser

Registered
Messages
199
Yes, some have many, many UAs.
My fixes are for OSEmu and oscam-emu.
You have to also take into account the fact the OSEmu/oscam-emu are for many different systems and must remain compatible...

@percivjr read my description in the other thread.
 

kebien

Registered
Messages
1,329
It's a big problem.

If we have:

UA: 12345678
SID: 0002

which keys will the script update: AFN or DISCOVERY ?

I see what you are saying.
Let's think it through

let's assume AFN changed key and Discovery didn't.
What would they have different in the line?
The date/time will be different,right?
Let's make the script to update only the latest found key.A check on the date.
So,you will find a new SID 0002 key for AFN.

The old key for Discovery will still be there,and Oscam will use it since the new one is not valid for discovery
Make sense to you?

But,let's say it doesn't know which one to update (I prefer it does know),the script will create new lines for BOTH channels.
But as the old keys are not deleted,and still in softcam,oscam will ALWAYS USE THE ONES THAT WORK.
Whatever key you updated will be irrelevant.
I do not see it as a big problem,but for efficiency we could just use the date only in case when we have 2 same UA for different packages.
or maybe just make new lines for ALL SID's for both trasponders,and be done with it.
let's get there first and we will try to handle it the best we can.
let's start assuming we don;t have this special case.
 
Last edited:

kebien

Registered
Messages
1,329
I thought somebody would come up with any idea by now,given how hard some guys are pushing to start changing oscam to do all sort of things that might or might help to solve the problem for powervu autoroll.

At least I was expecting for some to read about grep,sed,awk
All usefull tools already installed in their dreambox.

You can,for example,use awk to parse each line of softcam file,take the information needed,write new lines with the new keys.
I guess people is losing the chance to learn on their own,by making mistakes or having brilliant ideas.
But maybe spoonfeeding have reached far beyond the expected.

Nobody interested in posting some awk/sed/cat examples to do the simple tasks we need to take?
You do not need to know code,just read about it and make an expresion,an affirmation,that can later be translated into code.
 

kebien

Registered
Messages
1,329
let me give you a push with awk
this
Code:
awk '$1 ~ /^P/' /etc/tuxbox/config/SoftCam.Key *>*> /tmp/Unique
will copy all lines starting with P to a new file called Unique in /tmp folder.
awk = program call
$1 = means first column in the file
/P/ = is what we are searching for for first column
/etc/tuxbox/SoftCam,Key = is where our softcam is located
Code:
*>*>
is a redirection to another file,being double it appends the data without overwriting (forum doesn;t allow me to post it correctly,you have to remove the *,should be a double angle bracket
/tmp/Unique = is the destination folder/file

Look simple enough,I recommed to read about awk,and see what other options we can use to do what we want.

You can test it by entering the whole command in telnet in your dreambox.
Writing to /tmp doesn't affect the normal work of the box,and everything in this folder gets erased with every reboot.

The main idea is to use something as a basis,then start adding filtering to do what you need.

Writing to a new file avoid the problems we might have by writing to the same softcam file,you don;t want to screw with it until you know the script works as expected.

Now we know we can copy the lines we want.
We need to develop it to search for specific data (UA),extract different columns we need for the new lines (key type 00/01 and key value)
Then we need to build the new lines starting with a P, using the associated SID's as next field,key type,key data,deliminator (should be a ";") and the UA

Anybody think it is too hard to understand?
 
Last edited:

kebien

Registered
Messages
1,329
Ok
Let's make more commands that can help later

But first let's just put some conditions simply because we need a basic structure to work with.

Let's make the UA and associated SID's in one line in this way

Code:
UA:11223344556677 SID,0001,0140,0156

So,the idea to build this file is all about to collect all UA we have from out SoftCam.Key file and move it to the Unique file we mentioned before.
Making one line helps in the way is easier to parse than data being in different lines.
Columns and field separators are easy to parse from a single line.

We have couple choices,we can build this file manually,or we can do a script to make it.
Either way,to prove the concept we are going to just use it the simpler way : we make the lines manually.We are going to get to see results faster.

So,having establish the layout of the lines,we need to extract all SID's present and make a line with each of them with a preceding P and the key type and value.
I mentioned the use of awk because it a program in itself,that makes things easier and smaller,but anything can be used.
So,let's say you made a file called Unique in /tmp,and you wrote that line above.
a cmd like this
Code:
cut -s -d, -f2,3,4,5 /tmp/Unique
Will copy all SID found (in this case I used 2 to 5,but can be as many as necessary.
It will list them as it finds it,in a single line,with the separator,but we really need them to be in a single line each,with a preceding P,followed by key type and value.
Anybody want to give it a shot?

I promise i am not going to make this last forever to have a somewhat working script with eventual bugs that will need to fix.
But is a proof of concept development.

So,basically this
Code:
root@dm800:~# awk 'BEGIN {FS="," ; OFS=RS;$1=$1} ; {print "P " $2 " 00","P " $3
" 01","P " $4 " 00"}' /tmp/Unique                                              
P 0001 00                  
P 0140 01                    
P 0156 00
Will produce what we want.But feel free to post your own idea to do this.
Now we just need to import the working key into the last column (cut and paste,doesn't look that hard,right?),a single value and we can have a working file already.(if we end up writing to softcam,of course)
I was thinking,after a fact I noticed later,that the key type can also be imported,meaning we do not have to make 2 keys per SID but only one,the one in use,because we can import the key type and the key value together to this file.

So,a simple file with minimal information (Unique) and such a command is almost enough to prove the concept.
All the rest we need to do (like looking for latest updated key,and UA associated with it,and run the command on it) might come later,or not,all depends on people's interest.
I am not looking beyond the idea of educate some people and encourage them to use their dreambox in a different way ( is simply a linux pc) and be self sufficient.
And doing it also to prove my point about the idea to make alterations in oscam must come together with common sense,is not about to add countless of fields and comments,with the ones there are is enough.

Think it thoroughly,what it would take to run such command in oscam the moment right after it write the key to softcam? and it could read the SID's from an existing in use file,or in softcam itself.
I mean that oscam would do all the work.

In the meantime,regardless what oscam people decide to do and when,there is a working script people can use.

Nobody wants to give it a shot to the next command that copy the latest key in softcam.key and paste it in our Unique file? (if successful,we will end up writing directly to softcam)

giver
 
Last edited:

theGeneral

Registered
Messages
20
Don't waste time with shell, it would be much better if you implement this in C++ and add to oscam-emu/osemu, don't forget you also need to reload the key file in oscam after writing the new keys in!
 

kebien

Registered
Messages
1,329
Don't waste time with shell, it would be much better if you implement this in C++ and add to oscam-emu/osemu, don't forget you also need to reload the key file in oscam after writing the new keys in!
The General
Of course we won't forget nothing.
Once the development is finished it can easily be ported to any language,and submitted as a patch to oscam.

But it make a point people do not need to wait until someone do it for them,they can do it themselves.
Is it me losing my time or is them that are not willing to learn how to get something working before they can submit a patch to repo?
learning is NEVER wasted time.
 
Last edited:

zayden

Registered
Messages
61
Agreed learning is never a waste of time. However like theGeneral says I don't think people are interested in submitting patches to oscam either when the program is open source. The program itself is heavily Euro-centric (I should say Eastern Hemisphere!) and they are busy with many things that have little to do with anything in NA.

That shouldn't be taken as criticism of oscam because it isn't. There should be a fork perhaps called OscamNA that can separate the needs of those users. I am fairly new to this scene so take that for what it's worth.

I do applaud you though in your attempts to engage people in the "can do" attitude but in the end they will learn only what is of interest to them.
 
Last edited:

kebien

Registered
Messages
1,329
Of course,this is why I will finish this script,I am just giving people the time to digest the information.

We had lots of great emulators "america-only" like RQcamd and others private,and from the beginning,all of us were feeding the information for those european emulators to work in america,since the beginning of mgcam,evocamd,radegast,Mbox,Scam and most every development.
And also for DVB cards emulators like faust,Yankse and all the rest that came after.

What you are trying to do many done it before,to have something working or america.
But let's face it,powervu in america is no different from Asia or Europe,so a global solution will benefit everyone.
There is no need for a different branch.
My hopes is this script to help a few,but if not,at least is educative,everything I am trying to use in the net with enormous amount of details for everyone to learn and use.

The other problem with a fork for america lies in the nature of american coders (of course not all of them) to transform all that is free into a business,who is going to maintain it under those conditions?
The forums that use to do that are all closed now (DVBN,DB4NA).

giver
 
Top