Advertisement
Guest User

Untitled

a guest
May 9th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.77 KB | None | 0 0
  1. #!/usr/bin/expect
  2.  
  3. #������ �������� ��������� ������������ �� ���������. ���� ����� �� ������� ���������� ������������)
  4.  
  5. log_user 0
  6.  
  7. set controlc /x03
  8. set adminacc "admin"
  9. set adminpass "dafyxas"
  10. set guestacc "acc"
  11. set guestpass "kozaryv"
  12. set snmphost "172.19.1.15"
  13.  
  14. proc zyxel_setup { adminacc adminpass guestacc guestpass snmphost } {
  15. send_user "This is Zyxel.\r\n"
  16. send "$adminacc\r"
  17. expect "Password:"
  18. send "$adminpass\r"
  19. expect "#"
  20. send "config\r"
  21. expect "(config)#"
  22.  
  23. #���������� �������
  24. send "timesync ntp\r"
  25. expect "(config)#"
  26. send "timesync server 172.19.1.15\r"
  27. expect "(config)#"
  28. send "time timezone 1000\r"
  29. expect "(config)#"
  30. send "time daylight-saving-time\r"
  31. expect "(config)#"
  32. send "time daylight-saving start-date last sunday march 3\r"
  33. expect "(config)#"
  34. send "time daylight-saving end-date last sunday october 3\r"
  35. send_user "Timesync configured\r\n"
  36. expect "(config)#"
  37.  
  38. #�������
  39. send "logins username $guestacc password $guestpass\r"
  40. send_user "$guestacc account created\r\n"
  41.  
  42. #������ � ����������� (���������)
  43. expect "(config)#"
  44. send "remote-management 2 start-addr 172.19.0.0 end-addr 172.19.1.254 service icmp telnet http\r"
  45. expect "(config)#"
  46. send "remote-management 2\r"
  47. expect "(config)#"
  48. send "remote-management 3 start-addr 172.20.0.0 end-addr 172.20.0.254 service icmp telnet http\r"
  49. expect "(config)#"
  50. send "remote-management 3\r"
  51. expect "(config)#"
  52. send "remote-management 4 start-addr 172.19.33.252 end-addr 172.19.33.252 service icmp telnet http\r"
  53. expect "(config)#"
  54. send "remote-management 4\r"
  55. expect "(config)#"
  56. send "no remote-management 1 service http https snmp ssh telnet ftp\r"
  57. expect "(config)#"
  58. send "remote-management 1\r"
  59. send_user "trusted hosts added\r\n"
  60.  
  61. expect "(config)#"
  62. send "exit\r"
  63. expect "#"
  64. send "write memory\r"
  65. send_user "Switch saved\r\n"
  66. expect "#"
  67. send "logout\r"
  68. }
  69.  
  70. proc dlink_setup { adminacc adminpass guestacc guestpass snmphost } {
  71. send_user "Dlink Switch. Starting setup.\r\n"
  72. send "$adminacc\r"
  73. expect "PassWord:"
  74. send "$adminpass\r"
  75. expect "#"
  76.  
  77. #�������� ������� (��� ���������� ��������� ����� ������� ��� ���� ���� �����-�����). ��������� �� ��� �������.
  78. #��������� �������
  79. send "create account admin $adminacc\r"
  80. expect "Enter a case-sensitive new password:" {
  81. send_user "$adminacc account not exist. Creating.\r\n"
  82. send "$adminpass\r"
  83. expect "Enter the new password again for confirmation:"
  84. send "$adminpass\r"
  85. expect "Success"
  86. send_user "$adminacc account created.\r\n" } \
  87. "The specified user already exists. Enter a unique username." { send_user "$adminacc account already exist.\r\n" }
  88.  
  89. expect "#"
  90. #������� ����
  91.  
  92. send "create account user $guestacc\r"
  93. expect "Enter a case-sensitive new password:" {
  94. send_user "$guestacc account not exist. Creating.\r\n"
  95. send "$guestpass\r"
  96. expect "Enter the new password again for confirmation:"
  97. send "$guestpass\r"
  98. expect "Success"
  99. send_user "$guestacc account created.\r\n" } \
  100. "The specified user already exists. Enter a unique username." {
  101. #� ��� ���� ��� ���� ��� ��������� - ������ � �������� ������ (���� ���� � ���� ������� ����� �� ����� � �������� ������ ��� �����)
  102. send_user "$guestacc user already exist. Recreating.\r\n"
  103. expect "#"
  104. send "delete account $guestacc\r"
  105. expect "Success" { send_user "$guestacc deleted\r\n" }
  106. expect "#"
  107. send "create account user $guestacc\r"
  108. expect "Enter a case-sensitive new password:"
  109. send "$guestpass\r"
  110. expect "Enter the new password again for confirmation:"
  111. send "$guestpass\r"
  112. expect "Success" { send_user "$guestacc account created.\r\n"} }
  113.  
  114. expect "#"
  115.  
  116. #�������� ���������� ������������� �������� ��������
  117. #������ ������ ��� � �����
  118. send "delete trusted_host all\r"
  119. expect "Success" { send_user "trusted host list cleared\r\n" }
  120. expect "#"
  121. send "create trusted_host network 172.19.1.0/24\r"
  122. expect "Success" { send_user "trust for network 172.19.1.0/24 added\r\n" }
  123. expect "#"
  124. send "create trusted_host network 172.19.0.0/24\r"
  125. expect "Success" { send_user "trust for network 172.19.0.0/24 added\r\n" }
  126. expect "#"
  127. send "create trusted_host network 172.18.0.0/24\r"
  128. expect "Success" { send_user "trust for network 172.18.0.0/24 added\r\n" }
  129. expect "#"
  130. send "create trusted_host network 172.20.0.0/24\r"
  131. expect "Success" { send_user "trust for network 172.20.0.0/24 added\r\n" }
  132. expect "#"
  133. send "create trusted_host 172.19.33.252\r"
  134. expect "Success" { send_user "paha's host added to trusted =)\r\n" }
  135.  
  136. expect "#"
  137.  
  138. #��������� ����� - ��������� �������
  139. send "enable sntp\r"
  140. expect "Success" { send_user "sntp enabled\r\n" }
  141. expect "#"
  142. send "config sntp primary 172.19.1.15\r"
  143. expect "Success" { send_user "sntp primary server set to 172.19.1.15\r\n" }
  144. expect "#"
  145. send "config dst repeating s_week last s_mth 3 s_day sun s_time 03:00 e_week last e_mth 10 e_day sun e_time 03:00 offset 60\r"
  146. expect "Success" { send_user "daylight saving time configured\r\n" }
  147. expect "#"
  148. send "config time_zone operator + hour 10 min 0\r"
  149. expect "Success" { send_user "time zone configured\r\n" }
  150.  
  151. expect "#"
  152. send "save all\r"
  153. send_user "Switch saved\r\n"
  154. expect "#"
  155. send "logout\r"
  156.  
  157. }
  158.  
  159. spawn telnet $argv
  160. send_user "#############################\r\n"
  161. send_user "$argv starting...\r\n"
  162. expect "UserName:" { dlink_setup $adminacc $adminpass $guestacc $guestpass $snmphost } \
  163. "User name" { zyxel_setup $adminacc $adminpass $guestacc $guestpass $snmphost } \
  164. { send_user "What is $argv? Stop.\r\n" }
  165. send_user "$argv end.\r\n"
  166. send_user "#############################\r\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement