当前位置:网站首页>[笔记]Windows安全之《三》Shellcode 补充之 Get-InjectedThread脚本搭建环境及其使用
[笔记]Windows安全之《三》Shellcode 补充之 Get-InjectedThread脚本搭建环境及其使用
2022-06-10 12:53:00 【二次元怪兽】
文章目录
前言
Get-InjectedThread.ps1是一个可以扫描系统上的活动线程可疑的起始地址的脚本。用户可以利用它扫描其网络中的主机,并快速识别许多内存常驻恶意软件技术。该脚本通过使用NtQueryInformationThread函数查询每个活动线程来检索其起始地址。然后,使用VirtualQueryEx函数查询起始地址,以确定相关的节点属性。如果线程启动的存储器区域是未回调的并且是可执行的,即不是映像类型并且具有执行位设置,那么该线程就被认为是注入的。
Get-InjectedThread原理
- 使用ProcessId 为0(所有进程)并将Flag参数设置为4(TH32CS_SNAPTHREAD)调用Create Toolhelp Snapshot。这将返回所有当前正在运行的线程的快照。
- 使用Thread32First和Thread32Next处理快照中的所有线程。
以下每个步骤都将在每个线程上执行:
- 调用OpenThread以接收内核中的Thread对象的句柄。
- 使用Thread句柄,为ThreadInformationClass参数指定值为9(ThreadQuerySetWin32StartAddress)的NtQueryInformationThread。这将返回线程的内存起始地址。
- 调用OpenProcess来接收当前线程拥有进程的句柄。
- 将进程句柄和线程起始地址传递给VirtualQueryEx以查询目标内存页面。这将返回一个MEMORY_BASIC_INFORMATION结构。
- 检查返回结构中的State和Type字段。
- 所有线程的状态应该是MEM_COMMIT
- 所有线程的类型应为MEM_IMAGE
- 如果Type不等于MEM_IMAGE,那么你有一个正在运行代码的线程,这个线程不会被磁盘上的文件(又名注入)所支持。
环境搭建
win10 1903
powershell 5.1
powershell PackageManagement
PowershellGet
PowershellGet安装
Installing PowerShellGet on Windows
PowershellGet的安装非常重要 不然后面脚本会抛异常:
设置脚本运行权限
Set-ExecutionPolicy RemoteSigned
PowerShellGet和NuGet安装
Install-Module PowerShellGet -AllowClobber -Force
Install-PackageProvider -Name NuGet -Force
PSReflect-Functions模块安装
Install-Module PowerShellGet -AllowClobber -Force
Install-Module -Name PSReflect-Functions
TLS版本设置
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
设置PSGallery仓库可信任
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
脚本下载
https://gist.github.com/jaredcatkinson/23905d34537ce4b5b1818c3e6405c1d2

设置Powershell权限
Set-ExecutionPolicy RemoteSigned
导入模块
Import-Module .\Get-InjectedThread.ps1
Import-Module .\Get-MemorySectionContent.ps1
Import-Module .\New-InjectedThread.ps1
Import-Module .\Stop-Thread.ps1
创建一个被注入的线程-New-InjectedThread
Ps>New-InjectedThread

Ps>.\New-InjectedThread.ps1
注意:这种执行脚本需要在 ps中添加 执行内容即 文件尾部添加一行 执行的函数
执行检测-Get-InjectedThread
Ps>Get-InjectedThread

注意:这种执行脚本需要在 ps中添加 执行内容即 文件尾部添加一行 执行的函数
边栏推荐
- Tidb elementary course experience 8 (cluster management and maintenance, adding a tikv node)
- Office technical lecture: punctuation - Chinese - vertical
- 13、 System call and shell (freesanding shell, terminal and job control)
- Binary XML file line 96: error inflating class & lt; unknown>
- 2022 ciscn preliminary satool
- Development trend of Web Development
- Tidb Primary course experience 8 (Management Maintenance of Clusters, add a tikv Node)
- Shell Encyclopedia
- Yyds dry goods inventory # solve the problem of sword finger offer: jump step expansion
- 一些编码Tips
猜你喜欢

【NLP】NLP全路径学习推荐

【Multisim仿真】差分放大电路2

Leetcode 96. Different binary search trees

Sohu employees encounter wage subsidy fraud. What is the difference between black property and gray property and how to trace the source?

Shi Yigong and other teams posted on the cover of Science: AI and freeze electron microscope revealed the structure of "atomic level" NPC, a breakthrough in life science

Multithreading killer ---countdownlatch & cyclicbarrier

Qt数据库应用22-文件编码格式识别

日本版arXiv凉得一批:2个多月了,才收到37篇论文

深度神经网络每秒分类近20亿张图像,新型类脑光学分类器芯片登上Nature

Some words from ShareIt group
随机推荐
Yyds dry goods inventory # solve the problem of sword finger offer: jump step expansion
Multithreading killer ---countdownlatch & cyclicbarrier
Leetcode 96. 不同的二叉搜索樹
Neuron newsletter 2022-05 | add 2 southbound drivers and 1 northbound application, and realize customized extension with Modbus TCP
JS global timer case
谷歌提出超强预训练模型CoCa,在ImageNet上微调Top-1准确率达91%!在多个下游任务上SOTA!
线性动态规划专讲
拷贝和删除文件
Lecture on linear dynamic programming
出海企业遇瓶颈 茄子科技(SHAREit Group)有话说
2022 ciscn preliminary PWN complete WP
Some words from ShareIt group
Simple integration of client go gin six list watch two (about the improvement of RS, pod and deployment)
Can qiniu open an account? Is it safe to open an account in qiniu
[spark] (task8) pipeline channel establishment in sparkml
Yet Another Palindrome Partitioning
Introduction of Altium Designer
Tidb Primary course experience 8 (Management Maintenance of Clusters, add a tikv Node)
MySQL数据库(26):视图 view
施一公等团队登Science封面:AI与冷冻电镜揭示「原子级」NPC结构,生命科学突破