由於最近在備戰考試,煩心事超級多,每天埋沒在英語卷子裏都快吐了,輔導員給我打電話說如果我在忘記教育廳疫情打卡,就要給我處分,唉,無奈之下只能使用一些腳本自動化處理了
本程序禁止各種違法使用,比如說你身體出現了情況,卻使用我的腳本批量打卡, 本人不承擔任何責任。
採用python3編寫:
#author:r4bbit 2020 3月13
#!/usr/bin/python3.7
# -*- coding: UTF-8 -*-
import requests
import datetime as dt
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
import datetime
import http.cookiejar
from urllib.parse import urlencode
hanqiwenphoneNumber = "**"
hanqiwenidCard = "**"
hanqiwenMail = "**@qq.com";
def sendMsg(TargetMail,mailTitle,mailContents):
my_sender='**@qq.com'
my_pass = '**'
try:
# 郵件內容
msg=MIMEText(mailContents,'plain','utf-8')
# 括號裏的對應發件人郵箱暱稱、發件人郵箱賬號
msg['From']=formataddr(["辰安科技",my_sender])
# 括號裏的對應收件人郵箱暱稱、收件人郵箱賬號
msg['To']=formataddr(["",TargetMail])
# 郵件的主題
msg['Subject']=formataddr([mailTitle,TargetMail])
# SMTP服務器,騰訊企業郵箱端口是465,騰訊郵箱支持SSL(不強制), 不支持TLS
# qq郵箱smtp服務器地址:smtp.qq.com,端口號:456
# 163郵箱smtp服務器地址:smtp.163.com,端口號:25
server=smtplib.SMTP_SSL("smtp.qq.com", 465)
# 登錄服務器,括號中對應的是發件人郵箱賬號、郵箱密碼
server.login(my_sender, my_pass)
# 發送郵件,括號中對應的是發件人郵箱賬號、收件人郵箱賬號、發送郵件
server.sendmail(my_sender,[TargetMail,],msg.as_string())
# 關閉連接
print("發送成功")
except Exception as e:
print("發送郵件失敗");
print(e);
def Login(PhoneNumber, IDcard):
url = "http://jktb.haedu.gov.cn/?act=verify"
headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:73.0) Gecko/20100101 Firefox/73.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate",
"Cookie": "UM_distinctid=16e8d58890296-04d261c99e30af-4b536f-13c680-16e8d588903262; CNZZDATA1264405206=0%7C1584028912; CNZZDATA1255523150=0%7C1584027839; PHPSESSID=aj6m0sqne13itveoe70u9smj3j; sid=IyA6cCV4Zg%3D%3D; schoolExt=124; schoolType=2; schoolName=%E9%83%91%E5%B7%9E%E7%94%B5%E5%8A%9B%E9%AB%98%E7%AD%89%E4%B8%93%E7%A7%91%E5%AD%A6%E6%A0%A1; UM_distinctid=0; type=1; ulauth=b4e4a35b4ce2b400433eef49dad3a729; uniName=%E7%94%B5%E5%8A%9B%E5%B7%A5%E7%A8%8B%E5%AD%A6%E9%99%A2; uvauth=144e91e968491e16834c77e44e8019a4"
}
datas = {
"do": "check",
"str": "144e91e968491e16834c77e44e8019a4",
"mobile": PhoneNumber,
"idCard": IDcard
}
#roxys = {"http": "127.0.0.1:8080"}
try:
cookieSession = requests.session();
res = cookieSession.post(url, data=datas, headers=headers)
res = res.json();
if(res['code']==0):
print(res['msg']);
print("登陸成功 手機號:{}".format(PhoneNumber))
return cookieSession; #把session返回過去
except:
#print("ERROR");
return 0;
def CheckIN(cookieSession): #打卡發表單數據
url = "http://jktb.haedu.gov.cn/?act=health"
headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:74.0) Gecko/20100101 Firefox/74.0",
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"timestamp": "1584102693715",
"X-Requested-With": "XMLHttpRequest",
#"Cookie": "UM_distinctid=16e8d58890296-04d261c99e30af-4b536f-13c680-16e8d588903262; CNZZDATA1264405206=0%7C1584102103; CNZZDATA1255523150=0%7C1584097966; PHPSESSID=0; sid=IyA6cCl4bQ%3D%3D; schoolExt=124; schoolType=2; schoolName=%E9%83%91%E5%B7%9E%E7%94%B5%E5%8A%9B%E9%AB%98%E7%AD%89%E4%B8%93%E7%A7%91%E5%AD%A6%E6%A0%A1; UM_distinctid=0; type=1; ulauth=f90a0dde64cd962d91aad4b21eba2e75; uniName=%E4%BF%A1%E6%81%AF%E9%80%9A%E4%BF%A1%E5%AD%A6%E9%99%A2; uvauth=44224ee4084f0d6d88d21caeed11a292; uerrNum=0; uerrExpire=0; uin=1; uuid=JiU6Yi9sYnNlLmE%3D; utid=1; name=%E9%9F%A9%E5%A5%87%E6%96%87; healAjax=0"
}
#獲取今天日期
times = datetime.datetime.now();
date = "{}-{}-{}".format(times.year,times.month,times.day);
datas = {
"regYmd":date,
"regProvince":"490000",
"regCity":"491400",
"regArea":"491426",
"isCunDiag":"0",
"isToge":"0",
"cunAddr":"0",
"isGoHb":"0",
"goCity":"0",
"goYmd":"0",
"isTouch":"0",
"touchProvince":"0",
"touchCity":"0",
"touchArea":"0",
"touchAddr":"0",
"touchYmd":"0",
"isObs":"0",
"isDiag":"0",
"diagYmd":"0",
"diagHospital":"0",
"CureYmd":"0",
"isGood":"1",
"whatSitua":"0",
"cunWhere":"0",
"touchWhere":"0",
"do":"ajax",
}
#roxys = {"http": "127.0.0.1:8080"}
try:
res = cookieSession.post(url, data=datas, headers=headers)
result = res.json()
if(result['code']==0):
print(result['msg']);
print("表單已發送");
except Exception as e:
print("[x]打卡失敗 ERROR");
print(e);
exit(0);
def CheckResult(cookieSession,studentName):
global mailContent;
url = "http://jktb.haedu.gov.cn/?act=healok"
cookies = "UM_distinctid=16e8d58890296-04d261c99e30af-4b536f-13c680-16e8d588903262; CNZZDATA1264405206=0%7C1584102103; CNZZDATA1255523150=0%7C1584097966; PHPSESSID=0; sid=IyA6cCl4bQ%3D%3D; schoolExt=124; schoolType=2; schoolName=%E9%83%91%E5%B7%9E%E7%94%B5%E5%8A%9B%E9%AB%98%E7%AD%89%E4%B8%93%E7%A7%91%E5%AD%A6%E6%A0%A1; UM_distinctid=0; type=1; ulauth=f90a0dde64cd962d91aad4b21eba2e75; uniName=%E4%BF%A1%E6%81%AF%E9%80%9A%E4%BF%A1%E5%AD%A6%E9%99%A2; uvauth=44224ee4084f0d6d88d21caeed11a292; uerrNum=0; uerrExpire=0; uin=1; uuid=JiU6Yi9sYnNlLmE%3D; utid=1; name={}; healAjax=1".format(studentName);
#rint("cookies",cookies);
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:74.0) Gecko/20100101 Firefox/74.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"timestamp": "1584102693715",
"X-Requested-With": "XMLHttpRequest",
"Cookie" : cookies
}
try:
res = cookieSession.get(url, headers=headers)
#print(res.text);
html = res.text;
index = html.find("姓名");
#print("index",index);
mailContent = "";
mailContent = html[index:index+32];
print(mailContent);
flag = "提交成功";
if(html.rfind(flag)!=-1):
return True;
else:
return False;
except:
print("CheckResult ERROR");
exit(0);
def Sb(phoneNumber,idCard,targetMail,studentName):
loginSession = Login(phoneNumber,idCard);
if(loginSession!=0):
#LOGIN OK
CheckIN(loginSession);
if(CheckResult(loginSession,studentName)):
print("打卡成功");
mailTitle = "打卡成功"
sendMsg(targetMail,mailTitle,mailContent);
else:
print("打卡失敗");
mailTitle= "打卡失敗"
sendMsg(targetMail,mailTitle,mailContent);
else:
print("打卡失敗");
def main():
hanqiwen = "%e9%9**5%87%***%96%87" url編碼
mayue = "%e9%a9**e5%***%a4";
Sb(hanqiwenphoneNumber,hanqiwenidCard,"**@qq.com",hanqiwen);
Sb("**","**","**@qq.com",mayue);
if __name__ == '__main__':
main();
由於自己心態問題,快考試了比較急躁,程序寫的比較粗糙,但是可以自動打卡教育廳,教育廳疫情打卡平臺代碼也寫的比較粗糙,沒有驗證碼,瘋狂發包可以被ddos,還有一個cookie可以訪問登陸無數人的賬戶等等問題
腳本放在服務器運行寫一個定時計劃任務即可 打卡成功後會發送到郵箱提示
本來想做一個自動化平臺,php+python
算啦,哪有那麼多精力,但是我真的是手癢想做,如果不是因爲要考試,我就去逆一下丁丁打卡發的數據包,以此致我失去的初心。