diff --git a/bin/m_carve.php b/bin/m_carve.php index 3e738e6..38eb6f4 100644 --- a/bin/m_carve.php +++ b/bin/m_carve.php @@ -1,8 +1,11 @@ +#!/usr/bin/php +# # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,14 +29,15 @@ function carve($start, $stop, $dir, $pre){ //tokenize start and end file name by (.) $start_token = explode(".",$start); $stop_token = explode(".",$stop); + //check to make sure file is in (prefix).(suffix) format (size 2) - if(count($start_token)!=2 or count($stop_token)!=2){ + if(count($start_token)!=3 or count($stop_token)!=3){ print "Invalid file name format, must be two strings separated by a period (eg. cxt.12345)\n"; } else{ //assign start and end timestamp - $start_tstamp = $start_token[1]; - $stop_tstamp = $stop_token[1]; + $start_tstamp = $start_token[2]; + $stop_tstamp = $stop_token[2]; //store capture directory contents into variable $dircontents = list_dir($dir,$pre); //extract since it was passed from list_dir function @@ -54,7 +58,6 @@ function carve($start, $stop, $dir, $pre){ } //sort results and return array - //print "Searched ".count($dircontents)." files and found ".count($carve_results)." matching search criteria:\n"; sort($carve_results); return $carve_results; } @@ -65,28 +68,33 @@ function list_dir($directory,$pre){ $directory = $directory; $open_directory = opendir($directory); + $valid_files=array(); while($filename = readdir($open_directory)){ $filesplit = explode(".", $filename); - $check_prefix = $filesplit[0]; - if($check_prefix==$pre){ - $valid_files[] = $filesplit[1]; + + $check_prefix = $filesplit[0] .".". $filesplit[1]; + if($check_prefix==$pre or $check_prefix == "openfpc-Default_Node.pcap"){ + $valid_files[] = $filesplit[2]; } } closedir(); return $valid_files; } + + //Takes sorted list of files, the directory they are located in and the prefix of the //file name as arguments and retrieves each file's size and stores it in an array function get_sizes($files_array,$dir,$pre){ + //var_dump($files_array); for($i=0;$i