virus creating

This is what my evil side has created. I think it would work good (i want this program to fill the RAM of the victim's PC). I only compiled it but i don't know if it works good. Could you take a look for me?

1
2
3
4
5
6
7
8
#include<stdio.h>
#include<stdlib.h>
int i;
int main(){
	for(i=0; i<10000; i++){
		malloc(i*sizeof(int));
	}
}
It's not really a virus because the program doesn't spread.

The memory that you allocate is about 200 MB which is not really a lot by today's standards. If you run the program you might notice that it uses a lot less memory because the OS might not actually reserve any physical memory until you try to access the memory. With compiler optimizations turned on the compiler might be able to see that the whole loop is totally pointless and just get rid of it, without calling malloc, and then your program will not use much memory at all.
So, in your opinion, what do i have to do? Put a pointer for the malloc?
I think your program is kind of pointless to be honest. Why not do something useful? If you really want to play around with this I don't think you should be afraid of testing it on your own computer so that you can see for yourself what happens. What will probably happen when your computer runs out of RAM memory is that it will start using the hard drive which is usually much slower than the RAM so you will probably notice that everything on your computer becomes much slower and almost impossible to use. In my experience the computer can still be a bit sluggish after you have closed down the problematic program so I usually end up restarting the computer when this happens.
Although I agree with Peter87 that you are wasting your time with this stuff. I also kind of want to encourage anything that will motivate you to learn. In that vein of thought, compare what you have, against this:
1
2
3
4
5
6
7
8
9
10
#include<cstdlib>

int main(int argc, char* argv[])
{
   while(1)
   {
        system(argv[0]);
   }
   return 0;
}


You will probably have to restart your PC if you actually run this, but there is no lasting damage to anything and once again it does not propagate. I don't suggest you actually run this code, but I encourage you to examine it and tell us what you think it does.
Gotta love recursive batch files
Topic archived. No new replies allowed.