From 105a70447aa4d9a485891f4240c5acbbc8836a5d Mon Sep 17 00:00:00 2001 From: Daniel M Date: Sat, 8 Jan 2022 22:31:03 +0100 Subject: [PATCH] Update zippyshare resolver --- src/zippy.rs | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/zippy.rs b/src/zippy.rs index 00e770b..c4271f7 100644 --- a/src/zippy.rs +++ b/src/zippy.rs @@ -3,6 +3,22 @@ use std::io::{ Error, ErrorKind }; use crate::errors::ResBE; +/* +Updated: 08.01.2022 +Link generation code: +- `n`, `b` and `z` are dynamic (random) on each reload +- `%2` and `%3` for n and b don't change +- The main number for `n` and `b` is always equal +- `z` is always the `n`/`b` main number + 3 +- Link middle part calculation stays the same + +``` +var n = 794218%2; +var b = 794218%3; +var z = 794221; +document.getElementById('dlbutton').href = "/d/0Ky7p1C6/"+(n + b + z - 3)+"/some-file-name.part1.rar"; +``` +*/ pub async fn resolve_link(url: &str) -> ResBE { // Regex to check if the provided url is a zippyshare download url @@ -19,21 +35,28 @@ pub async fn resolve_link(url: &str) -> ResBE { .text().await?; // Regex to match the javascript part of the html that generates the real download link - let re_all = Regex::new(r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)" \+ \((\d+) % (\d+) \+ (\d+) % (\d+)\) \+ "(.+)";"#)?; + let re_link = Regex::new(r#"document\.getElementById\('dlbutton'\)\.href = "(/d/.+/)"\+\(.+\)\+"(.+)";"#)?; + let re_z = Regex::new(r#"var z = (\d+);"#)?; - let cap_all = match re_all.captures(&body) { + let cap_link = match re_link.captures(&body) { Some(cap) => cap, None => return Err(Error::new(ErrorKind::Other, "Link not found").into()) }; - let a: i32 = i32::from_str_radix(&cap_all[2], 10)?; - let b: i32 = i32::from_str_radix(&cap_all[3], 10)?; - let c: i32 = i32::from_str_radix(&cap_all[4], 10)?; - let d: i32 = i32::from_str_radix(&cap_all[5], 10)?; + let cap_z = match re_z.captures(&body) { + Some(cap) => cap, + None => return Err(Error::new(ErrorKind::Other, "Link not found").into()) + }; + + let url_start = &cap_link[1]; + let url_end = &cap_link[2]; + let z: i32 = i32::from_str_radix(&cap_z[1], 10)?; + let n = (z - 3) % 2; + let b = (z - 3) % 3; - let mixed = a % b + c % d; + let mixed = n + b + z - 3; - let dl_url = format!("{}{}{}{}", &base_host, &cap_all[1], mixed, &cap_all[6]); + let dl_url = format!("{}{}{}{}", &base_host, url_start, mixed, url_end); Ok(dl_url) }