Basic C++ “Virus”

March 25, 2017 | Views: 24534

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Hi everyone,

This is my first article on this site, I hope you will enjoy it! 🙂

What I’m going to show you today is a simple C++ virus, or scam (whatever you want to call it), that is very annoying once opened and requires a system reboot in order to stop it.

What it actually does is very simple to understand:

  • It basically goes in an infinite loop, running only one command that makes the computer to continuously produce a very annoying sound, and because of that infinite loop, the program cannot be closed.

Without further introduction, here is the code:

#include <iostream>

using namespace std;

int main() {

for(long long i=1;i<=100;i--)



// very important, when saving this program, save it with this extension: ".cpp" and after getting its executable, you can troll whoever you want XD

//notice that we started a loop with i=1 and set it to stop when i reaches 100, the only problem being that "i--", that creates the infinite loop


Thank you for reading my article. I hope you enjoyed it!

Best regards!

Share with Friends
Use Cybytes and
Tip the Author!
Share with Friends
Ready to share your knowledge and expertise?
  1. It’s very sad to see something like this on cybrary…

  2. It will actually terminate in O(2^64 * 2)

  3. Not a virus, just bad programming.

  4. Nice to know and good heads up

  5. It’d work on some less techie friends. But wouldn’t it be a simple task to just kill the process to get it to stop?

    • From what I tested, nothing worked in the attempt to kill the process, the window of the program “is not responding”, if you attempt to kill it from task manager, it also goes “not responding”.

      • Well, that’s why you don’t use windows and he said “Less techie friends”
        sudo kill -9

        Also, this thing is far away from any kind of “virus”, it’s just a little annoying.
        A forkbomb pretty much does the same.

Page 2 of 3«123»
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge


We recommend always using caution when following any link

Are you sure you want to continue?