Cyberbe Notes from Blackcat

Nginx secure link for HLS

Feb 072016

location /tv/ {
rewrite /tv/([a-zA-Z0-9_\-]*)/([0-9]*)/(.*)/(.*)$ /hls/$3/$4?secl=$1&sect=$2;
}

location /hls {.

access_log /var/log/nginx/hls.log;
secure_link $arg_secl,$arg_sect;
secure_link_md5 mysecret$uri$arg_sect$remote_addr;
root /mnt/ramdisk;
rewrite ^/hls/(.*)/(.*)$ /hls/$1/$2 break;
location ~ /index.m3u8 {.
if ($secure_link = "") { return 403; }
if ($secure_link = "0") { return 404; }
}

}
script

<?php
$url = 'digi_sport_1/index.m3u8';
$secret = 'mysecret';
$time = time() + 5*60;
$ip = '91.224.178.210';
$key =strtr(base64_encode(md5($secret . '/hls/' . $url . $time . $ip , true)),array( '+' => '-', '/' => '_', '=' => '' ));
$surl = "http://iptv.dyndns.ws:8080/tv/$key/$time/$url";
$surl1 = "http://iptv.dyndns.ws:8080/hls/$url?secl=$key&sect=$time";
echo $surl . PHP_EOL;
echo $surl1 . PHP_EOL;