secure-card 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/usr/local/bin/expect -f
  2. #
  3. # This script was written by Jim Isaacson <jcisaac@crl.com>. It is
  4. # designed to work as a script to use the SecureCARD(tm) device. This
  5. # little device is mated with a central controller. The number displayed
  6. # on this card changes every so often and you need to enter the number
  7. # along with your user account name in order to gain access. Since chat
  8. # is based upon fixed strings this procedure will not work with chat.
  9. #
  10. # It is included by permission. An excellent reference for the expect
  11. # program used by this script is in the book:
  12. #
  13. # "Exploring Expect"
  14. # by Don Libes
  15. # Published by O'Rielly and Associates
  16. #
  17. send_user "hello, starting ppp\n"
  18. system "stty 19200 -echoe -echo raw < /dev/ttyS3 > /dev/ttyS3"
  19. #
  20. # These are the parameters for the program.
  21. #
  22. set user Pxxxxxx
  23. set password xxxxxxx
  24. set modem /dev/ttyS3
  25. set dialup <put phone number here>
  26. set timeout 60
  27. spawn -noecho -open [open $modem "r+"]
  28. send "AT&F\r"
  29. expect "OK"
  30. send "ATe0v1x4&c1q0&d2&c1s2=128s0=0DT $dialup\r"
  31. set timeout 15
  32. set counter 0
  33. set still_connecting 1
  34. expect {
  35. -re ".*CONNECT.*\n" {
  36. set timeout 5
  37. set still_connecting 0
  38. continue -expect
  39. }
  40. -re ".*CONNECT.*\r" {
  41. set timeout 5
  42. set still_connecting 0
  43. continue -expect
  44. }
  45. -re ".*NO.*CARRIER" {
  46. send_user "Failed to Connect, exiting...\n"
  47. exit
  48. }
  49. -re ".*NO.*DIAL.*TONE" {
  50. send_user "Failed to Connect, exiting...\n"
  51. exit
  52. }
  53. -re ".*VOICE" {
  54. send_user "Failed to Connect, exiting...\n"
  55. exit
  56. }
  57. -re ".*sscode:.*\n" {
  58. continue -expect
  59. }
  60. -re ".*sscode:" {
  61. set timeout -1
  62. expect_user -re "(.*)\n"
  63. send "$expect_out(1,string)\r"
  64. set timeout 30
  65. continue -expect
  66. }
  67. -re ".*Next.*:" {
  68. set timeout -1
  69. expect_user -re "(.*)\n"
  70. send "$expect_out(1,string)\r"
  71. set timeout 30
  72. continue -expect
  73. }
  74. -re "Your.*" {
  75. send "\r"
  76. continue -expect
  77. }
  78. -re ".*in:" {
  79. send "$user\r"
  80. continue -expect
  81. }
  82. -re ".*word:" {
  83. send "$password\r"
  84. }
  85. timeout {
  86. if { $still_connecting > 0 } {
  87. continue -expect
  88. }
  89. set timeout 15
  90. send "\r"
  91. incr counter
  92. if { $counter > 8 } {
  93. send_user "Cannot Connect\n"
  94. exit
  95. } else {
  96. continue -expect
  97. }
  98. }
  99. }
  100. overlay -0 $spawn_id -1 $spawn_id pppd /dev/ttyS3 19200 192.111.187.215: \
  101. crtscts modem defaultroute debug