PingIM

Two simple scripts one to send data through ping, the other to recieve and display data (this requires ngrep, which can be obtained easily through apt-get).

Note in the reciever script, it wont simply work if you copy and paste, because the ^G symobols, should be a control character, this can be entered in vi, by using Control-V, then Control-G, in the appropiate position.

I know this should use the Net::Ping functions but it instead uses the ping command.

#!/usr/bin/perl
# - Transmitter
# the reciever IP is specified as the first argument

$ip=@ARGV[0];
while(){
 while($i <= length($_)-2){
  $out .= sprintf("%x",ord(substr($_,$i,1)));
  $i++;
  if($i % 16 == 0 || $i > length($_)-2){
   $n="00"x(16-($i-(16*int($i / 16))));
   system("ping -c 1 -q -p '".$out.$n."' $ip &> /dev/null");
   $out="";
  }
 }
 if(length($_)-1 ==16) { system("ping -c 1 -q -p '00' $ip &> /dev/null"); }
 $i=0;
 $out="";
}

#!/usr/bin/perl
# - Receiver 

$|=1;
$yourip="192.168.1.4"; #change to your IP
open(NGREP,"ngrep -P ^G -l -q '' icmp and dst host $yourip |");
while()
{
 if(substr($_,0,1) eq " "){
  $n=substr(substr($_,14,length($_)),8,16);
  print $n;
  $i=0;
  while($i <= length($n)){
   if(ord(substr($n,$i,1)) == 7){
    print "\n";
    $i=length($n);
   }
   $i++;
  }
 }
}
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: