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 __DEFAULT_IMPORT = require
 | 
			
		||||
local require = function(path)
 | 
			
		||||
| 
						 | 
				
			
			@ -7,11 +8,14 @@ local require = function(path)
 | 
			
		|||
        return __DEFAULT_IMPORT(path)
 | 
			
		||||
    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 config = require("config.lua")
 | 
			
		||||
    local LAST_USED = os.time()
 | 
			
		||||
    local mod = {}
 | 
			
		||||
    if not __UPDATE_HASH then
 | 
			
		||||
        __UPDATE_HASH = "WHATTHEFUCK";
 | 
			
		||||
    end
 | 
			
		||||
    local function checkForUpdate()
 | 
			
		||||
        local current_time = os.time()
 | 
			
		||||
        local difference = math.abs(current_time - LAST_USED)
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +30,7 @@ local KEYPADOS_UPDATE_HASH = "ThZGemtZHshNpaflGvUHcJoZ"rawset(__BUNDLER_FILES, "
 | 
			
		|||
                            fs.delete("backup.lua")
 | 
			
		||||
                        end
 | 
			
		||||
                        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")
 | 
			
		||||
                            file.write(update_code_text)
 | 
			
		||||
                            file.close()
 | 
			
		||||
| 
						 | 
				
			
			@ -76,9 +80,10 @@ local KEYPADOS_UPDATE_HASH = "ThZGemtZHshNpaflGvUHcJoZ"rawset(__BUNDLER_FILES, "
 | 
			
		|||
end)
 | 
			
		||||
rawset(__BUNDLER_FILES, "config.lua", function ()
 | 
			
		||||
    local config = {
 | 
			
		||||
        correctPin = "42169",
 | 
			
		||||
        correctPin = "42069",
 | 
			
		||||
        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",
 | 
			
		||||
        ntfy_url = "https://ntfy.sh/keypadOS_alerts",
 | 
			
		||||
        config_path = "keypadOS.config.lua"
 | 
			
		||||
    }
 | 
			
		||||
    local DEFAULT_CONFIG =  "return {\n" ..
 | 
			
		||||
| 
						 | 
				
			
			@ -189,7 +194,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function ()
 | 
			
		|||
        end)
 | 
			
		||||
        if not status and err ~= "Terminated" then
 | 
			
		||||
            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)
 | 
			
		||||
            utils.MonReset(0.5)
 | 
			
		||||
            fs.delete("basalt.lua")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
local config = {
 | 
			
		||||
    correctPin = "42169",
 | 
			
		||||
    correctPin = "42069",
 | 
			
		||||
    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",
 | 
			
		||||
    ntfy_url = "https://ntfy.sh/keypadOS_alerts",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										16
									
								
								x.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								x.py
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -1,7 +1,5 @@
 | 
			
		|||
#!/usr/bin/python
 | 
			
		||||
import string
 | 
			
		||||
import random
 | 
			
		||||
UPDATE_ID=  ''.join(random.choices(string.ascii_letters, k=24))
 | 
			
		||||
import hashlib
 | 
			
		||||
OUTPUT="keypadOS.lua";
 | 
			
		||||
FILES= [
 | 
			
		||||
    "updater.lua",
 | 
			
		||||
| 
						 | 
				
			
			@ -36,9 +34,14 @@ def minimise(buf: str) -> str:
 | 
			
		|||
        newbuf += line + "\n";
 | 
			
		||||
    return newbuf;
 | 
			
		||||
 | 
			
		||||
def get_hash(buf: str) -> str:
 | 
			
		||||
    hasher = hashlib.sha1();
 | 
			
		||||
 | 
			
		||||
    hasher.update(bytes(buf, "utf-8"));
 | 
			
		||||
    return hasher.hexdigest();
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    buf = ""
 | 
			
		||||
    buf += "local __UPDATE_HASH = \"" + {UPDATE_ID} + "\"";
 | 
			
		||||
    buf += "local __BUNDLER_FILES = {}\n";
 | 
			
		||||
    buf += "local __DEFAULT_IMPORT = require\n";
 | 
			
		||||
    buf += "local require = function(path)\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -52,13 +55,16 @@ def main():
 | 
			
		|||
    for file in FILES:
 | 
			
		||||
        print(f"=== FILE: {file}");
 | 
			
		||||
        buf += read_file(file);
 | 
			
		||||
    print(f"=== UPDATE HASH: {UPDATE_ID}")
 | 
			
		||||
 | 
			
		||||
    buf += "require(\"main.lua\").Main()\n";
 | 
			
		||||
 | 
			
		||||
    if MINIMISE:
 | 
			
		||||
        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:
 | 
			
		||||
        f.write(buf);
 | 
			
		||||
    print("DONE");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user