Created
October 25, 2022 02:59
-
-
Save songwutk/e35013a0d59c06c2e394d8172026acaa to your computer and use it in GitHub Desktop.
Mikrotik Autologin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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