/!\ Anyone interested in this Gist should look at the work of @danielchc ;)
-> https://gist.github.com/danielchc/c159626485a08c76856b2d30ae457e04
/!\ I used bind9 on my local server to add mb3admin.com entry for all devices ( like android app ) Otherwise in hosts fie :
<your_server> mb3admin.com
C:\Users\<YOUR_USER>\AppData\Roaming\Emby-Theater\system\electronapp
Add after app.on('window-all-closed', function () {
block L:18
To accept self certificate
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
event.preventDefault()
callback(true)
})
- Create /var/www/mb3admin.com folder
- In /var/www/mb3admin.com/ create file
index.php
with
<?php
if (false){
$file = 'data.log';
$content = file_get_contents($file);
$content .= date('Y-m-d H:i:s').' : '.$_SERVER['REMOTE_ADDR'].' URL : '.$_SERVER['REDIRECT_URL'].' Query : '.json_encode($_REQUEST)."\r\n";
file_put_contents($file, $content);
}
if ($_SERVER['REDIRECT_URL'] == '/admin/service/registration/validate'){
header('content-type:application/json');
$date = new DateTime();
$date->add(new DateInterval('P14D'));
echo '{"featId":"'.$_POST['feature'].'","registered":true,"expDate":"'.$date->format('Y-m-d').'","key":"'.$_POST['key'].'"}';
}elseif ($_SERVER['REDIRECT_URL'] == '/admin/service/registration/validateDevice'){
header('content-type:application/json');
echo '{"cacheExpirationDays":21,"resultCode":"GOOD","message":"Device Valid"}';
}
- Create file
.htaccess
Allow from all Options -Indexes <IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L] </IfModule>
# /etc/apache2/sites-enabled/mb3admin.conf
<VirtualHost *:80>
DocumentRoot "/var/www/mb3admin.com"
ServerName mb3admin.com
<Directory "/var/www/mb3admin.com/">
Options MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /var/log/apache2/mb3admin_access.log
ErrorLog /var/log/apache2/mb3admin_error.log
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/mb3admin.com"
ServerName mb3admin.com
SSLEngine on
SSLCertificateFile /etc/apache2/mb3admin.crt # Self signed certificate
SSLCertificateKeyFile /etc/apache2/mb3admin.key
<Directory "/var/www/mb3admin.com/">
Options MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /var/log/apache2/mb3admin_access.log
ErrorLog /var/log/apache2/mb3admin_error.log
</VirtualHost>
You can disassemble this file with ildasm and then reassemble it with ilasm after making the necessary changes.
E.g. if you have Emby server installed in
/system
on a Linux install.mkdir -p /tmp/patches cd /tmp/patches ildasm /system/Emby.Web.dll -out=Emby.Web.il
Now all the JS files are in the current directory (
/tmp/patches
) and you can apply the registration patches with a regular text editor.I personally like to replace the
getRegPromise
with a fully mocked server response.Reassemble the DLL and overwrite the original assembly.
On Windows you need to replace
-out=
with/out=
.The binaries for a typical 64-bit Linux install can be downloaded here.
Or use the native nuget client if you are on Windows.
For good measure, also patch the duplicate code in
/system/dashboard-ui/bower_components/emby-apiclient/connectionmanager.js
because I'm unsure when this file is served instead of the file embedded in Emby.Web.dll.After all this is said and done, some clients are unlocked while other still require client-side patching. There is a discrepancy between platforms where some platforms load the connection manager from the server while other apps are self-contained (e.g. the Electron edition of Emby Theater).
So far, Emby for Android seems to be fully unlocked after patching the connection manager in both locations. Emby Theater for Smart TV still shows the Premiere nagging popup so I suspect it contains its own connection manager. I don't know where to go from here without rooting my TV / other devices with self-contained Emby Theaters.