$av_obj_MAS = Masscan::Scanner->new();
$av_obj_MAS->add_host($av_loc_IP);
$av_obj_MAS->add_port(@av_arr_PORTS);
$av_obj_MAS->sudo(1);
$av_obj_MAS->verbose(1);
$av_tmp_SCAN = $av_obj_MAS->scan;
if ($av_tmp_SCAN)
{
$av_obj_SCANRESULT = $av_obj_MAS->scan_results;
$av_obj_RESULT = %$av_obj_SCANRESULT{scan_results};
@av_arr_SCANRESULT = @{%$av_obj_SCANRESULT{scan_results}};
# print "Test1: " . $%av_obj_RESULT{ip};
}
The first line to get the result from the object obviously works. It is according to the documentation.
It looks like the second line also brings one part of the result to a variable.
But to access the IP (and print it) and the array of port is still not working.
The documentation of the module shows some example data structure provided as result.
{
'scan_results' => [
{
'timestamp' => '1584816181',
'ip' => '10.0.0.1',
'ports' => [
{
'status' => 'open',
'reason' => 'syn-ack',
'port' => 443,
'proto' => 'tcp',
'ttl' => 60
}
]
},
{
'timestamp' => '1584816181',
'ip' => '10.0.0.2',
'ports' => [
{
'reason' => 'syn-ack',
'status' => 'open',
'port' => 443,
'ttl' => 60,
'proto' => 'tcp'
}
]
},
{
'ports' => [
{
'port' => 80,
'ttl' => 60,
'proto' => 'tcp',
'reason' => 'syn-ack',
'status' => 'open'
}
],
'ip' => '10.0.0.1',
'timestamp' => '1584816181'
},
{
'ip' => '10.0.0.2',
'timestamp' => '1584816181',
'ports' => [
{
'port' => 80,
'ttl' => 60,
'proto' => 'tcp',
'status' => 'open',
'reason' => 'syn-ack'
}
]
},
{
'timestamp' => '1584816181',
'ip' => '10.0.0.3',
'ports' => [
{
'reason' => 'syn-ack',
'status' => 'open',
'proto' => 'tcp',
'ttl' => 111,
'port' => 80
}
]
},
{
'ports' => [
{
'ttl' => 111,
'proto' => 'tcp',
'port' => 443,
'reason' => 'syn-ack',
'status' => 'open'
}
],
'timestamp' => '1584816181',
'ip' => '10.0.0.3'
}
],
'masscan' => {
'scan_stats' => {
'total_hosts' => 4,
'up_hosts' => 3
},
'command_line' => '/usr/bin/masscan --rate 100000
+ --banners -p 22,80,443,61222,25 10.0.0.2,10.0.0.1,10.0.0.3,10.0.0.4'
}
};
with:
$av_obj_SCANRESULT = $av_obj_MAS->scan_results;
I geht the data structure into a scalar - so far so good
now I would like e.g. to print the IP-Address as part of the data structure or move the whole result into an array or just run a foreach ... to process the results list.
but I don't know how
|