tsdecrypt reads and decrypts CSA encrypted incoming mpeg transport stream over UDP/RTP using code words obtained from OSCAM or similar CAM server. tsdecrypt communicates with CAM server using cs378x (camd35 over tcp) protocol or newcamd protocol. https://georgi.unixsol.org/programs/tsdecrypt/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FILTERING 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. tsdecrypt EMM filtering support
  2. ===============================
  3. tsdecrypt have no specific knowledge about EMMs of each of the
  4. supported CA systems. This allows tsdecrypt to work even when
  5. the CA system is unknown. It just sends the EMM/ECM streams to the
  6. CAMD server for processing and filtering. The lack of specific
  7. knowledge about each of the supported CA systems is a feature.
  8. However there are cases where limiting the number of EMMs that
  9. reach CAMD is a must have feature. Since there is no code in
  10. tsdecrypt to detect whether the EMM type is GLOBAL, SHARED,
  11. UNIQUE, there is no detection of provider IDs, channel IDs or
  12. card numbers a simpler approach to filtering was implemented.
  13. The basic idea was implemented by Julian Gardner in his emm-buffer-mask
  14. patches. These patches were never merged in tsdecrypt but they
  15. inspired the current filtering implementation.
  16. tsdecrypt's EMM filters describe whether EMM should be processed
  17. or not based on an offset and data bytes that are compared with the
  18. incoming EMM.
  19. The option responsible for defining EMM filters is --emm-filter (-a)
  20. followed by the filter definition. Up to 16 filters can be defined.
  21. Filter definitions
  22. ==================
  23. Filter definition contain command and command settings. The command
  24. and the settings are separated by / (forward slash) symbol, the
  25. settings are separated by comma (,) character and use setting=value
  26. notation.
  27. Command Settings
  28. ------- --------
  29. command[/setting1=abc,setting2=xyz...]
  30. Since filter definitions are passed as command line parameters, you must
  31. ensure that they are enclosed in quotes if they contain spaces.
  32. Filter commands
  33. ===============
  34. Currently defined commands are:
  35. accept_all - Set the default to allow all EMMs to reach CAMD except
  36. EMMs that match "reject" command.
  37. When no "accept_all" or "reject_all" commands were used it
  38. is assumed that "accept_all" was the first command.
  39. reject_all - Set the default to skip all EMMs except those that
  40. are accepted by "accept" command.
  41. * Both "accept_all" and "reject_all" can be used without command settings.
  42. accept - This command instructs tsdecrypt to allow EMM that matches
  43. the definition to be processed.
  44. reject - This command instructs tsdecrypt to skip EMM that matches
  45. the definition to be processed.
  46. * Both commands must have at least two settings (offset and data).
  47. Filter settings
  48. ===============
  49. Currently defined command settings are:
  50. * name=X - Sets the filter name (used when displaying filters).
  51. The name can not be longer than 32 symbols.
  52. * match=X1 X4 X5
  53. * mask=M1 M4 M5
  54. - Match bytes are series of hex numbers separated by
  55. space " " or dot ".". When the bytes are processed 0x
  56. prefix is removed from them. The maximum match bytes
  57. is 16.
  58. The match bytes are compared to the incoming packet
  59. by first applying the mask (binary AND operation) set
  60. in mask= setting. The default mask is 0xFF.
  61. The match bytes are compared to first, forth and so
  62. on bytes in the incoming EMM packet. Second and third
  63. incoming bytes in the EMM are not checked (they specify
  64. the section length).
  65. Here is an example EMM and match+mask that would match:
  66. Pos: 1 2 3 4 5 6 7 8 9 10 11 12 13
  67. -- -- -- -- -- -- -- -- -- -- -- -- --
  68. EMM: 82 70 b4 aa bb cc d0 00 01 xx xx xx xx
  69. Match: 82 aa bb cc dd
  70. Mask: ff ff ff ff f0
  71. Such filter is configured like that:
  72. --emm-filter "accept/name=Test_Filter,match=82 aa bb cc dd,mask=ff ff ff ff f0"
  73. * length=Num1 Num2 NumX
  74. - Match EMM packets that have section length "X".
  75. * offset=X - Sets the offset at which data bytes would be checked
  76. against EMM. The default offset is 0.
  77. This setting is ignored when match+mask are set.
  78. * data=XX YY ZZ - Data bytes are series of hex numbers separated by
  79. space " " or dot ".". When data bytes are processed 0x
  80. prefix is removed from them. The maximum data bytes is 16.
  81. This setting is ignored when match+mask is set.
  82. Using offset+data you can check any bytes in the
  83. incoming EMM packet.
  84. Filter processing
  85. =================
  86. Filters are processed one by one until "accept" or "reject" filter matches.
  87. If no "accept" or "reject" filters match, then the default match determined
  88. by "accept_all" or "reject_all" is returned.
  89. Example filters
  90. ===============
  91. Accept Bulcrypt EMMs that are for particular card (or card group). The card
  92. hex serial number is "aa bb cc dd".
  93. tsdecrypt ... \
  94. --emm \
  95. --emm-filter reject_all \
  96. --emm-filter "accept/name=Bulcrypt_EMMs,match=82 aa bb cc dd,mask=ff ff ff ff f0" \
  97. --emm-filter "accept/name=Bulcrypt_EMMs,match=84 aa bb cc dd,mask=ff ff ff ff f0" \
  98. --emm-filter "accept/name=Bulcrypt_EMMs,match=85 aa bb cc dd,mask=ff ff ff ff f0"
  99. Accept Bulcrypt EMMs that have sizes 190, 240 and 0xb4
  100. tsdecrypt ... \
  101. --emm \
  102. --emm-filter reject_all \
  103. --emm-filter "accept/name=Bulcrypt_EMMs,length=190 240 0xb4"
  104. Bulcrypt white list example:
  105. Accept all EMMs except those starting with 8a 70 b4, 8b 70 b4, 8c or 8d.
  106. tsdecrypt ... \
  107. --emm \
  108. --emm-filter accept_all \
  109. --emm-filter "reject/name=Bulcrypt_unknown_EMMs,offset=0,data=8a 70 b4" \
  110. --emm-filter "reject/name=Bulcrypt_unknown_EMMs,offset=0,data=8b 70 b4" \
  111. --emm-filter "reject/name=Some EMM,data=0x8c" \
  112. --emm-filter "reject/data=0x8d"
  113. Bulcrypt black list example:
  114. Reject all EMMs that don't start with 82, 84 or 85.
  115. tsdecrypt ... \
  116. --emm \
  117. --emm-filter reject_all \
  118. --emm-filter accept/name=Bulcrypt_EMMs,offset=0,data=82 \
  119. --emm-filter accept/name=Bulcrypt_EMMs,data=84 \
  120. --emm-filter accept/name=Bulcrypt_EMMs,data=85 \