Results 1 to 3 of 3
  1. #1

    shell script for BFD?


    I'm not good at shell scripting but I want my BFD (bruteforce detection) to only add IP addresses to the Ban list and not hostnames.

    So I'm trying to create a shellscript that does the following:
    - If the argument is an IP address, it just outputs that IP address back
    - If it's not (so if it is a hostname) it uses the "host" command to fetch the IP address and output it. Without the "hostname.ext has address" before it, offcourse.

    However, I can't manage to do it :| And I know that there are linux people in here who can write this in about 10 seconds... Can anyone help me?


    PS: If this is in the wrong forum, sorry...

  2. #2
    Join Date
    Jun 2003
    if [ -z $1 ]; then
        echo "$0 ip/hostname"
        exit 1
    RES=`host $1`
    IP=`echo $RES | awk {'print $4'}`
    echo $RES | grep "(NXDOMAIN)" &> /dev/null
    if [ $? -eq 0 ]; then
        echo $1
        exit 1
    echo $RES | grep "domain name pointer" &> /dev/null
    if [ $? -eq 0 ]; then
        echo $1
        exit 1
    echo $IP

  3. #3
    Works like a charm Thanks alot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts