Do you know what happens when your computer uses all of its memory? Think about it like this. Say you had an empty bucket, which in this case would be your computer. Your bucket only has a certain amount of space that it can fit stuff inside. Equally your computer only has a certain amount of memory that it can use to load programs/files. Now let's say you start pouring water into this bucket. Cool, nothing happens and everything is fine. Then you notice when you are about halfway filled with the bucket, that this bucket is getting pretty heavy. Equally your computer will start to run slower once that memory is begins to fill up. Anyway let's keep on pouring.
Once you fill about 90% of the bucket you tell yourself OMG this bucket cannot move anymore because it is soooo heavy. You will notice performance issues when your computer is running too many programs at once. What will happen if you fill the bucket all the way? Well, the bucket is going to being to overflow and no longer be able to carry anymore water. So this leads us to what happens when your computer memory is full... YOUR COMPUTER WILL CRASH. As a type of safety measure your computer will shut itself off as it can no longer fulfill any more tasks.
What if you can shut someones computer off with 3 lines of code? (why are these things so easy) Let's take a look at how this can be done with some python wooooo.
import os
while True:
os.startfile()
Isn't it scary how simple this is? Yes...this is literally all the code you need to crash anyones computer, including your own which leads me to my next point. DO NOT run this program on your local machine. Or any machine you care about for that matter. Make sure to run this program on a VM or something similar.
Let's explain what's happening here. First we import the python os module which is going to allow us to interact with the users operating system. Next we are just going to make an infinite loop of this file to open itself. .startfile() is just going to find the file path that is given and execute it. Let's add a few more things just to get it going.
import os
while True:
os.startfile(__file__)
Okay nice, now we are offically finished. So inside of .startfile() we are going to give it the file path which is going to be __file__ which in simple terms is the same file we are working on. Now we don't want it to be a boring .py file so let's spice it up a little.
import os
while True:
os.startfile(__file__[:-2]+"exe")
In order to change the file type we are going to do something called index slicing woaaa fancy...so we add brackets and tell the program to remove the last two characters of the file name which would be py. While we are at it let's add exe to the end of it instead...muahahaha. We are done, let's get to the fun part and execute it.
Like I stated before please ONLY run this on a virtual machine. Let's boot up our virtual windows machine.
Now that our machine is up and running let's break it LOL. Watch what happens when we run our program.
What I really want to emphasize is the task manager. You wil notice that the VM running on its own will average around ~10% cpu usage while idol. Notice when we run our program the cpu usage hits its maximum capacity almost instantly. This is because the program is running an infinite while loop to open the designated file. It took about 20 seconds after starting the program for the VM to crash and shut itself down.
This is just an small example of how programs are able to manipulate what your computer can do. The last thing you want is to download a file that you believe is non malicious and after running it...oops your computer crashed.