Skip to content

Commit

Permalink
Import
Browse files Browse the repository at this point in the history
  • Loading branch information
yyounan committed Apr 19, 2016
0 parents commit e399b7d
Show file tree
Hide file tree
Showing 14 changed files with 1,046 additions and 0 deletions.
47 changes: 47 additions & 0 deletions AccessMBR/AccessMBR.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*++
AccessMBR
Simple program to read sector 0 on Physical drive 0 and write that sector back.
Used as a testing program for MBRFilter. This overwrites your MBR, albeit with
data that's already there, nevertheless: USE WITH CAUTION.
Written by Yves Younan, Cisco Talos
Copyright (C) 2016 Cisco Systems Inc
Thanks to Aaron Adams for reviewing the code.
--*/

#include "stdafx.h"
#include "Windows.h"

#define BOOTSIG1 0x55
#define BOOTSIG2 0xAA

int _tmain(int argc, _TCHAR* argv[])
{
DWORD read, wrote, pos;
unsigned char buf[512];
HANDLE hDisk = CreateFileA("\\\\.\\PhysicalDrive0", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING|FILE_FLAG_RANDOM_ACCESS, NULL);
if (!ReadFile(hDisk, buf, 512, &read, 0)) {
printf("Read failed\n");
return 0;
}
if (buf[510]== BOOTSIG1 && buf[511] == BOOTSIG2){
printf("Disk bootable\n");
} else {
printf("Disk not bootable\n");
}
pos = SetFilePointer(hDisk, 0, NULL, FILE_BEGIN);
if (pos == INVALID_SET_FILE_POINTER) {
printf("SetFilePos failed\n");
return 0;
}
if (!WriteFile(hDisk, buf, read, &wrote, 0)) {
printf("Write failed\n");
return 0;
}
printf("Succesfully read/wrote sector 0 on PhysicalDrive0: read %d, wrote: %d\n", read, wrote);
return 0;
}

93 changes: 93 additions & 0 deletions AccessMBR/AccessMBR.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>AccessMBR</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AccessMBR.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
33 changes: 33 additions & 0 deletions AccessMBR/AccessMBR.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AccessMBR.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions AccessMBR/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// AccessMBR.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
15 changes: 15 additions & 0 deletions AccessMBR/stdafx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>



// TODO: reference additional headers your program requires here
8 changes: 8 additions & 0 deletions AccessMBR/targetver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

// Including SDKDDKVer.h defines the highest available Windows platform.

// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.

#include <SDKDDKVer.h>
112 changes: 112 additions & 0 deletions MBRFilter Driver.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AccessMBR", "AccessMBR\AccessMBR.vcxproj", "{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MBRFilter", "MBRFilter\MBRFilter.vcxproj", "{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Vista Debug|Win32 = Vista Debug|Win32
Vista Debug|x64 = Vista Debug|x64
Vista Release|Win32 = Vista Release|Win32
Vista Release|x64 = Vista Release|x64
Win7 Debug|Win32 = Win7 Debug|Win32
Win7 Debug|x64 = Win7 Debug|x64
Win7 Release|Win32 = Win7 Release|Win32
Win7 Release|x64 = Win7 Release|x64
Win8 Debug|Win32 = Win8 Debug|Win32
Win8 Debug|x64 = Win8 Debug|x64
Win8 Release|Win32 = Win8 Release|Win32
Win8 Release|x64 = Win8 Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Debug|Win32.ActiveCfg = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Debug|Win32.Build.0 = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Debug|Win32.Deploy.0 = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Debug|x64.ActiveCfg = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Release|Win32.ActiveCfg = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Release|Win32.Build.0 = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Release|Win32.Deploy.0 = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Release|x64.ActiveCfg = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Vista Debug|Win32.ActiveCfg = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Vista Debug|Win32.Build.0 = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Vista Debug|Win32.Deploy.0 = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Vista Debug|x64.ActiveCfg = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Vista Release|Win32.ActiveCfg = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Vista Release|Win32.Build.0 = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Vista Release|Win32.Deploy.0 = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Vista Release|x64.ActiveCfg = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win7 Debug|Win32.ActiveCfg = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win7 Debug|Win32.Build.0 = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win7 Debug|Win32.Deploy.0 = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win7 Debug|x64.ActiveCfg = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win7 Release|Win32.ActiveCfg = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win7 Release|Win32.Build.0 = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win7 Release|Win32.Deploy.0 = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win7 Release|x64.ActiveCfg = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win8 Debug|Win32.ActiveCfg = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win8 Debug|Win32.Build.0 = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win8 Debug|Win32.Deploy.0 = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win8 Debug|x64.ActiveCfg = Debug|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win8 Release|Win32.ActiveCfg = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win8 Release|Win32.Build.0 = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win8 Release|Win32.Deploy.0 = Release|Win32
{BB7F5ABF-3EDB-44CD-B51F-5BFB58599282}.Win8 Release|x64.ActiveCfg = Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Debug|Win32.ActiveCfg = Win7 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Debug|Win32.Build.0 = Win7 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Debug|Win32.Deploy.0 = Win7 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Debug|x64.ActiveCfg = Win7 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Debug|x64.Build.0 = Win7 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Debug|x64.Deploy.0 = Win7 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Release|Win32.ActiveCfg = Win8 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Release|Win32.Build.0 = Win8 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Release|Win32.Deploy.0 = Win8 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Release|x64.ActiveCfg = Win8 Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Release|x64.Build.0 = Win8 Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Release|x64.Deploy.0 = Win8 Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Debug|Win32.ActiveCfg = Vista Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Debug|Win32.Build.0 = Vista Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Debug|Win32.Deploy.0 = Vista Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Debug|x64.ActiveCfg = Vista Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Debug|x64.Build.0 = Vista Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Debug|x64.Deploy.0 = Vista Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Release|Win32.ActiveCfg = Vista Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Release|Win32.Build.0 = Vista Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Release|Win32.Deploy.0 = Vista Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Release|x64.ActiveCfg = Vista Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Release|x64.Build.0 = Vista Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Vista Release|x64.Deploy.0 = Vista Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Debug|Win32.Deploy.0 = Win7 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Debug|x64.Build.0 = Win7 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Debug|x64.Deploy.0 = Win7 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Release|Win32.Build.0 = Win7 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Release|x64.ActiveCfg = Win7 Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Release|x64.Build.0 = Win7 Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win7 Release|x64.Deploy.0 = Win7 Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Debug|Win32.Deploy.0 = Win8 Debug|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Debug|x64.Build.0 = Win8 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Debug|x64.Deploy.0 = Win8 Debug|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Release|Win32.Build.0 = Win8 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Release|Win32.Deploy.0 = Win8 Release|Win32
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Release|x64.ActiveCfg = Win8 Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Release|x64.Build.0 = Win8 Release|x64
{AC354F4F-6EE7-43A7-9D13-DCFF4037FF8B}.Win8 Release|x64.Deploy.0 = Win8 Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions MBRFilter/Guid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// {E70CBAAB-925B-4781-9B60-71F59DB575D9}
DEFINE_GUID(MBRFilterGuid, 0xe70cbaab, 0x925b, 0x4781, 0x9b, 0x60, 0x71, 0xf5, 0x9d, 0xb5, 0x75, 0xd9);
Loading

0 comments on commit e399b7d

Please sign in to comment.