in reply to Re^3: processing a module result
in thread processing a module result

Hi

here is my code:

$av_obj_MAS = Masscan::Scanner->new(); # host given by the command line option $av_obj_MAS->add_host($av_loc_IP); # set the ports given by the command line options $av_obj_MAS->ports(\@av_arr_PORTS); $av_obj_MAS->sudo(1); $av_obj_MAS->verbose(1); # now scan $av_tmp_SCAN = $av_obj_MAS->scan; # if result is available if ($av_tmp_SCAN) { # get result from module - this then seems to be an object $av_obj_SCANRESULT = $av_obj_MAS->scan_results; # # # now I need to fetch the part of scan_results from this object # $av_obj_RESULT = %$av_obj_SCANRESULT{scan_results}; # since the scan_result is an array of values, I need to put it in +to an array @av_arr_SCANRESULT = @{%$av_obj_SCANRESULT{scan_results}}; } # now to process this array of results # this should contain the e.g. the ip-address of the computer scanned +and an array of ports found in what status ever foreach $av_tmp_STRING ( @av_arr_SCANRESULT ) { # print simply the ip-address print %$av_tmp_STRING{ip} . "\n"; # now I need to put the array of ports scanned and reported as an +result into an array @av_arr_RESULTPORTS = @{%$av_tmp_STRING{ports}}; # this array may have several entries for each port scanned # now to process the array and print the results foreach $av_tmp_STRING ( @av_arr_RESULTPORTS ) { print "Port: " . %$av_tmp_STRING{port} . "\n"; print "Status: " . %$av_tmp_STRING{status} . "\n"; } }

I am sure there is a lot of optimization and shortening of commands possible - but one step after another

probably it will help also others struggling with this issue - if some

Regards Kallewirsch

Replies are listed 'Best First'.
Re^5: processing a module result -- strict and warnings
by Discipulus (Canon) on May 18, 2022 at 09:49 UTC
    Hello averlon,

    > I am sure there is a lot of optimization and shortening of commands possible - but one step after another

    You skipped the very first step: use strict and warnings :)

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      Hi,

      no, this is standard in my scrips, but further up in the code where all the use ... and variable definitions are.

      I only pasted the code relevant for processing the masscan result

      thanks anyway!

      Regards Kallewirsch