Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telnetlib
- import time
- ip = '192.168.1.1'
- user = 'admin'
- password = 'admin'
- loginOffice = '1234'
- PassOffice = '12345'
- tn = telnetlib.Telnet(ip)
- #Автологин
- tn.read_until(b"Login: ", timeout=5)
- tn.write(user.encode('ascii') + b"\n")
- tn.read_until(b"Password: ", timeout=5)
- tn.write(password.encode('ascii') + b"\n")
- # список команд (переменные вставляются через {} и .format)
- l = ['interface PPTP0',
- 'description Office',
- 'role misc',
- 'peer k4.office.ru',
- 'no ipv6cp',
- 'lcp echo 30 3',
- 'ipcp default-route',
- 'ipcp name-servers',
- 'ipcp dns-routes',
- 'ccp',
- 'security-level public',
- 'authentication identity {}'.format(loginOffice),
- 'authentication password {}'.format(PassOffice),
- 'encryption mppe',
- 'ip dhcp client dns-routes',
- 'ip dhcp client name-servers',
- 'ip global 16383',
- 'ip tcp adjust-mss pmtu',
- 'connect',
- 'up']
- for s in l:
- tn.read_until(b"(config)> ", timeout=5)
- time.sleep(1) # если быстро интервал можно увеличить
- tn.write(s.encode('ascii') + b"\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement