Windows Defense Mechanism - Part 1

news2024/11/24 16:08:00

Overview

If I’m a long-time CTF player (or HackTheBox lab machine player), things are gonna go a little off when I’m put into a real world scenario - meaning that, when facing a well defended Windows machine.

This article will summarize the main Windows defense mechanisms, to have an understanding of what you may encounter along the way.

Of course Linux machines will install anti-virus software too, but due to the huge market share and historical reasons (Windows being the main target of attacks), Windows are the one we’re going to talk about here.

We’re going to discuss Windows built-in anti-virus products and other protections in companion that Microsoft has made to improve Windows system security. These include Windows Defender, AppLocker, Attack Surface Reduction (ASR), and Windows Defender Application Control (WDAC).

At the time of writing, the ones mentioned above is the built-in defense line for cutting edge Windows workstations and servers.

We may discuss bypass techniques in detail in the future, but it is not the purpose of this article.

Let’s dive in.

Don’t Believe What You Hear

It will be a lot harder than simply drop someone an email with a malicious attachment and get a reverse shell or a beacon. Tricking someone to open the attachment and run the payload is the LOT easier part. The moment after clicking, if the payload is a raw one and has no evasion technique applied, nearly 100% of the time, it will be snatched by the first and most basic defense mechanism - Windows Defender.

Windows Defender is enabled as default on all Microsoft Windows system production lines (Legacy Windows 7s and 8s are off topic here). So, getting a foothold on a Windows machine, isn’t as trivial as it is and requires a lot more effort.

An example of default metasploit payload being detected and removed (Windows VM uses default setting, no tweaking of any kind).

Generating payload.

在这里插入图片描述

在这里插入图片描述

The moment touch the disk on a windows 10 workstation, Windows Defender pops up and removes the file.
在这里插入图片描述

在这里插入图片描述

Vanilla Beacon?

Way too easy for Windows Defender.

在这里插入图片描述

在这里插入图片描述

Windows Defense Mechanisms

Let’s look into the them one by one.

Windows Defender

Windows Defender is the first thing that kicks off when you create a file on the system. No matter you create it manually, or download and save a file from the Internet. Windows Defender will keep an eye on every thing generated on disk, and scan it right away to detect malicious content. Like the above examples, once metasploit payload and beacon touches the disk, they are scanned and flagged malicious, then removed.

Windows Defender has been around for a long long time, and has evolved into a formidable kind of protection for Microsoft Windows.

By default, when you finished installing a Windows 10 system or newer, Windows Defender is up and running at its full capacity. And Windows Update will keep Windows Defender well updated with the latest malicious signatures.

Windows Defender consists of four different components.

Open Windows Security Center -> Virus & thread protection -> Virus & threat protection settings -> Manage settings.

在这里插入图片描述

在这里插入图片描述

We can find the four parts of Windows Defender.

在这里插入图片描述

Among which, Real-time protection and Tamper Protection is the most significant functionalities.

Real-time protection, as name suggests, monitors the system on real time, and report any suspicious files or activities found.

Tamper Protection is the one which prevents malicious apps or unauthorized users from modifying system security settings.

We can check if Real Time Protection is enabled by issuing the following command with PowerShell.

powershell "Get-MpComputerStatus | Select RealTimeProtectionEnabled"

在这里插入图片描述

100% of the time, by default, it’s enabled.

To get a list of all the enabled features of Windows Defender, remove the Select part of the command.

powershell Get-MpComputerStatus

在这里插入图片描述

One more thing we want to pay attention to is the IoavProtectionEnabled feature.

This feature scans files downloaded from the Internet.

在这里插入图片描述

So, if you have compromised a privileged account, turn off both Real Time Protection and Ioav Protection to make sure all files dropped on target will not be flagged.

powershell Set-MpPreference -DisableRealtimeMonitoring $true
powershell Set-MpPreference -DisableIOAVProtection $true

Or additionally, remove the loaded signatures from Windows Defender.

\Progra~1\Window~1\MpCmdRun.exe -RemoveDefinitions -All

AppLocker

AppLocker is the replacement of what is called Software Restriction Policies (SRP) back in Windows 7. AppLocker is powerful, but on the other hand, quite difficult to manage and deploy at large scale.

Still, it’s not uncommon to see AppLocker around if an organization really hardens its environment via Group Policy.

We are going to talk about two features coming along with AppLocker, Application Whitelisting, and Constrained Language Mode (CLM).

Application Whitelisting

Application Whitelisting is a very effective way to stop malicious activities. As the section title suggests, this part of functionality depends on a whitelisting (blacklisting) approach. It includes execution policies for EXE executables, installers, scripts (JScripts etc.), and even DLLs.

Note that AppLocker is only fully functional on Windows Enterprise, Education and Server Editions. Test should be conducted on those versions.

We are demonstrating this in an active directory environment.

Open Group Policy Management on domain controller.

在这里插入图片描述

Expand the following entries.

在这里插入图片描述

Right click on Group Policy Objects -> New.

在这里插入图片描述

Give the policy a name.

在这里插入图片描述

Right click the created policy and select edit.

在这里插入图片描述

Go to Policies -> Windows Settings -> Security Settings -> Application Control Policies -> AppLocker.

在这里插入图片描述

Let’s add default rules for all categories.

Click Configure rule enforcement.

And tick the check box in each categories.

在这里插入图片描述
Click OK.

Next, let’s add rules to each categories.

Do the following for each category.

Click the category title.

在这里插入图片描述

AppLocker allows Administrators to create fine-grained rules, but in this case, we are only going to test the default rules.

Right click on the blank space and choose Create Default Rules.

在这里插入图片描述

在这里插入图片描述

After applying default rules to all categories, we can see numbers of rules appearing in the summary window.

在这里插入图片描述

Next, we have to link the created and edited GPO to a domain.

Go back to Group Policy Management console.

Right click on the domain you want to link the GPO to. And select LInk and Existing GPO….

在这里插入图片描述

And select the created GPO, then click OK.

在这里插入图片描述

Now, the policy will show under Group Policy Objects.

在这里插入图片描述

Select the policy, and right click on the right panel, select Enforced.
在这里插入图片描述

Then, go to System Services, right click on Application Identity -> Properties

在这里插入图片描述

Configure as following.

在这里插入图片描述

Next, back to a workstation that’s domain joined, we have to run gpupdate /force to enable the policies just created as Administrator.

在这里插入图片描述

Then, we can start a command prompt as another use.

Pin the command prompt to task bar. Close all existing command prompts. Then shift + Right Click command prompt, select Run as a different user,

在这里插入图片描述

and input the user’s credential.

在这里插入图片描述

Now, under non-admin user’s context, EXE executables can only be run from trusted locations, like C:\Windows\System32. Let’s try copy calc.exe to regular (not in Admin’s group) user’s desktop and try to run it.

copy \Windows\System32\calc.exe calc.exe

.\calc.exe

在这里插入图片描述

And if you’re Administrator or in Admin’s group, you can run the application without any problem.

在这里插入图片描述

The incident will be logged by eventvwr.

Win + R and run eventvwr.

在这里插入图片描述

Got to Applications and Services Logs -> Microsoft -> Windows -> AppLocker -> EXE and DLL.

Double click on the red error icon, and we can see who is failed to run what application, if it’s some malware, the application name should appear here.

在这里插入图片描述

Constrained Language Mode (CLM)

If AppLocker is configured on scripts, PowerShell will be configured into a Constrained Language Mode, where functionalities are limited.

在这里插入图片描述

Cmdlets like AddType, which is used for various malicious use cases, and all .Net functions, are blocked.

To check if PowerShell is in Constrained Language Mode, we can issue the following command.

powershell $ExecutionContext.SessionState.LanguageMode

在这里插入图片描述

We can try invoke .Net members as non-admin user.

在这里插入图片描述

We get error because we’re in Constrained Language Mode.

Bypassing this requires some work, in addition to Application Whitelisting tools, which will make an attacker’s life more miserable.

Summary

Windows Defender, together with AppLocker, will drastically limit what an attacker can do on the target. In part 2 of this series, we are going to talk about Attack Surface Reduction (ASR), and Windows Defender Application Control (WDAC).

References

  • https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_language_modes?view=powershell-7.3
  • https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/116590.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

基于Java(Struts2 框架)+Mysql实现(Web)学生成绩管理系统【100010053】

学生成绩信息管理系统 Summary JavaWeb 课程设计作品。类似学校的教务管理系统,实现了其中的部分功能,包括学生的增删改查,成绩的增删改查等。 Note 关于数据库 数据库名称:smxy_class字符集:UTF-8先建立数据库&am…

Zookeeper下载、本地模式安装、集群操作

目录 1、Zookeeper下载地址 2 、本地模式安装 2.1安装前准备 2.2配置修改 2.3操作 Zookeeper 2.4配置参数解读 3、集群操作 3.1 集群安装 3.2 ZK 集群启动停止脚本 4、客户端命令行操作 4.1、命令行语法 4.2、znode 节点数据信息 4.3点类型(持久/短暂…

【案例教程】基于现代R语言【Tidyverse、Tidymodel】的机器学习方法与案例分析实践技术应用

【点击观看视频】基于现代R语言【Tidyverse、Tidymodel】的机器学习方法与案例分析实践技术应用 机器学习已经成为继理论、实验和数值计算之后的科研“第四范式”,是发现新规律,总结和分析实验结果的利器。机器学习涉及的理论和方法繁多,编程…

【Unity篇】Unity入门介绍

目录 游戏引擎 Unity3D特点 窗口介绍 快捷键 创建工程 组件的获取 游戏引擎 程序的框架:一款游戏最最核心的代码。 包含以下系统:渲染系统,物理引擎,碰撞检测系统,音效,脚本引擎,动画系统,人工智能…

全志V85x芯片 Tina Linux RISC-V E907核心开发指南

全志V85x芯片 Tina Linux RISC-V E907核心开发指南 1 编写目的 介绍v85X 上E907 的启动环境和AMP 的环境搭建。 2 使用范围 全志V85X 系列芯片 3 环境 A7 SDK:Tina E907 SDK:melis 4 SDK 快捷命令说明 这里主要介绍几个下文会用到的命令&#xf…

【嵌入式项目开源】基于ESP32的墨水屏桌面小屏幕

首先简要介绍一下这个项目: 这个项目的开源主要包括硬件,固件和软件两部分,外壳后面如果做了也会开源出来。该项目主要是参考了以下教学视频。 链接:桌面小屏幕实战教学 其中硬件部分改动不大,主要是把USB驱动改成了Ty…

推荐系统从入门到入门(1)——推荐系统综述与协同过滤

本系列博客总结了不同框架、不同算法、不同界面的推荐系统,完整阅读需要大量时间(又臭又长),建议根据目录选择需要的内容查看,欢迎讨论与指出问题。 目录 系列文章梗概 系列文章目录 一、问题背景介绍 1.推荐算法与…

企业拥有PMO(项目管理办公室)的好处

PMO(项目管理办公室),是一个企业内定义和维护项目管理标准的办公室或部门。PMO为项目的执行提供指导和标准。他们创造切实的目标,与整个企业的愿景保持一致,并确保所有目标的实现。 PMO指导以项目模板、标准化流程、…

DoIP协议概述

大家好哈,我是穿拖鞋的汉子! 伴随着需求不断提升(车身数据传输速率和带宽需求),为了满足需求将以太网引进到车载网络中。车载以太网在诊断传输层的应用协议是ISO 13400(Diagnostic On IP—DoIP)…

模型实战(1)之YOLOv5 实现目标检测+训练自己的数据集

模型实战(1)之YOLOv5 实现目标检测训练自己的数据集 写一个小总结吧,关于yolov5使用可以参考我的两外两篇博文: 1.YOLOV5算法一之Windows10下yolov5安装测试并训练自己的数据集 2.YOLOV5算法二之数据集转换及自动划分训练集与测试…

代理模式之提出问题和代理模式的概念

代理模式之提出问题和代理模式的概念 1. 提出问题 ①现有代码缺陷 针对带日志功能的实现类,我们发现有如下缺陷: 对核心业务功能有干扰,导致程序员在开发核心业务功能时分散了精力 附加功能分散在各个业务功能方法中,不利于统一…

docker创建带有用户密码认证和web可视化界面的私有仓库

docker-registry的搭建 有时候使用Docker Hub这样的公共仓库可能不方便,用户可以创建一个本地仓库供私人使用。比如,基于公司内部项目构建的镜像。 docker-registry是官方提供的工具,可以用于构建私有的镜像仓库。 安装运行docker-registry…

Go语言设计与实现 -- 上下文

我们先来看一下context.Context的接口: // A Context carries a deadline, a cancellation signal, and other values across // API boundaries. // // Contexts methods may be called by multiple goroutines simultaneously. type Context interface {// Deadl…

【TypeScript】TS接口类型(三)

🐱个人主页:不叫猫先生 🙋‍♂️作者简介:前端领域新星创作者、华为云享专家、阿里云专家博主,专注于前端各领域技术,共同学习共同进步,一起加油呀! 💫系列专栏&#xff…

modnet:real-time trimap-free portrail matting via objective decomposition

目前抠图(Image Matting)的主流算法有哪些? - 知乎什么是抠图对于一张图I, 我们感兴趣的人像部分称为前景F,其余部分为背景B,则图像I可以视为F与B的加权…https://www.zhihu.com/question/68146993/answer/…

SpringCloud-Gateway配置及持久化、过滤器、异常处理

文章目录yml配置代码配置持久化数据结构predicates(断言) 和filters&#xff08;过滤&#xff09;新增配置说明相关接口全局过滤器局部过滤器全局异常处理gateway不能和web一起使用 需要排除掉<dependency><groupId>org.springframework.cloud</groupId><…

【Unity】Delegate, Event, UnityEvent, Action, UnityAction, Func 傻傻分不清

【Unity】Delegate, Event, UnityEvent, Action, UnityAction, Func 傻傻分不清Delegate 委托&#xff0c;函数指针一个简单的例子&#xff1a;一对一依赖一个简单的例子&#xff1a;一对多依赖所以话说……委托有啥用呢&#xff1f;事件 Event&#xff0c;特殊的委托UnityEven…

Failed to read artifact descriptor for XXX.jar错误分析

今天遇到极其恶心的坑&#xff0c;自己定义编写的工具类&#xff0c;之前使用一直没有问题&#xff0c;正常引入pom文件中&#xff0c;也能正常的使用工具类中自建类。今天就是无法导入包&#xff0c;报错信息如下。 Failed to read artifact descriptor for com.yuxuntoo.www…

JavaScript篇.day03-循环结构(while, for)

目录 1.循环结构 2.例题 (1)奇数乘积(while/do-while) (2)水仙花数(while) (3)最大公约数(for) (4)最小公倍数(for) (5)打印星星(for) (6)乘法表(for) 1.循环结构 循环结构在程序中可执行多次循环结构有while循环, do-while循环, for循环 名称执行顺序循环执行次数应用…

wireshark练习抓取网络数据包用C编程完成modbus协议,从云端服务器读取温湿度数据。

文章目录前言一、疯狂聊天室1、配置网络2、创建房间3、互发消息二、wireshark抓取网络数据包1.找到对应的包2、分析抓取包中的信息三、Modbus协议概述1、Modbus主/从协议原理2、通用Modbus帧结构---协议数据单元(PDU)3、两种Modbus串行传输模式4、ModbusTCP通信结构四、C编程完…