PowerShell添加或修改注册表开机启动项脚本
我的测试代码:
直接使用命令行操作,添加注册表:
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v xxxxKey /t REG_SZ /d "powershell -file helloword.ps1"
使用ps添加开机启动:
1 2 3 | $name = "test_date" $value = "powershell -file D:\out_test\test2.ps1" New - ItemProperty - Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" - Name $name - PropertyType String - Value $value - ErrorAction Stop |
运行方法:
powershell -file add2startup.ps1
再看我的test2.ps1
1 2 3 | Write - Host 'Hello, World!' Get - Process | Out - File - FilePath D:\out_test\processes.txt Get - Date | Out - File - FilePath D:\out_test\date.txtt |
然后每次开机启动都会生成2个日期和进程的文件!!!
类似的恶意文件案例:
https://any.run/report/765b38e1840a1d06361268647372dfc164062ceb5b081dfd9ac1f623a5fa2dfa/aaa62403-7ecb-4327-bf47-7edc78d7d4e5#registry
实现开机启动连接C2服务器:
3660
powershell.exe
write
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
SoftwareUpdater
C:\Users\admin\AppData\Roaming\CTkld85U\presentationhost.exe
https://any.run/report/f5a763e43cf2258a3add2a1769f9cc9aed3da84f108f4f87831bed16dd6a409b/6bbd7ddf-bd22-4684-b343-3e306214b87a
直接通过powershell进程设置:
- Powershell Set-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Run -Value 'C:\Users\admin\AppData\Local\Microsoft\s.vbs
3888
Powershell.exe
write
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
C:\Users\admin\AppData\Local\Microsoft\s.vbs
类似的,通过mshta创建开机启动项的:
https://any.run/report/a0c31e0b30559e9ec0bb20242226e569e3979a6b536cb0c96fb2450593890e05/c6d527f7-a532-4aa7-a591-c20b1aa68fc9
------------------------------
PowerShell添加或修改注册表开机启动项脚本
2016-12-08 1651
简介: 代码如下: $name = Read-Host "请输入开机启动项的名字(随便起)" $value = Read-Host "请输入开机启动项的值" try{ New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name $name -PropertyType String -Value $value -ErrorAction Stop $tip = "成功添加开机启动项"+$name+"。
标签:
安全分析
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
2018-03-21 python compileall 打包发布
2018-03-21 深度学习 dns tunnel检测 使用统计特征 全连接网络——精度99.8%
2018-03-21 pandas 绘图 机器学习看特征相关性
2017-03-21 倒排列表求交集算法 包括baeza yates的交集算法
2017-03-21 倒排列表求交集算法汇总