在php视图页面上显示JSON信息

时间:2017-06-24 13:40:47

标签: php json

如果我在Mozilla标签上输入该网址,我有一个返回以下json代码的网址:

{
    "results":[
        {
            "hostname":"localhost",
            "target":{
                "value":"localhost",
                "type":"ADDRESS"
            },
            "nmap-command":"/usr/bin/nmap -T5 -oX - localhost",
            "nmap-version":"7.01",
            "device-type":"unknown",
            "running-os":"unknown",
            "os-details":"unknown",
            "open-ports":[
                {
                    "service":"http",
                    "version":"unknown",
                    "port-number":"80"
                },
                {
                    "service":"mysql",
                    "version":"unknown",
                    "port-number":"3306"
                },
                {
                    "service":"unknown",
                    "version":"unknown",
                    "port-number":"55555"
                }
            ]
        }
    ],
    "targets":[
        {
            "value":"localhost",
            "type":"ADDRESS"
        }
    ],
    "start":1498303529660,
    "finish":null,
    "policy":{
        "description":"Análisis completo",
        "version":"1.0",
        "metadata":{
            "description":"Análisis completo",
            "version":"1.0",
            "name":"completo"
        },
        "params":[
            "-O",
            "-sV",
            "-T5"
        ],
        "name":"completo"
    },
    "status":"FINISHED",
    "id":"ebac2c53-2595-4523-bcaa-d2d49cb310d8"
}

另一方面,我在view.php页面上有这个,请注意,应用于file_get_contents()的网址与我在Mozzilla标签页上使用的网址相同:

$json = file_get_contents(http://localhost:55555/rema/analyzers/NMAP/analyses/a7819f0d-9c3e-4a74-b4bc-1f10bebd96c7);

$parsed_json = json_decode($json,true);

print_r($parsed_json);

print_r输出如下:

Array (
    [finish] => 
    [start] => 1498311204774
    [targets] => Array (
        [0] => Array (
            [value] => localhost
            [type] => ADDRESS
        )
    )
    [policy] => Array (
        [description] => Análisis completo
        [version] => 1.0
        [metadata] => Array (
            [description] => Análisis completo
            [version] => 1.0
            [name] => completo
        )
        [params] => Array (
            [0] => -O
            [1] => -sV
            [2] => -T5
        )
        [name] => completo
    )
    [status] => STARTED
    [id] => aabd7375-f9e8-41db-815c-9a6dd5941ef6
)

有些信息似乎错过了,我真的不知道为什么,我没有得到主机名,目标以及与nmap相关的所有信息,如nmap-version,device-type,runnig-os等......同样的有开放端口信息。请提前帮助和谢谢。

修改 这是我在浏览器网址上获得的内容,也许可以提供帮助 enter image description here

0 个答案:

没有答案