mirror of
https://github.com/iv-org/inv_sig_helper.git
synced 2025-05-19 20:17:45 +02:00
Refactored REGEX_SIGNATURE_FUNCTION_PATTERNS to match against global variable name for improved generality and compatibility.
This commit is contained in:
parent
168521dee9
commit
bde9973409
2 changed files with 15 additions and 9 deletions
|
@ -23,8 +23,9 @@ pub static NSIG_FUNCTION_ENDINGS: &[&str] = &[
|
|||
pub static REGEX_SIGNATURE_TIMESTAMP: &Lazy<Regex> = regex!("signatureTimestamp[=:](\\d+)");
|
||||
|
||||
pub static REGEX_SIGNATURE_FUNCTION_PATTERNS: &[&str] = &[
|
||||
r#"\s*?([a-zA-Z0-9_\$]{1,})=function\([a-zA-Z]{1}\)\{(.{1}=.{1}\.split\([a-zA-Z0-9\-_\$\[\]"]+\)[^\}{]+)return .{1}\.join\([a-zA-Z0-9\-_\$\[\]"]+\)\}"#,
|
||||
r#"([a-zA-Z0-9_$]{1,})=function\(r\)\{r=r\[[A-Z]\[\d+\]\]\([A-Z]\[\d+\]\);[a-zA-Z0-9$]+\[[A-Z]\[\d+\]\]\(r,\d+\);[a-zA-Z0-9$]+\[[A-Z]\[\d+\]\]\(r,\d+\);[a-zA-Z0-9$]+\[[A-Z]\[\d+\]\]\(r,\d+\);return r\[[A-Z]\[\d+\]\]\([A-Z]\[\d+\]\)\}"#,
|
||||
r#"\s*?([a-zA-Z0-9_\$]{1,})=function\([a-zA-Z]{1}\)\{(.{1}=.{1}\.split\([a-zA-Z0-9\-_\$\[\]"]+\)[^\}{]+)return .{1}\.join\([a-zA-Z0-9\-_\$\[\]"]+\)\}"#, // old regex
|
||||
r#"([a-zA-Z0-9_$]{1,})=function\(([a-zA-Z0-9_$]{1})\)\{[^}]*GLOBAL_VAR_NAME\[[^\]]+\][^}]*return [^}]*GLOBAL_VAR_NAME\[[^\]]+\][^}]*\}"#, // new regex
|
||||
r#"([a-zA-Z0-9_$]{1,})=function\(([a-zA-Z0-9_$]{1})\)\{[^}]*return [^}]*GLOBAL_VAR_NAME\[[^\]]+\][^}]*\}"#, // more general regex
|
||||
];
|
||||
|
||||
// pub static REGEX_SIGNATURE_FUNCTION: &Lazy<Regex> = regex!(r#"\s*?([a-zA-Z0-9_\$]{1,})=function\([a-zA-Z]{1}\)\{(.{1}=.{1}\.split\([a-zA-Z0-9\-_\$\[\]"]+\)[^\}{]+)return .{1}\.join\([a-zA-Z0-9\-_\$\[\]"]+\)\}"#);
|
||||
|
|
|
@ -214,19 +214,24 @@ pub async fn fetch_update(state: Arc<GlobalState>) -> Result<(), FetchUpdateStat
|
|||
break;
|
||||
}
|
||||
|
||||
if let Some((global_var, varname, _)) = extract_player_js_global_var(&player_javascript) {
|
||||
debug!("found global var for sig: {}", global_var);
|
||||
debug!("found varname for sig: {}", varname);
|
||||
let (global_var, varname, _) = extract_player_js_global_var(&player_javascript).unwrap();
|
||||
if !global_var.is_empty() {
|
||||
debug!("Found global var for sig: {}", global_var);
|
||||
debug!("Found varname for sig: {}", varname);
|
||||
} else {
|
||||
debug!("No global array variable found in player JS");
|
||||
debug!("No global var found for sig");
|
||||
}
|
||||
|
||||
// Extract signature function name
|
||||
let mut sig_function_name = String::new();
|
||||
let mut found_sig_function = false;
|
||||
|
||||
|
||||
for sig_pattern in REGEX_SIGNATURE_FUNCTION_PATTERNS.iter() {
|
||||
let sig_regex = match Regex::new(sig_pattern) {
|
||||
let _sig_pattern = sig_pattern.replace("GLOBAL_VAR_NAME", ®ex::escape(&varname));
|
||||
|
||||
debug!("sig pattern: {}", _sig_pattern);
|
||||
|
||||
let sig_regex = match Regex::new(&_sig_pattern) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
warn!("Failed to compile signature regex pattern: {}", e);
|
||||
|
@ -292,7 +297,7 @@ pub async fn fetch_update(state: Arc<GlobalState>) -> Result<(), FetchUpdateStat
|
|||
sig_code += &sig_function_name;
|
||||
sig_code += ";";
|
||||
|
||||
if let Some((global_var, varname, _)) = extract_player_js_global_var(&player_javascript) {
|
||||
if !global_var.is_empty() {
|
||||
sig_code += &global_var;
|
||||
sig_code += ";";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue