Advertisement
DOGGYWOOF

Untitled

Nov 20th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. -- Function to read the hashed ID from the JSON-like config file
  2. local function readHashedID()
  3. if not fs.exists("HardwareID.cfg") then
  4. return nil
  5. end
  6.  
  7. local file = fs.open("HardwareID.cfg", "r")
  8. local content = file.readAll()
  9. file.close()
  10.  
  11. -- Extract the HashedID from the JSON-like content
  12. local hashedID = content:match('"HashedID"%s*:%s*(%d+)')
  13. return hashedID and tonumber(hashedID)
  14. end
  15.  
  16. -- Reversible hash function to encode/decode the computer ID
  17. local function generateHash(id)
  18. return (id * 12345 + 67890) % 1000000
  19. end
  20.  
  21. -- Function to "unhash" the hashed ID to get the original ID
  22. local function unhashID(hashedID)
  23. for possibleID = 0, 10000 do -- Assuming a reasonable range for computer IDs
  24. if generateHash(possibleID) == hashedID then
  25. return possibleID
  26. end
  27. end
  28. return nil -- If no valid ID is found
  29. end
  30.  
  31. -- Function to display the error screen
  32. local function showErrorScreen()
  33. -- Clear the screen and set up colors
  34. term.clear()
  35. term.setBackgroundColor(colors.black)
  36. term.setTextColor(colors.white)
  37. term.clear()
  38.  
  39. -- Define the width and height of the screen
  40. local width, height = term.getSize()
  41.  
  42. -- Helper function to center text on the screen
  43. local function centerText(y, text, textColor)
  44. local x = math.floor((width - #text) / 2)
  45. term.setCursorPos(x, y)
  46. term.setTextColor(textColor)
  47. term.write(text)
  48. end
  49.  
  50. -- Display the dog ASCII art with red Xes for eyes
  51. local dogArt = {
  52. " |\\_/| ",
  53. " | X X SECURITY ERROR! ",
  54. " | <> _ ",
  55. " | _/\\------____ ((| |)) ",
  56. " | `--' | ",
  57. " _____|_ ___| |___. ",
  58. "/_/_____/____/_______| "
  59. }
  60.  
  61. local startLine = math.floor((height - #dogArt) / 2) - 2
  62.  
  63. -- Display the dog ASCII art with red Xes for eyes
  64. term.setTextColor(colors.red)
  65. for i, line in ipairs(dogArt) do
  66. centerText(startLine + i, line, colors.red)
  67. end
  68.  
  69. -- Display the error message below the dog ASCII art
  70. term.setTextColor(colors.white)
  71. centerText(startLine + #dogArt + 2, "Doggy OS Hardware Security Error", colors.white)
  72. centerText(startLine + #dogArt + 3, "Error: Cannot verify Security config hash", colors.white)
  73. centerText(startLine + #dogArt + 4, "", colors.white)
  74.  
  75. -- Suggest next steps
  76. centerText(startLine + #dogArt + 6,"", colors.yellow)
  77. centerText(startLine + #dogArt + 7, "", colors.yellow)
  78.  
  79. -- Provide support contact info
  80. centerText(height - 2, "Press F1 to recalibrate Hardware Security ID", colors.white)
  81.  
  82. -- Keep the screen static with the error message and wait for F1 key
  83. while true do
  84. local event, key = os.pullEvent("key")
  85. if key == keys.f1 then
  86. -- Code to initiate recalibration would go here
  87. term.clear()
  88. term.setTextColor(colors.white)
  89. print("Recalibrating Hardware ID...")
  90. -- You can add further code to handle the recalibration process, such as:
  91. -- request admin credentials, run /disk/os/HWID, etc.
  92. break -- Exit the error loop to proceed with the recalibration process
  93. end
  94. sleep(1)
  95. end
  96. end
  97.  
  98. -- Main program starts here
  99. local hashedID = readHashedID()
  100. if not hashedID then
  101. -- If no valid hashed ID is found, show the error screen immediately
  102. showErrorScreen()
  103. return
  104. end
  105.  
  106. -- Retrieve the real computer ID
  107. local currentID = os.getComputerID()
  108.  
  109. -- Unhash the hashed ID to get the original ID
  110. local unhashedID = unhashID(hashedID)
  111.  
  112. -- Check if the real computer ID matches the unhashed ID
  113. if currentID == unhashedID then
  114. print("Computer ID verified successfully. Access granted.")
  115.  
  116. -- Run the /disk/boot/CFW-check.lua script if verification passes
  117. if fs.exists("/disk/boot/CFW-check.lua") then
  118. shell.run("/disk/boot/CFW-check.lua")
  119. else
  120. print("Error: /disk/boot/CFW-check.lua not found.")
  121. end
  122. else
  123. showErrorScreen()
  124. end
  125.  
  126.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement