In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to use Node.js to get WI-FI passwords. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Demonstration effect
Global installation of wifi-password-cli dependency
Npm install wifi-password-cli-g # ornpx wifi-password-cli
Use
$wifi-password [network-name] $wifi-password12345678 $wifi-password Office wifia1234b2345
Think Node.js is amazing, huh? Actually, it's not. Let's see how it works.
Implementation principle OSX system
Query the wifi password with the following command
Security find-generic-password-D "AirPort network password"-wa "wifi-name" Linux system
All wi-fi connection information is in the / etc/NetworkManager/system-connections/ folder
We query the wifi password with the following command
Sudo cat / etc/NetworkManager/system-connections/Windows system
Query the wifi password with the following command
Netsh wlan show profile name= key=clear implementation source code
Its implementation source code is also very simple, you can learn if you are interested.
Https://github.com/kevva/wifi-password
The entry file is index.js. First of all, choose a different acquisition method by judging the user's operating system.
'use strict';const wifiName = require (' wifi-name'); module.exports = ssid = > {let fn = require ('. / lib/linux'); if (process.platform = = 'darwin') {fn = require ('. / lib/osx');} if (process.platform = 'win32') {fn = require ('. / lib/win') } if (ssid) {return fn (ssid);} return wifiName (). Then (fn);}; Linux'use strict';const execa = require ('execa'); module.exports = ssid = > {const cmd =' sudo'; const args = ['cat', `/ etc/NetworkManager/system-connections/$ {ssid}`] Return execa.stdout (cmd, args). Then (stdout = > {let ret; ret = / ^\ s * (?: psk | password) = (. +)\ s*$/gm.exec (stdout); ret = ret & & ret.length? Ret [1]: null; if (! ret) {throw new Error ('Could not get password');} return ret;});}; OSX'use strict';const execa = require (' execa'); module.exports = ssid = > {const cmd = 'security' Const args = ['find-generic-password','-dating, 'AirPort network password','-wa', ssid]; return execa (cmd, args) .then (res = > {if (res.stderr) {throw new Error (res.stderr)) } if (! res.stdout) {throw new Error ('Could not get password');} return res.stdout Catch (err = > {if (/ The specified item could not be found in the keychain/.test (err.message)) {err.message = 'Your network doesn\' t have a password';} throw err;}) }; Windows'use strict';const execa = require ('execa'); module.exports = ssid = > {const cmd =' netsh'; const args = ['wlan',' show', 'profile', `name=$ {ssid} `,' key=clear']; return execa.stdout (cmd, args) .then (stdout = > {let ret) Ret = / ^\ s*Key Content\ stdout: (. +)\ s*$/gm.exec (stdout); ret = ret & & ret.length? Ret [1]: null; if (! ret) {throw new Error ('Could not get password');} return ret;});}; Thank you for reading! This is the end of the article on "how to get the WI-FI password using Node.js". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.