403Webshell
Server IP : 103.119.228.120  /  Your IP : 3.15.6.140
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /usr/share/doc/ppp-2.4.5/scripts/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/share/doc/ppp-2.4.5/scripts/autopppd
#!/usr/bin/perl -w

# Auto dial script by Brian May <bam@snoopy.apana.org.au>

use Proc::Daemon;
use strict;
use Sys::Syslog qw(:DEFAULT setlogsock);  # default set, plus setlogsock
use Proc::WaitStat qw(:DEFAULT waitstat);


Proc::Daemon::Init;
open(PIDFILE,">/var/run/autopppd.pid");
print(PIDFILE "$$");
close(PIDFILE);

sub toseconds($) {
  my ($hours,$minutes,$seconds) = split(/:/,shift);
  return ($hours*60+$minutes)*60+$seconds;
}

sub dseconds($) {
  my ($total) = @_;

  my $seconds = $total % 60; $total = ($total - $seconds)/60;
  my $minutes = $total % 60; $total = ($total - $minutes)/60;
  my $hours   = $total % 24; $total = ($total - $hours)/24;
  my $days   = $total;
  if ($days > 0) {
    return(sprintf("%d-%02d:%02d:%02d",$days,$hours,$minutes,$seconds));
  } else {
    return(sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds));
  }
}

my $program="autopppd";

setlogsock('unix');
openlog($program, 'cons,pid', 'daemon');

my $pppd_start_time;
my $pppd_end_time;
my $pppd_run_time;
my $pppd_fail;
my $delay=0;
my $idelay=0;

my @delays = (
               toseconds("00:01:00"), # 1 minute
               toseconds("00:07:00"), # 8 minutes
               toseconds("00:07:00"), # 15 minutes
               toseconds("00:15:00"), # 30 minutes
               toseconds("00:30:00"), # 1 hour
               toseconds("01:00:00"), # 2 hours
               toseconds("01:00:00"), # 3 hours
               toseconds("03:00:00"), # 6 hours
               toseconds("06:00:00"), # 12 hours
               toseconds("12:00:00"), # 24 hours
               toseconds("24:00:00")  # 48 hours
             );

# action == 0 => immediate retry (!FIXME! needs to have some delay)
# action == 1 => delayed retry
# action == 2 => abort

my $code = {
  0 => { message=>"pppd detached",                              action=> 2 },
  1 => { message=>"fatal error",                                action=> 2 },
  2 => { message=>"options error",                              action=> 2 },
  3 => { message=>"not setuid-root error",                      action=> 2 },
  4 => { message=>"no kernel support for PPP",                  action=> 2 },
  5 => { message=>"SIGINT or SIGTERM or SIGHUP",                action=> 1 },
  6 => { message=>"Serial port locked",                         action=> 1 }, # should be 0
  7 => { message=>"Serial port open error",                     action=> 1 },
  8 => { message=>"Connect failed",                             action=> 1 },
  9 => { message=>"Could not execute pty command",              action=> 1 },
 10 => { message=>"PPP negotiation failed",                     action=> 1 },
 11 => { message=>"Peer failed to authenticate",                action=> 1 },
 12 => { message=>"Link was idle",                              action=> 1 },
 13 => { message=>"Time limit exceeded",                        action=> 1 },
 14 => { message=>"call back not implemented",                  action=> 2 },
 15 => { message=>"peer not responding",                        action=> 1 },
 16 => { message=>"modem hang up",                              action=> 1 },
 17 => { message=>"Serial loopback detected",                   action=> 1 },
 18 => { message=>"Init script failed",                         action=> 1 },
 19 => { message=>"We failed to authenticate",                  action=> 1 },
};

while (1)
{
  $pppd_start_time=time;
  syslog('info', 'restarting pppd');

  # logging sometimes stopped working after ppp was running for
  # some time. lets see if closing and reopening the log file helps...
  closelog();

  # run ppp
  my $rc=system("pppd","-detach",@ARGV);

  # reopon log file
  openlog($program, 'cons,pid', 'daemon');

  # calculate run time
  $pppd_end_time=time;
  $pppd_run_time=$pppd_end_time-$pppd_start_time;

  my $pppd_code = ($? >> 8);
  my $pppd_signal = $? & 127;
  my $pppd_coredump = $? & 128;

  $pppd_fail = 1;
  if ($pppd_signal != 0) {
    if ($pppd_coredump)
    { syslog('err',"pppd died with signal $pppd_signal, coredump"); }
    else
    { syslog('err',"pppd died with signal $pppd_signal"); }
  }
  elsif ($pppd_coredump) {
    syslog('err',"pppd died with coredump");
  }
  elsif (defined($code->{$pppd_code}) && $code->{$pppd_code}{"action"} == 0) {
    syslog('err', "pppd returned: ".$code->{$pppd_code}{"message"}." ($pppd_code), immediate retry");
    $pppd_fail = 0;
  }
  elsif (defined($code->{$pppd_code}) && $code->{$pppd_code}{"action"} == 1) {
    syslog('err', "pppd returned: ".$code->{$pppd_code}{"message"}." ($pppd_code), delayed retry");
    $pppd_fail = 1;
  }
  elsif (defined($code->{$pppd_code}) && $code->{$pppd_code}{"action"} >= 2) {
    syslog('err', "pppd returned: ".$code->{$pppd_code}{"message"}." ($pppd_code), aborting");
    exit(255);
  }
  elsif (defined($code->{$pppd_code}) && $code->{$pppd_code}{"action"} >= 2) {
    syslog('err', "pppd returned: unknown error ($pppd_code), delayed retry");
    $pppd_fail = 1;
  }
  # if it hasn't ran for at least an hour, then somthing went wrong
  elsif ($pppd_run_time < toseconds("01:00:00")) {
    syslog('err',"pppd session didn't last 1 hour, delayed retry");
    $pppd_fail = 1;
  }
  else { $pppd_fail = 0; }

  # if not failed, then reset delay.
  if (!$pppd_fail) { $idelay = 0; }

  # get next delay.
  $delay = $delays[$idelay];

  # log statistics.
  syslog('info',"rc=".waitstat($rc)." runtime=".dseconds($pppd_run_time)." delay[$idelay]=".dseconds($delay)."");

  # delay for desired time.
  sleep($delay);

  # increment delay for next time.
  if (defined($delays[$idelay+1])) { $idelay++; }
}

closelog();

Youez - 2016 - github.com/yon3zu
LinuXploit