#!/usr/bin/expect # @(#)poptart.exp 06 NOV 1998 Rob Thomas robt@cymru.com # A script to probe the POP and IMAP daemons (ports 110 and 143 TCP) for # the version. # ## main set inpfile [lindex $argv 0] set timeo [lindex $argv 1] # Check for enough args, display usage if we don't have enough. if 0==$argc { send_user "poptart.exp: usage: poptart.exp \[timeout\]\n" send_user "\nWhere is a columnar list of hostnames or IP\n" send_user "addresses, and \[timeout\] is an optional timeout value, in\n" send_user "seconds.\n" exit 1 } # Set the optional timeout value, in seconds. Default is 30 seconds. if {![string compare $timeo ""]} { set timeout 30 } else { set timeout $timeo } # See if we can open the input file if [catch {open $inpfile} fh] { puts "$fh" exit 1 } while {[gets $fh hostie] != -1} { send_user "poptart $hostie: POP test beginning...\n" spawn telnet $hostie 110 expect "+OK *" { send_user "poptart $hostie: $expect_out(0,string)\n" } "refused" { send_user "poptart $hostie: connect to POP refused\n" } timeout { send_user "poptart $hostie: connect to POP timeout\n" } send "quit\n" send_user "\npoptart $hostie: IMAP test beginning...\n" spawn telnet $hostie 143 expect "? OK *" { send_user "poptart $hostie: $expect_out(0,string)\n" } "refused" { send_user "poptart $hostie: connect to IMAP refused\n" } timeout { send_user "poptart $hostie: connect to IMAP timeout\n" } send_user "\npoptart $hostie: audit complete.\n\n*****\n\n" } close $fh exit ## FINI