zepek_al

Cpanel

Nov 5th, 2017
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. BEGIN {
  4. unshift @INC,'/scripts';
  5. }
  6.  
  7. use Socket;
  8. my $httpClient;
  9. eval {
  10. require cPScript::HttpRequest;
  11. $httpClient = cPScript::HttpRequest->new();
  12. };
  13.  
  14.  
  15.  
  16. my $gotSigALRM=0;
  17. my $connecttimeout = 30;
  18.  
  19. my $system;
  20. my $machine;
  21. chomp($system = `uname -s`);
  22. chomp($machine = `uname -m`);
  23.  
  24. my %UPCONF = loadcpupdateconf();
  25.  
  26. my $HTTPB='RELEASE';
  27. if ($UPCONF{'CPANEL'} =~ /stable/i) {
  28. $HTTPB='STABLE';
  29. } elsif ($UPCONF{'CPANEL'} =~ /current/i) {
  30. $HTTPB='CURRENT';
  31. } elsif ($UPCONF{'CPANEL'} =~ /edge/i) {
  32. $HTTPB='EDGE';
  33. } elsif ($UPCONF{'CPANEL'} =~ /nightly/i) {
  34. $HTTPB='NIGHTLY';
  35. }
  36.  
  37. my $arch = '';
  38. if ($system =~ /freebsd/i) {
  39. $arch = '-FREEBSD';
  40. }
  41. if ($machine =~ /x86_64/i) {
  42. $arch .= '-x86_64';
  43. }
  44. if ($machine =~ /amd64/i) {
  45. $arch .= '-amd64';
  46. }
  47.  
  48.  
  49. print "cPanel Security Patch (w/new wrapper) (sec092506) v1n";
  50. checkcpsec();
  51. updatewrapper();
  52. print "Patch Completen";
  53.  
  54.  
  55. sub updatewrapper {
  56. my $wrap_path='/usr/local/cpanel/bin/cpwrap';
  57. if (! -e $wrap_path) {
  58. print "No wrapper present (ok) ... skippedn";
  59. return();
  60. }
  61.  
  62. my $updated=0;
  63.  
  64. open(WR,'',$wrap_path);
  65. print WR $cpwrap;
  66. close(WR);
  67. chmod(oct(4755),$wrap_path);
  68. print "Donen";
  69. }
  70.  
  71.  
  72.  
  73. sub checkcpsec() {
  74. patchps('/usr/local/cpanel/bin/mysqladmin');
  75. patchps('/usr/local/cpanel/bin/hooksadmin');
  76. }
  77.  
  78.  
  79. sub patchps {
  80. my $script = shift;
  81. if (! -e $script) { return; }
  82.  
  83. my %TA=('unshift( @INC, "/usr/local/cpanel" );'=>0,,
  84. '@INC=grep(!/(^.|..|/.+)/,@INC);'=>0,
  85. '@INC=grep(/^(/usr/libd*/perl|/usr/local/libd*/perl|/usr/local/cpanel)/,@INC);'=>0);
  86. my @RM = ('/usr/lib/perl|','push(@INC','push( @INC');
  87.  
  88. open(SS,'+
Advertisement
Add Comment
Please, Sign In to add comment