To use:
1. Be sure that you have a reliable alternate way to make an emergency call, as this script might cause your magicJack service to stop working unexpectedly.
2. If you don't have perl on your PC, you can find a distibution here http://www.activestate.com/store/downlo ... d58c2648ca . The MSI package is easiest to install.
3. Put the script into a file. Edit the values of $srcnum, $spoof, and $cidblock as desired.
4. Edit your hosts file (typically C:\windows\system32\drivers\etc\hosts), adding a line like this:
Code: Select all
127.0.0.1 proxy1.nashville.talk4free.com
6. Restart MJ.
Notes:
1. You cannot block or spoof on toll-free calls.
2. If you choose to block on all calls, per-call unblocking does not work.
3. If you don't run your PC 24/7, you will need to cause the script to run when the PC is started.
4. If you have trouble, undo the change to your hosts file, restart MJ, and you should be back to normal.
5. If you add features or make other improvements, please post them here.
Here is the script:
Code: Select all
#!/usr/bin/perl -w
# Warning: this software may be unstable. Before using it, be sure that you have
# a reliable alternate means of making an emergency call.
use IO::Socket;
$srcnum = '2124610000'; # change this to your MJ number
$spoof = '2125551212'; # change this to number to send as Caller ID
$cidblock = 0; # set to 1 to block ID on all calls
$mjip = '127.0.0.1'; # change if MJ running on different host from this script
$server = '67.90.152.70'; # MJ proxy to use
sub outgoing { # handle outgoing call features
return if $ibuf =~ /sip:911/; # don't mess with 911 calls
if ($cidblock || $ibuf =~ /Anonymous/) { # want to block
$ibuf =~ s/\r\n\r\n/\r\nPrivacy: id\r\nP-Asserted-Identity: <sip:$srcnum\@x>\r\n\r\n/;
}
elsif ($spoof ne $srcnum) { # want to spoof
$ibuf =~ s/\r\n\r\n/\r\nP-Asserted-Identity: <sip:$spoof\@x>\r\n\r\n/;
}
}
$lport = 5070; # port to listen on
$dgs = new IO::Socket::INET(LocalPort => $lport, Proto => 'udp') or die "Socket: $!\n";
while (1) {
$rcv = $dgs->recv($ibuf, 2000, 0);
next unless $rcv && length($rcv) >= 8; # ignore errors
$raddr = inet_ntoa((sockaddr_in($rcv))[1]); # get source addr
if ($raddr eq $mjip) { # packet from MJ
if ($ibuf =~ /\nAuthorization:/) { # INVITE packet for outgoing call
&outgoing();
}
$dpaddr = sockaddr_in(5070, inet_aton($server));
$dgs->send($ibuf, 0, $dpaddr); # send to server
}
elsif ($raddr eq $server) { # packet from server
$dpaddr = sockaddr_in(5060, inet_aton($mjip));
$dgs->send($ibuf, 0, $dpaddr); # send to MJ
}
}