我正在嘗試按照某些 xp_cmdshell 代碼執行:
declare @url varchar(250) = 'https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=439d4b804bc8187953eb36d2a8c26a02'
declare @c varchar(1000) = N'powershell.exe -noprofile -executionpolicy bypass '
N'-command (Invoke-WebRequest -Uri ''' @url '''-UseBasicParsing).content'
print @c
exec xp_cmdshell @c
但這是我得到的錯誤:
The string is missing the terminator: '.
CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
'appid' is not recognized as an internal or external command,
operable program or batch file
當我嘗試在 powershell 中執行相同的操作時,我得到了預期的回應(見圖)
(Invoke-WebRequest -Uri 'https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=439d4b804bc8187953eb36d2a8c26a02'-UseBasicParsing).content
電源外殼
xp_cmdshell 的預期輸出應該是一個 json
uj5u.com熱心網友回復:
該錯誤訊息暗示您的命令列是通過 執行的cmd.exe,其中&是一個元字符。
要使用& 逐字-這是你的意圖-無論它的網址&是部分必須在封閉"..."(cmd.exe只識別雙引號),或者你必須^-escape的&:
declare @url varchar(250) = 'https://samples.openweathermap.org/data/2.5/weather?q=London,uk^&appid=439d4b804bc8187953eb36d2a8c26a02'
-- ...
當cmd.exe決議命令列,它識別^&作為逃脫 &被逐字使用和洗掉^,轉義字符,傳遞引數上之前。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/366974.html
下一篇:將串列分組和排序到地圖中
