From 35741bc99ca6da731df8f579b4e2f4f12ff97eeb Mon Sep 17 00:00:00 2001 From: Richard Blair Date: Sat, 21 Jan 2023 01:31:25 -0500 Subject: [PATCH] Initial commit of update-proxy --- .gitignore | 3 ++ TODO.txt | 2 ++ [Todo] Secure Mechanism.md | 1 + composer.json | 15 ++++++++ index.php | 73 ++++++++++++++++++++++++++++++++++++++ update-proxy.ini | 3 ++ 6 files changed, 97 insertions(+) create mode 100644 .gitignore create mode 100644 TODO.txt create mode 100644 [Todo] Secure Mechanism.md create mode 100644 composer.json create mode 100644 index.php create mode 100644 update-proxy.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..702d6a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +BUILD-DATA diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..9520557 --- /dev/null +++ b/TODO.txt @@ -0,0 +1,2 @@ +(B) Provide mechanism for verifying GPG signatures on requested pages. note:"[Todo] Secure Mechanism.md" +(A) \ No newline at end of file diff --git a/[Todo] Secure Mechanism.md b/[Todo] Secure Mechanism.md new file mode 100644 index 0000000..8193ba1 --- /dev/null +++ b/[Todo] Secure Mechanism.md @@ -0,0 +1 @@ +This may allow us to create a GPG-encrypted transmission mode between the update-server and client. \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..ca3ad44 --- /dev/null +++ b/composer.json @@ -0,0 +1,15 @@ +{ + "name": "tononixos/update-proxy", + "description": "Update proxy for the tononixOS Bootloader to add device authentication information to requests", + "type": "project", + "authors": [ + { + "name": "Richard Blair", + "email": "dreamcaster23@gmail.com" + } + ], + "require": { + "symfony/yaml": "^6.2", + "hassankhan/config": "^3.1" + } +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..68cb85b --- /dev/null +++ b/index.php @@ -0,0 +1,73 @@ + $SerialNumber, + 'X-Device-Bootloader-Version' => $RecoveryVersion +]; + +switch($_GET['file']) +{ + case 'BUILD-DATA': + $vars = [ + "action"=> "selfupdate_check" + ]; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $SelfUpdateUrl); + curl_setopt($ch, CURLOPT_HTTPHEADER, $UpdateServiceHeaders); + #curl_setopt($ch, CURLOPT_POST, 1); + #curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CRLF, 1); + $buildData = curl_exec($ch); + if(curl_errno($ch)) { + print "Error ". curl_errno($ch); + exit(); + } + curl_close($ch); + $version = $buildData; + + ## Begin Processing and Outputting of the data file. + print($version."\r\n"); + ## End Processing and Outputting of the data file. + + break; + case 'recovery.zip': + $vars = [ + "action" => "selfupdate_file" + ]; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $SelfUpdateZipUrl); + curl_setopt($ch, CURLOPT_HTTPHEADER, $UpdateServiceHeaders); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $recoveryZipData = curl_exec($ch); + if(curl_errno($ch)) { + print "Error ". curl_errno($ch); + exit(); + } + curl_close($ch); + + # BEGIN Processing and Outputting of ZIP file + echo($recoveryZipData); + # END Processing and Outputting of ZIP file + + break; +} \ No newline at end of file diff --git a/update-proxy.ini b/update-proxy.ini new file mode 100644 index 0000000..95b909d --- /dev/null +++ b/update-proxy.ini @@ -0,0 +1,3 @@ +[proxy-urls] +self-update-file=https://tonoxisisle.services/tononixOS/recovery/BUILD-DATA +self-update-zip=https://tonoxisisle.services/tononixOS/recovery/recovery.zip \ No newline at end of file