fix dynamic risk challenge
This commit is contained in:
@ -477,4 +477,10 @@ class Api {
|
|||||||
|
|
||||||
/// 获取未读动态数
|
/// 获取未读动态数
|
||||||
static const getUnreadDynamic = '/x/web-interface/dynamic/entrance';
|
static const getUnreadDynamic = '/x/web-interface/dynamic/entrance';
|
||||||
|
|
||||||
|
/// 用户动态主页
|
||||||
|
static const dynamicSpmPrefix = 'https://space.bilibili.com/1/dynamic';
|
||||||
|
|
||||||
|
/// 激活buvid3
|
||||||
|
static const activateBuvidApi = '/x/internal/gaia-gateway/ExClimbWuzhi';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
// ignore_for_file: avoid_print
|
// ignore_for_file: avoid_print
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math' show Random;
|
||||||
import 'package:cookie_jar/cookie_jar.dart';
|
import 'package:cookie_jar/cookie_jar.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dio/io.dart';
|
import 'package:dio/io.dart';
|
||||||
@ -11,6 +13,7 @@ import 'package:hive/hive.dart';
|
|||||||
import 'package:pilipala/utils/id_utils.dart';
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
import '../utils/storage.dart';
|
import '../utils/storage.dart';
|
||||||
import '../utils/utils.dart';
|
import '../utils/utils.dart';
|
||||||
|
import 'api.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'interceptor.dart';
|
import 'interceptor.dart';
|
||||||
|
|
||||||
@ -24,6 +27,7 @@ class Request {
|
|||||||
late bool enableSystemProxy;
|
late bool enableSystemProxy;
|
||||||
late String systemProxyHost;
|
late String systemProxyHost;
|
||||||
late String systemProxyPort;
|
late String systemProxyPort;
|
||||||
|
static final RegExp spmPrefixExp = RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
|
||||||
|
|
||||||
/// 设置cookie
|
/// 设置cookie
|
||||||
static setCookie() async {
|
static setCookie() async {
|
||||||
@ -51,13 +55,12 @@ class Request {
|
|||||||
}
|
}
|
||||||
setOptionsHeaders(userInfo, userInfo != null && userInfo.mid != null);
|
setOptionsHeaders(userInfo, userInfo != null && userInfo.mid != null);
|
||||||
|
|
||||||
if (cookie.isEmpty) {
|
|
||||||
try {
|
try {
|
||||||
await Request().get(HttpString.baseUrl);
|
await buvidActivate();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("setCookie, ${e.toString()}");
|
log("setCookie, ${e.toString()}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
final String cookieString = cookie
|
final String cookieString = cookie
|
||||||
.map((Cookie cookie) => '${cookie.name}=${cookie.value}')
|
.map((Cookie cookie) => '${cookie.name}=${cookie.value}')
|
||||||
.join('; ');
|
.join('; ');
|
||||||
@ -87,6 +90,33 @@ class Request {
|
|||||||
dio.options.headers['referer'] = 'https://www.bilibili.com/';
|
dio.options.headers['referer'] = 'https://www.bilibili.com/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future buvidActivate() async {
|
||||||
|
var html = await Request().get(Api.dynamicSpmPrefix);
|
||||||
|
String spmPrefix = spmPrefixExp.firstMatch(html.data)!.group(1)!;
|
||||||
|
Random rand = Random();
|
||||||
|
String rand_png_end = base64.encode(
|
||||||
|
List<int>.generate(32, (_) => rand.nextInt(256)) +
|
||||||
|
List<int>.filled(4, 0) +
|
||||||
|
[73, 69, 78, 68] +
|
||||||
|
List<int>.generate(4, (_) => rand.nextInt(256))
|
||||||
|
);
|
||||||
|
|
||||||
|
String jsonData = json.encode({
|
||||||
|
'3064': 1,
|
||||||
|
'39c8': '${spmPrefix}.fp.risk',
|
||||||
|
'3c43': {
|
||||||
|
'adca': 'Linux',
|
||||||
|
'bfe9': rand_png_end.substring(rand_png_end.length - 50),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await Request().post(
|
||||||
|
Api.activateBuvidApi,
|
||||||
|
data: {'payload': jsonData},
|
||||||
|
options: Options(contentType: 'application/json')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* config it and create
|
* config it and create
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -79,6 +79,8 @@ class MemberHttp {
|
|||||||
String order = 'pubdate',
|
String order = 'pubdate',
|
||||||
bool orderAvoided = true,
|
bool orderAvoided = true,
|
||||||
}) async {
|
}) async {
|
||||||
|
String dmImgStr = Utils.base64EncodeRandomString(16, 64);
|
||||||
|
String dmCoverImgStr = Utils.base64EncodeRandomString(32, 128);
|
||||||
Map params = await WbiSign().makSign({
|
Map params = await WbiSign().makSign({
|
||||||
'mid': mid,
|
'mid': mid,
|
||||||
'ps': ps,
|
'ps': ps,
|
||||||
@ -88,7 +90,11 @@ class MemberHttp {
|
|||||||
'order': order,
|
'order': order,
|
||||||
'platform': 'web',
|
'platform': 'web',
|
||||||
'web_location': 1550101,
|
'web_location': 1550101,
|
||||||
'order_avoided': orderAvoided
|
'order_avoided': orderAvoided,
|
||||||
|
'dm_img_list': '[]',
|
||||||
|
'dm_img_str': dmImgStr.substring(0, dmImgStr.length - 2),
|
||||||
|
'dm_cover_img_str': dmCoverImgStr.substring(0, dmCoverImgStr.length - 2),
|
||||||
|
'dm_img_inter': '{"ds":[],"wh":[0,0,0],"of":[0,0,0]}',
|
||||||
});
|
});
|
||||||
var res = await Request().get(
|
var res = await Request().get(
|
||||||
Api.memberArchive,
|
Api.memberArchive,
|
||||||
|
|||||||
@ -16,6 +16,8 @@ import '../http/index.dart';
|
|||||||
import '../models/github/latest.dart';
|
import '../models/github/latest.dart';
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
|
static final Random random = Random();
|
||||||
|
|
||||||
static Future<String> getCookiePath() async {
|
static Future<String> getCookiePath() async {
|
||||||
final Directory tempDir = await getApplicationSupportDirectory();
|
final Directory tempDir = await getApplicationSupportDirectory();
|
||||||
final String tempPath = "${tempDir.path}/.plpl/";
|
final String tempPath = "${tempDir.path}/.plpl/";
|
||||||
@ -180,7 +182,7 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static String makeHeroTag(v) {
|
static String makeHeroTag(v) {
|
||||||
return v.toString() + Random().nextInt(9999).toString();
|
return v.toString() + random.nextInt(9999).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int duration(String duration) {
|
static int duration(String duration) {
|
||||||
@ -340,4 +342,15 @@ class Utils {
|
|||||||
|
|
||||||
return md5String;
|
return md5String;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static List<int> generateRandomBytes(int minLength, int maxLength) {
|
||||||
|
return List<int>.generate(
|
||||||
|
random.nextInt(maxLength-minLength+1), (_) => random.nextInt(0x60) + 0x20
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String base64EncodeRandomString(int minLength, int maxLength) {
|
||||||
|
List<int> randomBytes = generateRandomBytes(minLength, maxLength);
|
||||||
|
return base64.encode(randomBytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user