Last active
September 27, 2018 11:05
-
-
Save turicas/209f8b3a6b5c7d70b69aa84b46d6b29e to your computer and use it in GitHub Desktop.
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
| #pip install requests splinter | |
| # TODO: add argparse | |
| import shlex | |
| import subprocess | |
| import requests | |
| import splinter | |
| def get_ips(device): | |
| for line in subprocess.check_output(shlex.split('ip address show dev wlp2s0')).decode().splitlines(): | |
| line = line.strip() | |
| if line.startswith('inet '): | |
| ipv4 = line.split()[1].split('/')[0] | |
| elif line.startswith('inet6 ') and 'global' in line: | |
| ipv6 = line.split()[1].split('/')[0] | |
| response = requests.get('https://api.ipify.org') | |
| return response.text, ipv6 | |
| username = 'XXX' | |
| password = 'YYY' | |
| subdomain = 'xxx.ddns.net' | |
| new_ipv4, new_ipv6 = get_ips('eth0') | |
| browser = splinter.Browser() | |
| browser.visit('https://www.no-ip.com/login') | |
| browser.fill('username', username) | |
| browser.fill('password', password) | |
| browser.find_by_name('Login').click() | |
| browser.find_by_text('Active')[0].click() | |
| browser.find_by_text(subdomain)[0].click() | |
| browser.find_by_name('target')[-1].fill(new_ipv4) | |
| browser.find_by_name('ipv6')[-1].fill(new_ipv6) | |
| browser.find_by_xpath('//button[contains(@class, "btn-success")]')[-1].click() | |
| browser.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment