关于某仙网抢茅台的协议分析和源代码(续)
本帖最后由 qiucx 于 2021-4-2 14:06 编辑关于某仙网抢茅台的协议分析和源代码 https://www.52pojie.cn/thread-1396064-1-1.html
发布后,得到很多网友的支持,但很多网友不理解怎么写,现提供部分源码供研究,请勿用于商业用途,否则后果自负。
Date deadDate = getDeadline();
String token = "";
while (true) {
// login the system before buying 12 seconds.
if ((deadDate.getTime() - new Date().getTime()) / 1000 > 20) {
System.out.println("Going to sleep 5 second...");
Thread.sleep(5000);
continue;
}
System.out.println("Starting to login system...");
token = login();
cookie = cookie + token;
// preReservationOrderUrl = (preReservationOrderUrl +
// token).replace("APPKEYXXX", appkey).replace("PUSHTOKENXXX",
// pushToken);
settlementUrl = (settlementUrl + token).replace("APPKEYXXX", appkey).replace("PUSHTOKENXXX", pushToken);
// getAccountSecurityUrl = (getAccountSecurityUrl+
// token).replace("APPKEYXXX", appkey).replace("PUSHTOKENXXX",
// pushToken);
// collectUrl = (collectUrl + token).replace("APPKEYXXX",
// appkey);//.replace("PUSHTOKENXXX", pushToken);
System.out.println("ANDROID" + URLDecoder.decode(appkey, "UTF-8") + DEVICE_ID);
// //System.out.println(MD5Util.encode("ANDROID" +
// URLDecoder.decode(appkey, "UTF-8") + DEVICE_ID));
orderUrl = (orderUrl + token)
.replace("APPKEYXXX", appkey)
.replace("PUSHTOKENXXX", pushToken)
.replace("RESERVATIONTOKENXXX",
JiuXianWebMd5.encode("ANDROID" + URLDecoder.decode(appkey, "UTF-8") + DEVICE_ID));
// reservationProDetailURL = (reservationProDetailURL +
// token).replace("APPKEYXXX", appkey).replace("PUSHTOKENXXX",
// pushToken);
// cookie = cookie+token;
System.out.println("settlementUrl= " + settlementUrl);
System.out.println("ordertUrl= " + orderUrl);
break;
}
while (true) {
System.out.println("========The server date is ===========" + new Date());
// long internal = sysTime - new Date().getTime();
if (new Date().getTime() > deadDate.getTime()) {
settlement(settlementUrl);
// for (int i = 0; i < 100; i++) {
while (true) {
JiuXianWebAndroid.getInstance().httpAsyncSendByMap();
// Thread.sleep(1111111);
}
} }
private static String login() {
String url = "";
String urlConf = config.get("LoginURL");
if (urlConf != null && urlConf.trim().length() > 0) {
url = urlConf;
}
url = url.replace("APPKEYXXX", appkey).replace("PUSHTOKENXXX", pushToken);
//System.out.println("loginUrl==" + url);
HttpPost post = new HttpPost(url);
post.setHeader("Content-Type", contentType);
post.setHeader("Accept", accept);
post.setHeader("User-Agent", agent);
post.setHeader("Cookie", cookie);
try {
HttpResponse response = httpClient.execute(post);
HttpEntity entitys = response.getEntity();
if (entitys != null) {
InputStream instream = entitys.getContent();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] data = new byte;
int count = -1;
while ((count = instream.read(data, 0, 1024)) != -1)
outStream.write(data, 0, count);
data = null;
String ret = new String(outStream.toByteArray(), "utf-8");
//System.out.println(ret);
JSONObject jsonArray = JSONObject.fromObject(ret);
String token = "";
try {
token = jsonArray.getJSONObject("result").getJSONObject("userInfo").getString("token");
} catch (Exception e) {
int idx = ret.indexOf("\"token\":\"");
token = ret.substring(idx + 9, idx + 50);
}
System.out.println("Login successfully and the return token is : " + token);
return token;
}
} catch (Exception e) {
e.printStackTrace();
// break;
}
return null;
}
private static void settlement(String setUrl) {
HttpPost post = new HttpPost(setUrl);
post.setHeader("Content-Type", contentType);
post.setHeader("Accept", accept);
post.setHeader("User-Agent", agent);
post.setHeader("Cookie", cookie);
try {
while (true) {
HttpResponse response = httpClient.execute(post);
HttpEntity entitys = response.getEntity();
if (entitys != null) {
InputStream instream = entitys.getContent();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] data = new byte;
int count = -1;
while ((count = instream.read(data, 0, 1024)) != -1)
outStream.write(data, 0, count);
data = null;
String ret = new String(outStream.toByteArray(), "utf-8");
JSONObject jsonArray = JSONObject.fromObject(ret);
System.out.println("settlement response============" + ret);
JSONArray arr = jsonArray.getJSONObject("result").getJSONObject("productsList").getJSONArray("unableProducts");
if(arr.size() == 0) {
break;
}
}
Thread.sleep(80);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void order(String orderUrl) {
//System.out.println("settlementUrl=" + setUrl + ", orderUrl=" + orderUrl);
/* HttpPost post = new HttpPost(setUrl);
post.setHeader("Content-Type", contentType);
post.setHeader("Accept", accept);
post.setHeader("User-Agent", agent);
post.setHeader("Cookie", cookie);
try {
HttpResponse response = httpClient.execute(post);
HttpEntity entitys = response.getEntity();
if (entitys != null) {
InputStream instream = entitys.getContent();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] data = new byte;
int count = -1;
while ((count = instream.read(data, 0, 1024)) != -1)
outStream.write(data, 0, count);
data = null;
String ret = new String(outStream.toByteArray(), "utf-8");
System.out.println("settlement response============" + ret);
}
} catch (Exception e) {
e.printStackTrace();
}*/
HttpPost post = new HttpPost(orderUrl);
post.setHeader("Content-Type", contentType);
post.setHeader("Accept", accept);
post.setHeader("User-Agent", agent);
post.setHeader("Cookie", cookie);
try {
HttpResponse response = httpClient.execute(post);
HttpEntity entitys = response.getEntity();
if (entitys != null) {
InputStream instream = entitys.getContent();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] data = new byte;
int count = -1;
while ((count = instream.read(data, 0, 1024)) != -1)
outStream.write(data, 0, count);
data = null;
String ret = new String(outStream.toByteArray(), "utf-8");
System.out.println("Order response============" + ret);
}
} catch (Exception e) {
e.printStackTrace();
}
}
打字不易,有帮助就点个赞,加个分。 zfyuser 发表于 2021-4-2 13:42
上次加了Q 本想把SK的加密方式告诉你 奈何你不回我 等了一个礼拜 我就把你删了
不好意思,可能不小心忽视了。SK加密算法已经搞好了,谢谢! hjlost 发表于 2021-4-4 22:48
DEVICE_ID这个参数是什么 ?是 deviceIdentify 吗?那不是跟appKey一样了?
有些设备一样,有些设备不一样的 本帖最后由 qiucx 于 2021-3-20 11:27 编辑
另外,在不同的设备登录N次都不影响,每个token都有效。也就是说,你用10台手机登录同一个账户都没问题。 感谢分享~ 来学习一下
厉害厉害。有心了 来学习学习感谢大佬分享 学习学习感谢大佬 nb大佬 学习学习 来学习学习 nb大佬 学习学习