Python as a high-level programming language, its positioning is elegant, clear and simple. Reading the code written in Python feels like reading English, which allows users to focus on solving problems rather than figuring out the language itself. Python is written in C, but it is simple and easy to learn by abandoning the complex pointers in C. And as open source software, Python allows reading, copying, and even improving the code. These performance achievements Python's high efficiency, "Life is short, I use Python", said, is a very exciting and powerful language.
In the recent company project development in contact with the Python language and WiFi-related knowledge, just what you learned recently and share.
0X0001 Development Environment:
Windows 10+python2.7.15
0x0002 Development Goals:
Develop a dictionary-based hack for WiFi hotspot password gadgets
In the development of this tool, I now search for some projects on the Internet, but all under Linux, not directly for the Windows platform, so decided to combine the found under the Linux project, modified to run under Windows.
First find the article "a very easy to understand WiFi password blasting python script" but the article said that the use of the Pywifi module, "This module in win a little chicken, the author in the call Wlanapi did not do a good wlan_security_attributes package , so it is recommended to run under Linux, my test is Kali 2.0 comes with Python 2.7.6, can be installed directly through the PIP install Pywifi. "But I found in the test, under Windows can still run, because the module's source code to make some changes, so there is no installation module, but directly copy the module source code to the project directory.
Changes to the 0X0003 module:
When using the module's own test case, it was found that print was outputting a lot of useless information, so the call to "Show_my_need_info" was removed from the _wifiutil_win.py 335 lines.
0X0004 Program Execution Process
Functional requirements are clear, so our steps are as follows:
1, get the local wireless network card information
2. Scan around WiFi hotspots
3. Try connecting to a WiFi hotspot using a dictionary
4. Output Scan Results
Follow the above process to write code.
0x0005 Code Implementation
Get Wireless Network Information
After referencing the module, the main use of the interfaces function to obtain the native wireless network card information, the specific code is encapsulated as follows:
Scan around hotspots
Mainly through the scan function to obtain the scan_results results, the specific code package is as follows, here Sleep (2) is because the test when the wireless network card return information needs some time, of course, if your network card performance is good, you can remove this sleep:
Try to connect (crack password)
Password cracking first define a profile, and then call Connect as a parameter for the connection attempt, using the status function to take the return value of the connection result, if it is Const. The iface_connected is connected successfully, showing the result, if the other is the failure.
The main code as above, the effect is as follows:
Problem
One problem here is that the Windows version of the Pywifi module does not implement encryption status information for WiFi hotspots, such as using WPA, WPA2, WPA2PSK, or WPAPSK encryption authentication. So I'm going to treat all WiFi hotspots as a cryptographic authentication by default and treat them as "profile.akm.append" (const) when cracked. AKM_TYPE_WPA2PSK) "For a crack attempt.
Start to notice the points:
1. Code specification, which is in itself a very good habit, if you start not to foster good code planning, will be very painful
2. More hands, less reading, a lot of people learn python blindly reading, this is not learning mathematics physics, you see examples may be, learning Python is mainly learning programming ideas.
3. Diligent practice, learn new knowledge points, must remember how to apply, otherwise after learning will forget, learn our line is mainly practical operation.
4. Learn to be efficient, if you feel that efficiency is very low, then stop, look for reasons, to ask the experienced who this is why
I have a public number, and I often share some of the stuff about Python technology. If you like my share, you can use the search "Python language learning" to follow
Python Black tech: Still upset about the lack of WiFi? This article addresses your obsession.