Ejemplo n.º 1
0
 private void decryptLinks(final ArrayList<DownloadLink> decryptedLinks, final CryptedLink param)
     throws Exception {
   br.setFollowRedirects(false);
   final String[] matches = br.getRegex("getFile\\('(cid=\\w*?&lid=\\d*?)'\\)").getColumn(0);
   try {
     Browser brc = null;
     for (final String match : matches) {
       Thread.sleep(2333);
       handleCaptchaAndPassword("http://www.relink.us/frame.php?" + match, param);
       if (ALLFORM != null && ALLFORM.getRegex("captcha").matches()) {
         logger.warning("Falsche Captcheingabe, Link wird übersprungen!");
         continue;
       }
       brc = br.cloneBrowser();
       if (brc != null
           && brc.getRedirectLocation() != null
           && brc.getRedirectLocation().contains("relink.us/getfile")) {
         brc.getPage(brc.getRedirectLocation());
       }
       if (brc.getRedirectLocation() != null) {
         final DownloadLink dl =
             createDownloadlink(Encoding.htmlDecode(brc.getRedirectLocation()));
         try {
           distribute(dl);
         } catch (final Throwable e) {
           /* does not exist in 09581 */
         }
         decryptedLinks.add(dl);
         break;
       } else {
         final String url = brc.getRegex("iframe.*?src=\"(.*?)\"").getMatch(0);
         final DownloadLink dl = createDownloadlink(Encoding.htmlDecode(url));
         if (url != null) {
           try {
             distribute(dl);
           } catch (final Throwable e) {
             /* does not exist in 09581 */
           }
           decryptedLinks.add(dl);
         } else {
           /* as bot detected */
           return;
         }
       }
       PROGRESS.increase(1);
     }
   } finally {
     br.setFollowRedirects(true);
   }
 }
Ejemplo n.º 2
0
  private void handleCaptchaAndPassword(final String partLink, final CryptedLink param)
      throws Exception {
    br.getPage(partLink);
    ALLFORM = br.getFormbyProperty("name", "form");
    boolean b = ALLFORM == null ? true : false;
    // 20150120 - raztoki
    if (ALLFORM == null
        && br.containsHTML(">Please Wait\\.\\.\\.<")
        && br.containsHTML("class=\"timer\">\\d+</span>\\s*seconds</div>")) {
      // pile of redirects happen here
      final String link =
          br.getRegex(
                  "class=\"timer\">\\d+</span>\\s*seconds</div>\\s*<a href=\"\\s*(https?://(\\w+\\.)?relink\\.us/.*?)\\s*\"")
              .getMatch(0);
      if (link != null) {
        br.getPage(link.trim());
        ALLFORM = br.getFormbyProperty("name", "form");
        b = ALLFORM == null ? true : false;
      } else {
        // possible plugin defect
        logger.warning("Possible Plugin Defect!");
      }
    }

    if (b) {
      ALLFORM = br.getForm(0);
      ALLFORM =
          ALLFORM != null
                  && ALLFORM.getAction() != null
                  && ALLFORM
                      .getAction()
                      .matches("^https?://(\\w+\\.)?relink\\.us/container_password\\.php.*")
              ? ALLFORM
              : null;
    }
    if (ALLFORM != null) {
      for (int i = 0; i < 5; i++) {
        if (ALLFORM.containsHTML("password")) {
          final String passCode = Plugin.getUserInput(null, param);
          ALLFORM.put("password", passCode);
        }
        if (ALLFORM.containsHTML("captcha")) {
          ALLFORM.remove("button");
          final String captchaLink = ALLFORM.getRegex("src=\"(.*?)\"").getMatch(0);
          if (captchaLink == null) {
            break;
          }
          final File captchaFile = this.getLocalCaptchaFile();
          Browser.download(
              captchaFile,
              br.cloneBrowser().openGetConnection("http://www.relink.us/" + captchaLink));
          final Point p =
              UserIO.getInstance()
                  .requestClickPositionDialog(
                      captchaFile, "relink.us | " + String.valueOf(i + 1) + "/5", null);
          if (p == null) {
            throw new DecrypterException(DecrypterException.CAPTCHA);
          }
          ALLFORM.put("button.x", String.valueOf(p.x));
          ALLFORM.put("button.y", String.valueOf(p.y));
        }
        br.submitForm(ALLFORM);
        if (br.getURL().contains("error.php")) {
          br.getPage(partLink);
          continue;
        }
        ALLFORM = br.getFormbyProperty("name", "form");
        ALLFORM = ALLFORM == null && b ? br.getForm(0) : ALLFORM;
        if (ALLFORM != null
            && ALLFORM.getAction().startsWith("http://www.relink.us/container_password.php")) {
          continue;
        }
        ALLFORM = null;
        break;
      }
    }
  }
Ejemplo n.º 3
0
  private void doFree(final DownloadLink downloadLink) throws Exception {
    if (ALL_PREMIUMONLY) {
      try {
        throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_ONLY);
      } catch (final Throwable e) {
        if (e instanceof PluginException) {
          throw (PluginException) e;
        }
      }
      throw new PluginException(
          LinkStatus.ERROR_FATAL, "This file can only be downloaded by premium users");
    }
    if (br.containsHTML(LIMITREACHED)) {
      // edt: to support bug when server load = 100% and daily limit
      // reached are simultaneously displayed
      if (br.containsHTML("Current load 100%") || br.containsHTML("Server load: 100%")) {
        throw new PluginException(
            LinkStatus.ERROR_IP_BLOCKED,
            JDL.L(
                "plugins.hoster.HellShareCom.error.DailyLimitReached",
                "Daily Limit for free downloads reached"),
            WAITTIMEDAILYLIMIT);
      }
    }
    br.setFollowRedirects(false);
    final String changetocz =
        br.getRegex(
                "lang=\"cz\" xml:lang=\"cz\" href=\"(http://download\\.cz\\.hellshare\\.com/.*?/\\d+)\"")
            .getMatch(0);
    if (changetocz == null) {
      // Do NOT throw an exeption here as this part isn't that important
      // but it's bad that the plugin breaks just because of this regex
      logger.warning("Language couldn't be changed. This will probably cause trouble...");
    } else {
      br.getPage(changetocz);
      if (br.containsHTML("No htmlCode read")) {
        br.getPage(downloadLink.getDownloadURL());
      }
    }
    br.setDebug(true);
    // edt: new string for server 100% load
    if (br.containsHTML("Current load 100%") || br.containsHTML("Server load: 100%")) {
      throw new PluginException(
          LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
          JDL.L(
              "plugins.hoster.HellShareCom.error.CurrentLoadIs100Percent",
              "The current serverload is 100%"),
          WAITTIME100PERCENT);
    }
    // edt: added more logging info
    if (br.containsHTML(LIMITREACHED)) {
      throw new PluginException(
          LinkStatus.ERROR_IP_BLOCKED,
          JDL.L(
              "plugins.hoster.HellShareCom.error.DailyLimitReached",
              "Daily Limit for free downloads reached"),
          WAITTIMEDAILYLIMIT);
    }
    final String fileId = new Regex(downloadLink.getDownloadURL(), "/(\\d+)(/)?$").getMatch(0);
    if (fileId == null) {
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    boolean secondWay = true;
    String freePage = getDownloadOverview(fileId);
    if (freePage == null) {
      // edt: seems that URL for download is already final for all the
      // links, so br.getURL doesn't need to be changed, secondWay always
      // works good
      freePage = br.getURL(); // .replace("hellshare.com/serialy/",
      // "hellshare.com/").replace("/pop/",
      // "/").replace("filmy/", "");
      secondWay = false;
    }

    // edt: if we got response then secondWay works for all the links
    // br.getPage(freePage);
    if (!br.containsHTML("No htmlCode read")) { // (br != null) {
      secondWay = true;
    }
    if (br.containsHTML("The server is under the maximum load")) {
      logger.info(
          JDL.L(
              "plugins.hoster.HellShareCom.error.ServerUnterMaximumLoad",
              "Server is under maximum load"));
      throw new PluginException(
          LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
          JDL.L(
              "plugins.hoster.HellShareCom.error.ServerUnterMaximumLoad",
              "Server is under maximum load"),
          10 * 60 * 1000l);
    }
    if (br.containsHTML("You are exceeding the limitations on this download")) {
      logger.info("You are exceeding the limitations on this download");
      throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 10 * 60 * 1000l);
    }
    // edt: added more logging info
    if (br.containsHTML(LIMITREACHED)) {
      throw new PluginException(
          LinkStatus.ERROR_IP_BLOCKED,
          JDL.L(
              "plugins.hoster.HellShareCom.error.DailyLimitReached",
              "Daily Limit for free downloads reached"),
          WAITTIMEDAILYLIMIT);
    }
    if (br.containsHTML("<h1>File not found</h1>")) {
      throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
    }

    if (secondWay) {
      Form captchaForm = null;
      final Form[] allForms = br.getForms();
      if (allForms != null && allForms.length != 0) {
        for (final Form aForm : allForms) {
          if (aForm.containsHTML("captcha-img")) {
            captchaForm = aForm;
            break;
          }
        }
      }
      if (captchaForm == null) {
        logger.warning("captchaform equals null!");
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      }

      String captchaLink = captchaForm.getRegex("src=\"(.*?)\"").getMatch(0);
      if (captchaLink == null) {
        captchaLink =
            br.getRegex("\"(http://(www\\.)?hellshare\\.com/captcha\\?sv=.*?)\"").getMatch(0);
      }
      if (captchaLink == null) {
        throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
      }

      try {
        final String code = getCaptchaCode(Encoding.htmlDecode(captchaLink), downloadLink);
        captchaForm.put("captcha", code);
      } catch (Exception e) {
        throw new PluginException(LinkStatus.ERROR_FATAL, "reCaptcha aborted!");
      }

      br.setFollowRedirects(true);
      br.setReadTimeout(120 * 1000);
      dl =
          jd.plugins.BrowserAdapter.openDownload(
              br, downloadLink, captchaForm, FREE_RESUME, FREE_MAXCHUNKS);
    } else {
      Form form = br.getForm(1);
      if (form == null) {
        form = br.getForm(0);
      }
      final String captcha = "http://www.en.hellshare.com/antispam.php?sv=FreeDown:" + fileId;
      final String code = getCaptchaCode(captcha, downloadLink);
      form.put("captcha", Encoding.urlEncode(code));
      dl =
          jd.plugins.BrowserAdapter.openDownload(
              br, downloadLink, form, FREE_RESUME, FREE_MAXCHUNKS);
    }
    if (!dl.getConnection().isContentDisposition()) {
      if (dl.getConnection().getResponseCode() == 403) {
        throw new PluginException(
            LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error 403", 60 * 60 * 1000l);
      } else if (dl.getConnection().getResponseCode() == 404) {
        throw new PluginException(
            LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error 404", 60 * 60 * 1000l);
      }
      br.followConnection();
      if (br.getURL().contains("errno=404")) {
        throw new PluginException(
            LinkStatus.ERROR_FATAL,
            JDL.L(
                "plugins.hoster.HellShareCom.error.404",
                "404 Server error. File might not be available for your country!"));
      }
      if (br.containsHTML("<h1>File not found</h1>")) {
        throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
      }
      // edt: new string for server 100% load
      if (br.containsHTML("The server is under the maximum load")
          || br.containsHTML("Server load: 100%")) {
        logger.info(
            JDL.L(
                "plugins.hoster.HellShareCom.error.ServerUnterMaximumLoad",
                "Server is under maximum load"));
        throw new PluginException(
            LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE,
            JDL.L(
                "plugins.hoster.HellShareCom.error.ServerUnterMaximumLoad",
                "Server is under maximum load"),
            WAITTIME100PERCENT);
      }
      if (br.containsHTML("(Incorrectly copied code from the image|Opište barevný kód z obrázku)")
          || br.getURL().contains("error=405")) {
        throw new PluginException(LinkStatus.ERROR_CAPTCHA);
      }
      if (br.containsHTML("You are exceeding the limitations on this download")) {
        logger.info("You are exceeding the limitations on this download");
        throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 10 * 60 * 1000l);
      }
      if (this.br.toString().length() < 30) {
        /* E.g. empty page */
        throw new PluginException(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Unknown server error");
      }
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    // downloadLink.setProperty("free_directlink", dllink);
    dl.startDownload();
  }
Ejemplo n.º 4
0
  @Override
  public ArrayList<DownloadLink> decryptIt(
      final CryptedLink param, final ProgressController progress) throws Exception {
    synchronized (LOCK) {
      PROGRESS = progress;
      final ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
      final String parameter = correctCryptedLink(param.toString());
      setBrowserExclusive();
      br.setFollowRedirects(true);
      br.getHeaders().put("User-Agent", UA);

      /* Handle Captcha and/or password */
      handleCaptchaAndPassword(parameter, param);
      if (!br.getURL().contains("relink.us/")) {
        try {
          validateLastChallengeResponse();
        } catch (final Throwable e) {
        }
        logger.info("Link offline: " + parameter);
        return decryptedLinks;
      }
      if (br.containsHTML("<title>404</title>")) {
        logger.info("Link offline: " + parameter);
        return decryptedLinks;
      }
      if (ALLFORM != null && ALLFORM.getRegex("password").matches()) {
        throw new DecrypterException(DecrypterException.PASSWORD);
      }
      if (ALLFORM != null && ALLFORM.getRegex("captcha").matches()) {
        throw new DecrypterException(DecrypterException.CAPTCHA);
      }

      final String page = br.toString();
      progress.setRange(0);
      final String title =
          br.getRegex("shrink\"><th>(Titel|Baslik|Title)</th><td>(.*?)</td></tr>").getMatch(1);
      FilePackage fp = null;
      if (title != null && title.trim().length() > 0) {
        fp = FilePackage.getInstance();
        fp.setName(title);
        fp.setProperty("ALLOW_MERGE", true);
      }

      /* use cnl2 button if available */
      String cnlUrl = "http://127\\.0\\.0\\.1:9666/flash/addcrypted2";
      if (br.containsHTML(cnlUrl)) {
        final Browser cnlbr = br.cloneBrowser();

        Form cnlForm = null;
        for (Form f : cnlbr.getForms()) {
          if (f.containsHTML(cnlUrl)) {
            cnlForm = f;
          }
        }
        if (cnlForm != null) {

          if (System.getProperty("jd.revision.jdownloaderrevision") != null) {
            String jk =
                cnlbr.getRegex("<input type=\"hidden\" name=\"jk\" value=\"([^\"]+)\"").getMatch(0);
            HashMap<String, String> infos = new HashMap<String, String>();
            infos.put(
                "crypted", Encoding.urlDecode(cnlForm.getInputField("crypted").getValue(), false));
            infos.put("jk", jk);
            String source = cnlForm.getInputField("source").getValue();
            if (StringUtils.isEmpty(source)) {
              source = parameter.toString();
            } else {
              source = Encoding.urlDecode(source, true);
            }
            infos.put("source", source);
            String json = JSonStorage.toString(infos);
            final DownloadLink dl =
                createDownloadlink(
                    "http://dummycnl.jdownloader.org/"
                        + HexFormatter.byteArrayToHex(json.getBytes("UTF-8")));
            if (fp != null) {
              fp.add(dl);
            }
            try {
              distribute(dl);
            } catch (final Throwable e) {
              /* does not exist in 09581 */
            }
            decryptedLinks.add(dl);
            return decryptedLinks;
          } else {
            String jk =
                cnlbr.getRegex("<input type=\"hidden\" name=\"jk\" value=\"([^\"]+)\"").getMatch(0);
            cnlForm.remove("jk");
            cnlForm.put("jk", (jk != null ? jk.replaceAll("\\+", "%2B") : "nothing"));
            try {
              cnlbr.submitForm(cnlForm);
              if (cnlbr.containsHTML("success")) {
                return decryptedLinks;
              }
              if (cnlbr.containsHTML("^failed")) {
                logger.warning(
                    "relink.us: CNL2 Postrequest was failed! Please upload now a logfile, contact our support and add this loglink to your bugreport!");
                logger.warning("relink.us: CNL2 Message: " + cnlbr.toString());
              }
            } catch (Throwable e) {
              logger.info("relink.us: ExternInterface(CNL2) is disabled!");
            }
          }
        }
      }
      if (!br.containsHTML("download.php\\?id=[a-f0-9]+") && !br.containsHTML("getFile\\(")) {
        return null;
      }
      if (!decryptContainer(page, parameter, "dlc", decryptedLinks)) {
        if (!decryptContainer(page, parameter, "ccf", decryptedLinks)) {
          decryptContainer(page, parameter, "rsdf", decryptedLinks);
        }
      }
      /* Webdecryption */
      if (decryptedLinks.isEmpty()) {
        decryptLinks(decryptedLinks, param);
        final String more_links[] =
            new Regex(
                    page,
                    Pattern.compile(
                        "<a href=\"(go\\.php\\?id=[a-zA-Z0-9]+\\&seite=\\d+)\">",
                        Pattern.CASE_INSENSITIVE))
                .getColumn(0);
        for (final String link : more_links) {
          br.getPage("http://relink.us/" + link);
          decryptLinks(decryptedLinks, param);
        }
      }
      if (decryptedLinks.isEmpty() && br.containsHTML(cnlUrl)) {
        throw new DecrypterException("CNL2 only, open this link in Browser");
      }
      try {
        validateLastChallengeResponse();
      } catch (final Throwable e) {
      }
      if (fp != null) {
        fp.addLinks(decryptedLinks);
      }
      return decryptedLinks;
    }
  }
Ejemplo n.º 5
0
  private void login(final Account account, final boolean force) throws Exception {
    synchronized (LOCK) {
      // Load cookies
      try {
        setBrowserExclusive();
        br.setFollowRedirects(true);
        final Object ret = account.getProperty("cookies", null);
        boolean acmatch =
            Encoding.urlEncode(account.getUser())
                .equals(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
        if (acmatch) {
          acmatch =
              Encoding.urlEncode(account.getPass())
                  .equals(account.getStringProperty("pass", Encoding.urlEncode(account.getPass())));
        }
        if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
          final HashMap<String, String> cookies = (HashMap<String, String>) ret;
          if (account.isValid()) {
            for (final Map.Entry<String, String> cookieEntry : cookies.entrySet()) {
              final String key = cookieEntry.getKey();
              final String value = cookieEntry.getValue();
              br.setCookie(br.getHost(), key, value);
            }
            return;
          }
        }
        String u = account.getUser();
        String p = account.getPass();
        String s = " + ";

        br.getPage("http://www.trilulilu.ro/login");
        Form loginform = br.getFormbyProperty("id", "login_form");
        String n =
            loginform
                .getRegex("<input id=\"login_nonce\" type=\"hidden\" value=\"([0-9a-f]+)\"")
                .getMatch(0);

        String ditati =
            br.getRegex("<script src=\"(http://static\\.trilulilu\\.ro/\\w+/ditati\\.js\\?\\d+)\"")
                .getMatch(0);
        Browser md5fn = br.cloneBrowser();
        md5fn.getPage(ditati == null ? "http://static.trilulilu.ro/compiled/ditati.js" : ditati);

        NONSTANDARDMD5 =
            md5fn.getRegex("(var hexcase.*?)String\\.prototype\\.htmlentities").getMatch(0);
        if (n == null || NONSTANDARDMD5 == null) {
          throw new PluginException(
              LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
        }

        String postdata = "action=login";
        postdata += "&username="******"&remember=0";
        postdata += "&PAS5WORD=" + md5hex(p + md5hex(u) + s + n + s);
        postdata += "&PAS5W0RD=" + md5hex(p + s + md5hex(u + s + n));
        postdata += "&PA55WORD=" + md5hex(s + md5hex(n + u) + s + p);
        postdata += "&PASSW0RD=" + md5hex(md5hex(p) + s + n + s + u);
        postdata += "&PA5SW0RD=" + md5hex(md5hex(s + u + p) + s + n);
        postdata += "&PA5SWORD=" + md5hex(u + s + md5hex(n + s + p));
        postdata += "&PA55W0RD=" + md5hex(n + md5hex(s + p + u + s));
        postdata += "&PASSWORD="******"/login", postdata);
        if (!br.containsHTML("ok")) {
          throw new PluginException(
              LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
        }
        // cookies
        final HashMap<String, String> cookies = new HashMap<String, String>();
        final Cookies add = br.getCookies(br.getHost());
        for (final Cookie c : add.getCookies()) {
          cookies.put(c.getKey(), c.getValue());
        }
        account.setProperty("name", Encoding.urlEncode(account.getUser()));
        account.setProperty("pass", Encoding.urlEncode(account.getPass()));
        account.setProperty("cookies", cookies);
      } catch (final PluginException e) {
        account.setProperty("cookies", null);
        throw e;
      }
    }
  }