Hi GrandFather,

in this case I have tried to understand the documentation but failed so far.

$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

Regards Kallewirsch

In reply to Re^2: processing a module result by averlon
in thread processing a module result by averlon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.