├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── convert_wifi.pl ├── selftest-ro ├── WifiConfigStore.xml └── wpa_supplicant.conf └── selftest-rw └── .nomedia /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | WifiConfigStore.xml* 3 | wpa_supplicant.conf* 4 | /selftest-rw/* 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for android-wifi-upgrade project to automate 2 | # its typical tasks and selftest 3 | # 4 | # Copyright (C) 2020 by Jim Klimov 5 | # released under Apache 2.0 license (see LICENSE file). 6 | 7 | ### Default target is first 8 | all: WifiConfigStore.xml 9 | 10 | check: check-syntax check-sample-data 11 | 12 | convert_wifi_SCRIPT = convert_wifi.pl 13 | 14 | # TODO: Guess via path to this Makefile 15 | src_dir = . 16 | 17 | ### The practical use-case 18 | wpa_supplicant.conf: 19 | @if [ ! -s "$@" ]; then echo "Please download $@ from your old Android system and place here" >&2 ; exit 1; fi 20 | 21 | WifiConfigStore.xml: wpa_supplicant.conf $(src_dir)/$(convert_wifi_SCRIPT) 22 | $(src_dir)/$(convert_wifi_SCRIPT) < $< > $@ 23 | @echo "Converted without major errors. Please see README.md about uploading $@ to your new phone." >&2 24 | 25 | ### Self-tests of the script 26 | check-syntax: $(src_dir)/$(convert_wifi_SCRIPT) 27 | perl -c $< 28 | 29 | selftest-rw/WifiConfigStore.xml: selftest-ro/wpa_supplicant.conf $(src_dir)/$(convert_wifi_SCRIPT) 30 | $(src_dir)/$(convert_wifi_SCRIPT) < $< > $@ 31 | 32 | # Note: the check below filters away lines that depend on generation time 33 | # or come from Android/MIUI extensions in the sample data file (redacted 34 | # .XML extract from a real Android 10 phone) and are not really founded 35 | # in any lines from the older .CONF equivalent. 36 | check-sample-data: selftest-ro/WifiConfigStore.xml selftest-rw/WifiConfigStore.xml 37 | @diff -bu $^ \ 38 | | grep -E -v 'name="(CreationTime|LastConnectUid|ValidatedInternetAccess|HasEverConnected|HiddenSSID|ConnectChoiceTimeStamp|ConnectChoice)"' \ 39 | | grep -E -v 'name="(staId|ShareThisAp)"' \ 40 | | grep -E -v '(MacAddressMap|name="MacMapEntry")' \ 41 | | grep -E -v 'name="(RandomizedMacAddress|MacRandomizationSetting)"' \ 42 | | grep -E -v 'name="(DppConnector|DppNetAccessKey|DppNetAccessKeyExpiry|DppCsign)"' \ 43 | | grep -E -v '^(\-\-\-|\+\+\+)' | grep -E '^[+-]' \ 44 | && { echo "FAILED: Got unexpected line differences in output, see above" >&2 ; exit 1; } \ 45 | || { echo "SUCCESS: No unexpected line differences in output" >&2 ; exit 0; } 46 | 47 | clean: 48 | rm -f selftest-rw/WifiConfigStore.xml 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-wifi-upgrade 2 | convert WiFi passwords from old Android wpa_supplicant.conf to newer (post-Oreo) WifiConfigStore.xml 3 | 4 | This perl script reads old wpa_supplicant.conf on STDIN, and outputs new WifiConfigStore.xml to STDOUT 5 | 6 | ## Description 7 | For me, upgrading LG G3 from LineageOS 14.1 (Android 7.1.2 "Nougat") to LineageOS 16.0 (Android 9 "Pie") resulted 8 | in all my wifi password being lost. The reason is the information is no longer kept in 9 | */data/misc/wifi/wpa_supplicant.conf* but instead in */data/misc/wifi/WifiConfigStore.xml* 10 | 11 | This script is a quick hack to convert (most of the) passwords to new format 12 | so I don't have to remember and type them all again. 13 | 14 | All of the project is released under Apache 2.0 license (see LICENSE file). 15 | 16 | ## Usage 17 | 18 | * `adb root` 19 | 20 | (make sure you have first set permissions in developer settings root ADB) 21 | 22 | * `adb pull /data/misc/wifi/wpa_supplicant.conf` 23 | 24 | (or in whatever location it is in your device - maybe */data/wifi/bcm_supp.conf* or */data/misc/wifi/wpa.conf*) 25 | 26 | * `./convert_wifi.pl < wpa_supplicant.conf > WifiConfigStore.xml` 27 | 28 | (and check any warnings / error outputed on the screen) 29 | 30 | * disable WiFi on your phone 31 | 32 | * push new config on the phone (to correct location - check first where is current *WifiConfigStore.xml*): 33 | ``` 34 | adb push WifiConfigStore.xml /data/misc/wifi/WifiConfigStore.xml 35 | adb shell chmod 600 /data/misc/wifi/WifiConfigStore.xml 36 | adb shell chown system:system /data/misc/wifi/WifiConfigStore.xml 37 | adb shell rm /data/misc/wifi/WifiConfigStore.xml.encrypted-checksum 38 | adb reboot 39 | ``` 40 | 41 | Note that location of *WifiConfigStore.xml* on your device might be something other than */data/misc/wifi* (like */data/misc/apexdata/com.android.wifi*), so you need to verify that first (and update the commands above accordingly). 42 | 43 | * enable WiFi on your phone 44 | 45 | ## Troubleshooting 46 | * some phone require WAPI support, and others do not support it. 47 | If `master` git branch at https://github.com/mnalis/android-wifi-upgrade 48 | report errors when you try to upload `WifiConfigStore.xml`, 49 | try `wapi` git branch: https://github.com/mnalis/android-wifi-upgrade/tree/wapi 50 | 51 | This is because different phones have different config format requirements, 52 | see https://github.com/mnalis/android-wifi-upgrade/issues/6 for details 53 | 54 | * if all else fails, please report new issue at https://github.com/mnalis/android-wifi-upgrade/issues 55 | 56 | ## TODO 57 | * Never write XML by hand as I do here! It will seem to work in most cases, 58 | and then break badly on some non-escaped value or similar. 59 | 60 | * only config supports implemented currently are open networks (no PSK), 61 | WEP networks with up to 4 preshared keys, and WPA2 networks (with ASCII PSK); 62 | WPA1 may be or not be supported per chosen bit masks, but was not tested 63 | directly. Maybe support other (WPA1, EAP-xxx thingies)? 64 | 65 | * set uid to 1000 or 0 ? or -1 ? 66 | 67 | * there are UIDs in "CreatorUid", "LastUpdateUid", "LastConnectUid", 68 | "CreatorName" => "android.uid.system:1000", 69 | "LastUpdateName" => "android.uid.system:1000"... 70 | are they all same or may be different? 71 | 72 | * parse id_str (url_decode, JSON) for creatorUid & configKey ? 73 | 74 | * where to put "priority" and "bssid" from wpa_supplicant.conf ? 75 | 76 | * possibly, bssid maps to DefaultGwMacAddress ? 77 | 78 | * wpa_supplicant.conf: is "disabled" always "1" ? 79 | 80 | * warn for all unhandled key/value pairs (or even better, handle them correctly) 81 | 82 | * add options to select 'WAPI' (`$AllowedProtocols`) and `$ConfigKey` 83 | formats, instead of using different git branches (need to fix `make check` 84 | too then) 85 | 86 | * FIXMEs in code 87 | -------------------------------------------------------------------------------- /convert_wifi.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Original copyright (C) 2019,2020 by Matija Nalis , started 2019-12-02 3 | # Portions copyright (C) 2020 by Jim Klimov 4 | # Released under Apache 2.0 license (see LICENSE file) 5 | # 6 | # converts android WiFi passwords from old wpa_supplicant.conf to newer WifiConfigStore.xml 7 | # 8 | 9 | use warnings; 10 | use strict; 11 | use autodie; 12 | use Data::Dumper; 13 | 14 | use POSIX qw(strftime); 15 | 16 | my $DEBUG = $ENV{DEBUG} || 0; 17 | my $IGNORE_OPEN = $ENV{IGNORE_OPEN} || 0; # ignore open networks (without password) and do not convert them 18 | my $CreationUID = $ENV{FORCEUID} || '1000'; # FIXME user configurable? or read from id_str (but it can be "-1" there!) or fix to "0" ? 19 | 20 | $| = 1; 21 | 22 | sub dbg($$) { 23 | my ($lvl, $msg) = @_; 24 | print STDERR "dbg:$lvl" . (' ' x ($lvl*1)) . "$msg\n" if $DEBUG >= $lvl; 25 | } 26 | 27 | my %CUR=(); 28 | 29 | # header of WifiConfigStore.xml 30 | sub start_xml() { 31 | print < 33 | 34 | 35 | 36 | EOF 37 | } 38 | 39 | # FIXME: we should never do XML by hand like this. oh well. 40 | sub quote_xml($) { 41 | my ($str) = @_; 42 | $str =~ s{&}{&}g; 43 | $str =~ s{<}{<}g; 44 | $str =~ s{>}{>}g; 45 | $str =~ s{\'}{'}g; 46 | $str =~ s{\"}{"}g; 47 | return $str; 48 | } 49 | 50 | #my $cnt = 0; 51 | # constructs one network entry in WifiConfigStore.xml 52 | sub add_xml() { 53 | my $SSID = $CUR{ssid}; 54 | if (!defined $SSID) { return warn "Skipping - no SSID?! in " . Dumper(\%CUR) }; 55 | #if ($SSID !~ /^[a-zA-Z0-9_ \-\"\'\.<>&()@]+$/) { warn "Possibly problematic SSID name $SSID (FIXME needs escaping?)" }; 56 | 57 | my $key_mgmt = $CUR{key_mgmt} || 'WPA-PSK'; warn "no key_mgmt for SSID $SSID; trying to continue, but it might not work" if not defined $CUR{key_mgmt}; 58 | if ($key_mgmt ne 'NONE') { 59 | if ($key_mgmt =~ /\b(WPA-PSK\S*)\b/) { 60 | $key_mgmt = $1; # line can be e.g. "key_mgmt=WPA-PSK FT-PSK WPA-PSK-SHA256", so if it has WPA-PSK, assume that 61 | } else { 62 | return warn "Skipping network with unknown key_mgmt=$key_mgmt for SSID $SSID" 63 | }; 64 | } 65 | $key_mgmt =~ tr/-/_/; 66 | 67 | if ($IGNORE_OPEN and $key_mgmt eq 'NONE') { return }; 68 | #return if $DEBUG > 0 and $cnt++ < 49; # FIXME DELME debug why it doesn't work will all 74 networks? 69 | 70 | my $CreationTime = strftime "time=%m-%d %H:%M:%S.000", localtime; # FIXME example: time=12-02 01:47:38.625 -- year is lost?? 71 | 72 | my $PSK_LINE = ''; 73 | # https://developer.android.com/reference/android/net/wifi/WifiConfiguration#SECURITY_TYPE_WAPI_PSK 74 | # Values below are BitSet's = arrays of booleans at numbered bit positions: 75 | 76 | my $AllowedKeyMgmt = '01'; # NONE 77 | # https://developer.android.com/reference/android/net/wifi/WifiConfiguration.KeyMgmt 78 | # 0 NONE - WPA is not used; plaintext or static WEP could be used. 79 | # 1 WPA_PSK - WPA pre-shared key (requires preSharedKey to be specified). 80 | # 2 WPA_EAP - WPA using EAP authentication. Generally used with an external authentication server. 81 | # 3 IEEE8021X - IEEE 802.1X using EAP authentication and (optionally) dynamically generated WEP keys. 82 | # 8 SAE - Simultaneous Authentication of Equals 83 | # 9 OWE - Opportunististic Wireless Encryption 84 | # 10 SUITE_B_192 85 | 86 | my $AllowedProtocols = '03'; # WPA1+WPA2 87 | #my $AllowedProtocols = '0b'; # WPA1+WPA2+WAPI - FIXME integrate as script option? 88 | # https://developer.android.com/reference/android/net/wifi/WifiConfiguration.Protocol 89 | # 0 WPA1 (deprecated) 90 | # 1 RSN WPA2/WPA3/IEEE 802.11i 91 | # 3 WAPI 92 | 93 | my $AllowedAuthAlgos = '01'; # open 94 | # https://developer.android.com/reference/android/net/wifi/WifiConfiguration.AuthAlgorithm 95 | # 0 OPEN - Open System authentication (required for WPA/WPA2) 96 | # 1 SHARED - Shared Key authentication (requires static WEP keys) 97 | # 2 LEAP/Network EAP (only used with LEAP) 98 | # 3 SAE (Used only for WPA3-Personal) 99 | if (defined $CUR{auth_alg}) { 100 | $AllowedAuthAlgos = 0; 101 | if ($CUR{auth_alg} =~ m/OPEN/) { $AllowedAuthAlgos |= 1 ; } 102 | if ($CUR{auth_alg} =~ m/SHARED/) { $AllowedAuthAlgos |= 1 << 1 ; } 103 | if ($CUR{auth_alg} =~ m/LEAP/) { $AllowedAuthAlgos |= 1 << 2 ; } 104 | if ($AllowedAuthAlgos eq 0) { warn "probably don't know how to correctly handle auth_alg=$CUR{auth_alg} in SSID $SSID"; } 105 | else { $AllowedAuthAlgos = sprintf "%02x", $AllowedAuthAlgos; } 106 | }; 107 | 108 | #my $AllowedGroupCiphers = '0f'; # 001111 = wep+tkip+aes 109 | my $AllowedGroupCiphers = '2f'; # 101111 = wep+tkip+aes+aes 110 | # https://developer.android.com/reference/android/net/wifi/WifiConfiguration.GroupCipher 111 | # 0 WEP40 = WEP (Wired Equivalent Privacy) with 40-bit key (original 802.11) 112 | # 1 WEP104 = WEP (Wired Equivalent Privacy) with 104-bit key 113 | # 2 TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0] 114 | # 3 CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0] 115 | # 5 GCMP_256 = AES in Galois/Counter Mode 116 | # 6 SMS4 = SMS4 cipher for WAPI 117 | 118 | #my $AllowedPairwiseCiphers = '06'; # TKIP(2)/AES(4) 119 | my $AllowedPairwiseCiphers = '0e'; # TKIP(2)/AES(4)/AES(8) 120 | # https://developer.android.com/reference/android/net/wifi/WifiConfiguration.PairwiseCipher 121 | # 0 NONE - Use only Group keys (deprecated) 122 | # 1 TKIP (WPA1) - deprecated 123 | # 2 CCMP - AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0] 124 | # 3 GCMP_256 - AES in Galois/Counter Mode 125 | # 4 SMS4 cipher for WAPI 126 | 127 | my $AllowedGroupMgmtCiphers = ''; # The samples I've seen have it empty 128 | # https://developer.android.com/reference/android/net/wifi/WifiConfiguration.GroupMgmtCipher 129 | # 0 BIP_CMAC_256 = Cipher-based Message Authentication Code 256 bits 130 | # 1 BIP_GMAC_128 = Galois Message Authentication Code 128 bits 131 | # 2 BIP_GMAC_256 = Galois Message Authentication Code 256 bits 132 | 133 | my $AllowedSuiteBCiphers = '01'; 134 | # SuiteB Ciphers are for WPA3-Enterprise, documentation not detailed at that page above 135 | 136 | if ($key_mgmt ne 'NONE') { 137 | if (!defined $CUR{psk}) { return warn "Skipping - no PSK for SSID $SSID" }; 138 | my $PreSharedKey = quote_xml $CUR{psk}; 139 | $AllowedKeyMgmt = '02'; 140 | $PSK_LINE = '' . $PreSharedKey . ''; 141 | } 142 | 143 | my $WEP_LINE = ''; 144 | if (defined $CUR{wep_key0} || defined $CUR{wep_key1} || defined $CUR{wep_key2} || defined $CUR{wep_key3}) { 145 | $WEP_LINE = '' . "\n"; 146 | if (defined $CUR{wep_key0}) { $WEP_LINE .= '' . "\n"; } else { $WEP_LINE .= '' . "\n"; } 147 | if (defined $CUR{wep_key1}) { $WEP_LINE .= '' . "\n"; } else { $WEP_LINE .= '' . "\n"; } 148 | if (defined $CUR{wep_key2}) { $WEP_LINE .= '' . "\n"; } else { $WEP_LINE .= '' . "\n"; } 149 | if (defined $CUR{wep_key3}) { $WEP_LINE .= '' . "\n"; } else { $WEP_LINE .= '' . "\n"; } 150 | $WEP_LINE .= ''; 151 | 152 | if ($key_mgmt eq 'NONE') { $key_mgmt = 'WEP'; } # For the ConfigKey below to be meaningful 153 | } 154 | 155 | $SSID = quote_xml $SSID; 156 | #my $ConfigKey = "${SSID}-$key_mgmt"; # FIXME integrate version with '-' as script option 157 | my $ConfigKey = "${SSID}$key_mgmt"; 158 | my $priority = $CUR{priority} || 0; 159 | 160 | # output main config block with all variables filled-in 161 | print qq{ 162 | 163 | $ConfigKey 164 | $SSID 165 | any 166 | $PSK_LINE 167 | $WEP_LINE 168 | 169 | 170 | 171 | $AllowedKeyMgmt 172 | $AllowedProtocols 173 | $AllowedAuthAlgos 174 | $AllowedGroupCiphers 175 | $AllowedPairwiseCiphers 176 | $AllowedGroupMgmtCiphers 177 | $AllowedSuiteBCiphers 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | android.uid.system:$CreationUID 193 | $CreationTime 194 | 195 | android.uid.system:$CreationUID 196 | 197 | 198 | 199 | 200 | 201 | NETWORK_SELECTION_ENABLED 202 | NETWORK_SELECTION_ENABLE 203 | 204 | 205 | 206 | 207 | 208 | DHCP 209 | NONE 210 | 211 | 212 | }; 213 | 214 | #die "FIXME TEST KRAJ"; 215 | 216 | # FIXME original looks like this: 217 | #network={ 218 | # ssid="SomeNet name" 219 | # bssid=a4:1d:6b:4b:3e:2f 220 | # psk="SomePassword" 221 | # key_mgmt=WPA-PSK 222 | # priority=201 223 | # disabled=1 224 | # id_str="%7B%22creatorUid%22%3A%22-1%22%2C%22configKey%22%3A%22%5C%22SomeNet+name%5C%22WPA_PSK%22%7D" 225 | #} 226 | 227 | } 228 | 229 | # footer of WifiConfigStore.xml 230 | sub end_xml() { 231 | print < 233 | 234 | 235 | 236 | 237 | EOF 238 | } 239 | 240 | # 241 | # here goes the main loop 242 | # 243 | 244 | start_xml(); 245 | while () 246 | { 247 | chomp; 248 | dbg 9, "line: $_"; 249 | next if /^\s*$/; 250 | 251 | if (/^\s*network\s*=\s*{/) { # "network={" begins a new block 252 | %CUR=(); 253 | next; 254 | } 255 | 256 | if (/^\s*}/) { # sole "}" ends the block 257 | dbg 5, "block end: " . Dumper(\%CUR); 258 | if (!defined $CUR{'ssid'}) { 259 | warn "can't parse network without SSID, ignoring block:" . Dumper(\%CUR); 260 | } 261 | add_xml(); 262 | %CUR=(); 263 | next; 264 | } 265 | 266 | if (/^\s*(\w+)\s*=\s*(.*)$/) { # key=value pairs 267 | $CUR{lc($1)}=$2; 268 | } else { 269 | warn "ignoring unparseable line: $_"; 270 | } 271 | } 272 | 273 | end_xml(); 274 | -------------------------------------------------------------------------------- /selftest-ro/WifiConfigStore.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | "myhome-wpa"WPA_PSK 8 | "myhome-wpa" 9 | 10 | 11 | 12 | "MyWpa@h0mePSK" 13 | 14 | 15 | 16 | 17 | 02 18 | 03 19 | 01 20 | 2f 21 | 0e 22 | 23 | 01 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | android.uid.system:1000 39 | time=11-06 18:12:05.803 40 | 41 | android.uid.system:1000 42 | 43 | 44 | 45 | b6:5d:82:4f:37:8e 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | NETWORK_SELECTION_ENABLED 54 | NETWORK_SELECTION_ENABLE 55 | "myhome-wep"WEP 56 | 57 | 58 | 59 | 60 | DHCP 61 | NONE 62 | 63 | 64 | 65 | 66 | "myhome-wep"WEP 67 | "myhome-wep" 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 01 82 | 03 83 | 03 84 | 2f 85 | 0e 86 | 87 | 01 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | android.uid.system:1000 103 | time=12-20 15:09:21.754 104 | 105 | android.uid.system:1000 106 | 107 | 108 | 109 | 22:8f:19:8f:29:e3 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | NETWORK_SELECTION_ENABLED 118 | NETWORK_SELECTION_ENABLE 119 | 120 | 121 | 122 | 123 | 124 | DHCP 125 | NONE 126 | 127 | 128 | 129 | 130 | "OpenNet"NONE 131 | "OpenNet" 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 01 141 | 03 142 | 01 143 | 2f 144 | 0e 145 | 146 | 01 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | android.uid.system:1000 162 | time=12-20 15:14:43.239 163 | 164 | android.uid.system:1000 165 | 166 | 167 | 168 | 4a:08:cc:f0:76:87 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | NETWORK_SELECTION_ENABLED 177 | NETWORK_SELECTION_ENABLE 178 | 179 | 180 | 181 | 182 | 183 | DHCP 184 | NONE 185 | 186 | 187 | 188 | 189 | "YICarCam"WPA_PSK 190 | "YICarCam" 191 | 192 | "CamPass" 193 | 194 | 195 | 196 | 197 | 02 198 | 03 199 | 01 200 | 2f 201 | 0e 202 | 203 | 01 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | android.uid.system:1000 219 | time=12-20 15:54:52.000 220 | 221 | android.uid.system:1000 222 | 223 | 224 | 225 | 226 | 227 | NETWORK_SELECTION_ENABLED 228 | NETWORK_SELECTION_ENABLE 229 | 230 | 231 | 232 | 233 | 234 | DHCP 235 | NONE 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | -------------------------------------------------------------------------------- /selftest-ro/wpa_supplicant.conf: -------------------------------------------------------------------------------- 1 | ctrl_interface=/data/misc/wifi/sockets 2 | driver_param=use_p2p_group_interface=1 3 | update_config=1 4 | device_name=copper 5 | manufacturer=MadeInChina 6 | model_name=Blumi 4 7 | model_number=Blumi 4 8 | serial_number=ABCD12345EFGH789 9 | device_type=10-0050F204-5 10 | os_version=01020300 11 | config_methods=physical_display virtual_push_button 12 | p2p_no_group_iface=1 13 | external_sim=1 14 | wowlan_triggers=disconnect 15 | 16 | network={ 17 | ssid="myhome-wpa" 18 | psk="MyWpa@h0mePSK" 19 | key_mgmt=WPA-PSK 20 | } 21 | 22 | network={ 23 | ssid="myhome-wep" 24 | key_mgmt=NONE 25 | auth_alg=OPEN SHARED 26 | wep_key0="Me@h0meWepKey" 27 | priority=461 28 | } 29 | 30 | network={ 31 | ssid="OpenNet" 32 | key_mgmt=NONE 33 | priority=12 34 | } 35 | 36 | network={ 37 | ssid="YICarCam" 38 | scan_ssid=1 39 | psk="CamPass" 40 | key_mgmt=WPA-PSK 41 | auth_alg=OPEN 42 | priority=1011 43 | disabled=1 44 | } 45 | -------------------------------------------------------------------------------- /selftest-rw/.nomedia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mnalis/android-wifi-upgrade/8eb3811c526dfad0877b9baf352c7aa9f5e3deb1/selftest-rw/.nomedia --------------------------------------------------------------------------------