【发布时间】:2021-03-01 07:11:27
【问题描述】:
想要的输出:
nicholas@mordor:~$
nicholas@mordor:~$ lynx https://api.iocparser.com/url --dump
{"message": "The method is not allowed for the requested URL."}
nicholas@mordor:~$
不必是pretty。
当前输出:
PS /home/nicholas>
PS /home/nicholas> (Invoke-RestMethod -Method Post -Uri 'https://api.iocparser.com/url' -Headers @{"Content-Type" = "application/json"} -Body (@{'url' = 'https://pastebin.com/raw/rgnvuYi2'} | ConvertTo-Json) | ConvertTo-xml).outerxml
<?xml version="1.0" encoding="utf-8"?><Objects><Object Type="System.Management.Automation.PSCustomObject"><Property Name="data" Type="System.Management.Automation.PSCustomObject"><Property Type="System.String">@{FILE_HASH_SHA1=System.Object[]; DOMAIN=System.Object[]; IPv6=System.Object[]; YARA_RULE=System.Object[]; IPv4=System.Object[]; EMAIL=System.Object[]; FILE_NAME=System.Object[]; BITCOIN_ADDRESS=System.Object[]; URL=System.Object[]; MAC_ADDRESS=System.Object[]; FILE_HASH_MD5=System.Object[]; CVE=System.Object[]; FILE_HASH_SHA256=System.Object[]; ASN=System.Object[]; MITRE_ATT&CK=System.Object[]}</Property><Property Name="FILE_HASH_SHA1" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="DOMAIN" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="IPv6" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="YARA_RULE" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="IPv4" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="EMAIL" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="FILE_NAME" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="BITCOIN_ADDRESS" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="URL" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="MAC_ADDRESS" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="FILE_HASH_MD5" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="CVE" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="FILE_HASH_SHA256" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="ASN" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property><Property Name="MITRE_ATT&CK" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property></Property><Property Name="meta" Type="System.Management.Automation.PSCustomObject"><Property Type="System.String">@{description=https://pastebin.com/raw/rgnvuYi2; title=https://pastebin.com/raw/rgnvuYi2; url=https://pastebin.com/raw/rgnvuYi2; tags=System.Object[]}</Property><Property Name="description" Type="System.Management.Automation.PSNoteProperty">https://pastebin.com/raw/rgnvuYi2</Property><Property Name="title" Type="System.Management.Automation.PSNoteProperty">https://pastebin.com/raw/rgnvuYi2</Property><Property Name="url" Type="System.Management.Automation.PSNoteProperty">https://pastebin.com/raw/rgnvuYi2</Property><Property Name="tags" Type="System.Management.Automation.PSNoteProperty">System.Object[]</Property></Property><Property Name="status" Type="System.String">success</Property></Object></Objects>
PS /home/nicholas>
PS /home/nicholas>
PS /home/nicholas>
PS /home/nicholas> (Invoke-RestMethod -Method Post -Uri 'https://api.iocparser.com/url' -Headers @{"Content-Type" = "application/json"} -Body (@{'url' = 'https://pastebin.com/raw/rgnvuYi2'} | ConvertTo-Json) | ConvertTo-json).tostring
OverloadDefinitions
-------------------
string ToString()
string ToString(System.IFormatProvider provider)
string IConvertible.ToString(System.IFormatProvider provider)
PS /home/nicholas>
撇开我没有正确传递URL 不谈,我只对原始结果感兴趣,或者更好的是JSON 对象(或similar)。
【问题讨论】:
-
在第一次快速浏览之后,您可能已经省略了
toString上的括号,它只显示了输出中显示的重载。将其更新为toString()并查看是否可以修复它。 -
我不确定这是不是完全正确的输出,@mjsqu 但它可能已经足够了,所以我可以开始使用 API。
标签: json powershell rest microservices invoke-restmethod