0byt3m1n1
Path:
/
data
/
16
/
.snapshot
/
daily.2025-03-10_0010
/
inventory
/
ARCHIVE
/
[
Home
]
File: vux_htfix.pl
#!/usr/local/bin/perl $file = $ARGV[0]; chomp($file); $filesection = $file; open LIST, "<${file}"; $file =~ s/\.txt//; @FILEPARTS = (split /\// ,$file); $file = pop(@FILEPARTS); open STATUS, ">/data/16/inventory/done/HTScan/${file}-CLEANED.txt"; open PURGED, ">/data/16/inventory/done/HTScan/${file}-PURGED.txt"; use File::Copy; while (<LIST>) { #1 $htfile = $_; chomp($htfile); $test = "qU3Ry="; $user_path = (split /\/htdocs/, $htfile)[0]; open HTFILE, "<${htfile}"; @HT_LINES = <HTFILE>; close HTFILE; @ATTRIBS = stat($htfile); $uid = $ATTRIBS[4]; $gid = $ATTRIBS[5]; $savefile = "$htfile-SAVE"; move($htfile, $savefile); $N = 0; $M = 1; $O = -1; $P = -2; $write_flag = "ON"; open NEWHT, ">${htfile}"; foreach(@HT_LINES) { #5 $new_line = $_; chomp($new_line); if ((($HT_LINES[$N] =~ /^\#([0-9a-zA-Z]){20,35}/) || ($HT_LINES[$N] =~ /^\#NOT MODIFY/)) && ($HT_LINES[$M] =~ /^RewriteEngine On/)) { $write_flag = "OFF"; print PURGED "START $htfile\n"; } print PURGED "$new_line\n" if ($write_flag eq 'OFF'); if (($P >= 0) && ($write_flag eq 'OFF')) { if ((($HT_LINES[$P] =~ /$user_path/) || ($HT_LINES[$P] =~ /$test/)) && (($HT_LINES[$O] =~ /^\#([0-9a-zA-Z]){20,35}/) || ($HT_LINES[$O] =~ /^\#NOT MODIFY/))) { $write_flag = "ON"; print PURGED "END $htfile\n"; } } print NEWHT "$new_line\n" if ($write_flag eq 'ON'); $N++; $M++; $O++; $P++; } #5 close NEWHT; `chown $uid.$gid $htfile`; print STATUS "Cleaned $htfile\n"; } print STATUS "All done...\n"; close STATUS;