change default code, implement true hashes
This commit is contained in:
parent
a2546cb9ba
commit
87fb39b9bd
13
keypadOS.lua
13
keypadOS.lua
|
@ -1,3 +1,4 @@
|
||||||
|
local __UPDATE_HASH = "399a256a8643d08b369cb0171b5a609324a79303"
|
||||||
local __BUNDLER_FILES = {}
|
local __BUNDLER_FILES = {}
|
||||||
local __DEFAULT_IMPORT = require
|
local __DEFAULT_IMPORT = require
|
||||||
local require = function(path)
|
local require = function(path)
|
||||||
|
@ -7,11 +8,14 @@ local require = function(path)
|
||||||
return __DEFAULT_IMPORT(path)
|
return __DEFAULT_IMPORT(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local KEYPADOS_UPDATE_HASH = "ThZGemtZHshNpaflGvUHcJoZ"rawset(__BUNDLER_FILES, "updater.lua", function ()
|
rawset(__BUNDLER_FILES, "updater.lua", function ()
|
||||||
local utils = require("utils.lua")
|
local utils = require("utils.lua")
|
||||||
local config = require("config.lua")
|
local config = require("config.lua")
|
||||||
local LAST_USED = os.time()
|
local LAST_USED = os.time()
|
||||||
local mod = {}
|
local mod = {}
|
||||||
|
if not __UPDATE_HASH then
|
||||||
|
__UPDATE_HASH = "WHATTHEFUCK";
|
||||||
|
end
|
||||||
local function checkForUpdate()
|
local function checkForUpdate()
|
||||||
local current_time = os.time()
|
local current_time = os.time()
|
||||||
local difference = math.abs(current_time - LAST_USED)
|
local difference = math.abs(current_time - LAST_USED)
|
||||||
|
@ -26,7 +30,7 @@ local KEYPADOS_UPDATE_HASH = "ThZGemtZHshNpaflGvUHcJoZ"rawset(__BUNDLER_FILES, "
|
||||||
fs.delete("backup.lua")
|
fs.delete("backup.lua")
|
||||||
end
|
end
|
||||||
fs.copy("startup.lua", "backup.lua")
|
fs.copy("startup.lua", "backup.lua")
|
||||||
if not string.find(update_code_text, KEYPADOS_UPDATE_HASH) then
|
if not string.find(update_code_text, __UPDATE_HASH) then
|
||||||
local file = fs.open("startup.lua", "w")
|
local file = fs.open("startup.lua", "w")
|
||||||
file.write(update_code_text)
|
file.write(update_code_text)
|
||||||
file.close()
|
file.close()
|
||||||
|
@ -76,9 +80,10 @@ local KEYPADOS_UPDATE_HASH = "ThZGemtZHshNpaflGvUHcJoZ"rawset(__BUNDLER_FILES, "
|
||||||
end)
|
end)
|
||||||
rawset(__BUNDLER_FILES, "config.lua", function ()
|
rawset(__BUNDLER_FILES, "config.lua", function ()
|
||||||
local config = {
|
local config = {
|
||||||
correctPin = "42169",
|
correctPin = "42069",
|
||||||
release_url = "https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/main/keypadOS.lua",
|
release_url = "https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/main/keypadOS.lua",
|
||||||
basalt_url = "https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua",
|
basalt_url = "https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua",
|
||||||
|
ntfy_url = "https://ntfy.sh/keypadOS_alerts",
|
||||||
config_path = "keypadOS.config.lua"
|
config_path = "keypadOS.config.lua"
|
||||||
}
|
}
|
||||||
local DEFAULT_CONFIG = "return {\n" ..
|
local DEFAULT_CONFIG = "return {\n" ..
|
||||||
|
@ -189,7 +194,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
|
||||||
end)
|
end)
|
||||||
if not status and err ~= "Terminated" then
|
if not status and err ~= "Terminated" then
|
||||||
print("Error detected: " .. err)
|
print("Error detected: " .. err)
|
||||||
http.post("https://ntfy.sh/keypadOS_alerts", err, {Priority = "urgent"}) --exposed ntfy url no spam me pls
|
http.post(config.ntfy_url, err, {Priority = "urgent"}) --exposed ntfy url no spam me pls
|
||||||
sleep(5)
|
sleep(5)
|
||||||
utils.MonReset(0.5)
|
utils.MonReset(0.5)
|
||||||
fs.delete("basalt.lua")
|
fs.delete("basalt.lua")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local config = {
|
local config = {
|
||||||
correctPin = "42169",
|
correctPin = "42069",
|
||||||
release_url = "https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/main/keypadOS.lua",
|
release_url = "https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/main/keypadOS.lua",
|
||||||
basalt_url = "https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua",
|
basalt_url = "https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua",
|
||||||
ntfy_url = "https://ntfy.sh/keypadOS_alerts",
|
ntfy_url = "https://ntfy.sh/keypadOS_alerts",
|
||||||
|
|
16
x.py
16
x.py
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import string
|
import hashlib
|
||||||
import random
|
|
||||||
UPDATE_ID= ''.join(random.choices(string.ascii_letters, k=24))
|
|
||||||
OUTPUT="keypadOS.lua";
|
OUTPUT="keypadOS.lua";
|
||||||
FILES= [
|
FILES= [
|
||||||
"updater.lua",
|
"updater.lua",
|
||||||
|
@ -36,9 +34,14 @@ def minimise(buf: str) -> str:
|
||||||
newbuf += line + "\n";
|
newbuf += line + "\n";
|
||||||
return newbuf;
|
return newbuf;
|
||||||
|
|
||||||
|
def get_hash(buf: str) -> str:
|
||||||
|
hasher = hashlib.sha1();
|
||||||
|
|
||||||
|
hasher.update(bytes(buf, "utf-8"));
|
||||||
|
return hasher.hexdigest();
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
buf = ""
|
buf = ""
|
||||||
buf += "local __UPDATE_HASH = \"" + {UPDATE_ID} + "\"";
|
|
||||||
buf += "local __BUNDLER_FILES = {}\n";
|
buf += "local __BUNDLER_FILES = {}\n";
|
||||||
buf += "local __DEFAULT_IMPORT = require\n";
|
buf += "local __DEFAULT_IMPORT = require\n";
|
||||||
buf += "local require = function(path)\n";
|
buf += "local require = function(path)\n";
|
||||||
|
@ -52,13 +55,16 @@ def main():
|
||||||
for file in FILES:
|
for file in FILES:
|
||||||
print(f"=== FILE: {file}");
|
print(f"=== FILE: {file}");
|
||||||
buf += read_file(file);
|
buf += read_file(file);
|
||||||
print(f"=== UPDATE HASH: {UPDATE_ID}")
|
|
||||||
|
|
||||||
buf += "require(\"main.lua\").Main()\n";
|
buf += "require(\"main.lua\").Main()\n";
|
||||||
|
|
||||||
if MINIMISE:
|
if MINIMISE:
|
||||||
buf = minimise(buf);
|
buf = minimise(buf);
|
||||||
|
update_hash = get_hash(buf);
|
||||||
|
|
||||||
|
buf = f"local __UPDATE_HASH = \"{update_hash}\"\n" + buf;
|
||||||
|
|
||||||
|
print(f"=== UPDATE HASH: {update_hash}")
|
||||||
with open(OUTPUT, "w", encoding="utf-8") as f:
|
with open(OUTPUT, "w", encoding="utf-8") as f:
|
||||||
f.write(buf);
|
f.write(buf);
|
||||||
print("DONE");
|
print("DONE");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user