Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 104 lines (98 sloc) 2.667 kb
77bbcdf @jschauma add the awful autopw password injector
authored
1 #!/usr/local/bin/expect --
2 #
3 # A generic password injector.
4 #
5 # Copyright (c) 2011 Yahoo! Inc.
6 # All rights reserved.
7 #
8 # Redistribution and use of this software in source and binary forms,
9 # with or without modification, are permitted provided that the following
10 # conditions are met:
11 #
12 # * Redistributions of source code must retain the above
13 # copyright notice, this list of conditions and the
14 # following disclaimer.
15 #
16 # * Redistributions in binary form must reproduce the above
17 # copyright notice, this list of conditions and the
18 # following disclaimer in the documentation and/or other
19 # materials provided with the distribution.
20 #
21 # * Neither the name of Yahoo! Inc. nor the names of its
22 # contributors may be used to endorse or promote products
23 # derived from this software without specific prior
24 # written permission of Yahoo! Inc.
25 #
26 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
27 # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
29 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
38 proc respond { pw } {
39 global pws
40 if {![info exists pws($pw)]} {
41 send_user " (autopw) "
42 stty -echo
43 expect_user -re "(.+)\n"
44 stty echo
45 set pws($pw) \
46 [exec perl -ne "print pack(q{u}, \$_)" << $expect_out(1,string)]
47 } else {
48 send_user " (autopw'ed)"
49 }
50 log_user 0
51 send -- "[exec perl -ne "print unpack(q{u}, \$_)" << $pws($pw)]\n";
52 log_user 1
53 }
54
55 ## main ()
56
57 set timeout -1
58 global pws
59
60 eval spawn -noecho $argv
61
62 expect {
63 "assword:" {
64 respond system
65 exp_continue
66 }
67 "Enter passphrase for " {
68 respond ssh
69 exp_continue
70 }
71 "Bad passphrase, try again" {
72 unset pws(ssh)
73 respond ssh
74 exp_continue
75 }
76 "Enter PEM pass phrase:" {
77 respond pem
78 exp_continue
79 }
80 "Enter passphrase: " {
81 respond gpg
82 exp_continue
83 }
84 "y,n,?" {
85 send -- "y\n"
86 exp_continue
87 }
88 "(y/n)?" {
89 send -- "y\n"
90 exp_continue
91 }
92 "?,??,q" {
93 send -- "\n"
94 exp_continue
95 }
96 "(yes/no)?" {
97 send -- "yes\n"
98 exp_continue
99 }
100 eof {
101 exit
102 }
103 }
Something went wrong with that request. Please try again.