首页
社区
课程
招聘
[求助]如何主动产生蓝屏
发表于: 2015-3-15 08:28 5379

[求助]如何主动产生蓝屏

2015-3-15 08:28
5379
驱动编写中,想要实现这个功能:如果察觉环境不对,主动抛出一个bug错误代码0xaaaa....,
那么,应该是调用哪个系统API呢?

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (6)
雪    币: 615
活跃值: (530)
能力值: ( LV4,RANK:40 )
在线值:
发帖
回帖
粉丝
2
https://msdn.microsoft.com/en-us/library/windows/hardware/ff551948(v=vs.85).aspx
2015-3-15 08:37
0
雪    币: 52
活跃值: (27)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
BugCheck
2015-3-15 09:27
0
雪    币: 719
活跃值: (777)
能力值: ( LV8,RANK:120 )
在线值:
发帖
回帖
粉丝
4
端口100写ffff
2015-3-15 11:33
0
雪    币: 19
活跃值: (1086)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
KeBugCheck
2015-3-15 13:03
0
雪    币: 80
活跃值: (109)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
6
以前也有这样的问题
话说……这个函数是内核的,应用层咋办?

网上有别人的代码动态调用这个函数,貌似没戏。xp下测试过,失败。
2015-3-15 17:24
0
雪    币: 30050
活跃值: (2377)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
7
应用层的:

program Project2;

uses
  Windows;
(*
原作者:不详。据说是逆的smss的代码。
*)

type
{$Z4}
  _HARDERROR_RESPONSE_OPTION = (
    OptionAbortRetryIgnore,
    OptionOk,
    OptionOkCancel,
    OptionRetryCancel,
    OptionYesNo,
    OptionYesNoCancel,
    OptionShutdownSystem,
    OptionOkNoWait,
    OptionCancelTryContinue
    );
  HARDERROR_RESPONSE_OPTION = _HARDERROR_RESPONSE_OPTION;
{$Z1}

  _UNICODE_STRING = record
    Length: USHORT;
    MaximumLength: USHORT;
    Buffer: PWideChar;
  end;
  UNICODE_STRING = _UNICODE_STRING;
  PUNICODE_STRING = ^_UNICODE_STRING;

  pfnZwRaiseHardError = function(ErrorStatus: Integer;
    NumberOfParameters: ULONG;
    UnicodeStringParameterMask: ULONG; //PUNICODE_STRING;
    Parameters: Pointer;
    ValidResponseOptions: HARDERROR_RESPONSE_OPTION;
    Response: PULONG): Integer; stdcall;

function DebugPrivilege(PName: LPCTSTR; bEnable: BOOL): BOOL;
var
  hToken: THANDLE;
  TokenPrivileges: TOKEN_PRIVILEGES;
  ReturnLength: DWORD;
begin
  Result := False;
  if (not OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY or TOKEN_ADJUST_PRIVILEGES, hToken)) then Exit;

  TokenPrivileges.PrivilegeCount := 1;
  if bEnable then
    TokenPrivileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
  else
    TokenPrivileges.Privileges[0].Attributes := 0;
  LookupPrivilegeValue(nil, PName, TokenPrivileges.Privileges[0].Luid);
  AdjustTokenPrivileges(hToken, FALSE, TokenPrivileges, sizeof(TOKEN_PRIVILEGES), nil, ReturnLength);
  if (GetLastError() <> ERROR_SUCCESS) then Exit;

  CloseHandle(hToken);
  Result := True;
end;

const
  SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';//NtRaiseHardError需要关机权限
var
  str: UNICODE_STRING;
  args: array[0..2] of THandle;
  x: ULONG;
  hDll: HMODULE;
  ZwRaiseHardError: pfnZwRaiseHardError;
begin
  str.Length := 8;
  str.MaximumLength := 10;
  str.Buffer := 'test';

  args[0] := $12345678;
  args[1] := $87654321;
  args[2] := THandle(@str);
  hDll := GetModuleHandle('ntdll.dll');
  @ZwRaiseHardError := GetProcAddress(hDll, 'ZwRaiseHardError');

  DebugPrivilege(SE_SHUTDOWN_NAME, TRUE);
  ZwRaiseHardError(Integer($C000021A), 3, 4, @args, OptionShutdownSystem, @x);
end.

注意:64位系统请编译为64位EXE。需要管理员权限。

另外一个是

uses
  Windows;

function MakeMeCritical(Yes: Boolean): Boolean;
const
  SE_DEBUG_PRIVILEGE = $14;
  SE_PROC_INFO = $1D;
var
  Enabled: PBOOL;
  DllHandle: THandle;
  BreakOnTermination: ULong;
  HR: HRESULT;
  RtlAdjustPrivilege: function(Privilege: ULONG; Enable: BOOL; CurrentThread: BOOL; var Enabled: PBOOL): DWORD; stdcall;
  NtSetInformationProcess: function(ProcHandle: THandle; ProcInfoClass: ULONG; ProcInfo: Pointer;  ProcInfoLength: ULONG): HResult; WINAPI;
begin
  Result := False;
  DllHandle := LoadLibrary('ntdll.dll') ;
  if DllHandle <> 0 then
  begin
     @RtlAdjustPrivilege := GetProcAddress(dllHandle, 'RtlAdjustPrivilege');
     if (@RtlAdjustPrivilege <> nil) then
     begin
       if RtlAdjustPrivilege(SE_DEBUG_PRIVILEGE, True, True, Enabled) = 0 then
       begin
          @NtSetInformationProcess := GetProcAddress(dllHandle, 'NtSetInformationProcess');
          if (@NtSetInformationProcess <> nil) then
          begin
          BreakOnTermination := Ord(Yes);
          HR := NtSetInformationProcess(GetCurrentProcess(), SE_PROC_INFO, @BreakOnTermination, SizeOf(BreakOnTermination));
          Result := HR = S_OK;
          end;
       end;
     end;
     FreeLibrary(DllHandle);
  end
end;

begin
  if MakeMeCritical(True) then
  begin
    //the user cannot termintate the process now
    MessageBoxA(0, PAnsiChar('千万不要从任务管理器结束我,否则马上蓝你MB的屏'), PAnsiChar('Test'), 0);
  end
  else
    MessageBoxA(0, PAnsiChar('Something went wrong'), PAnsiChar('Test'), 0);
end.
2015-3-28 22:15
0
游客
登录 | 注册 方可回帖
返回
//