{"id":989,"date":"2022-01-12T09:15:41","date_gmt":"2022-01-12T01:15:41","guid":{"rendered":"http:\/\/www.eait.co\/?p=989"},"modified":"2022-01-12T09:58:46","modified_gmt":"2022-01-12T01:58:46","slug":"python-%e4%ba%91%e7%9b%98%e5%8d%8a%e9%80%8f%e6%98%8e%e5%8a%a0%e5%af%86%e5%b7%a5%e5%85%b7","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=989","title":{"rendered":"python \u4e91\u76d8\u534a\u900f\u660e\u52a0\u5bc6\u5de5\u5177"},"content":{"rendered":"<p>\u7528\u4e91\u76d8\u548c\u79fb\u52a8\u786c\u76d8\u6570\u636e\u5b89\u5168\u6027\u90fd\u77e5\u9053\u7684\uff0c\u575a\u679c\u4e91\u4e4b\u524d\u76f4\u63a5\u4e0d\u5efa\u8bae\u7528\u6765\u540c\u6b65\u4ee3\u7801\uff0c\u4e8e\u662f\u505a\u4e2a\u81ea\u52a8\u52a0\u89e3\u5bc6\u7684\u5de5\u5177\uff1a<br \/>\n\uff08\u53ef\u4ee5\u5c06\u89e3\u5bc6\u5730\u5740\u8bbe\u8ba1\u6210\u684c\u9762\uff0c\u5b9e\u73b0\u62d6\u52a8\u89e3\u5bc6,\u7b2c\u4e00\u6b21\u7528\u800c\u4e14\u6570\u636e\u91cf\u8f83\u5927\uff0c\u4e8e\u662f\u52a0\u4e86\u4e2a\u54c8\u5e0c\u9a8c\u8bc1\uff0c\u540e\u9762\u53ef\u4ee5\u53bb\u6389\uff09<br \/>\n\u7f3a\u70b9\uff0c\u6682\u65f6\u5bf9\u5927\u6587\u4ef6\u652f\u6301\u4e0d\u662f\u5f88\u53cb\u597d\uff0c\u5360\u7528\u5185\u5b58\uff0c\u5e94\u8be5\u6709\u7c7b\u4f3c\u54c8\u5e0c\u7684update\u65b9\u6cd5\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n\r\nif __name__ == &quot;__main__&quot;:\r\n    while True:\r\n        print('\u5f00\u59cb%s'%(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))\r\n        # \u81ea\u52a8\u52a0\u5bc6\u9636\u6bb5\r\n        encpath = r'C:\\Users\\Administrator\\Desktop\\\u52a0\u5bc6'\r\n        files = os.walk(encpath)\r\n        for path,dirlist,filelist in files:\r\n            for file in filelist:\r\n                if'baiduyun.uploading.cfg' in file:\r\n                    continue\r\n                if not file.startswith('enc777'):\r\n                    file_path = os.path.join(path, file)\r\n                    with open(file=os.path.join(path,file),mode='rb') as f:\r\n                        file_content = f.read()\r\n                    content_hash = hashlib.md5(file_content).hexdigest()\r\n                    aes = AESCipher()\r\n                    enc_content = aes.encrypt(file_content)\r\n                    dec_contnet = aes.decrypt(enc_content)\r\n                    content_hashdec = hashlib.md5(dec_contnet).hexdigest()\r\n                    if content_hashdec==content_hash:\r\n                        with open(os.path.join(path,'enc777'+file),'wb+') as f:\r\n                            f.write(enc_content)\r\n                        os.remove(os.path.join(path,file))\r\n                    else:\r\n                        print('\u524d\u540e\u4e0d\u4e00\u6837\u62d2\u7edd\u52a0\u5bc6')\r\n                        continue\r\n\r\n        # \u81ea\u52a8\u89e3\u5bc6\u9636\u6bb5\uff1a\r\n        decpath = r'C:\\Users\\Administrator\\Desktop\\\u89e3\u5bc6'\r\n        files = os.walk(decpath)\r\n        for path, dirlist, filelist in files:\r\n            for file in filelist:\r\n                if file.startswith('enc777'):\r\n                    file_path = os.path.join(path, file)\r\n                    with open(file=os.path.join(path, file), mode='rb') as f:\r\n                        file_content = f.read()\r\n                    content_hash = hashlib.md5(file_content).hexdigest()\r\n                    aes = AESCipher()\r\n                    dec_content = aes.decrypt(file_content)\r\n                    enc_contnet = aes.encrypt(dec_content)\r\n                    content_hashdec = hashlib.md5(enc_contnet).hexdigest()\r\n                    # if content_hashdec == content_hash:\r\n                    if True:\r\n                        with open(os.path.join(path, file&#x5B;6:]), 'wb+') as f:\r\n                            f.write(dec_content)\r\n                        os.remove(os.path.join(path, file))\r\n                    else:\r\n                        print('\u524d\u540e\u4e0d\u4e00\u6837\u62d2\u7edd\u89e3\u5bc6') # \u518d\u52a0\u5bc6\u65f6iv\u4e0d\u540c\uff0c\u56e0\u6b64\u51c9\u51c9\r\n                        continue\r\n        time.sleep(1)\r\n        # print('\u52a0\u89e3\u5bc6\u5b8c\u6210')\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7528\u4e91\u76d8\u548c\u79fb\u52a8\u786c\u76d8\u6570\u636e\u5b89\u5168\u6027\u90fd\u77e5\u9053\u7684\uff0c\u575a\u679c\u4e91\u4e4b\u524d\u76f4\u63a5\u4e0d\u5efa\u8bae\u7528\u6765\u540c\u6b65\u4ee3\u7801\uff0c\u4e8e\u662f\u505a\u4e2a\u81ea\u52a8\u52a0\u89e3\u5bc6\u7684\u5de5\u5177\uff1a \uff08\u53ef\u4ee5\u5c06\u89e3\u5bc6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,29],"tags":[20],"class_list":["post-989","post","type-post","status-publish","format-standard","hentry","category-java","category-29","tag-python"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=989"}],"version-history":[{"count":4,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/989\/revisions"}],"predecessor-version":[{"id":993,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/989\/revisions\/993"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}