-
-
-
-
-
+
+
+
+
+
+
+
+
+
/images/misc/progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar' alt='' />
|
-
-
-
-
-
- |
-
-
-
- |
-
+
+
+
+
+
+
+
+
+
+ |
+
+
+
\n\n", update_status(gettext("Your rules are up to date...")), update_output_window(gettext("You may start Snort now.")), hide_progress_bar_status(), exit(0);
+}
-/* multi user system, request new filename and create directory */
-$tmpfname = tempnam("/tmp", "snortRules");
-exec("/bin/rm -rf {$tmpfname};/bin/mkdir -p {$tmpfname}");
+/* echo "You are Not Up to date!\n"; */
+update_status(gettext("You are NOT up to date..."));
-/* download snort rules */
-$static_output = gettext("Downloading current snort rules... ");
+/* remove old {$snortdir} files */
+if (file_exists("{$snortdir}")) {
+ /* echo "removing old {$snortdir} files\n"; */
+ update_status(gettext("Removing old snort rules..."));
+ update_output_window(gettext("May take a while..."));
+ exec("/bin/rm -r {$snortdir}/*");
+}
-/* Set URL we are downloading in bottom textarea and
- * download snort rules
- */
-update_all_status($static_output);
-update_output_window("{$dl}");
-download_file_with_progress_bar($dl, $tmpfname . "/{$snort_filename}", "read_body_firmware");
-verify_downloaded_file($tmpfname . "/{$snort_filename}");
+/* download snortrules file */
+if (file_exists("{$tmpfname}/{$snort_filename}")) {
+ /* echo "{$snort_filename} does exists\n"; */
+ update_status(gettext("Snortrule tar file exists..."));
+} else {
+ /* echo "downloading rules\n"; */
+ update_status(gettext("Downloading rules..."));
+ update_output_window(gettext("May take 4 to 10 min..."));
-/* download snort rules md5 file */
-$static_output = gettext("Downloading current snort rules md5... ");
+update_output_window("{$snort_filename}");
+download_file_with_progress_bar("http://dl.snort.org/reg-rules/snortrules-snapshot-2.8.tar.gz?oink_code=658d6fe74f30ac3efd01e7ff551f63d91a926430", $tmpfname . "/{$snort_filename}", "read_body_firmware");
update_all_status($static_output);
-update_output_window("{$dl_md5}");
-download_file_with_progress_bar($dl_md5, $tmpfname . "/{$snort_filename_md5}", "read_body_firmware");
-verify_downloaded_file($tmpfname . "/{$snort_filename_md5}");
+ /* echo "done\n"; */
+ update_status(gettext("Done."));
+}
-/* verify downloaded rules signature */
-update_status(gettext("Verifying MD5 Signature..."));
-verify_snort_rules_md5($tmpfname);
-/* extract rules */
-update_status(gettext("Extracting rules..."));
-extract_snort_rules_md5($tmpfname);
+/* Compair md5 sigs */
+$md555 = file_get_contents("{$tmpfname}/{$snort_filename_md5}");
+$md5 = `/bin/echo "{$md555}" | /usr/bin/awk '{ print $4 }'`;
+$file_md5_ondisk = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`;
-$static_output = gettext("Your snort rules are now up to date.");
-update_all_status($static_output);
+ if ($md5 == $file_md5_ondisk)
+ /* echo "Valid checksum pass\n"; */
+ update_status(gettext("Valid checksum pass"));
-$config['installedpackages']['snort']['last_ruleset_download'] = date("Y-m-d");
-write_config();
+/* Untar snort rules file */
+if (file_exists("{$tmpfname}/rules")) {
+ /* echo "The directory {$tmpfname}/rules exists\n"; */
+ update_status(gettext("The directory rules exists..."));
+} else {
+ /* echo "extracting rules\n"; */
+ update_status(gettext("Extracting rules..."));
+ update_output_window(gettext("May take a while..."));
+ exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$tmpfname}");
+ update_status(gettext("Done."));
+}
-update_status(gettext("Stopping Snort..."));
-update_output_window(gettext("One moment please..."));
-stop_service("snort");
-update_status(gettext("Starting Snort..."));
-update_output_window(gettext("One moment please..."));
-start_service("snort");
+/* Copy rules dir to snort dir */
+if (file_exists("{$snortdir}/rules")) {
+ /* echo "The directory {$snortdir}/rules exists\n"; */
+ update_status(gettext("Directory rules exists..."));
+} else {
+ /* echo "copying rules to {$snortdir}\n"; */
+ update_status(gettext("Copying rules..."));
+ update_output_window(gettext("May take a while..."));
+ exec("/bin/cp -r {$tmpfname}/rules {$snortdir}/rules");
+ update_status(gettext("Done."));
+}
-/* cleanup temporary directory */
-update_status(gettext("Cleaning up..."));
-update_output_window(gettext("One moment please..."));
-exec("/bin/rm -rf {$tmpfname};");
+/* Copy md5 sig to snort dir */
+if (file_exists("{$snortdir}/$snort_filename_md5")) {
+ /* echo "The {$snort_filename_md5} exists in the {$snortdir} exists\n"; */
+ update_status(gettext("The md5 file exists..."));
+} else {
+ /* echo "copying sig to {$snortdir}\n"; */
+ update_status(gettext("Copying md5 sig to snort directory..."));
+ exec("/bin/cp {$tmpfname}/$snort_filename_md5 {$snortdir}/$snort_filename_md5");
+}
+
+/* Copy configs to snort dir */
+if (file_exists("{$snortdir}/Makefile.am")) {
+ /* echo "The Snort configs exists in the {$snortdir} exists\n"; */
+ update_status(gettext("The snort configs exists..."));
+} else {
+ /* echo "copying sig to {$snortdir}\n"; */
+ update_status(gettext("Copying configs to snort directory..."));
+ exec("/bin/cp {$tmpfname}/etc/* {$snortdir}");
+}
+
+/* Copy signatures dir to snort dir */
+if (file_exists("{$snortdir}/doc/signatures")) {
+ /* echo "The directory {$snortdir}/signatures exists\n"; */
+ update_status(gettext("Directory signatures exists..."));
+} else {
+ /* echo "copying signatures to {$snortdir}\n"; */
+ update_status(gettext("Copying signatures..."));
+ update_output_window(gettext("May take a while..."));
+ exec("/bin/cp -r {$tmpfname}/doc/signatures {$snortdir}/signatures");
+ update_status(gettext("Done."));
+}
+
+/* echo "done finnal\n"; */
+update_status(gettext("Rules update finished..."));
+update_output_window(gettext("You may start Snort now."));
/* hide progress bar and lets end this party */
hide_progress_bar_status();
?>
-