|
@@ -11,6 +11,10 @@
|
11
|
11
|
#include <sys/time.h>
|
12
|
12
|
#include <sys/errno.h>
|
13
|
13
|
|
|
14
|
+#include <sys/socket.h>
|
|
15
|
+#include <netinet/in.h>
|
|
16
|
+#include <arpa/inet.h>
|
|
17
|
+
|
14
|
18
|
#include <openssl/aes.h>
|
15
|
19
|
#include <openssl/md5.h>
|
16
|
20
|
|
|
@@ -58,6 +62,9 @@ void LOG_func(const char *msg) {
|
58
|
62
|
}
|
59
|
63
|
|
60
|
64
|
enum CA_system req_CA_sys = CA_CONNAX;
|
|
65
|
+char *camd35_server = "10.0.1.78";
|
|
66
|
+struct in_addr camd35_server_ip;
|
|
67
|
+uint16_t camd35_port = 2233;
|
61
|
68
|
char *camd35_user = "user";
|
62
|
69
|
char *camd35_pass = "pass";
|
63
|
70
|
uint32_t camd35_auth = 0;
|
|
@@ -346,22 +353,68 @@ static uint8_t *camd35_recv_cw(uint8_t *data, int data_len) {
|
346
|
353
|
|
347
|
354
|
void show_help() {
|
348
|
355
|
printf("TSDECRYPT v1.0\n");
|
349
|
|
- puts("Copyright (c) 2011 Unix Solutions Ltd.");
|
350
|
|
- puts("");
|
351
|
|
- puts(" Usage: tsdecrypt [opts] < data > data.decrypted");
|
352
|
|
- puts("");
|
|
356
|
+ printf("Copyright (c) 2011 Unix Solutions Ltd.\n");
|
|
357
|
+ printf("\n");
|
|
358
|
+ printf(" Usage: tsdecrypt [opts] < mpeg_ts > mpeg_ts.decrypted\n");
|
|
359
|
+ printf("\n");
|
|
360
|
+ printf(" Options:\n");
|
|
361
|
+ printf(" -C ca_system | default: %s valid: IRDETO, CONNAX, CRYPTOWORKS\n", ts_get_CA_sys_txt(req_CA_sys));
|
|
362
|
+ printf("\n");
|
|
363
|
+ printf(" Server options:\n");
|
|
364
|
+ printf(" -S server_ip | default: %s\n", camd35_server);
|
|
365
|
+ printf(" -P server_port | default: %u\n", (unsigned int)camd35_port);
|
|
366
|
+ printf(" -u server_user | default: %s\n", camd35_user);
|
|
367
|
+ printf(" -p server_pass | default: %s\n", camd35_pass);
|
|
368
|
+ printf("\n");
|
353
|
369
|
exit(0);
|
354
|
370
|
}
|
355
|
371
|
|
356
|
372
|
void parse_options(int argc, char **argv) {
|
357
|
|
- int j;
|
358
|
|
- while ((j = getopt(argc, argv, "f:h")) != -1) {
|
|
373
|
+ int j, ca_err = 0, server_err = 0;
|
|
374
|
+ while ((j = getopt(argc, argv, "C:S:P:u:p:h")) != -1) {
|
359
|
375
|
switch (j) {
|
|
376
|
+ case 'C':
|
|
377
|
+ if (strcasecmp("IRDETO", optarg) == 0)
|
|
378
|
+ req_CA_sys = CA_IRDETO;
|
|
379
|
+ else if (strcasecmp("CONNAX", optarg) == 0)
|
|
380
|
+ req_CA_sys = CA_CONNAX;
|
|
381
|
+ else if (strcasecmp("CRYPTOWORKS", optarg) == 0)
|
|
382
|
+ req_CA_sys = CA_CRYPTOWORKS;
|
|
383
|
+ else
|
|
384
|
+ ca_err = 1;
|
|
385
|
+ break;
|
|
386
|
+ case 'S':
|
|
387
|
+ camd35_server = optarg;
|
|
388
|
+ if (inet_aton(optarg, &camd35_server_ip) == 0)
|
|
389
|
+ server_err = 1;
|
|
390
|
+ break;
|
|
391
|
+ case 'P':
|
|
392
|
+ camd35_port = atoi(optarg);
|
|
393
|
+ break;
|
|
394
|
+ case 'u':
|
|
395
|
+ camd35_user = optarg;
|
|
396
|
+ break;
|
|
397
|
+ case 'p':
|
|
398
|
+ camd35_pass = optarg;
|
|
399
|
+ break;
|
360
|
400
|
case 'h':
|
361
|
401
|
show_help();
|
362
|
402
|
exit(0);
|
363
|
403
|
}
|
364
|
404
|
}
|
|
405
|
+ if (ca_err || server_err) {
|
|
406
|
+ if (ca_err)
|
|
407
|
+ fprintf(stderr, "ERROR: Unknown CA\n");
|
|
408
|
+ if (server_err)
|
|
409
|
+ fprintf(stderr, "ERROR: Invalid server IP address\n");
|
|
410
|
+ fprintf(stderr, "\n");
|
|
411
|
+ show_help();
|
|
412
|
+ exit(1);
|
|
413
|
+ }
|
|
414
|
+ fprintf(stderr, "CA System : %s\n", ts_get_CA_sys_txt(req_CA_sys));
|
|
415
|
+ fprintf(stderr, "Server\n");
|
|
416
|
+ fprintf(stderr, " Addr : %s:%d\n", camd35_server, camd35_port);
|
|
417
|
+ fprintf(stderr, " Auth : %s / %s\n", camd35_user, camd35_pass);
|
365
|
418
|
}
|
366
|
419
|
|
367
|
420
|
#define FRAME_SIZE (188 * 7)
|