Skip to content

Commit

Permalink
2021-01-11:添加Cloud类型学校自动登录获取cookie版本
Browse files Browse the repository at this point in the history
  • Loading branch information
meethigher committed Jan 10, 2021
1 parent 17fc939 commit 93f13c0
Show file tree
Hide file tree
Showing 43 changed files with 1,228 additions and 14 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
# 使用的话,只需要修改collection.properties即可。
# 使用的话,只需要修改collection.properties即可。适合单选问卷!

不需要密码,需要抓包到MOD_AUTH_CAS,脚本自动保持登录,适用于所有学校
auto_cookie与auto_login是不同的版本,可以单独使用。auto_cookie是去年5月份搞的,今年有时间,就把auto_login的也整了。

思路看篇文章[今日校园实现自动监测并提交最新表单](https://meethigher.top/blog/2020/cpdaily-automation/)
auto_cookie不需要密码,需要抓包到MOD_AUTH_CAS,脚本自动保持登录,适用于所有学校

历史源码(2021年1月9日)
auto_login只需要配置好collection.properties即可,免抓包。网上千篇一律自动登录的,我看了一下,好像都是NOCLOUD学校的。auto_login支持今日校园CLOUD学校,截止到2021年1月11,我应该是第一个开源这类学校自动登录源码的吧,网上还有人付费卖,啧啧

auto_cookie实现思路看这篇文章[今日校园实现自动监测并提交最新表单](https://meethigher.top/blog/2020/cpdaily-automation/)

auto_login实现思路看这篇文章[今日校园自动登录教程](https://meethigher.top/blog/2021/cpdaily-autologin/)

历史源码(2021年1月11日)

* [1.0](https://github.com/meethigher/cpdaily-submit/tree/1.0):已失效
* [2.0](https://github.com/meethigher/cpdaily-submit/tree/2.0):已失效
* [2.1](https://github.com/meethigher/cpdaily-submit/tree/2.1)
* [最新版](https://github.com/meethigher/cpdaily-submit)

使用方法

1. [查看所有学校信息](https://static.campushoy.com/apicache/tenantListSort就是),找到你学校的id,如果是ccut这种的,直接第3步,如果是一串字母数字,跳到第2步
2. https://mobile.campushoy.com/v6/config/guest/tenant/info?ids=你学校的id,找到idsUrl。比方说,有https://ccut.campusphere.net/iap,则ccut即你的id,跳到第三步。
3. 登录http(s)://你学校.campusphere.net/portal/index.html,比如[长春工业大学](https://ccut.campusphere.net/portal/index.html)
4. 电脑直接用开发者工具、或者点击地址栏的小锁头选择cookie获取MOD_AUTH_CAS即可。
5. 手机使用HttpCanary抓取浏览器记录即可。
6. 运行Main.java
* [3.0](https://github.com/meethigher/cpdaily-submit/tree/3.0)

更新记录

* 2021-01-11:添加自动登录版本,监测到登录失效自动登录。也就是auto_login下的代码。

* 2021-01-08:更新加密算法密钥,感谢ZimoLoveShuang大佬

* 2021-01-06:
Expand Down
8 changes: 8 additions & 0 deletions easy/collection.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
host=你的学校host,如https://ccut.campusphere.net
fromail=你的发件邮箱账号,如meethigher@qq.com
fromailPw=你的发件邮箱密码
key=37.3\u2103\u4EE5\u4E0B,\u5065\u5EB7,\u5426,中文注意采用unicode编码
id=5201314
pw=密码
poi=\u4E2D\u56FD\u5C71\u4E1C\u7701\u6CF0\u5B89\u5E02\u65B0\u6CF0\u5E02,中文注意采用unicode编码
tomail=你的收件邮箱
Binary file added easy/cpdaily.jar
Binary file not shown.
Binary file added easy/tessdata/eng.traineddata
Binary file not shown.
Binary file added lib/tess-lib/commons-beanutils-1.9.2.jar
Binary file not shown.
Binary file added lib/tess-lib/commons-io-2.6.jar
Binary file not shown.
Binary file added lib/tess-lib/commons-logging-1.2.jar
Binary file not shown.
Binary file added lib/tess-lib/fontbox-2.0.9.jar
Binary file not shown.
Binary file added lib/tess-lib/ghost4j-1.0.1.jar
Binary file not shown.
Binary file added lib/tess-lib/hamcrest-core-1.3.jar
Binary file not shown.
Binary file added lib/tess-lib/itext-2.1.7.jar
Binary file not shown.
Binary file added lib/tess-lib/jai-imageio-core-1.4.0.jar
Binary file not shown.
Binary file added lib/tess-lib/jbig2-imageio-3.0.0.jar
Binary file not shown.
Binary file added lib/tess-lib/jboss-vfs-3.2.12.Final.jar
Binary file not shown.
Binary file added lib/tess-lib/jcl-over-slf4j-1.7.25.jar
Binary file not shown.
Binary file added lib/tess-lib/jna-4.1.0.jar
Binary file not shown.
Binary file added lib/tess-lib/jul-to-slf4j-1.7.25.jar
Binary file not shown.
Binary file added lib/tess-lib/junit-4.12.jar
Binary file not shown.
Binary file added lib/tess-lib/lept4j-1.6.4.jar
Binary file not shown.
Binary file added lib/tess-lib/log4j-1.2.17.jar
Binary file not shown.
Binary file added lib/tess-lib/log4j-over-slf4j-1.7.25.jar
Binary file not shown.
Binary file added lib/tess-lib/logback-classic-1.2.3.jar
Binary file not shown.
Binary file added lib/tess-lib/logback-core-1.2.3.jar
Binary file not shown.
11 changes: 11 additions & 0 deletions lib/tess-lib/nblibraries.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To change this template, choose Tools | Templates
# and open the template in the editor.

libs.hamcrest.classpath=\
${base}/hamcrest-core-1.3.jar
libs.hamcrest.displayName=Hamcrest 1.3
libs.hamcrest.prop-maven-dependencies=org.hamcrest:hamcrest-core:1.3:jar
libs.junit_4.classpath=\
${base}/junit-4.12.jar
libs.junit_4.displayName=JUnit 4.12
libs.junit_4.prop-maven-dependencies=junit:junit:4.12:jar
Binary file added lib/tess-lib/pdfbox-2.0.9.jar
Binary file not shown.
Binary file added lib/tess-lib/pdfbox-tools-2.0.9.jar
Binary file not shown.
Binary file added lib/tess-lib/slf4j-api-1.7.25.jar
Binary file not shown.
Binary file added lib/tess-lib/win32-x86-64/libtesseract3051.dll
Binary file not shown.
Binary file added lib/tess-lib/win32-x86/libtesseract3051.dll
Binary file not shown.
Binary file added lib/tess-lib/xmlgraphics-commons-1.5.jar
Binary file not shown.
Binary file added lib/tess4j-3.4.8.jar
Binary file not shown.
91 changes: 91 additions & 0 deletions src/auto_login/CaptchaDecoding.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package auto_login;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

/**
*
* CaptchaDecoding 用来识别验证码
*
* @author kit chen
* @github https://github.com/meethigher
* @blog https://meethigher.top
* @time 2021年1月10日
*/
public class CaptchaDecoding {
/**
* 云端下载验证码
*
* @param url
* @param headers
* @return
*/
public static File downloadCaptcha(String url, Map<String, String> headers) {
InputStream is = null;
FileOutputStream fos = null;
try {
URL realUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
// 必须设置false,否则会自动重定向到目标地址
conn.setInstanceFollowRedirects(false);
if (headers != null) {
Set<Entry<String, String>> set = headers.entrySet();
for (Entry<String, String> header : set) {
conn.setRequestProperty(header.getKey(), header.getValue());
}
}
conn.connect();
is = conn.getInputStream();
fos = new FileOutputStream("captcha.jpg");
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
} catch (Exception e) {
System.out.println("读取验证码出错!");
e.printStackTrace();
} finally {
try {
if (is != null)
is.close();
if (fos != null)
fos.close();
} catch (Exception e2) {

}
}
return new File("captcha.jpg");
}

/**
* 识别验证码
*
* @param file
* @return
*/
public static String parseCaptcha(File file) {
Tesseract tess = new Tesseract();
//开发环境运行时设置
tess.setDatapath(ClassLoader.getSystemResource("tessdata").getPath().substring(1));
//jar包运行时设置
// String tesspath = System.getProperty("user.dir");
// tess.setDatapath(tesspath+"/tessdata");
tess.setLanguage("eng");
try {
return tess.doOCR(file).replace(" ", "");
} catch (TesseractException e) {
System.out.println("解析验证码出错!");
e.printStackTrace();
return null;
}
}
}
93 changes: 93 additions & 0 deletions src/auto_login/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package auto_login;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

/**
*
* Config 读取配置文件工具类
*
* @author kit chen
* @github https://github.com/meethigher
* @blog https://meethigher.top
* @time 2021年1月6日
*/
public class Config {
private static String host;
private static String id;
private static String pw;
private static String poi;
private static String tomail;
private static String fromail;
private static String fromailPw;
private static String key;

public static Properties pro;
static {
InputStream is =null;
ClassLoader cl = Config.class.getClassLoader();
try {
//这个是开发环境运行时设置
is = cl.getResourceAsStream("collection.properties");
//这个是jar包时设置
// is=new FileInputStream(new File("collection.properties"));
pro = new Properties();
pro.load(is);
host = pro.getProperty("host");
id = pro.getProperty("id");
pw = pro.getProperty("pw");
poi = pro.getProperty("poi");
tomail = pro.getProperty("tomail");
fromail = pro.getProperty("fromail");
fromailPw = pro.getProperty("fromailPw");
key = pro.getProperty("key");
} catch (IOException e) {
System.out.println("读取配置文件出现错误");
e.printStackTrace();
} finally {
try {
if (is != null)
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

public static String getHost() {
return host;
}

public static String getId() {
return id;
}

public static String getPw() {
return pw;
}

public static String getPoi() {
return poi;
}

public static String getTomail() {
return tomail;
}

public static String getFromail() {
return fromail;
}

public static String getFromailPw() {
return fromailPw;
}

public static String getKey() {
return key;
}
}
Loading

0 comments on commit 93f13c0

Please sign in to comment.