diff --git a/src/OpenDirectoryDownloader/DirectoryParser.cs b/src/OpenDirectoryDownloader/DirectoryParser.cs index 1d0c5f80..070216b8 100644 --- a/src/OpenDirectoryDownloader/DirectoryParser.cs +++ b/src/OpenDirectoryDownloader/DirectoryParser.cs @@ -88,7 +88,8 @@ public static async Task ParseHtml(WebDirectory webDirectory, stri htmlDocument.QuerySelector("script[src*=\"/sawankumar/Google-Drive-Index-III\" i]") != null || htmlDocument.QuerySelector("script[src*=\"/goIndex-theme-nexmoe\" i]") != null || htmlDocument.QuerySelector("script[src*=\"/cheems/GDIndex\" i]") != null || - htmlDocument.QuerySelector("script[src*=\"/cheems/goindex-extended\" i]") != null) + htmlDocument.QuerySelector("script[src*=\"/cheems/goindex-extended\" i]") != null || + htmlDocument.QuerySelector("script[src*=\"/@googledrive/index\" i]") != null) { return await BhadooIndexParser.ParseIndex(htmlDocument, httpClient, webDirectory); } diff --git a/src/OpenDirectoryDownloader/Site/GoIndex/BhadooIndexParser.cs b/src/OpenDirectoryDownloader/Site/GoIndex/BhadooIndexParser.cs index 90c922fc..04349f48 100644 --- a/src/OpenDirectoryDownloader/Site/GoIndex/BhadooIndexParser.cs +++ b/src/OpenDirectoryDownloader/Site/GoIndex/BhadooIndexParser.cs @@ -26,6 +26,7 @@ public static class BhadooIndexParser private static readonly RateLimiter RateLimiter = new RateLimiter(1, TimeSpan.FromSeconds(1)); private static Engine JintEngine { get; set; } + private static bool Obfuscated { get; set; } public static async Task ParseIndex(IHtmlDocument htmlDocument, HttpClient httpClient, WebDirectory webDirectory) { @@ -41,12 +42,13 @@ public static async Task ParseIndex(IHtmlDocument htmlDocument, Ht OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password] = "@ttu001"; Dictionary postValues = new Dictionary - { - { "password", OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password] }, - { "page_token", string.Empty }, - { "page_index", "0" }, - { "q", "" } - }; + { + { "password", OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password] }, + { "page_token", string.Empty }, + { "page_index", "0" }, + { "q", "" } + }; + HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, webDirectory.Uri) { Content = new FormUrlEncodedContent(postValues) }; HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(httpRequestMessage); @@ -96,17 +98,42 @@ private static async Task DecodeResponse(IHtmlDocument htmlDocument, Htt { if (JintEngine == null) { - IHtmlScriptElement appJsScript = htmlDocument.Scripts.FirstOrDefault(s => s.Source?.Contains("app.js") == true || s.Source?.Contains("app.min.js") == true); - string appJsSource = await httpClient.GetStringAsync(appJsScript.Source); + IHtmlScriptElement appJsScript = htmlDocument.Scripts.FirstOrDefault(s => + s.Source?.Contains("app.js") == true || + s.Source?.Contains("app.min.js") == true || + s.Source?.Contains("app.obf.js") == true || + s.Source?.Contains("app.obf.min.js") == true + ); + + Obfuscated = appJsScript.Source.Contains("obf."); + + string appJsSource = await httpClient.GetStringAsync(appJsScript.Source.Replace("obf.", string.Empty)); List functions = JavaScriptHelper.Parse(appJsSource); - JavaScriptHelper.Function readFunction = functions.FirstOrDefault(f => f.Name == "read"); JintEngine = new Engine(); - JintEngine.Execute(readFunction.Body); + + JintEngine.Execute(functions.FirstOrDefault(f => f.Name == "read").Body); + + if (Obfuscated) + { + Func atob = str => Encoding.UTF8.GetString(Convert.FromBase64String(str)); + JintEngine.SetValue("atob", atob); + + JintEngine.Execute(functions.FirstOrDefault(f => f.Name == "gdidecode").Body); + } } JsValue jsValue = JintEngine.Invoke("read", responseString); - responseJson = Encoding.UTF8.GetString(Convert.FromBase64String(jsValue.ToString())); + + if (Obfuscated) + { + jsValue = JintEngine.Invoke("gdidecode", jsValue.ToString()); + responseJson = jsValue.ToString(); + } + else + { + responseJson = Encoding.UTF8.GetString(Convert.FromBase64String(jsValue.ToString())); + } } return responseJson; @@ -137,11 +164,12 @@ private static async Task ScanAsync(IHtmlDocument htmlDocument, Ht Logger.Warn($"Retrieving listings for {webDirectory.Uri}, page {pageIndex + 1}"); Dictionary postValues = new Dictionary - { - { "password", OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password] }, - { "page_token", nextPageToken }, - { "page_index", pageIndex.ToString() } - }; + { + { "password", OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password] }, + { "page_token", nextPageToken }, + { "page_index", pageIndex.ToString() } + }; + HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, webDirectory.Uri) { Content = new FormUrlEncodedContent(postValues) }; HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(httpRequestMessage); diff --git a/src/OpenDirectoryDownloader/Site/GoIndex/GdIndexParser.cs b/src/OpenDirectoryDownloader/Site/GoIndex/GdIndexParser.cs index 04f6155a..c09fd2d0 100644 --- a/src/OpenDirectoryDownloader/Site/GoIndex/GdIndexParser.cs +++ b/src/OpenDirectoryDownloader/Site/GoIndex/GdIndexParser.cs @@ -63,12 +63,12 @@ public static async Task ParseIndex(HttpClient httpClient, WebDire Logger.Info($"Using password: {OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password]}"); httpResponseMessage = await httpClient.PostAsync($"{webDirectory.Uri}?rootId={rootId}", new StringContent(JsonConvert.SerializeObject(new Dictionary - { - { "page_index", 0 }, - { "page_token", null }, - { "password", OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password] }, - { "q", "" } - }))); + { + { "page_index", 0 }, + { "page_token", null }, + { "password", OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password] }, + { "q", "" } + }))); if (httpResponseMessage.IsSuccessStatusCode) {