PowerShell腳本遇到的問題彙總
PowerSploit: Exception calling “GetMethod” with “1” argument(s): “Ambiguous match found.”
Exception calling "GetMethod" with "1" argument(s): "Ambiguous match found."
解決方案是將
$GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress')
改爲
$GetProcAddress = $UnsafeNativeMethods.GetMethod('GetProcAddress',
[Type[]]@([System.Runtime.InteropServices.HandleRef], [String]))
增加的參數表明了GetProcAddress函數的參數類型。如果GetMethod的目標函數不是GetProcAddress,則根據目標函數的原型調整上述代碼即可。
項識別爲 cmdlet、函數、腳本文件或可運行程序的名稱。請檢查名稱的拼寫,如果包括路徑,請確保路徑正確,然後再試一次
用戶如果是第一次使用powershell 執行腳本 的話。其中的原因是:
windows默認不允許任何腳本運行,你可以使用"Set-ExecutionPolicy"cmdlet來改變的你PowerShell環境。
你可以使用如下命令讓PowerShell運行在無限制的環境之下:
Set-ExecutionPolicy Unrestricted
Unrestricted 爲允許所有的腳本運行
在win7(含)以上必須使用管理員的權限啓動命令命令行,否則會報“Set-ExecutionPolicy : 對註冊表項“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell”的訪問被拒絕。”錯誤。
方法調用失敗,因爲[System.Object[]]不包含名爲「op_Division」的方法。
(Get-WmiObject -Class Win32_Processor).AddressWidth / 8
測試AddressWidth .getType()得到類型爲數組,改爲
(Get-WmiObject -Class Win32_Processor).AddressWidth[0] / 8
OperationStopped: (😃 [], InvalidCastException
+ ... if (($PEInfo.DllCharacteristics -band $Win32Constants.IMAGE_D ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ + CategoryInfo : OperationStopped: (:) [], InvalidCastException
報錯對應的代碼爲:
$PEInfo.DllCharacteristics -band $Win32Constants.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
位運算符-band位與運算錯誤,操作數1爲enum,操作數2爲int。嘗試強轉:
[Int]$PEInfo.DllCharacteristics -band $Win32Constants.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
使用“2”個參數調用“DownloadFile”時發生異常:“在 WebClient 請求期間發生異常。
使用“2”個參數調用“DownloadFile”時發生異常:“在 WebClient 請求期間發生異常。”
所在位置 行:1 字符: 1
+ (new-object System.Net.WebClient).DownloadFile('https://x.x.x./ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
對應報錯代碼爲:
(new-object System.Net.WebClient).DownloadFile('https://x.x.x.x/aaaa.exe','C:\aaaa.exe');
參數2需要文件保存路徑(包括文件名),雖然我填寫的是文件路徑,但是問題是權限太低了