--- ------- ---  -- - - -
 NewCS readme
- -- ---  -- - - -

We have no politics.. this is just for fun - blame yourself..

 "How should I know if it works? That's what beta testers are for. I only coded it."
  -Linus Torvalds


--- Index ------- ---  -- - - -

1.  File Descriptions
2.  Runtime Arguments
3.  Configfile
4.  TCP-Commands
5.  FAQ
6.  Changelog
7.  Troubleshooting
8.  Special Notes
9.  Known Bugs
10. Greets


1.-- File Descriptions ------- ---  -- - - -

newcs.ppc			->	NewCS binary for dreambox, tripledragon and other powerpc machines.
newcs.ppc-infinity		->	NewCS with support for the Infinity-USB programmer for powerpc machines.
newcs.mips-7025			->	NewCS binary for the 7025 dreambox.
newcs.x86			->	32bit NewCS binary for linux on Intel compatible machines.
newcs.x86-pcsc			->	32bit NewCS binary for linux on Intel compatible machines, with PC/SC support.
newcs.x86-infinity		->	32bit NewCS binary with support for the Infinity-USB programmer for Intel compatible machines.
newcs.amd64			->	64bit NewCS binary for linux on AMD64.
newcs.amd64-pcsc		->	64bit NewCS binary for linux on AMD64, with PC/SC support.
newcs.amd64-infinity		->	64bit NewCS with support for the Infinity-USB programmer on AMD64.
newcs.mips-openwrt		->	NewCS binary for linux on MIPS machines. (OpenWRT) (this only support phoenix as type)
newcs.nslu2   			->	NewCS binary for linux on ARM machines. (NSLU2) (this only support phoenix as type)
newcs.exe			->	NewCS binary for 2K/XP/2003/Vista. (this only support pcsc, phoenix and sc8 as type)
newcs.xml			->	The configfile that NewCS reads, should be placed in /var/tuxbox/config.
libusb-0.1.so.4.ppc		->	libusb for powerpc machines. (needed by newcs-infinity.ppc)
libusb-0.1.4.x86		->	libusb for Intel compatible machines. (needed by newcs-infinity.x86)
libusb-0.1.4.amd64		->	libusb for AMD64. (needed by newcs-infinity.amd64)
readme.txt			->	This file you smartass :P


2.-- Runtime Arguments ------- ---  -- - - -

NewCS can be run with some arguments when you start it, here are some of them explained:

-c configfile, here you can specify the path to a configfile.
-h help, will show something similar to this.
-v version, this will show when the binary is compiled and which version it is.
-nd this is will prevent NewCS from forking.
example:
/var/newcs -c /etc/newcs-usb.xml (you give full path to configfile)

3.-- Configfile ------- ---  -- - - -

Remember to always close the tags, there is a beginner tag "<tag>" and a end tag "</tag>", if the tag start
with a "<!-- " and ends with a " -->" it is a comment. More info about xml you will find on google..

Look in the configfile for explanations on what the different sections are.
Configfile isnt case-sensitive and shouldnt care about dos/unix crlf differences.


4.-- TCP-Commands ------- ---  -- - - -

Telnet to the tcp-port (default is 1001) and write the commands hit enter to execute it:
PS! In windows the standard telnet client doesnt work, try using f.ex Putty as a client instead (raw mode).

.--------------------------------------------------------------------.
| Command  |   Parameters    |       Description                     |
|----------|-----------------|---------------------------------------'
| keys     | None            | Show AU/SA serialnumbers from card.
| users    | None            | Show stats about users.
| readers  | None            | Show Readers and their status.
| uptime   | None            | Show how long NewCS have been running.
| cache    | None            | Show cache statistics, how many total ECM's, and how many who hit cache.
| version  | None            | Show NewCS version, compile-time and config used.
| shutdown | None            | Shutdown NewCS server.
| restart  | None            | Restart NewCS server.
| reset    | [reader number] | Reset the card in reader slot thats given.
| ban      | [user id]       | Ban a user, user will be kicked out, and cannot log in.
| unban    | [user id]       | Unban a user, the user can log back in.
| sub      | [reader number] | Shows entitlements from card, give -1 as param for all readers.
| sids     | (add/remove)    | Shows SID statistics, if you use params you can manually add or
|          | (reader number) | remove SID's.
|          | (sid)           |
|          | (allow/deny)    |
| adduser  | [username]      | Adding a user without restarting NewCS.
|          | [password]      |
|          | [spider]        | yes/no if spider should be able to connect with this user.
|          | [au]            | on/off if user should be able to send EMM.
|          | [sidoverride]   | on/off if user should be able to override SID-filter.
| blocker  | (reader number) | Show blocker status, with params you can change them.
|          | (ua/sa/ga)      |
|          | (yes/no)        |
| level    | (level)         | Shows logging level in tcp-console, give param to set new level.
|          |                 | Valid levels:
|          |                 | 0 - None
|          |                 | 1 - Normal
|          |                 | 2 - Verbose
|          |                 | 3 - Spam
| type     | (type)          | Shows logging type for tcp-console, give param to set new type.
|          |                 | 0 - None
|          |                 | 1 - General
|          |                 | 2 - Init
|          |                 | 4 - ECMs
|          |                 | 8 - EMMs
|          |                 | 16 - Network traffic
|          |                 | 255 - All
| osd      | [username]      | Send a OSD message to the Newcamd-client you specify.(max 255 characters)
|          | [message]       | (this is only supported by mgcamd at this moment)
| auth     | [password]      | Authenticates to the tcp-console if protected.
| exit     | None            | Exit the tcp-console.
|-----------------------------------------------------.
| Parameters in [] is mandatory, () is optional       |
'-----------------------------------------------------'

PS! if logging bothers you when using tcp-commands, please set loglevel to 0 to stop logging.


5.-- FAQ ------- ---  -- - - -

Q: Who are you, and why are you doing this?
A: we are a group that tries to have some fun, during our spare time we have satellite-studying as
   a hobby - and since newcamd project has its own strange politics, gbox project isnt public and
   the rest of the available isnt quite like we wanted to have it - we wrote our own :o)

Q: Why NewCS as project name?
A: Since newcamd already "stole" the cardserver name - we found out to differ it from newcamd project's
   cardserver, we made another name for it.. NewCS - "New CardServer"
   If you find out another nice name for it, just let us know, we rather code a little as to think about names :o)

Q: Which protocols are supported, and why that new one?
A: Both radegast and newcamd protocol are 100% supported, this to be compatible with any of the current
   clients out there.. eg. mgcamd, evocamd, newcamd and so on.. The reason we made a new protocol is
   because we wanted something of our own - this we can extend and do whatever we want with, the others
   is in the hands of their respective authors.. and can be changed without us kinda "approving" it..

Q: So, which cards are supported?
A: well.. good question :) (since i asked it myself it must be faboulous :p)
   At this moment the following cards are supported:
    *- Conax       (ecm&emm)   *- Seca        (ecm&emm)
    *- Irdeto      (ecm&emm)   *- Cryptoworks (ecm&emm&ecm w/mosc)
    *- Betacrypt   (ecm&emm)   *- Viaccess    (ecm&emm)
    *- Dreamcrypt  (ecm&emm)   *- Videoguard  (ecm&emm)
    *- D2mac       (ecm&emm)   *- Nagravision Ver.2(ecm&emm)
    (all needs to be tested ofc, we dont have the opportunity to do extensive tests).

Q: Where can i find the sourcecode for NewCS?
A: The sourcecode wont be released as we have done alot of work to design it, and really not much help around
   .. personally i can deeply recommend starting on your own project, you'll learn much - i promise :o)

Q: Help? It DOESNT work - where can i reach you?
A: Well.. we hope that when NewCS gets public, there will be a few experts around on the different
   forums and irc channels all around the globe.. you cant reach us, but if you post your questions,
   or if you got errorlog, etc. - on a english-speaking or german-speaking forum, we will probably see it :o)

Q: I Want to donate money to your project, where do i send them?
A: We do this just for fun, and have no commercial interest what-so-ever, we suggest that you send
   the money to a help-organization like f.ex the red-cross, or something similar :)

Q: Why cant newcamd connect to my card?
A: Well, newcamd guys have some strange politics.. some cards cant be used in newcamd with the standard
   protocol.. for some reasons newcamd can only use that with betad and some bloody *nix socket..
   To watch these cards, you have to use the NewCS compliant camds (evocamd or mgcamd) - or maybe some others that havent got limitation.

Q: Why cant gbox connect to my card?
A: Gbox isnt a public project, and "only a few" ppl can get updated versions.. and so on (we all know its BS though).
   anyway.. the protocol used in gbox are unknown at this moment, they change it everytime someone figures it out,
   so we wont support it unless gbox should find out that they would like to use NewCS.. then they can make support :)
   (cs2gbox could work, but who knows or cares :P)

Q: Is the xml protocol available?
A: Yes! :) will be documented here ASAP!

Q: Whats the "node" for Infinity-USB programmer?
A: The USB-port is "only" used to set the programmer to phoenix-mode, all communication with reader goes through serial, so to get it to work
   you have to specify the serialport it is connected to as "node".

Q: Why doesnt my card work with NewCS in windows when it works with NewCS on linux?
A: There can be many reasons, the code for handling communication with the card is 100% different, timeing can be very different too, also
   some devices seems to have better drivers in linux then in windows, and vice versa.


6.-- Changelog ------- ---  -- - - -

v.1.16 -Release Candidate 9:
   Fixed version numbering, seems we skipped v.1.15 in binary.. *blush*
   More commands available from webinterface.
   Fixed problem (we think) with SID-filter if no static or autosid where enabled.
   Now own option for users to override the SID-filter (instead of AU-user).
   Removed the support for users in own .txt file, the "addusers" are now written directly into the xml configfile.
   Fixed misc debug messages.
   Fixed some bugs with PC/SC reader.
   Fixed a problem with xml-tags in config beeing case-sensitive. (they are now case-insensitive!)
   Added debug when missing config elements in user-sections.
   Fixed bug in cryptoworks entitlements, thanks for proper debug/logs ;)
   Fixed humongus bug in the ban tcp-command.
   Fixed Nagra blocker for EMM-G, thanks for proper debug/logs ;)

   NB!
   pcsc-lite is only needed on linux, on windows it should go automatic :)


v.1.15 -Release Candidate 8:
   Fixed delete newcs.pid when using shutdown tcp-command.
   Added possibility to overclock the dreambox readers. (be careful..)
   Added client-detection for all known clients, look in special notes for more info.
   Fixed recieving client-id on reverse login.
   Added HTTP interface, point the browser to the tcp-port. (http://ip:port/)
   Fixed SID-handling again, now AU-users are free of the SID-filter.
   Added support for SC8 on windows, atleast some CAS (we need logs of those which dont work).
   Fixed Adduser tcp-command, users couldnt login.
   Added Nagra2 entitlements.
   Added Conax PPV entitlements.
   Misc. bugfixes.
   Added PC/SC support.

   NB! For PC/SC support you have to install pcsc-lite and configure it.


v.1.14 -Release Candidate 7:
    Fixed bug in N2 EMM on phoenix/sc8.
    Hopefully fixed bug in tcp-console where data was sendt faster then windows could handle.
    More and better error-handling.
    Added tcp-console password protection.
    Better compability for the Relook box.
    Fixed bug in sid-handling, now sid-lists also apply for AU-users though.
    Added osd tcp-command to send osd messages to clients which support it.
    Fixed Session-key renewal for cards that use dt08.
    Added spider/au option to the adduser command. (old userfile is now incompatible)
    Fixed bug in irdeto EMM handling.
    Misc. cleanups.
    Compiled new binary for the new dreambox 7025.

    NB! tcp-console protection is plain and simple, probably easily hackable..
        You are Warned!


v.1.13 -Release Candidate 6:
    Fixed bug in Nagra2, for cards that use dt08.
    Better info in users tcp-command, also for radegast users now. (show tcp-connections to rdgd)
    Fixed bug in Nagra2 sessionkey implementation.
    Fixed bug in config-reading, some options was case-sensitive.
    Fixed 3.57mhz in infinity reader.
    Added Nagra2 EMM (needs support in camd).
    Added <deny> for readers in <user>-tag.
    Added dynamic ECM cache. (uses less ram)
    Optimize N2 on all devices.


v.1.12 -Release Candidate 5:
    Added Nagra2 support!! Read Special notes! (Nagra1 still not supported, funny eyh? :P)
    Fixed bug that made radegast server hang.
    Added numbering to sids in tcp-command.
    Fixed bug in dreamcrypt, sorry..
    Misc. bugfixes etc.
    Added support for multiple Infinity-usb devices.


v.1.11 -Release Candidate 4:
    Added Auto-sid feature. (see special notes)
    Changed cosmetics on most of the tcp-commands.
    Changed cards command to readers instead, added some more info.
    Added sids command, statistics for sids, and you can add/remove sids with correct parameters.
    Added blocker command, show status for blocker, and you can open/block with correct parameters.
    Added seca-pin option.
    Fixed Cryptoworks Bios5 cards should work ok, opos as a sideeffect :)
    Fixed Irdeto EMM's - thanks to all for pointing that out!
    Fixed irdeto in Dragon.
    Fixed potential bug in ecm-queue.
    Removed PIN on Cryptoworks.
    Fixed Seca EMM, yet again.
    Fixed Viaccess EMM, yet again.
    Misc. bugfixes etc.
    
    NB!
    Removed cw-cache, this was specially made so that newcamd should work with channels that only has 1 cw (NDS),
    please use other client which actually support a single cw, newcamd _WILL_ glitch.
    
    NB2!
    DT special is broken in this release!
    

v.1.10 -Release Candidate 3 -bugfix:
		Fixed bug in NDS on phoenix.
		Remove port from the newcamd-section, should of course be in reader now.
		Fixed Cryptoworks blocker.


v.1.09	-Release Candidate 3:
		Added Entitlements to Viaccess, Seca, Conax, Cryptoworks, irdeto and Videoguard.
		Added tcp-command sub to show entitlements from cards.
		Added some more valid frequencies: 10.71MHz, 10.00MHz and 8.00MHz.
		Fixed EMM-blocker on NDS.
		Added config-option for PTShandshake(look iso 7816 for details). (used on viaccess, cryptoworks and Conax-CAS7 cards)
		Changed ECM-queue per card.
		LOTS of error-handling, but its still a work in progress.
		Added warning message when overclocking card.
		Fixed infinity reader, should now only need the parity/mhz parameters like phoenix.
		Fixed reset tcp-command, should now work ok.
		Optimized keys command, show reader.
		Fixed Viaccess EMM.
		Changed SID-filter to be per-reader, instead of per-caid.
		Changed enabled, exported and rdgd server config options to be yes & no like the rest.
		Added sids tcp-command.
		Fixed irdeto for new version5 cards, should now work with some odd versions too. (thnx to FMalibu for figuring that one out)

		NB!
		Config file has changed, you HAVE!!!!!! to change it! sorry.. :D


v.1.08	-Release Candidate 2:
		Fixed serious bug in newcamd server.
		Optimized speed on some CAS.
		Optimized speed in INIT of Cryptoworks and Viaccess.
		Changed debug print of client detection, some confusion around unknown clients, they are now Generic clients.


v.1.07	-Release Candidate 1:
		Fixed some potential bad filedescriptor bugs. (we have never seen one though, and we miss good logs from those who claim to have them ;)
		Added SC8in1 on Dbox2!!
		Changed ALL devices to use <mhz> + ATR to set Baud/Parity. (<parity> is still used for pre-ATR parity) (be careful with overclocking :)
		Removed <baud> and <databits> from config (not needed anymore).
		Misc cosmetic changes on tcp-commands.
		Added more specific help in tcp-commands.
		Added one more priority type, "round" - look in config for example, possible to select between the 3 different ones.
		Added newcamd client detection (hopefully will be supported by most clients with time, look in special notes).
		Misc newcamd fixes.
		Fixed double resets on some cards in Sci.
		Added <spider> option, possiblity to deny spider to login to useraccount.
		Fixed Crypto-special after attack.
		Fixed Viaccess EMM bugs.
		Added Cryptoworks EMM.
		Added "keys" tcp-command, to show keys from card.
		Made reverse login better.
		Added Win32 binary.
		Fixed a nasty bug in tcp-debug.
			

v.1.06	-Public Beta:
		Fixed NDS EMM with Newcamd (we hope - if not, use mgcamd/evocamd).
		Added ECM Queue, low-id users' ECM gets through first.
		Added EMM cache to dont stress the card with Identical emms. (suggest high EMM cache for this to work good)
		Fixed  VR3 UPC in conax mode.
		Fixed some cosmetic logviewing in telnet ++.
		Crosscompiled for NSLU2 (yet again, we do NOT know if this will ever work).
		Other misc. fixes.
		Added new commands: cache & version.
		Added D2MAC support.
      
		NB!!
		IF you want to report a bug, PLEASE include some log samples and config file.. we're not mindreaders ;)


v.1.05	-Public Beta:
		Added Conformance logic 1.1 (this fixes the spider issues).
		Improved Sci-handling.
		Improved timeing.
		Dbox2 fixed nds in slot for 3.5 and 6mhz.
		Crosscompiled for OpenWRT routers (mips). (absolutely no idea if it will ever work though :o))
		Fixed rdgd server.
		Fixed NDS Skyitaly in phoenix. (we hope)
		Lots of bugfixes..
      

v.1.04	-Public Beta:
		Fixed Viaccess on Dbox (tested on 6Mhz multicam)
		Added option to allow users to only access specified card. (look for changes in configs)
		Added option to specify port for each card. (look for changes in configs)
		Fixed segfault when some options(thats not needed on these) was missing for sci/dragon.
		Changed alot of debug levels.
		Fix baudrate for YES cards.
		Added logging of tcp-commands.
		New tcp-command: uptime.
		Newcamd server close connection if user is unknown.
		Fixed rare login problems.


v.1.03	-Public Beta:
		Fixed Viaccess-init in dbox.
		Fixed Seca-init.
		Made carddetect faster.
		Removed SID checking on irdeto/beta.
		
		NB!!
		Disable carddetect on dbox, it doesnt work.. none of us in the dev-team has access to one, so we
		program in blind. If anyone got info on how to do carddetect on Dbox, please point us in the right
		direction by posting it on boards or something like that.


v.1.02	-Public Beta:
		Fixed Skyitaly ATR (seems they have two different ones, one has same starting bytes as nagra :O)
		Fixed Digital ALB unknown nano.
		Added missing Dbox-type in commented config.
			
		NB!! We have recieved info that Newcamd Cardspider has additional checks for NDS cards, it seems that
		the cards are added to the spider as normal, but the cw's wont reach the other peers (it works locally)..
		In general newcamd dont support 1 single cw, so to have it 100% stable use mgcamd or evocamd.


v.1.01	-Public Beta:
		Reached beta-stage.
		Documentation should be nearly done.


7.-- Troubleshooting ------- ---  -- - - -



8.-- Special Notes ------- ---  -- - - -

Cache (ECM/EMM):
  What can i say, have no idea how to explain this so _everyone_ can understand what the hell it is.. but
  lets have another go.. as with default config, lets assume there is dynamic cache configured:
  Imagine an ECM comes to the server, this NewCS have never seen before, it sends it to the card, the card
  responds with the decrypted control words, the dynamic cache know that this is a good response, and is valid
  for a certain period of time. So it puts it into a storage which is compared with every new ECM sendt to NewCS.
  Now lets imagine there is another client that sends the exactly same ECM within a few seconds, then NewCS compare
  this new ECM to the cache, and finds that the card already have decrypted this ECM, so it just sends the decrypted
  control words to the client, without sending the ECM to the card.
  Since the ECM is only valid for a certain period of time, there isnt need to store them for a longer period (it is
  not very likely that the provider sends the same ECM twice -without there beeing a big bug in their software).
  Regarding EMM cache, it checks the cache if EMM has been sendt to the card before, if it hasnt, then its sendt,
  else its ignored.


Nagra Ver.2:
  Well, finally..
  There are some problems with nagra2, on old boxes thats upgraded, you most probably only need the boxkey,
  but on new boxes you have to get out both the boxkey AND a RSA key.
  The procedure is not known to us, so please dont ask..

  Tested Providers:
   - DigiTV (RSA)
   - Polsat (dt08 and RSA)
   - D+ (RSA)
   - DishNet (dt08)
   - ExpressVu (dt08)

  EMM for Nagra Ver.2:
    Clients which want to support EMM for NewCS must be like this:

    EMM-G are globally addressed EMMs. These use table_id 0x82, and the IRD sends all of that type it finds out to the
    card (after adding the standard nagra2 header 21406DA0CA000067). f.ex.
    Sample:
    82706C 00000000 00 046548018200185A8674FFD850E738097E5250ED3FD84B6D3AED72D4830038DB1D6E5F8538A665865258F006F6BD3
    1F1705DD68BFBA487CE7BA24C2C2635817429F0A3CB48E750686919F96FFF12AE3A8310B9810C16705BF258E3BD3EFE0363D1940A0D2B2605

    EMM-S are for the whole card group. These are table_id 0x83 EMMs with EMM[7]==0x10. The IRD filters those, and any
    addressed with the first three bytes matching our camid are sendt out to the card. f.ex for camid 11223344
    Sample:
    83706C 33221100 10 0465490181009885268C6DF70666450BB4997424EDA046D3D66719B8366F2E06BD307A762370B57150F3B9C7161A55
    DBA97886CB95B0F4770D282E3ADEFC580865E6CEC5A58584CD5C21AF36DA3D229660243E117E6DF08D9703BEDF312E128E7D21F9396C9166

    EMM-U are for a single card. These are table_id 0x83 EMMs with EMM[7]==0x00. The IRD filters those, and any addressed
    with all four bytes matching our camid are sendt to the card. f.ex. for camid 11223344
    Sample:
    83706C 33221144 00 04654901810098D3D487B9F3B9D128EA2556A7ED12130C0DF9AE5692B1C432B182FAA511639E16DD461C5C776A69F
    806C82E4E3E0926F9697E00D3316EC716B1018939D1C2544B4773868CF13F8DC05864AD8A4D15A03EAF0A0B2D538C0802E40A90129F8A9E51

    NewCS use real serial from card, the client must swap the serial so it can match the EMM for the card.


Auto-SID:
  If you enable this, NewCS will learn which channels your cards can decode, and deny the others,
  this will hopefully lower the load on your card, giving it a longer life and faster decryption.
  The Configfile options will override the auto-sid feature, so think through your setup.
  A valid EMM will reset the denied auto-sids.


User numbering:
  There has been ALOT of suspicions etc. around the fact that our userid's start at number 2.
  First of all, if we wanted to make a backdoor, you really think we would make it that obvious?
  The REAL reason for userid's starting at 2 is that newcamd always assumes that userid 1 has AU-rights,
  we dont like this policy, so ALL newcs-users has to have <au>on</au> to get AU-rights.
  Simple as that :)


Client Detection:
  The two custom-bytes in login is used for identifying the client, the following are assigned by us:

    #define CL_VDRSC  0x5644 - VDR-SC
    #define CL_LCE    0x4C43 - LinCardEMU
    #define CL_CAMD3  0x4333 - Camd3
    #define CL_RDGD   0x7264 - Radegast
    #define CL_GBOX   0x6762 - Gbox
    #define CL_WINCSC 0x7763 - WinCSC


ECM Queue:
 There are 3 types supported:
  Hard:
  low-id users' ECM gets through first,that mean first user in config will have the highest priority.
 Round:
  All users have equal chance of getting theire ECM through, its called "Round Robin"-algoritm.
 FIFO:
  First in, First out - as the name says, the one who sendt first, gets answer first.

   
USB2Serial:
  Well, this is some tricky stuff..
  There seems to be adapters that emulate almost 100% and works with all CAS, we have seen them in both pl2303 adapters and ftdi adapters.
  And then we have the adapters that work on conax, seca, viaccess, cryptoworks, dreamcrypt, irdeto - and if your are lucky, videoguard -
  or maybe only a few of them.. seems some adapters are really really slow, or just dont read/write all bytes :(

Infinity USB burner:
  There seems to be some slight problems if the usb isnt put in before the machine is booted, you can always check manually if its detected,
  just do: cat /proc/bus/usb/devices | grep "wbe" - if you get anything then all probably should go very well :)

Mp35 burner: 
  The timing on this device seems to be a little strange - works on some CAS and not on others, not much to do about it..
  

9.-- Known Bugs ------- ---  -- - - -

1. Errorchecking of config is still very much nonexistant.
  

10.-- Thanks guys, You ROCK! ------- ---  -- - - -

Much precious time has been spent on the project, remember its all about fun, not about money..
We are against all commercial cardsharing, and will do as much as we can to prevent it - without
limiting the "normal" user..


