Description: modify rip.pl for use on *nix
Forwarded: not-needed
Author: Jan Gruber <j4n6ru@gmail.com>
Last-Update: 2021-04-24 
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/rip.pl
+++ b/rip.pl
@@ -1,4 +1,4 @@
-#! c:\perl\bin\perl.exe
+#!/usr/bin/perl
 #-------------------------------------------------------------------------
 # Rip - RegRipper, CLI version
 # Use this utility to run a plugins file or a single plugin against a Reg
@@ -30,6 +30,9 @@
 # Author: H. Carvey, keydet89@yahoo.com
 #-------------------------------------------------------------------------
 use strict;
+# Add /usr/lib/regripper to the include path, to ensure that the patched
+# versions of Parse::Win32Registry's Base.pm, File.pm and Key.pm are used
+use lib '/usr/lib/regripper';
 use Parse::Win32Registry qw(:REG_);
 use Getopt::Long;
 use Time::Local;
@@ -55,23 +58,15 @@ my %config;
 Getopt::Long::Configure("prefix_pattern=(-|\/)");
 GetOptions(\%config,qw(reg|r=s file|f=s csv|c dirty|d auto|a autoTLN|aT guess|g user|u=s sys|s=s plugin|p=s update|uP list|l help|?|h));
 
-# Code updated 20090102
-my @path;
-my $str = $0;
-($^O eq "MSWin32") ? (@path = split(/\\/,$0))
-                   : (@path = split(/\//,$0));
-$str =~ s/($path[scalar(@path) - 1])//;
-
-# Suggested addition by Hal Pomeranz for compatibility with Linux
-#push(@INC,$str);
-# code updated 20190318
-my $plugindir;
-($^O eq "MSWin32") ? ($plugindir = $str."plugins/")
-                   : ($plugindir = File::Spec->catfile("plugins"));
-#my $plugindir = $str."plugins/";
-#my $plugindir = File::Spec->catfile("plugins");
-#print "Plugins Dir = ".$plugindir."\n";
-# End code update
+# Retrieves the absolute path to rip.pl, even if called by a symlink
+my $scriptpath = Cwd::realpath($0);
+
+# Retrieves the absolute path of rip.pl's parent directory
+my $scriptdir = File::Basename::dirname($scriptpath);
+
+# Sets plugin directory
+my $plugindir = File::Spec->catdir($scriptdir, "plugins");
+
 my $VERSION = "3\.0";
 my @alerts = ();
 
@@ -564,4 +559,4 @@ sub getDateFromEpoch {
 	my ($sec,$min,$hour,$mday,$mon,$year) = gmtime($epoch);
 	my $fmt = sprintf("%04d-%02d-%02d %02d:%02d:%02d",(1900 + $year),($mon + 1),$mday,$hour,$min,$sec);
 	return $fmt;
-}
\ No newline at end of file
+}
