#!/usr/bin/perl # Copyright Andrew Gavin 2009-2012 # # This file is part of OpenDLP. # # OpenDLP is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenDLP is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with OpenDLP. If not, see . use CGI qw/:standard/; use DBI; use POSIX qw( floor ); use MIME::Base64; my $version = get_version(); my $db_admin_file = "../etc/db_admin"; my $is_valid = 1; my %systems = (); open( DB, $db_admin_file ); my $db_line = ; close( DB ); chomp $db_line; my ($db_username, $db_password) = split( ":", $db_line ); header(); my $query = CGI->new; my $scanname = $query->param('scanname'); if( $scanname ne "" && $scanname !~ /^[a-z0-9\ \,\.\-\_]+$/i ) { $is_valid = 0; print "Invalid scan name

\n"; } my $system = $query->param('system'); if( $system ne "" && $system !~ /^[A-Z0-9]{32}$/ ) { $is_valid = 0; print "Invalid system tracker

\n"; } if( $is_valid ) { print "View Results

\n"; ############################# # if no arguments are given # ############################# if( $system eq "" && $scanname eq "" ) { my %scans = (); print "On this screen, you can:
\n"; print "
  • Select a scan to view its systems and results
  • \n"; print "
  • Pause, Resume, or Stop/Uninstall agents on all systems in scan
  • \n"; print "
    For a more granular way to control agents, select the scan and click \"View Scan Details\".

    \n"; my $dbh = DBI->connect("DBI:mysql:database=OpenDLP;host=localhost",$db_username,$db_password); my $string = "SELECT DISTINCT scan,ip,control,scantype FROM systems"; my $sth = $dbh->prepare( $string ); $sth->execute(); my $agent_count = 0; my $win_agentless_count = 0; my $unix_agentless_count = 0; my $win_share_count = 0; my $db_count = 0; while( my $results = $sth->fetchrow_arrayref() ) { if( $$results[2] eq "running" ) { $scans{$$results[0]}{running}++; } elsif( $$results[2] eq "finished" ) { $scans{$$results[0]}{finished}++; } elsif( $$results[2] eq "stopped" ) { $scans{$$results[0]}{stopped}++; } elsif( $$results[2] eq "uninstalled" ) { $scans{$$results[0]}{uninstalled}++; } $scans{$$results[0]}{scantype} = $$results[3]; if( $$results[3] eq "win_agent" ) { $agent_count++; } elsif( $$results[3] eq "win_agentless" ) { $win_agentless_count++; } elsif( $$results[3] eq "win_share" ) { $win_share_count++; } elsif( $$results[3] eq "unix_agentless" ) { $unix_agentless_count++; } elsif( $$results[3] =~ /^(mssql_agentless|mysql_agentless|oracle_agentless)$/ ) { $db_count++; } } if( $agent_count > 0 ) { my $total_finished = $total_running = $total_paused = $total_uninstalled = $total_total = 0; print "
    \n"; print "\n"; print "\n"; foreach my $scankey( sort( keys( %scans ))) { if( $scans{$scankey}{scantype} eq "win_agent" ) { my $total = $scans{$scankey}{running} + $scans{$scankey}{finished} + $scans{$scankey}{stopped} + $scans{$scankey}{uninstalled}; $total_total += $total; $total_running += $scans{$scankey}{running}; $total_finished += $scans{$scankey}{finished}; $total_paused += $scans{$scankey}{stopped}; $total_uninstalled += $scans{$scankey}{uninstalled}; print "\n"; print "\n"; print "\n"; # Finished if( $scans{$scankey}{finished} == 0 ) { print "\n"; } else { print "\n"; } # Running if( $scans{$scankey}{running} == 0 ) { print "\n"; } else { print "\n"; } # Paused if( $scans{$scankey}{stopped} == 0 ) { print "\n"; } else { print "\n"; } # Uninstalled if( $scans{$scankey}{uninstalled} == 0 ) { print "\n"; } else { print "\n"; } print "\n"; if( $total eq $scans{$scankey}{finished} ) { print "\n"; print "\n"; print "\n"; } else { # pause if( $scans{$scankey}{running} > 0 ) { print "\n"; } else { print "\n"; } # resume if( $scans{$scankey}{stopped} > 0 ) { print "\n"; } else { print "\n"; } # uninstall my $stopped_and_running = $scans{$scankey}{stopped} + $scans{$scankey}{running}; if( $stopped_and_running > 0 ) { print "\n"; } else { print "\n"; } } print "\n"; } } print "\n"; print "\n"; print "
    DetailsScan nameScan typeFinishedRunningPausedUninstalledTotalPauseResumeUninstall
    $scankey$scans{$scankey}{scantype}0$scans{$scankey}{finished}0$scans{$scankey}{running}0$scans{$scankey}{stopped}0$scans{$scankey}{uninstalled}$totalN/AN/AN/APause $scans{$scankey}{running} AgentsN/AResume $scans{$scankey}{stopped} AgentsN/AUninstall $stopped_and_running AgentsN/A
    Total$total_finished$total_running$total_paused$total_uninstalled$total_total
    \n"; } if( $win_agentless_count > 0 ) { my $total_finished = $total_running = $total_paused = $total_uninstalled = $total_total = 0; print "
    \n"; print "\n"; print "\n"; foreach my $scankey( sort( keys( %scans ))) { if( $scans{$scankey}{scantype} eq "win_agentless" ) { my $total = $scans{$scankey}{running} + $scans{$scankey}{finished} + $scans{$scankey}{stopped} + $scans{$scankey}{uninstalled}; $total_total += $total; $total_running += $scans{$scankey}{running}; $total_finished += $scans{$scankey}{finished}; $total_paused += $scans{$scankey}{stopped}; $total_uninstalled += $scans{$scankey}{uninstalled}; print "\n"; print "\n"; print "\n"; # Finished if( $scans{$scankey}{finished} == 0 ) { print "\n"; } else { print "\n"; } # Running if( $scans{$scankey}{running} == 0 ) { print "\n"; } else { print "\n"; } # Paused if( $scans{$scankey}{stopped} == 0 ) { print "\n"; } else { print "\n"; } # Uninstalled if( $scans{$scankey}{uninstalled} == 0 ) { print "\n"; } else { print "\n"; } # total print "\n"; if( $total eq $scans{$scankey}{finished} ) { print "\n"; print "\n"; print "\n"; } else { # pause if( $scans{$scankey}{running} > 0 ) { print "\n"; } else { print "\n"; } # resume if( $scans{$scankey}{stopped} > 0 ) { print "\n"; } else { print "\n"; } # uninstall my $stopped_and_running = $scans{$scankey}{stopped} + $scans{$scankey}{running}; if( $stopped_and_running > 0 ) { print "\n"; } else { print "\n"; } } print "\n"; } } print "\n"; print "\n"; print "
    DetailsScan nameScan typeFinishedRunningPausedUninstalledTotalPauseResumeKill
    $scankey$scans{$scankey}{scantype}0$scans{$scankey}{finished}0$scans{$scankey}{running}0$scans{$scankey}{stopped}0$scans{$scankey}{uninstalled}$totalN/AN/AN/APause $scans{$scankey}{running} ScansN/AResume $scans{$scankey}{stopped} ScansN/AUninstall $stopped_and_running ScansN/A
    Total$total_finished$total_running$total_paused$total_uninstalled$total_total
    \n"; } if( $win_share_count > 0 ) { my $total_finished = $total_running = $total_paused = $total_uninstalled = $total_total = 0; print "
    \n"; print "\n"; print "\n"; foreach my $scankey( sort( keys( %scans ))) { if( $scans{$scankey}{scantype} eq "win_share" ) { my $total = $scans{$scankey}{running} + $scans{$scankey}{finished} + $scans{$scankey}{stopped} + $scans{$scankey}{uninstalled}; $total_total += $total; $total_running += $scans{$scankey}{running}; $total_finished += $scans{$scankey}{finished}; $total_paused += $scans{$scankey}{stopped}; $total_uninstalled += $scans{$scankey}{uninstalled}; print "\n"; print "\n"; print "\n"; # Finished if( $scans{$scankey}{finished} == 0 ) { print "\n"; } else { print "\n"; } # Running if( $scans{$scankey}{running} == 0 ) { print "\n"; } else { print "\n"; } # Paused if( $scans{$scankey}{stopped} == 0 ) { print "\n"; } else { print "\n"; } # Uninstalled if( $scans{$scankey}{uninstalled} == 0 ) { print "\n"; } else { print "\n"; } # total print "\n"; if( $total eq $scans{$scankey}{finished} ) { print "\n"; print "\n"; print "\n"; } else { # pause if( $scans{$scankey}{running} > 0 ) { print "\n"; } else { print "\n"; } # resume if( $scans{$scankey}{stopped} > 0 ) { print "\n"; } else { print "\n"; } # uninstall my $stopped_and_running = $scans{$scankey}{stopped} + $scans{$scankey}{running}; if( $stopped_and_running > 0 ) { print "\n"; } else { print "\n"; } } print "\n"; } } print "\n"; print "\n"; print "
    DetailsScan nameScan typeFinishedRunningPausedUninstalledTotalPauseResumeKill
    $scankey$scans{$scankey}{scantype}0$scans{$scankey}{finished}0$scans{$scankey}{running}0$scans{$scankey}{stopped}0$scans{$scankey}{uninstalled}$totalN/AN/AN/APause $scans{$scankey}{running} ScansN/AResume $scans{$scankey}{stopped} ScansN/AUninstall $stopped_and_running ScansN/A
    Total$total_finished$total_running$total_paused$total_uninstalled$total_total
    \n"; } if( $unix_agentless_count > 0 ) { my $total_finished = $total_running = $total_paused = $total_uninstalled = $total_total = 0; print "
    \n"; print "\n"; print "\n"; foreach my $scankey( sort( keys( %scans ))) { if( $scans{$scankey}{scantype} eq "unix_agentless" ) { my $total = $scans{$scankey}{running} + $scans{$scankey}{finished} + $scans{$scankey}{stopped} + $scans{$scankey}{uninstalled}; $total_total += $total; $total_running += $scans{$scankey}{running}; $total_finished += $scans{$scankey}{finished}; $total_paused += $scans{$scankey}{stopped}; $total_uninstalled += $scans{$scankey}{uninstalled}; print "\n"; print "\n"; print "\n"; # Finished if( $scans{$scankey}{finished} == 0 ) { print "\n"; } else { print "\n"; } # Running if( $scans{$scankey}{running} == 0 ) { print "\n"; } else { print "\n"; } # Paused if( $scans{$scankey}{stopped} == 0 ) { print "\n"; } else { print "\n"; } # Uninstalled if( $scans{$scankey}{uninstalled} == 0 ) { print "\n"; } else { print "\n"; } # total print "\n"; if( $total eq $scans{$scankey}{finished} ) { print "\n"; print "\n"; print "\n"; } else { # pause if( $scans{$scankey}{running} > 0 ) { print "\n"; } else { print "\n"; } # resume if( $scans{$scankey}{stopped} > 0 ) { print "\n"; } else { print "\n"; } # uninstall my $stopped_and_running = $scans{$scankey}{stopped} + $scans{$scankey}{running}; if( $stopped_and_running > 0 ) { print "\n"; } else { print "\n"; } } print "\n"; } } print "\n"; print "\n"; print "
    DetailsScan nameScan typeFinishedRunningPausedUninstalledTotalPauseResumeKill
    $scankey$scans{$scankey}{scantype}0$scans{$scankey}{finished}0$scans{$scankey}{running}0$scans{$scankey}{stopped}0$scans{$scankey}{uninstalled}$totalN/AN/AN/APause $scans{$scankey}{running} ScansN/AResume $scans{$scankey}{stopped} ScansN/AUninstall $stopped_and_running ScansN/A
    Total$total_finished$total_running$total_paused$total_uninstalled$total_total
    \n"; } if( $db_count > 0 ) { my $total_finished = $total_running = $total_paused = $total_uninstalled = $total_total = 0; print "
    \n"; print "\n"; print "\n"; foreach my $scankey( sort( keys( %scans ))) { if( $scans{$scankey}{scantype} =~ /^(mssql_agentless|mysql_agentless|oracle_agentless)$/ ) { my $total = $scans{$scankey}{running} + $scans{$scankey}{finished} + $scans{$scankey}{stopped} + $scans{$scankey}{uninstalled}; $total_total += $total; $total_running += $scans{$scankey}{running}; $total_finished += $scans{$scankey}{finished}; $total_paused += $scans{$scankey}{stopped}; $total_uninstalled += $scans{$scankey}{uninstalled}; print "\n"; print "\n"; print "\n"; # Finished if( $scans{$scankey}{finished} == 0 ) { print "\n"; } else { print "\n"; } # Running if( $scans{$scankey}{running} == 0 ) { print "\n"; } else { print "\n"; } # Paused if( $scans{$scankey}{stopped} == 0 ) { print "\n"; } else { print "\n"; } # killed if( $scans{$scankey}{uninstalled} == 0 ) { print "\n"; } else { print "\n"; } # total print "\n"; if( $total eq $scans{$scankey}{finished} ) { print "\n"; print "\n"; print "\n"; } else { # pause if( $scans{$scankey}{running} > 0 ) { print "\n"; } else { print "\n"; } # resume if( $scans{$scankey}{stopped} > 0 ) { print "\n"; } else { print "\n"; } # uninstall my $stopped_and_running = $scans{$scankey}{stopped} + $scans{$scankey}{running}; if( $stopped_and_running > 0 ) { print "\n"; } else { print "\n"; } } print "\n"; } } print "\n"; print "\n"; print "
    DetailsScan nameScan typeFinishedRunningPausedKilledTotalPauseResumeKill
    $scankey$scans{$scankey}{scantype}0$scans{$scankey}{finished}0$scans{$scankey}{running}0$scans{$scankey}{stopped}0$scans{$scankey}{uninstalled}$totalN/AN/AN/APause $scans{$scankey}{running} ScansN/AResume $scans{$scankey}{stopped} ScansN/AUninstall $stopped_and_running ScansN/A
    Total$total_finished$total_running$total_paused$total_uninstalled$total_total
    \n"; } $sth->finish(); $dbh->disconnect(); } ####################################################### # if scanname is given as an argument, but not system # ####################################################### elsif( $scanname ne "" && $system eq "" ) { my $scantype = ""; my $dbh = DBI->connect("DBI:mysql:database=OpenDLP;host=localhost",$db_username,$db_password); my $string = "SELECT DISTINCT tracker,system,ip,status,filestotal,filesdone,bytestotal,bytesdone,updated,control,scantype,pid,dbtotal,dbdone,tabletotal,tabledone,columntotal,columndone FROM systems WHERE scan=?"; my $sth = $dbh->prepare( $string ); $sth->execute( $scanname ); while( my $results = $sth->fetchrow_arrayref() ) { $system{$$results[0]}{system} = $$results[1]; $system{$$results[0]}{ip} = $$results[2]; $system{$$results[0]}{status} = $$results[3]; $system{$$results[0]}{filestotal} = $$results[4]; $system{$$results[0]}{filesdone} = $$results[5]; $system{$$results[0]}{bytestotal} = $$results[6]; $system{$$results[0]}{bytesdone} = $$results[7]; $system{$$results[0]}{updated} = $$results[8]; $system{$$results[0]}{control} = $$results[9]; $scantype = $$results[10]; $system{$$results[0]}{pid} = $$results[11]; $system{$$results[0]}{dbtotal} = $$results[12]; $system{$$results[0]}{dbdone} = $$results[13]; $system{$$results[0]}{tabletotal} = $$results[14]; $system{$$results[0]}{tabledone} = $$results[15]; $system{$$results[0]}{columntotal} = $$results[16]; $system{$$results[0]}{columndone} = $$results[17]; } $sth->finish(); if( $scantype eq "win_agent" ) { print "Select a system to view its results for scan \"$scanname\":

    \n"; print "
    \n"; print "\n"; print "\n"; print "\n"; foreach my $tracking( sort( keys( %system ))) { my $string = "SELECT COUNT(*) FROM results WHERE scan=? AND tracker=?"; $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $tracking ); my $results = $sth->fetchrow_arrayref(); $system{$tracking}{count} = $$results[0]; $sth->finish(); print "\n\n"; print "\n"; print "\n"; print "\n"; if( $system{$tracking}{status} == -1 ) { print "\n"; } elsif( $system{$tracking}{status} == 0 ) { print "\n"; } elsif( $system{$tracking}{status} == 1 ) { print "\n"; } elsif( $system{$tracking}{status} == 2 ) { print "\n"; } elsif( $system{$tracking}{status} == 3 ) { print "\n"; } if( $system{$tracking}{filesdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{filestotal} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{bytesdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{bytestotal} ne "" ) { print "\n"; } else { print "\n"; } my $time = localtime( $system{$tracking}{updated} ); my $currenttime = time(); my $time_diff = $currenttime - $system{$tracking}{updated}; my $hours = floor($time_diff / 3600); my $leftovers = $time_diff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $time_diff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "\n"; print "\n"; # pause if( $system{$tracking}{control} eq "running" ) { print "\n"; } else { print "\n"; } # resume if( $system{$tracking}{control} eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall if( $system{$tracking}{control} =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; } print "

    Network nameIP addressStatusStepFiles doneTotal filesBytes doneTotal bytesUpdatedFindingsPauseResumeUninstall
    $system{$tracking}{system}$system{$tracking}{ip}$system{$tracking}{control}-1: Deploying0: All files1: Whitelisting2: Scanning3: Done" . commify($system{$tracking}{filesdone}) . "N/A" . commify($system{$tracking}{filestotal}) . "N/A" . commify($system{$tracking}{bytesdone}) . "N/A" . commify($system{$tracking}{bytestotal}) . "N/A$hours:$minutes:$seconds ago$system{$tracking}{count}PauseN/AResumeN/AUninstallN/A

    \n"; my $rounded = ""; if( $system{$tracking}{status} > 1 ) { if( $system{$tracking}{status} != 3 ) { my $percent = 100 * $system{$tracking}{bytesdone} / $system{$tracking}{bytestotal}; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    "; if( $system{$tracking}{status} > 1 ) { print "$rounded\% done"; if( $system{$tracking}{status} != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $tracking ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print ", approx $hours:$minutes:$seconds remaining"; } } else { print "
    \n"; } print "
    \n"; } elsif( $scantype eq "win_agentless" ) { print "Select a system to view its results for scan \"$scanname\":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; foreach my $tracking( sort( keys( %system ))) { my $string = "SELECT COUNT(*) FROM results WHERE scan=? AND tracker=?"; $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $tracking ); my $results = $sth->fetchrow_arrayref(); $system{$tracking}{count} = $$results[0]; $sth->finish(); print "\n\n"; print "\n"; print "\n"; print "\n"; if( $system{$tracking}{status} == -1 ) { print "\n"; } elsif( $system{$tracking}{status} == 0 ) { print "\n"; } elsif( $system{$tracking}{status} == 1 ) { print "\n"; } elsif( $system{$tracking}{status} == 2 ) { print "\n"; } elsif( $system{$tracking}{status} == 3 ) { print "\n"; } if( $system{$tracking}{filesdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{filestotal} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{bytesdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{bytestotal} ne "" ) { print "\n"; } else { print "\n"; } my $time = localtime( $system{$tracking}{updated} ); my $currenttime = time(); my $time_diff = $currenttime - $system{$tracking}{updated}; my $hours = floor($time_diff / 3600); my $leftovers = $time_diff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $time_diff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "\n"; print "\n"; # pause if( $system{$tracking}{control} eq "running" ) { print "\n"; } else { print "\n"; } # resume if( $system{$tracking}{control} eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall if( $system{$tracking}{control} =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; } print "

    Network nameIP addressStatusStepFiles doneTotal filesBytes doneTotal bytesUpdatedFindingsPauseResumeKill
    $system{$tracking}{system}$system{$tracking}{ip}$system{$tracking}{control}-1: Deploying0: All files1: Whitelisting2: Scanning3: Done" . commify($system{$tracking}{filesdone}) . "N/A" . commify($system{$tracking}{filestotal}) . "N/A" . commify($system{$tracking}{bytesdone}) . "N/A" . commify($system{$tracking}{bytestotal}) . "N/A$hours:$minutes:$seconds ago$system{$tracking}{count}PauseN/AResumeN/AUninstallN/A

    \n"; my $rounded = ""; if( $system{$tracking}{status} > 1 ) { if( $system{$tracking}{status} != 3 ) { my $percent = 100 * $system{$tracking}{bytesdone} / $system{$tracking}{bytestotal}; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    "; if( $system{$tracking}{status} > 1 ) { print "$rounded\% done"; if( $system{$tracking}{status} != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $tracking ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print ", approx $hours:$minutes:$seconds remaining"; } } else { print "
    \n"; } print "
    \n"; } elsif( $scantype eq "win_share" ) { print "Select a system to view its results for scan \"$scanname\":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; foreach my $tracking( sort( keys( %system ))) { my $string = "SELECT COUNT(*) FROM results WHERE scan=? AND tracker=?"; $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $tracking ); my $results = $sth->fetchrow_arrayref(); $system{$tracking}{count} = $$results[0]; $sth->finish(); print "\n\n"; print "\n"; print "\n"; print "\n"; if( $system{$tracking}{status} == -1 ) { print "\n"; } elsif( $system{$tracking}{status} == 0 ) { print "\n"; } elsif( $system{$tracking}{status} == 1 ) { print "\n"; } elsif( $system{$tracking}{status} == 2 ) { print "\n"; } elsif( $system{$tracking}{status} == 3 ) { print "\n"; } if( $system{$tracking}{filesdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{filestotal} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{bytesdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{bytestotal} ne "" ) { print "\n"; } else { print "\n"; } my $time = localtime( $system{$tracking}{updated} ); my $currenttime = time(); my $time_diff = $currenttime - $system{$tracking}{updated}; my $hours = floor($time_diff / 3600); my $leftovers = $time_diff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $time_diff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "\n"; print "\n"; # pause if( $system{$tracking}{control} eq "running" ) { print "\n"; } else { print "\n"; } # resume if( $system{$tracking}{control} eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall if( $system{$tracking}{control} =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; } print "

    Network nameIP addressStatusStepFiles doneTotal filesBytes doneTotal bytesUpdatedFindingsPauseResumeKill
    $system{$tracking}{system}$system{$tracking}{ip}$system{$tracking}{control}-1: Deploying0: All files1: Whitelisting2: Scanning3: Done" . commify($system{$tracking}{filesdone}) . "N/A" . commify($system{$tracking}{filestotal}) . "N/A" . commify($system{$tracking}{bytesdone}) . "N/A" . commify($system{$tracking}{bytestotal}) . "N/A$hours:$minutes:$seconds ago$system{$tracking}{count}PauseN/AResumeN/AUninstallN/A

    \n"; my $rounded = ""; if( $system{$tracking}{status} > 1 ) { if( $system{$tracking}{status} != 3 ) { my $percent = 100 * $system{$tracking}{bytesdone} / $system{$tracking}{bytestotal}; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    "; if( $system{$tracking}{status} > 1 ) { print "$rounded\% done"; if( $system{$tracking}{status} != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $tracking ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print ", approx $hours:$minutes:$seconds remaining"; } } else { print "
    \n"; } print "
    \n"; } elsif( $scantype eq "unix_agentless" ) { print "Select a system to view its results for scan \"$scanname\":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; foreach my $tracking( sort( keys( %system ))) { my $string = "SELECT COUNT(*) FROM results WHERE scan=? AND tracker=?"; $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $tracking ); my $results = $sth->fetchrow_arrayref(); $system{$tracking}{count} = $$results[0]; $sth->finish(); print "\n\n"; print "\n"; print "\n"; print "\n"; if( $system{$tracking}{status} == -1 ) { print "\n"; } elsif( $system{$tracking}{status} == 0 ) { print "\n"; } elsif( $system{$tracking}{status} == 1 ) { print "\n"; } elsif( $system{$tracking}{status} == 2 ) { print "\n"; } elsif( $system{$tracking}{status} == 3 ) { print "\n"; } if( $system{$tracking}{filesdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{filestotal} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{bytesdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{bytestotal} ne "" ) { print "\n"; } else { print "\n"; } my $time = localtime( $system{$tracking}{updated} ); my $currenttime = time(); my $time_diff = $currenttime - $system{$tracking}{updated}; my $hours = floor($time_diff / 3600); my $leftovers = $time_diff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $time_diff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "\n"; print "\n"; # pause if( $system{$tracking}{control} eq "running" ) { print "\n"; } else { print "\n"; } # resume if( $system{$tracking}{control} eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall if( $system{$tracking}{control} =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; } print "

    Network nameIP addressStatusStepFiles doneTotal filesBytes doneTotal bytesUpdatedFindingsPauseResumeKill
    $system{$tracking}{system}$system{$tracking}{ip}$system{$tracking}{control}-1: Deploying0: All files1: Whitelisting2: Scanning3: Done" . commify($system{$tracking}{filesdone}) . "N/A" . commify($system{$tracking}{filestotal}) . "N/A" . commify($system{$tracking}{bytesdone}) . "N/A" . commify($system{$tracking}{bytestotal}) . "N/A$hours:$minutes:$seconds ago$system{$tracking}{count}PauseN/AResumeN/AUninstallN/A

    \n"; my $rounded = ""; if( $system{$tracking}{status} > 1 ) { if( $system{$tracking}{status} != 3 ) { my $percent = 100 * $system{$tracking}{bytesdone} / $system{$tracking}{bytestotal}; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    "; if( $system{$tracking}{status} > 1 ) { print "$rounded\% done"; if( $system{$tracking}{status} != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $tracking ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print ", approx $hours:$minutes:$seconds remaining"; } } else { print "
    \n"; } print "
    \n"; } elsif( $scantype =~ /^(mssql_agentless|mysql_agentless|oracle_agentless)$/ ) { print "Select a database to view its results for scan \"$scanname\":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; foreach my $tracking( sort( keys( %system ))) { my $string = "SELECT COUNT(*) FROM results WHERE scan=? AND tracker=?"; $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $tracking ); my $results = $sth->fetchrow_arrayref(); $system{$tracking}{count} = $$results[0]; $sth->finish(); print "\n\n"; print "\n"; print "\n"; if( $system{$tracking}{status} == -1 ) { print "\n"; } elsif( $system{$tracking}{status} == 0 ) { print "\n"; } elsif( $system{$tracking}{status} == 1 ) { print "\n"; } elsif( $system{$tracking}{status} == 2 ) { print "\n"; } elsif( $system{$tracking}{status} == 3 ) { print "\n"; } if( $system{$tracking}{dbdone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{dbtotal} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{tabledone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{tabletotal} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{columndone} ne "" ) { print "\n"; } else { print "\n"; } if( $system{$tracking}{columntotal} ne "" ) { print "\n"; } else { print "\n"; } my $time = localtime( $system{$tracking}{updated} ); my $currenttime = time(); my $time_diff = $currenttime - $system{$tracking}{updated}; my $hours = floor($time_diff / 3600); my $leftovers = $time_diff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $time_diff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "\n"; print "\n"; # pause if( $system{$tracking}{control} eq "running" ) { print "\n"; } else { print "\n"; } # resume if( $system{$tracking}{control} eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall if( $system{$tracking}{control} =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; } print "

    IP addressStatusStepDatabases doneTotal databasesTables doneTotal tablesColumns doneTotal columnsUpdatedFindingsPauseResumeUninstall
    $system{$tracking}{ip}$system{$tracking}{control}-1: Deploying0: All files1: Whitelisting2: Scanning3: Done" . commify($system{$tracking}{dbdone}) . "N/A" . commify($system{$tracking}{dbtotal}) . "N/A" . commify($system{$tracking}{tabledone}) . "N/A" . commify($system{$tracking}{tabletotal}) . "N/A" . commify($system{$tracking}{columndone}) . "N/A" . commify($system{$tracking}{columntotal}) . "N/A$hours:$minutes:$seconds ago$system{$tracking}{count}PauseN/AResumeN/AUninstallN/A

    \n"; my $rounded = ""; if( $system{$tracking}{status} > 1 ) { if( $system{$tracking}{status} != 3 ) { my $percent = 100 * $system{$tracking}{columndone} / $system{$tracking}{columntotal}; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    "; if( $system{$tracking}{status} > 1 ) { print "$rounded\% done"; if( $system{$tracking}{status} != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $tracking ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print ", approx $hours:$minutes:$seconds remaining"; } } else { print "
    \n"; } print "
    \n"; } $dbh->disconnect(); } ###################################### # look at details of specific system # ###################################### elsif( $scanname ne "" && $system ne "" ) { my $dbh = DBI->connect("DBI:mysql:database=OpenDLP;host=localhost",$db_username,$db_password); my $string = "SELECT system,ip,status,filestotal,filesdone,bytestotal,bytesdone,updated,profile,control,scantype,pid,dbtotal,dbdone,tabletotal,tabledone,columntotal,columndone FROM systems WHERE scan=? AND tracker=?"; my $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $system ); my $results = $sth->fetchrow_arrayref(); my $hostname = $$results[0]; my $ip = $$results[1]; my $status = $$results[2]; my $filestotal = $$results[3]; my $filesdone = $$results[4]; my $bytestotal = $$results[5]; my $bytesdone = $$results[6]; my $updated = $$results[7]; my $profile = $$results[8]; my $control = $$results[9]; $scantype = $$results[10]; my $pid = $$results[11]; my $dbtotal = $$results[12]; my $dbdone = $$results[13]; my $tabletotal = $$results[14]; my $tabledone = $$results[15]; my $columntotal = $$results[16]; my $columndone = $$results[17]; $sth->finish(); my $string = "SELECT COUNT(*) FROM results WHERE scan=? AND tracker=?"; $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $system ); my $results = $sth->fetchrow_arrayref(); my $total = $$results[0]; $sth->finish(); my $string = "SELECT COUNT(*) FROM results WHERE scan=? AND tracker=? AND is_false=\"1\""; $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $system ); my $results = $sth->fetchrow_arrayref(); my $fp_count = $$results[0]; $sth->finish(); if( $scantype eq "win_agent" ) { print "Results for $ip"; if( $hostname ne "" ) { print " ($hostname)"; } print ":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if( $filesdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $filestotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $bytesdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $bytestotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $diff = $total - $fp_count; print "\n"; my $currenttime = time(); my $updatedtime = localtime( $updated ); my $timediff = $currenttime - $updated; print "\n"; # pause print "\n"; if( $control eq "running" ) { print "\n"; } else { print "\n"; } # resume print "\n"; if( $control eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall print "\n"; if( $control =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "
    Profile$profile
    Status$control
    Step\n"; if( $status == -1 ) { print "-1: Deploying\n"; } elsif( $status == 0 ) { print "0: All files\n"; } elsif( $status == 1 ) { print "1: Whitelisting\n"; } elsif( $status == 2 ) { print "2: Scanning\n"; } elsif( $status == 3 ) { print "3: Done\n"; } print "
    Files Done" . commify($filesdone) . "
    N/A
    Files Total" . commify($filestotal) . "
    N/A
    Bytes Done" . commify($bytesdone) . "
    N/A
    Bytes Total" . commify($bytestotal) . "
    N/A
    Progress\n"; my $rounded = ""; if( $status > 1 ) { if( $status != 3 ) { my $percent = 100 * $bytesdone / $bytestotal; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    Percentage\n"; if( $status > 1 ) { if( $status != 3 ) { print $rounded; } else { print "100"; } print "\%"; } else { print "
    "; } print "
    Completion Time"; if( $status > 1 ) { if( $status != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $system ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "Approx $hours:$minutes:$seconds remaining"; } else { print "
    "; } } else { print "
    "; } print "
    Total Findings$total
    False Positives$fp_count
    Valid Findings$diff
    Updated"; my $hours = floor($timediff / 3600); my $leftovers = $timediff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $timediff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "$hours:$minutes:$seconds ago
    PausePause
    N/A
    ResumeResume
    N/A
    Stop and UninstallUninstall
    N/A


    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $string = "SELECT DISTINCT type,pattern,file,offset,md5,number,is_false FROM results WHERE scan=? AND tracker=? AND is_false != \"1\" ORDER BY number"; my $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $system ); my $row_counter = 1; while( my $results = $sth->fetchrow_arrayref() ) { my $type = $$results[0]; my $pattern = $$results[1]; my $file = $$results[2]; my $offset = $$results[3]; my $md5 = $$results[4]; my $number = $$results[5]; print "\n"; $row_counter++; print "\n"; my $pattern_copy = replacechars( $pattern ); print "\n"; my $file_printme = $file; $file_printme =~ s/\\\\/\\/g; $file_printme = replacechars( $file_printme ); my $encode_file = encode_base64( $file ); $encode_file =~ s/\n//g; my $encode_ip = encode_base64( $ip ); $encode_ip =~ s/\n//g; my $encode_profile = encode_base64( $profile ); $encode_profile =~ s/\n//g; print "\n"; print "\n"; print "\n\n"; # make a fancy false positive interface in the next release # print "\n"; } print "\n"; print "
    #RegexPatternFile (click to download)Byte offsetFalse?
    $row_counter$type$pattern_copy$file_printme$offset
    \n"; } elsif( $scantype eq "win_agentless" ) { print "Results for $ip"; if( $hostname ne "" ) { print " ($hostname)"; } print ":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if( $filesdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $filestotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $bytesdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $bytestotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $diff = $total - $fp_count; print "\n"; my $currenttime = time(); my $updatedtime = localtime( $updated ); my $timediff = $currenttime - $updated; print "\n"; # pause print "\n"; if( $control eq "running" ) { print "\n"; } else { print "\n"; } # resume print "\n"; if( $control eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall print "\n"; if( $control =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "
    Profile$profile
    Status$control
    Step\n"; if( $status == -1 ) { print "-1: Deploying\n"; } elsif( $status == 0 ) { print "0: All files\n"; } elsif( $status == 1 ) { print "1: Whitelisting\n"; } elsif( $status == 2 ) { print "2: Scanning\n"; } elsif( $status == 3 ) { print "3: Done\n"; } print "
    Files Done" . commify($filesdone) . "
    N/A
    Files Total" . commify($filestotal) . "
    N/A
    Bytes Done" . commify($bytesdone) . "
    N/A
    Bytes Total" . commify($bytestotal) . "
    N/A
    Progress\n"; my $rounded = ""; if( $status > 1 ) { if( $status != 3 ) { my $percent = 100 * $bytesdone / $bytestotal; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    Percentage\n"; if( $status > 1 ) { if( $status != 3 ) { print $rounded; } else { print "100"; } print "\%"; } else { print "
    "; } print "
    Completion Time"; if( $status > 1 ) { if( $status != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $system ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "Approx $hours:$minutes:$seconds remaining"; } else { print "
    "; } } else { print "
    "; } print "
    Total Findings$total
    False Positives$fp_count
    Valid Findings$diff
    Updated"; my $hours = floor($timediff / 3600); my $leftovers = $timediff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $timediff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "$hours:$minutes:$seconds ago
    PausePause
    N/A
    ResumeResume
    N/A
    KillUninstall
    N/A


    \n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $string = "SELECT DISTINCT type,pattern,file,offset,md5,number,is_false FROM results WHERE scan=? AND tracker=? AND is_false != \"1\" ORDER BY number"; my $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $system ); my $row_counter = 1; while( my $results = $sth->fetchrow_arrayref() ) { my $type = $$results[0]; my $pattern = $$results[1]; my $file = $$results[2]; my $offset = $$results[3]; my $md5 = $$results[4]; my $number = $$results[5]; print "\n"; $row_counter++; print "\n"; my $pattern_copy = replacechars( $pattern ); print "\n"; my $file_printme = $file; $file_printme =~ s/\\\\/\\/g; $file_printme = replacechars( $file_printme ); my $encode_file = encode_base64( $file ); $encode_file =~ s/\n//g; my $encode_ip = encode_base64( $ip ); $encode_ip =~ s/\n//g; my $encode_profile = encode_base64( $profile ); $encode_profile =~ s/\n//g; print "\n"; print "\n"; print "\n\n"; # make a fancy false positive interface in the next release # print "\n"; } print "\n"; print "
    #RegexPatternFile (click to download)Byte offsetFalse?
    $row_counter$type$pattern_copy$file_printme$offset
    \n"; } elsif( $scantype eq "win_share" ) { print "Results for " . replacechars($ip); if( $hostname ne "" ) { print " ($hostname)"; } print ":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if( $filesdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $filestotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $bytesdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $bytestotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $diff = $total - $fp_count; print "\n"; my $currenttime = time(); my $updatedtime = localtime( $updated ); my $timediff = $currenttime - $updated; print "\n"; # pause print "\n"; if( $control eq "running" ) { print "\n"; } else { print "\n"; } # resume print "\n"; if( $control eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall print "\n"; if( $control =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "
    Profile$profile
    Status$control
    Step\n"; if( $status == -1 ) { print "-1: Deploying\n"; } elsif( $status == 0 ) { print "0: All files\n"; } elsif( $status == 1 ) { print "1: Whitelisting\n"; } elsif( $status == 2 ) { print "2: Scanning\n"; } elsif( $status == 3 ) { print "3: Done\n"; } print "
    Files Done" . commify($filesdone) . "
    N/A
    Files Total" . commify($filestotal) . "
    N/A
    Bytes Done" . commify($bytesdone) . "
    N/A
    Bytes Total" . commify($bytestotal) . "
    N/A
    Progress\n"; my $rounded = ""; if( $status > 1 ) { if( $status != 3 ) { my $percent = 100 * $bytesdone / $bytestotal; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    Percentage\n"; if( $status > 1 ) { if( $status != 3 ) { print $rounded; } else { print "100"; } print "\%"; } else { print "
    "; } print "
    Completion Time"; if( $status > 1 ) { if( $status != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $system ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "Approx $hours:$minutes:$seconds remaining"; } else { print "
    "; } } else { print "
    "; } print "
    Total Findings$total
    False Positives$fp_count
    Valid Findings$diff
    Updated"; my $hours = floor($timediff / 3600); my $leftovers = $timediff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $timediff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "$hours:$minutes:$seconds ago
    PausePause
    N/A
    ResumeResume
    N/A
    KillUninstall
    N/A


    \n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $string = "SELECT DISTINCT type,pattern,file,offset,md5,number,is_false FROM results WHERE scan=? AND tracker=? AND is_false != \"1\" ORDER BY number"; my $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $system ); my $row_counter = 1; while( my $results = $sth->fetchrow_arrayref() ) { my $type = $$results[0]; my $pattern = $$results[1]; my $file = $$results[2]; my $offset = $$results[3]; my $md5 = $$results[4]; my $number = $$results[5]; print "\n"; $row_counter++; print "\n"; my $pattern_copy = replacechars( $pattern ); print "\n"; my $file_printme = $file; $file_printme =~ s/\\\\/\\/g; $file_printme = replacechars( $file_printme ); my $encode_file = encode_base64( $file ); $encode_file =~ s/\n//g; my $encode_ip = encode_base64( $ip ); $encode_ip =~ s/\n//g; my $encode_profile = encode_base64( $profile ); $encode_profile =~ s/\n//g; print "\n"; print "\n"; print "\n\n"; # make a fancy false positive interface in the next release # print "\n"; } print "\n"; print "
    #RegexPatternFile (click to download)Byte offsetFalse?
    $row_counter$type$pattern_copy$file_printme$offset
    \n"; } elsif( $scantype eq "unix_agentless" ) { print "Results for $ip"; if( $hostname ne "" ) { print " ($hostname)"; } print ":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if( $filesdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $filestotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $bytesdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $bytestotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $diff = $total - $fp_count; print "\n"; my $currenttime = time(); my $updatedtime = localtime( $updated ); my $timediff = $currenttime - $updated; print "\n"; # pause print "\n"; if( $control eq "running" ) { print "\n"; } else { print "\n"; } # resume print "\n"; if( $control eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall print "\n"; if( $control =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "
    Profile$profile
    Status$control
    Step\n"; if( $status == -1 ) { print "-1: Deploying\n"; } elsif( $status == 0 ) { print "0: All files\n"; } elsif( $status == 1 ) { print "1: Whitelisting\n"; } elsif( $status == 2 ) { print "2: Scanning\n"; } elsif( $status == 3 ) { print "3: Done\n"; } print "
    Files Done" . commify($filesdone) . "
    N/A
    Files Total" . commify($filestotal) . "
    N/A
    Bytes Done" . commify($bytesdone) . "
    N/A
    Bytes Total" . commify($bytestotal) . "
    N/A
    Progress\n"; my $rounded = ""; if( $status > 1 ) { if( $status != 3 ) { my $percent = 100 * $bytesdone / $bytestotal; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    Percentage\n"; if( $status > 1 ) { if( $status != 3 ) { print $rounded; } else { print "100"; } print "\%"; } else { print "
    "; } print "
    Completion Time"; if( $status > 1 ) { if( $status != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $system ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "Approx $hours:$minutes:$seconds remaining"; } else { print "
    "; } } else { print "
    "; } print "
    Total Findings$total
    False Positives$fp_count
    Valid Findings$diff
    Updated"; my $hours = floor($timediff / 3600); my $leftovers = $timediff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $timediff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "$hours:$minutes:$seconds ago
    PausePause
    N/A
    ResumeResume
    N/A
    KillUninstall
    N/A


    \n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $string = "SELECT DISTINCT type,pattern,file,offset,md5,number,is_false FROM results WHERE scan=? AND tracker=? AND is_false != \"1\" ORDER BY number"; my $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $system ); my $row_counter = 1; while( my $results = $sth->fetchrow_arrayref() ) { my $type = $$results[0]; my $pattern = $$results[1]; my $file = $$results[2]; my $offset = $$results[3]; my $md5 = $$results[4]; my $number = $$results[5]; print "\n"; $row_counter++; print "\n"; my $pattern_copy = replacechars( $pattern ); print "\n"; my $file_printme = $file; $file_printme =~ s/\\\\/\\/g; $file_printme = replacechars( $file_printme ); my $encode_file = encode_base64( $file ); $encode_file =~ s/\n//g; my $encode_ip = encode_base64( $ip ); $encode_ip =~ s/\n//g; my $encode_profile = encode_base64( $profile ); $encode_profile =~ s/\n//g; print "\n"; print "\n"; print "\n\n"; # make a fancy false positive interface in the next release # print "\n"; } print "\n"; print "
    #RegexPatternFile (click to download)Byte offsetFalse?
    $row_counter$type$pattern_copy$file_printme$offset
    \n"; } ############# # databases # ############# elsif( $scantype =~ /^(mssql_agentless|mysql_agentless|oracle_agentless)$/ ) { print "Results for database server $ip"; if( $hostname ne "" ) { print " ($hostname)"; } print ":

    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if( $dbdone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $dbtotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $tabledone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $tabletotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $columndone ne "" ) { print "\n"; } else { print "\n"; } print "\n"; if( $columntotal ne "" ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $diff = $total - $fp_count; print "\n"; my $currenttime = time(); my $updatedtime = localtime( $updated ); my $timediff = $currenttime - $updated; print "\n"; # pause print "\n"; if( $control eq "running" ) { print "\n"; } else { print "\n"; } # resume print "\n"; if( $control eq "stopped" ) { print "\n"; } else { print "\n"; } # uninstall print "\n"; if( $control =~ /^(stopped|running)$/i ) { print "\n"; } else { print "\n"; } print "
    Profile$profile
    Status$control
    Step\n"; if( $status == -1 ) { print "-1: Deploying\n"; } elsif( $status == 0 ) { print "0: All files\n"; } elsif( $status == 1 ) { print "1: Whitelisting\n"; } elsif( $status == 2 ) { print "2: Scanning\n"; } elsif( $status == 3 ) { print "3: Done\n"; } print "
    Databases Done" . commify($dbdone) . "
    N/A
    Databases Total" . commify($dbtotal) . "
    N/A
    Tables Done" . commify($tabledone) . "
    N/A
    Tables Total" . commify($tabletotal) . "
    N/A
    Columns Done" . commify($columndone) . "
    N/A
    Columns Total" . commify($columntotal) . "
    N/A
    Progress\n"; my $rounded = ""; if( $status > 1 ) { if( $status != 3 ) { my $percent = 100 * $columndone / $columntotal; $rounded = sprintf( "%.2f", $percent ); } else { $rounded = "100"; } my $width = 2 * $rounded; $width = floor( $width ); print "
    \n"; print "\n"; print "
    \n"; } else { print "
    "; } print "
    Percentage\n"; if( $status > 1 ) { if( $status != 3 ) { print $rounded; } else { print "100"; } print "\%"; } else { print "
    "; } print "
    Completion Time"; if( $status > 1 ) { if( $status != 3 ) { my $string = "SELECT updated FROM logs WHERE tracker=? ORDER BY updated LIMIT 1"; $sth = $dbh->prepare( $string ); $sth->execute( $system ); my $results = $sth->fetchrow_arrayref(); my $starttime = $$results[0]; $sth->finish(); my $currenttime = time(); my $difftime = $currenttime - $starttime; my $eta = ($difftime / ($rounded / 100 )) - $difftime; $eta = floor( $eta ); my $hours = floor( $eta / 3600 ); my $leftovers = $eta % 3600; my $minutes = floor( $leftovers / 60 ); $seconds = $eta % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "Approx $hours:$minutes:$seconds remaining"; } else { print "
    "; } } else { print "
    "; } print "
    Total Findings$total
    False Positives$fp_count
    Valid Findings$diff
    Updated"; my $hours = floor($timediff / 3600); my $leftovers = $timediff % 3600; my $minutes = floor($leftovers / 60); my $seconds = $timediff % 60; if( $hours < 10 ) { $hours = "0" . $hours; } if( $minutes < 10 ) { $minutes = "0" . $minutes; } if( $seconds < 10 ) { $seconds = "0" . $seconds; } print "$hours:$minutes:$seconds ago
    PausePause
    N/A
    ResumeResume
    N/A
    KillUninstall
    N/A


    \n"; print "
    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; my $string = "SELECT DISTINCT type,pattern,db,tbl,col,row,number,is_false FROM results WHERE scan=? AND tracker=? AND is_false != \"1\" ORDER BY number"; my $sth = $dbh->prepare( $string ); $sth->execute( $scanname, $system ); my $row_counter = 1; while( my $results = $sth->fetchrow_arrayref() ) { my $type = $$results[0]; my $pattern = $$results[1]; my $db = $$results[2]; my $tbl = $$results[3]; my $col = $$results[4]; my $row = $$results[5]; my $number = $$results[6]; print "\n"; $row_counter++; print "\n"; my $pattern_copy = replacechars( $pattern ); print "\n"; my $db_printme = replacechars( $db ); print "\n"; my $tbl_printme = replacechars( $tbl ); print "\n"; my $col_printme = replacechars( $col ); print "\n"; print "\n"; print "\n\n"; # make a fancy false positive interface in the next release # print "\n"; } print "\n"; print "
    #RegexPatternDatabaseTableColumnRowFalse?
    $row_counter$type$pattern_copy$db_printme$tbl_printme$col_printme" . commify($row) . "
    \n"; } $sth->finish(); $dbh->disconnect(); } } footer(); sub header { print "Content-type: text/html\n\n"; print "\n\n"; print "OpenDLP $version\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print qq { }; print "\n"; print "\n"; print '
    ' . "\n"; } sub footer { print "
    \n"; } sub replacechars { my $string = shift; $string =~ s/\&/\&/g; $string =~ s/\#/#/g; $string =~ s/"/"/g; $string =~ s/\%/%/g; $string =~ s/\'/'/g; $string =~ s/\////g; $string =~ s//>/g; $string =~ s/\[/[/g; $string =~ s/\\/\/g; $string =~ s/\]/]/g; $string =~ s/`/`/g; $string =~ s/{/{/g; $string =~ s/\|/|/g; $string =~ s/}/}/g; $string =~ s/\(/(/g; $string =~ s/\)/)/g; $string =~ s/\n//g; $string =~ s/\r//g; $string =~ s/\ / /g; return $string; } sub get_version { open( V, "<../etc/version" ); my $v = ; close( V ); chomp $v; return $v; } sub commify { my $input = shift; $input = reverse $input; $input =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return reverse $input; }