Posted: Fri Jun 06, 2008 5:00 pm Post subject: Turing Virus
well, for all of you that says you can't write a virus in turing, here it is.
still a noob to recursion, i wrote one using recursion that deletes every file/folder on levels lower than where the file is placed.
i did not go about trying to make it delete files/folders on levels above the file though. might be pretty hard for me to test it out
code:
Turing:
setscreen("text") var WinID :int
WinID :=Window.Open("text") var streamNumber :array1.. 100ofint% assign 100 empty int var for the streamNumber var fileName :array1.. 100ofstring% assign 100 empty string var for the fileName
% this does not mean that it can only delete 100 files % since fileName (k) is replaced each time after file is deleted % rather, the 100's here in these 2 arrays mean that you can delete % 100 levels of folder in or lower than where this file is placed.
var k :=1% initiate first streamNumber and fileName index
% please read from below the % line first
proc recursion
Dir.Change(fileName (k))% we now set that directory as our Dir.Current
k +=1% we need to change both the streamNumber and the fileName var
streamNumber (k):=Dir.Open(".")% now we open the current directory assert streamNumber (k) > 0% check for success for i :1.. 2
fileName (k):=Dir.Get(streamNumber (k))% the first 2 filenames will always be the current directory and the parent directory. exitwhen fileName (k)=""% we cannot delete those yet put fileName (k) endfor loop
fileName (k):=Dir.Get(streamNumber (k))% get the first file name from the new Dir.Current
if fileName (k)=""then% if there are no more files then Dir.Close(streamNumber (k))% close current directory putDir.Current Dir.Delete(Dir.Current)% delete current directory ifError.Last= eNoError then% if success, proceed put" deleted" else% if not, print Error.LastMsg put" did not delete" put"Error: ",Error.LastMsg endif exit% exit endif% end if
put fileName (k) File.Delete(fileName (k))% delete the file ifError.Last= eNoError then% if success, proceed put" deleted" else% if not, it means that it is yet another directory Dir.Delete(fileName (k))% try deleting the directory ifError.Last= eNoError then% if success, proceed put" deleted" else% if not, it means there are yet more files/folders in that directory
recursion % repeat above steps endif endif endloop Dir.Change("..")% if all files are deleted, change Dir.Current to the parent directory
k -=1% change the streamNumber and the fileName var back to the parent folder end recursion
streamNumber (k):=Dir.Open(".")% open current directory assert streamNumber (k) > 0% check for success for i :1.. 2
fileName (k):=Dir.Get(streamNumber (k))% the first 2 filenames will always be the current directory and the parent directory. exitwhen fileName (k)=""% we cannot delete those yet put fileName (k) endfor
loop
fileName (k):=Dir.Get(streamNumber (k))% get the first file name exitwhen fileName (k)=""% exit if there are no more files put fileName (k) File.Delete(fileName (k))% delete the file ifError.Last= eNoError then% if the file is deleted, then proceed to next filename put" deleted" else% if the file is not deleted, it means it is a directory Dir.Delete(fileName (k))% attempt to delete the directory ifError.Last= eNoError then% if the directory is deleted, then proceed to next filename put" deleted" else% if it is not, then it means there are files within that directory
recursion % see Proc recursion
endif endif endloop
[/code]
Sponsor Sponsor
Dan
Posted: Fri Jun 06, 2008 6:04 pm Post subject: Re: Turing Virus
chopperdudes @ 6th June 2008, 5:00 pm wrote:
well, for all of you that says you can't write a virus in turing, here it is.
I do not know if any one has side that but what you have made is not a virus. A computer virus needs to infect other files so it may spread to other computers. What you have here is just a maulasices program.
Also most opearting systems will not let you delete system files with out any kind of authenetication or adminstator level user access. Addtional you can delete all the files in a simual way with a singal call to a system command and it would be ran in the background.
However for a beginger at turing it is not bad but you might want to try learning about the more beffical sides of programming then hurting peoleop :p
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
r691175002
Posted: Fri Jun 06, 2008 6:18 pm Post subject: Re: Turing Virus
As dan has said, this really isn't a virus. You can make a program that will delete folders recursively in almost any language (And even in things that aren't languages, you could probably make word do it with a script/macro).
chopperdudes
Posted: Fri Jun 06, 2008 6:31 pm Post subject: Re: Turing Virus
hmm yeah true. just doing this for fun cuz i think i read it on here or somewhere that some guy made a similar code but deleted it when he accidentally ran it. so i was just doing this for fun.
Aziz
Posted: Sat Jun 07, 2008 1:08 am Post subject: Re: Turing Virus
chopperdudes @ Fri Jun 06, 2008 7:31 pm wrote:
hmm yeah true. just doing this for fun cuz i think i read it on here or somewhere that some guy made a similar code but deleted it when he accidentally ran it. so i was just doing this for fun.
Oh yes, the world has it's ways of dealing with stupid people. Keep that in mind when you have an unsaved 300 line file and it's storming outside. No personal experience myself, but I've laughed at plenty of the poor bastards. I'm a CTRL+S Nazi.
TripleBla
Posted: Thu Jun 12, 2008 8:13 am Post subject: RE:Turing Virus
"I'm a CTRL+S Nazi."
I am too,
Ironically, it's the safest choice.
Aziz
Posted: Thu Jun 12, 2008 8:43 am Post subject: RE:Turing Virus
Why is that ironic? :/
SNIPERDUDE
Posted: Thu Jun 12, 2008 1:39 pm Post subject: RE:Turing Virus
calling it a nazi would be pretty ironic.
Anywho I'm a CTRL + s 'nazi' too.
Sponsor Sponsor
Aziz
Posted: Thu Jun 12, 2008 1:55 pm Post subject: RE:Turing Virus
Wtf is up with these weird uses of ironic?
Zampano
Posted: Thu Jun 12, 2008 3:02 pm Post subject: Re: RE:Turing Virus
TripleBla @ Thu Jun 12, 2008 8:13 am wrote:
"I'm a CTRL+S Nazi."
I am too,
Ironically, it's the safest choice.
I suppose that the irony lies in the juxtaposition of the safety of saving often and the danger of being a Nazi (in a society like ours, where Nazis are unaccepted). Of course, that's stretching the bounds of irony.
Aziz
Posted: Thu Jun 12, 2008 3:46 pm Post subject: RE:Turing Virus
Indeed it is. Irony is something that happens when it is opposite to the expected. I think it's taken on the other meaning officially, too though =/ http://en.wiktionary.org/wiki/irony
jeffgreco13
Posted: Fri Jun 13, 2008 8:31 am Post subject: Re: Turing Virus
I blame it on Alanis Morissette and her song Ironic...
Quote:
And isn't it ironic...don't you think
Tony
Posted: Fri Jun 13, 2008 9:12 am Post subject: RE:Turing Virus
I actually had a conversation about that just the other day. The irony of the song Ironic is that nothing mentioned in the song is actually ironic. Get it?