-
Notifications
You must be signed in to change notification settings - Fork 148
/
authenticate.exp
39 lines (36 loc) · 1.47 KB
/
authenticate.exp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/expect -f
exp_internal 1
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn -noecho /usr/local/bin/reauth.sh
match_max 100000
#sleep 5
expect {
"Please enter two-factor authentication code: " {
exec /usr/local/bin/sendmessage.sh mfacode
exec >@stdout 2>@stderr /usr/bin/inotifywait -qq -t 600 -e close_write /tmp/icloudpd/mfacode.txt
set MFACODE [exec cat /tmp/icloudpd/mfacode.txt]
send -- "${MFACODE}\r"
}
"Please enter two-factor authentication code or device index * to send SMS with a code: " {
exec /usr/local/bin/sendmessage.sh smschoice
exec >@stdout 2>@stderr /usr/bin/inotifywait -qq -t 600 -e close_write /tmp/icloudpd/smschoice.txt
set SMSCHOICE [exec cat /tmp/icloudpd/smschoice.txt]
send -- "${SMSCHOICE}\r"
expect "Please enter two-factor authentication code that you received over SMS: " {
exec /usr/local/bin/sendmessage.sh mfacode
exec >@stdout 2>@stderr /usr/bin/inotifywait -qq -t 600 -e close_write /tmp/icloudpd/mfacode.txt
set MFACODE [exec cat /tmp/icloudpd/mfacode.txt]
send -- "${MFACODE}\r"
}
}
}
expect eof