Skip to content

Instantly share code, notes, and snippets.

@songwutk
Created October 25, 2022 02:59
Show Gist options
  • Save songwutk/e35013a0d59c06c2e394d8172026acaa to your computer and use it in GitHub Desktop.
Save songwutk/e35013a0d59c06c2e394d8172026acaa to your computer and use it in GitHub Desktop.
Mikrotik Autologin
#!/usr/bin/env python3
from httplib2 import Http
from urllib.parse import urlencode
URL = 'http://10.0.0.11/login'
h = Http()
username='username'
password='password'
def flogin(username, password):
data = {'username':username, 'password':password, 'dst':'', 'popup':'true'}
payload = urlencode(data)
headers = {}
headers.update({'Content-Type':'application/x-www-form-urlencoded'})
response, _ = h.request(URL, method='POST', body=payload, headers=headers)
assert(response.status==200)
def main():
response, content = h.request(URL)
assert(response.status==200)
flogin(username,password)
print ('Successfully logged in ;)')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment