From 10416c66a33bb21468e90896747cf2734ff54cc3 Mon Sep 17 00:00:00 2001 From: "shiyue.liu" Date: Mon, 19 Nov 2018 14:16:27 +0100 Subject: [PATCH 1/6] Support for connection to hidden networks for Linux --- pywifi/_wifiutil_linux.py | 5 +++++ pywifi/iface.py | 1 + pywifi/profile.py | 1 + tests/pywifi_test.py | 29 +++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/pywifi/_wifiutil_linux.py b/pywifi/_wifiutil_linux.py index d923d95..17530fc 100755 --- a/pywifi/_wifiutil_linux.py +++ b/pywifi/_wifiutil_linux.py @@ -160,6 +160,11 @@ def add_network_profile(self, obj, params): obj['name'], 'SET_NETWORK {} psk \"{}\"'.format(network_id, params.key)) + if params.hidden: + self._send_cmd_to_wpas( + obj['name'], + 'SET_NETWORK {} scan_ssid \{}\"'.format(network_id, 1)) + return params def network_profiles(self, obj): diff --git a/pywifi/iface.py b/pywifi/iface.py index b4ed703..970ac64 100755 --- a/pywifi/iface.py +++ b/pywifi/iface.py @@ -89,6 +89,7 @@ def network_profiles(self): self._logger.info("\tauth: %s", profile.auth) self._logger.info("\takm: %s", profile.akm) self._logger.info("\tcipher: %s", profile.cipher) + self._logger.info("\thidden: %s", profile.hidden) return profiles diff --git a/pywifi/profile.py b/pywifi/profile.py index e30c30c..dc977b9 100755 --- a/pywifi/profile.py +++ b/pywifi/profile.py @@ -16,6 +16,7 @@ def __init__(self): self.ssid = None self.bssid = None self.key = None + self.hidden = False def process_akm(self): diff --git a/tests/pywifi_test.py b/tests/pywifi_test.py index e65c790..9c13687 100755 --- a/tests/pywifi_test.py +++ b/tests/pywifi_test.py @@ -135,6 +135,35 @@ def test_connect_open(): assert iface.status() in\ [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE] +def test_connect_hidden(): + wifi = pywifi.PyWiFi() + + iface = wifi.interfaces()[0] + + iface.disconnect() + time.sleep(1) + assert iface.status() in \ + [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE] + + profile = pywifi.Profile() + profile.ssid = 'hiddentestap' + profile.auth = const.AUTH_ALG_OPEN + profile.akm.append(const.AKM_TYPE_NONE) + profile.hidden = True + + iface.remove_all_network_profiles() + tmp_profile = iface.add_network_profile(profile) + + iface.connect(tmp_profile) + time.sleep(40) + assert iface.status() == const.IFACE_CONNECTED + + iface.disconnect() + time.sleep(1) + assert iface.status() in \ + [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE] + + def test_disconnect(): wifi = pywifi.PyWiFi() From fde73618037e7f0f78386acf14566a219997e19b Mon Sep 17 00:00:00 2001 From: "shiyue.liu" Date: Mon, 19 Nov 2018 14:46:50 +0100 Subject: [PATCH 2/6] Typo --- .idea/dictionaries/shiyue.xml | 3 +++ pywifi/_wifiutil_linux.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .idea/dictionaries/shiyue.xml diff --git a/.idea/dictionaries/shiyue.xml b/.idea/dictionaries/shiyue.xml new file mode 100644 index 0000000..ccea679 --- /dev/null +++ b/.idea/dictionaries/shiyue.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/pywifi/_wifiutil_linux.py b/pywifi/_wifiutil_linux.py index 17530fc..1e18eb7 100755 --- a/pywifi/_wifiutil_linux.py +++ b/pywifi/_wifiutil_linux.py @@ -163,7 +163,7 @@ def add_network_profile(self, obj, params): if params.hidden: self._send_cmd_to_wpas( obj['name'], - 'SET_NETWORK {} scan_ssid \{}\"'.format(network_id, 1)) + 'SET_NETWORK {} scan_ssid \"{}\"'.format(network_id, 1)) return params From 5d0ca76ad07492b2d31637fa84542621f8aa5d35 Mon Sep 17 00:00:00 2001 From: "shiyue.liu" Date: Mon, 19 Nov 2018 15:01:52 +0100 Subject: [PATCH 3/6] Remove quotes for correct format --- pywifi/_wifiutil_linux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywifi/_wifiutil_linux.py b/pywifi/_wifiutil_linux.py index 1e18eb7..76606ee 100755 --- a/pywifi/_wifiutil_linux.py +++ b/pywifi/_wifiutil_linux.py @@ -163,7 +163,7 @@ def add_network_profile(self, obj, params): if params.hidden: self._send_cmd_to_wpas( obj['name'], - 'SET_NETWORK {} scan_ssid \"{}\"'.format(network_id, 1)) + 'SET_NETWORK {} scan_ssid {}'.format(network_id, 1)) return params From 062cf32e72e1bfaba8770ea531fd6428f5d4ad90 Mon Sep 17 00:00:00 2001 From: "shiyue.liu" Date: Mon, 19 Nov 2018 15:37:21 +0100 Subject: [PATCH 4/6] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2e12554..2aa4726 100755 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ build/ dist/ *.egg-info/ *.pyc +.idea/ \ No newline at end of file From 1a60d1ff0902cc99c50b3108c74df3fabd5c5f4c Mon Sep 17 00:00:00 2001 From: "shiyue.liu" Date: Mon, 19 Nov 2018 15:40:00 +0100 Subject: [PATCH 5/6] delete xml --- .idea/dictionaries/shiyue.xml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .idea/dictionaries/shiyue.xml diff --git a/.idea/dictionaries/shiyue.xml b/.idea/dictionaries/shiyue.xml deleted file mode 100644 index ccea679..0000000 --- a/.idea/dictionaries/shiyue.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file From fdb5458127b3176c254a607cc29d4078543c493f Mon Sep 17 00:00:00 2001 From: "shiyue.liu" Date: Mon, 19 Nov 2018 16:00:12 +0100 Subject: [PATCH 6/6] fork as own package --- AUTHORS.md | 1 + setup.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 4634154..6848256 100755 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -6,3 +6,4 @@ various contributors - Thomas Bell https://github.com/bell345 - William Gaylord https://github.com/chibill - Tucker Kern https://github.com/mill1000 +- Shiyue Liu https://github.com/iceananas diff --git a/setup.py b/setup.py index d78522c..eb8fc4e 100755 --- a/setup.py +++ b/setup.py @@ -6,18 +6,18 @@ from distutils.core import setup setup( - name='pywifi', - version='1.1.10', - author='Jiang Sheng-Jhih', - author_email='shengjhih@gmail.com', + name='pywifimotius', + version='1.2', + author='Shiyue Liu', + author_email='shiyue.liu@motius.de', description="A cross-platform module for manipulating WiFi devices.", packages=find_packages(), install_requires=[ 'comtypes' ], - url='https://github.com/awkman/pywifi', + url='https://github.com/motius/pywifi', license='MIT', - download_url='https://github.com/awkman/pywifi/archive/master.zip', + download_url='https://github.com/motius/pywifi/archive/master.zip', classifiers=[ 'Intended Audience :: Developers', 'Topic :: Utilities',