powershell API - 内核函数NtRaiseHardError,RtlAdjustPrivilege,NtShutdownSystem(蓝屏,提权,关机)

17 篇文章 0 订阅
1 篇文章 0 订阅

声明:未经允许不得转载,转载时请标注来源;禁止用作商业及其他衍生目的。

有误请指正,侵权请联系删除。有更好的方法也请联系我。

1.提权+蓝屏

Add-Type @"
using System;
using System.Runtime.InteropServices;
using System.Text;

public class YZX
{
[DllImport("ntdll.dll")]
    public static extern uint NtRaiseHardError(
    uint ErrorStatus,
    uint NumberOfParameters,
    uint UnicodeStringParameterMask,
    IntPtr Parameters,
    uint ValidResponseOption,
    out uint Response);

    [DllImport("ntdll.dll")] 
 public static extern void RtlAdjustPrivilege(int Privilege, int NewValue, int NewThread, out bool OldValue); 
    }

"@ -Language CSharp -ReferencedAssemblies System.Drawing,System.Data,System.Windows.Forms
[YZX]::RtlAdjustPrivilege(19, $true, $false, [ref]0);   #提上关机权限
[YZX]::NtRaiseHardError(3221226528, 0, 0, 0, 6, [ref]0);  #执行蓝屏

注:使用内核蓝屏,程序只需要关机权限

2.提权+关机

此处的关机指的是关闭内核,此时应提前保存好信息(不显示关机界面)

$type = @'
using System.Runtime.InteropServices;

public class YZX { 

 [DllImport("ntdll.dll")] 
 public static extern void RtlAdjustPrivilege(int Privilege, int NewValue, int NewThread, out bool OldValue); 
 [DllImport("ntdll.dll")] 
 public static extern void NtShutdownSystem(int Action);

}
'@

Add-Type -TypeDefinition $type
$t = "0"
[YZX]::RtlAdjustPrivilege(19, 1, 0, [ref]$t) 
[YZX]::NtShutdownSystem(1) #也可为0 代表着重启和关机
注:a.NtShutdownSystem 继承自 NtSetSystemPowerState

b.也可用ZwShutdownSystem 继承自 ZwSetSystemPowerState

  • 13
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值