Exemplo n.º 1
0
  private boolean handlePassword() throws DecrypterException, IOException {
    final boolean passwordRequired;
    if ((this.br.getRedirectLocation() != null
            && this.br.getRedirectLocation().contains(urlpart_passwordneeded))
        || this.br.getURL().contains(urlpart_passwordneeded)) {
      logger.info("Blog password needed");
      passwordRequired = true;

      // final String password_required_url;
      // if (this.br.getRedirectLocation() != null) {
      // password_required_url = this.br.getRedirectLocation();
      // } else {
      // password_required_url = this.br.getURL();
      // }
      // final String blog_user = new Regex(password_required_url, "/blog_auth/(.+)").getMatch(0);
      // if (blog_user != null) {
      // this.br = prepBR(new Browser());
      // this.br.setFollowRedirects(true);
      // this.br.getPage("https://www.tumblr.com/blog_auth/" + blog_user);
      // } else {
      // this.br.setFollowRedirects(true);
      // }

      boolean success = false;
      for (int i = 0; i <= 2; i++) {
        if (this.passCode == null) {
          this.passCode = getUserInput("Password?", this.param);
        }
        Form form = br.getFormbyKey("auth");
        if (form == null) {
          form = br.getFormbyKey("password");
        }
        form.put("password", Encoding.urlEncode(this.passCode));
        br.submitForm(form);
        form = br.getFormbyKey("auth");
        if (form != null) {
          form.put("password", Encoding.urlEncode(passCode));
          br.submitForm(form);
        }
        if (this.br.getURL().contains(urlpart_passwordneeded)) {
          passCode = null;
          continue;
        }
        success = true;
        break;
      }
      if (!success) {
        throw new DecrypterException(DecrypterException.PASSWORD);
      }
      this.br.setFollowRedirects(false);
    } else {
      passwordRequired = false;
    }
    return passwordRequired;
  }
Exemplo n.º 2
0
 private void login(Account account) throws Exception {
   this.setBrowserExclusive();
   br.setCookie("http://gigapeta.com", "lang", "us");
   br.setDebug(true);
   /*
    * Workaround for a serverside 502 error (date: 04.03.15). Accessing the wrong ('/dl/') link next line in the code will return a 404
    * error but we can login and download fine then.
    */
   br.getPage("http://gigapeta.com/dl/");
   final String auth_token = br.getRegex("name=\"auth_token\" value=\"([a-z0-9]+)\"").getMatch(0);
   final String lang = System.getProperty("user.language");
   if (auth_token == null) {
     if ("de".equalsIgnoreCase(lang)) {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "\r\nPlugin defekt, bitte den JDownloader Support kontaktieren!",
           PluginException.VALUE_ID_PREMIUM_DISABLE);
     } else {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "\r\nPlugin broken, please contact the JDownloader Support!",
           PluginException.VALUE_ID_PREMIUM_DISABLE);
     }
   }
   br.postPage(
       br.getURL(),
       "auth_login="******"&auth_passwd="
           + Encoding.urlEncode(account.getPass())
           + "&auth_token="
           + auth_token);
   if (br.getCookie("http://gigapeta.com/", "adv_sess") == null) {
     if ("de".equalsIgnoreCase(lang)) {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen? Versuche folgendes:\r\n1. Falls dein Passwort Sonderzeichen enthält, ändere es (entferne diese) und versuche es erneut!\r\n2. Gib deine Zugangsdaten per Hand (ohne kopieren/einfügen) ein.",
           PluginException.VALUE_ID_PREMIUM_DISABLE);
     } else {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "\r\nInvalid username/password!\r\nYou're sure that the username and password you entered are correct? Some hints:\r\n1. If your password contains special characters, change it (remove them) and try again!\r\n2. Type in your username/password by hand without copy & paste.",
           PluginException.VALUE_ID_PREMIUM_DISABLE);
     }
   }
   if (br.containsHTML("You have <b>basic</b> account")) {
     nopremium = true;
     simultanpremium.set(1);
   } else if (br.getRegex("You have <b>([^<>\"]*?)</b> account till").getMatch(0) != null) {
     simultanpremium.set(-1);
   } else {
     logger.warning("Unknown accounttype, disabling it...");
     throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
   }
 }
Exemplo n.º 3
0
 private void login(Account account) throws Exception {
   this.setBrowserExclusive();
   br.setFollowRedirects(false);
   br.postPage(
       "https://secure.nicovideo.jp/secure/login?site=niconico",
       "next_url=&mail="
           + Encoding.urlEncode(account.getUser())
           + "&password="******"user_session") == null)
     throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
 }
Exemplo n.º 4
0
 private boolean getUserLogin() throws IOException, DecrypterException {
   br.setFollowRedirects(true);
   String username = null;
   String password = null;
   synchronized (LOCK) {
     username = this.getPluginConfig().getStringProperty("user", null);
     password = this.getPluginConfig().getStringProperty("pass", null);
     if (username != null && password != null) {
       br.postPage(
           POSTPAGE,
           "user="******"&passwrd="
               + Encoding.urlEncode(password)
               + "&cookielength=2&hash_passwrd=");
     }
     for (int i = 0; i < 3; i++) {
       boolean valid = false;
       final Cookies allCookies = this.br.getCookies(MAINPAGE);
       for (final Cookie c : allCookies.getCookies()) {
         if (c.getKey().contains("SMFCookie")) {
           valid = true;
           break;
         }
       }
       if (!valid) {
         this.getPluginConfig().setProperty("user", Property.NULL);
         this.getPluginConfig().setProperty("pass", Property.NULL);
         username =
             UserIO.getInstance().requestInputDialog("Enter Loginname for " + DOMAIN + " :");
         if (username == null) return false;
         password = UserIO.getInstance().requestInputDialog("Enter password for " + DOMAIN + " :");
         if (password == null) return false;
         br.postPage(
             POSTPAGE,
             "user="******"&passwrd="
                 + Encoding.urlEncode(password)
                 + "&cookielength=2&hash_passwrd=");
       } else {
         this.getPluginConfig().setProperty("user", username);
         this.getPluginConfig().setProperty("pass", password);
         this.getPluginConfig().save();
         return true;
       }
     }
   }
   throw new DecrypterException("Login or/and password wrong");
 }
Exemplo n.º 5
0
 @SuppressWarnings("unchecked")
 private void login(final Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     try {
       /** Load cookies */
       br.setCookiesExclusive(true);
       prepBrowser(br);
       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();
             this.br.setCookie(COOKIE_HOST, key, value);
           }
           return;
         }
       }
       br.setFollowRedirects(true);
       getPage(COOKIE_HOST + "/login.html");
       final Form loginform = br.getFormbyProperty("name", "FL");
       if (loginform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
       loginform.put("login", Encoding.urlEncode(account.getUser()));
       loginform.put("password", Encoding.urlEncode(account.getPass()));
       sendForm(loginform);
       if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null)
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
       if (!br.getURL().contains("/?op=my_account")) {
         getPage("/?op=my_account");
       }
       if (!new Regex(correctedBR, "(Premium(\\-| )Account expire|>Renew premium<)").matches()) {
         account.setProperty("nopremium", true);
       } else {
         account.setProperty("nopremium", false);
       }
       /** Save cookies */
       final HashMap<String, String> cookies = new HashMap<String, String>();
       final Cookies add = this.br.getCookies(COOKIE_HOST);
       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", Property.NULL);
       throw e;
     }
   }
 }
 private boolean getUserLogin() throws Exception {
   /*
    * we have to load the plugins first! we must not reference a plugin class without loading it before
    */
   final PluginForHost hosterPlugin = JDUtilities.getPluginForHost("mediafire.com");
   final Account aa = AccountController.getInstance().getValidAccount(hosterPlugin);
   if (aa != null) {
     // Try to re-use session token as long as possible (it's valid for 10 minutes)
     final String savedusername = this.getPluginConfig().getStringProperty("username");
     final String savedpassword = this.getPluginConfig().getStringProperty("password");
     final String sessiontokenCreateDateObject =
         this.getPluginConfig().getStringProperty("sessiontokencreated2");
     long sessiontokenCreateDate = -1;
     if (sessiontokenCreateDateObject != null && sessiontokenCreateDateObject.length() > 0) {
       sessiontokenCreateDate = Long.parseLong(sessiontokenCreateDateObject);
     }
     if ((savedusername != null && savedusername.matches(aa.getUser()))
         && (savedpassword != null && savedpassword.matches(aa.getPass()))
         && System.currentTimeMillis() - sessiontokenCreateDate < 600000) {
       SESSIONTOKEN = this.getPluginConfig().getStringProperty("sessiontoken");
     } else {
       // Get token for user account
       apiRequest(
           br,
           "https://www.mediafire.com/api/user/get_session_token.php",
           "?email="
               + Encoding.urlEncode(aa.getUser())
               + "&password="******"&application_id="
               + MdfrFldr.APPLICATIONID
               + "&signature="
               + JDHash.getSHA1(
                   aa.getUser()
                       + aa.getPass()
                       + MdfrFldr.APPLICATIONID
                       + Encoding.Base64Decode(MdfrFldr.APIKEY))
               + "&version=1");
       SESSIONTOKEN = getXML("session_token", br.toString());
       this.getPluginConfig().setProperty("username", aa.getUser());
       this.getPluginConfig().setProperty("password", aa.getPass());
       this.getPluginConfig().setProperty("sessiontoken", SESSIONTOKEN);
       this.getPluginConfig().setProperty("sessiontokencreated2", "" + System.currentTimeMillis());
       this.getPluginConfig().save();
     }
   }
   return false;
 }
Exemplo n.º 7
0
 private String get_dllink(final DownloadLink dl) throws IOException, PluginException {
   /* First check if the id was set in the decrypter */
   String fileid = dl.getStringProperty("plain_fid", null);
   if (fileid == null) {
     fileid = br.getRegex("id=\"fileDetails_(\\d+)\"").getMatch(0);
   }
   if (fileid == null) {
     fileid = br.getRegex("fileIdContainer\"\\s*rel=\"(\\d+)\"").getMatch(0);
   }
   final String requestvtoken =
       br.getRegex("name=\"__RequestVerificationToken\" type=\"hidden\" value=\"([^<>\"]*?)\"")
           .getMatch(0);
   if (fileid == null || requestvtoken == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   Browser br2 = br.cloneBrowser();
   br2.getHeaders().put("X-Requested-With", "XMLHttpRequest");
   br2.postPage(
       "/action/License/Download",
       "fileId=" + fileid + "&__RequestVerificationToken=" + Encoding.urlEncode(requestvtoken));
   String dllink = br2.getRegex("\"redirectUrl\":\"(http[^<>\"]*?)\"").getMatch(0);
   if (dllink == null) {
     // general failover
     dllink =
         br2.getRegex("(https?://\\w+\\.lolabits\\.es/File\\.aspx\\?[^\"]+)(\\\\\")?").getMatch(0);
     if (dllink == null) {
       throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     }
   }
   dllink = unescape(dllink);
   return dllink;
 }
Exemplo n.º 8
0
 private void handlePassword(final DownloadLink dl) throws PluginException, IOException {
   if (br.getURL().contains("/file_password.html")) {
     logger.info("Current link is password protected");
     String passCode = dl.getStringProperty("pass", null);
     if (passCode == null) {
       passCode = Plugin.getUserInput("Password?", dl);
       if (passCode == null || passCode.equals("")) {
         logger.info("User has entered blank password, exiting handlePassword");
         dl.setProperty("pass", Property.NULL);
         throw new PluginException(LinkStatus.ERROR_RETRY, "Wrong password entered");
       }
       dl.setProperty("pass", passCode);
     }
     br.postPage(
         br.getURL(),
         "submit=access+file&submitme=1&file="
             + this.getFID(dl)
             + "&filePassword="******"/file_password.html")) {
       logger.info("User entered incorrect password --> Retrying");
       dl.setProperty("pass", Property.NULL);
       throw new PluginException(LinkStatus.ERROR_RETRY, "Wrong password entered");
     }
     logger.info("User entered correct password --> Continuing");
   }
 }
Exemplo n.º 9
0
 @Override
 public void handleFree(DownloadLink link) throws Exception {
   this.requestFileInformation(link);
   br.setDebug(true);
   String postCode = br.getRegex("name=\"code\" value=\"(.*?)\"").getMatch(0);
   if (postCode == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   // Ticket Time
   String ttt = "10";
   ttt = br.getRegex("var time_wait = (.*?);").getMatch(0);
   int tt = Integer.parseInt(ttt);
   sleep(tt * 1001, link);
   br.postPage(link.getDownloadURL(), "code=" + Encoding.urlEncode(postCode));
   String server = br.getRegex("hostname\" value=\"(.*?)\"").getMatch(0);
   String hash = br.getRegex("hash\" value=\"(.*?)\"").getMatch(0);
   String filename = br.getRegex("filename\" value=\"(.*?)\"").getMatch(0);
   if (server == null || hash == null || filename == null)
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   String dllink = "http://" + server + "/get/" + hash + "/" + filename;
   dl = BrowserAdapter.openDownload(br, link, dllink, true, 0);
   if (dl.getConnection().getContentType().contains("html")) {
     br.followConnection();
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   dl.startDownload();
 }
Exemplo n.º 10
0
 public String handlePassword(String passCode, Form pwform, DownloadLink thelink)
     throws IOException, PluginException {
   passCode = thelink.getStringProperty("pass", null);
   if (passCode == null) passCode = Plugin.getUserInput("Password?", thelink);
   pwform.put("password", passCode);
   logger.info("Put password \"" + passCode + "\" entered by user in the DLForm.");
   return Encoding.urlEncode(passCode);
 }
Exemplo n.º 11
0
 private void loginAPI(final Account account) throws Exception {
   synchronized (lock) {
     try {
       br.setCookiesExclusive(true);
       /* session_id might be stored for API usage */
       final Cookies cookies = account.loadCookies("");
       restoreSession(account);
       if (cookies != null && this.apiSession != null) {
         br.setCookies(this.getHost(), cookies);
         getPageAPI(getAPIProtocol() + this.getHost() + "/login/json_checkLogin");
         if (this.getAPIStatuscode(this.br) == api_status_all_ok) {
           logger.info("Successfully re-used previous session");
           return;
         }
         logger.info("Failed to re-use previous session --> Performing full login");
       }
       postPageAPI(
           getAPIProtocol() + this.getHost() + "/login/json",
           "user="******"&pass="******"session");
       if (this.apiSession == null) {
         /* Actually this should not happen as errorhandling is done inside postPageAPI() */
         if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nUngültiger Benutzername/Passwort!\r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen? Versuche folgendes:\r\n1. Falls dein Passwort Sonderzeichen enthält, ändere es (entferne diese) und versuche es erneut!\r\n2. Gib deine Zugangsdaten per Hand (ohne kopieren/einfügen) ein.",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         } else {
           throw new PluginException(
               LinkStatus.ERROR_PREMIUM,
               "\r\nInvalid username/password!\r\nYou're sure that the username and password you entered are correct? Some hints:\r\n1. If your password contains special characters, change it (remove them) and try again!\r\n2. Type in your username/password by hand without copy & paste.",
               PluginException.VALUE_ID_PREMIUM_DISABLE);
         }
       }
       account.saveCookies(br.getCookies(this.getHost()), "");
       saveSession(account);
     } catch (final PluginException e) {
       account.clearCookies("");
       throw e;
     }
   }
 }
Exemplo n.º 12
0
 @SuppressWarnings("unchecked")
 private void login(Account account, boolean force) throws Exception {
   synchronized (LOCK) {
     /** Load cookies */
     br.setCookiesExclusive(false);
     br.setFollowRedirects(true);
     final Object ret = account.getProperty("cookies", null);
     boolean acmatch =
         Encoding.urlEncode(account.getUser())
             .matches(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
     if (acmatch)
       acmatch =
           Encoding.urlEncode(account.getPass())
               .matches(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();
           this.br.setCookie(COOKIE_HOST, key, value);
         }
         return;
       }
     }
     br.setCookie(COOKIE_HOST, "lang", "english");
     br.getPage(COOKIE_HOST + "/login.html");
     Form loginform = br.getForm(0);
     if (loginform == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     loginform.put("login", Encoding.urlEncode(account.getUser()));
     loginform.put("password", Encoding.urlEncode(account.getPass()));
     br.submitForm(loginform);
     if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null)
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     br.getPage(COOKIE_HOST + "/?op=my_account");
     doSomething();
     if (!new Regex(BRBEFORE, "(Premium\\-Account expire|Upgrade to premium|>Renew premium<)")
         .matches())
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     if (!new Regex(BRBEFORE, "(Premium\\-Account expire|>Renew premium<)").matches())
       account.setProperty("nopremium", "true");
     /** Save cookies */
     final HashMap<String, String> cookies = new HashMap<String, String>();
     final Cookies add = this.br.getCookies(COOKIE_HOST);
     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);
   }
 }
Exemplo n.º 13
0
 @Override
 public AvailableStatus requestFileInformation(final DownloadLink parameter) throws Exception {
   setBrowserExclusive();
   br.setDebug(true);
   /* workaround as server does not send correct encoding information */
   br.setCustomCharset("UTF-8");
   final String lastDl = parameter.getDownloadURL().replaceFirst("http://.*?/", "/");
   br.setCookie("http://hotfile.com", "lastdl", Encoding.urlEncode(lastDl));
   prepareBrowser(br);
   br.setFollowRedirects(true);
   // Differ between normal- and directlinks
   URLConnectionAdapter con = null;
   try {
     con = br.openGetConnection(parameter.getDownloadURL());
     if (!con.getContentType().contains("html")) {
       directDownload = true;
       parameter.setDownloadSize(con.getLongContentLength());
       parameter.setFinalFileName(getFileNameFromHeader(con));
       return AvailableStatus.TRUE;
     } else {
       br.followConnection();
     }
   } finally {
     try {
       con.disconnect();
     } catch (Throwable e) {
     }
   }
   br.setFollowRedirects(false);
   final Browser cl = new Browser();
   cl.setDebug(true);
   cl.setCookie("http://hotfile.com", "lastdl", br.getCookie("http://hotfile.com", "lastdl"));
   prepareBrowser(cl);
   cl.getHeaders().put("Referer", "http://hotfile.com/styles/structure.css");
   Browser.download(
       this.getLocalCaptchaFile(), cl.openGetConnection("http://hotfile.com/i/blank.gif"));
   if (br.getRedirectLocation() != null) {
     br.getPage(br.getRedirectLocation());
   }
   String filename = br.getRegex("Downloading <b>(.+?)</b>").getMatch(0);
   if (filename == null) {
     /* polish users get this */
     filename = br.getRegex("Downloading:</strong>(.*?)<").getMatch(0);
   }
   String filesize = br.getRegex("<span class=\"size\">(.*?)</span>").getMatch(0);
   if (filesize == null) {
     /* polish users get this */
     filesize = br.getRegex("Downloading:</strong>.*?span.*?strong>(.*?)<").getMatch(0);
   }
   if (filename == null || filesize == null) {
     throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   }
   parameter.setName(filename.trim());
   parameter.setDownloadSize(SizeFormatter.getSize(filesize.trim()));
   return AvailableStatus.TRUE;
 }
Exemplo n.º 14
0
 private void login(Account account, final boolean force) throws Exception {
   synchronized (LOCK) {
     // Load/Save cookies, if we do NOT do this parallel downloads fail
     br.setCookiesExclusive(false);
     final Object ret = account.getProperty("cookies", null);
     boolean acmatch =
         account.getUser().matches(account.getStringProperty("name", account.getUser()));
     if (acmatch)
       acmatch = account.getPass().matches(account.getStringProperty("pass", account.getPass()));
     if (acmatch && ret != null && ret instanceof HashMap<?, ?> && !force) {
       final HashMap<String, String> cookies = (HashMap<String, String>) ret;
       if (cookies.containsKey("jforumUserHash") && account.isValid()) {
         for (final String key : cookies.keySet()) {
           this.br.setCookie(MAINPAGE, key, cookies.get(key));
         }
         return;
       }
     }
     br.getPage(MAINPAGE);
     br.postPage(
         "http://www.yunfile.com/view?module=user&action=validateLogin",
         "username="******"&password="******"&remember=on");
     if (br.getCookie(MAINPAGE, "jforumUserHash") == null
         || br.getCookie(MAINPAGE, "membership") == null
         || !br.getCookie(MAINPAGE, "membership").equals("2"))
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     // Save cookies
     final HashMap<String, String> cookies = new HashMap<String, String>();
     final Cookies add = this.br.getCookies(MAINPAGE);
     for (final Cookie c : add.getCookies()) {
       cookies.put(c.getKey(), c.getValue());
     }
     account.setProperty("name", account.getUser());
     account.setProperty("pass", account.getPass());
     account.setProperty("cookies", cookies);
   }
 }
Exemplo n.º 15
0
  @SuppressWarnings("deprecation")
  @Override
  public void handleMultiHost(final DownloadLink link, final Account account) throws Exception {
    this.br = newBrowser();
    final boolean forceNewLinkGeneration = true;

    synchronized (hostUnavailableMap) {
      HashMap<String, Long> unavailableMap = hostUnavailableMap.get(account);
      if (unavailableMap != null) {
        Long lastUnavailable = unavailableMap.get(link.getHost());
        if (lastUnavailable != null && System.currentTimeMillis() < lastUnavailable) {
          final long wait = lastUnavailable - System.currentTimeMillis();
          throw new PluginException(
              LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE,
              "Host is temporarily unavailable via " + this.getHost(),
              wait);
        } else if (lastUnavailable != null) {
          unavailableMap.remove(link.getHost());
          if (unavailableMap.size() == 0) {
            hostUnavailableMap.remove(account);
          }
        }
      }
    }

    /*
     * When JD is started the first time and the user starts downloads right away, a full login might not yet have happened but it is
     * needed to get the individual host limits.
     */
    synchronized (CTRLLOCK) {
      if (hostMaxchunksMap.isEmpty() || hostMaxdlsMap.isEmpty()) {
        logger.info("Performing full login to set individual host limits");
        this.fetchAccountInfo(account);
      } else {
        login(account, false);
      }
    }
    this.setConstants(account, link);

    String dllink = checkDirectLink(link, NICE_HOSTproperty + "directlink");
    if (dllink == null || forceNewLinkGeneration) {
      /* request creation of downloadlink */
      br.setFollowRedirects(true);
      this.postAPISafe(
          "http://jetdebrid.com/index.php?rand=0." + System.currentTimeMillis(),
          "urllist=" + Encoding.urlEncode(link.getDownloadURL()) + "&captcha=none&");
      dllink = br.getRegex("(https?://[a-z0-9\\-]+\\.jetdebrid\\.com/dl/[^<>\"\\']+)").getMatch(0);
      if (dllink == null) {
        logger.warning("Final downloadlink is null");
        handleErrorRetries("dllinknull", 10, 10 * 60 * 1000l);
      }
    }
    handleDL(account, link, dllink);
  }
Exemplo n.º 16
0
  @Override
  public void handleFree(final DownloadLink downloadLink) throws Exception, PluginException {
    requestFileInformation(downloadLink);
    String dllink = this.checkDirectLink(downloadLink, "cache");
    if (dllink == null) {
      final Form f = br.getForm(0);
      InputField i = null;
      for (final InputField inputfield : f.getInputFields()) {
        if ("trackvalue".equals(inputfield.getKey())
            && inputfield.getValue().equals(downloadLink.getStringProperty("iFilename", null))) {
          i = inputfield;
          break;
        }
      }
      // lets remove all other files execpt the one we want, they are all prechecked.
      while (f.getInputField("trackvalue") != null) {
        f.remove("trackvalue");
      }
      // add the one we want
      f.addInputField(i);
      if (f != null && f.hasInputFieldByName("securityCode")) {
        // has captcha
        final String captcha =
            new Regex(br.getURL(), "https?://(?:www\\.)?oshoworld\\.com/[^/]+/").getMatch(-1)
                + "CAPTCHA/CAPTCHA_image.asp";
        final String code = this.getCaptchaCode(captcha, downloadLink);
        f.put("securityCode", Encoding.urlEncode(code));
      }
      br.setFollowRedirects(false);
      br.submitForm(f);
      // redirect show show correct.
      // they come in the form of
      // http://www.oshoarchive.com/ow-english/download.php?id=T1NITy1UaGVfQXJ0X29mX0R5aW5nXzEwLm1wMw
      // the id = base64 iFilename, if we knew the /ow-english/ (for english section) was static we
      // could theoretically bypass
      // captcha..

      dllink = br.getRedirectLocation();
      if (dllink == null) {
        throw new PluginException(LinkStatus.ERROR_CAPTCHA);
      }
    }
    dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, false, 1);
    if (dl.getConnection().getContentType().contains("html")) {
      if (dl.getConnection().getResponseCode() == 404) {
        throw new PluginException(
            LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "Server error 404", 30 * 60 * 1000l);
      }
      br.followConnection();
      throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
    }
    downloadLink.setProperty("cache", dllink);
    dl.startDownload();
  }
Exemplo n.º 17
0
 private void login(final Account account) throws Exception {
   setBrowserExclusive();
   br.setFollowRedirects(true);
   br.getHeaders().put("User-Agent", UA.get());
   br.setCookie(COOKIE_HOST, "lang", "english");
   br.getPage(COOKIE_HOST + "/login.html");
   Form loginform = br.getForm(0);
   if (loginform == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   loginform.put("login", Encoding.urlEncode(account.getUser()));
   loginform.put("password", Encoding.urlEncode(account.getPass()));
   loginform.put("x", String.valueOf((int) (Math.random() * 57)));
   loginform.put("y", String.valueOf((int) (Math.random() * 21)));
   br.submitForm(loginform);
   br.getPage(COOKIE_HOST + "/?op=my_account");
   if (br.getCookie(COOKIE_HOST, "login") == null || br.getCookie(COOKIE_HOST, "xfss") == null) {
     throw new PluginException(LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
   }
 }
Exemplo n.º 18
0
 private void getPageAPI(String url) throws Exception {
   if (apiSession != null) {
     if (!url.contains("?")) {
       url += "?";
     } else {
       url += "&";
     }
     url += "session=" + Encoding.urlEncode(apiSession);
   }
   getPage(url);
   handleErrorsAPI();
 }
Exemplo n.º 19
0
 @SuppressWarnings("deprecation")
 private void postPageAPI(final String url, String postData) throws Exception {
   if (apiSession != null) {
     if (postData == null || postData.equals("")) {
       postData = "";
     } else {
       postData += "&";
     }
     postData += "session=" + Encoding.urlEncode(apiSession);
   }
   postPage(url, postData);
   handleErrorsAPI();
 }
Exemplo n.º 20
0
 private void loginWebsite(Account account, boolean force) throws Exception {
   synchronized (lock) {
     try {
       br.setCookiesExclusive(true);
       final Cookies cookies = account.loadCookies("");
       if (cookies != null && !force) {
         br.setCookies(this.getHost(), cookies);
         return;
       }
       getPage("http://" + this.getHost() + "/login");
       Form login = br.getForm(0);
       if (login == null) {
         logger.warning("Couldn't find login form");
         throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, getPhrase("NO_LOGIN_FORM"));
       }
       login.put("user_email", Encoding.urlEncode(account.getUser()));
       login.put("user_password", Encoding.urlEncode(account.getPass()));
       submitForm(login);
       getPage("/");
       if (br.containsHTML("(Konto:[\r\t\n ]+)*Darmowe")) {
         account.setType(AccountType.FREE);
       } else if ((br.containsHTML("(Konto:[\r\t\n ]+)*Premium \\(<b>\\d+ dni</b>\\)"))
           || (br.containsHTML(
               "(Konto:[\r\t\n ]+)+Premium \\(<b><span style=\"color: red\">\\d+ godzin</span></b>\\)"))) {
         account.setType(AccountType.PREMIUM);
       } else {
         /* Unknown account type */
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM,
             getPhrase("LOGIN_ERROR"),
             PluginException.VALUE_ID_PREMIUM_DISABLE);
       }
       account.saveCookies(br.getCookies(this.getHost()), "");
     } catch (final PluginException e) {
       account.clearCookies("");
       throw e;
     }
   }
 }
Exemplo n.º 21
0
 @SuppressWarnings("unchecked")
 private void login(Account account, boolean force) throws Exception {
   synchronized (LOCK) {
     /** Load cookies */
     br.setCookiesExclusive(false);
     final Object ret = account.getProperty("cookies", null);
     boolean acmatch =
         Encoding.urlEncode(account.getUser())
             .matches(account.getStringProperty("name", Encoding.urlEncode(account.getUser())));
     if (acmatch)
       acmatch =
           Encoding.urlEncode(account.getPass())
               .matches(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();
           this.br.setCookie(MAINPAGE, key, value);
         }
         return;
       }
     }
     br.setFollowRedirects(true);
     br.postPage(
         MAINPAGE + "/login.php",
         "user="******"&pass="******"&submit=Login&task=dologin&return=%2F");
     if (!br.containsHTML(PREMIUMTEXT)) {
       br.getPage(MAINPAGE + "/members/myfiles.php");
       if (!br.containsHTML(PREMIUMLIMIT))
         throw new PluginException(
             LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     }
     /** Save cookies */
     final HashMap<String, String> cookies = new HashMap<String, String>();
     final Cookies add = this.br.getCookies(MAINPAGE);
     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);
   }
 }
Exemplo n.º 22
0
 private void login(Account account) throws Exception {
   this.setBrowserExclusive();
   br.postPage(
       "http://www.datpiff.com/login",
       "cmd=login&username="******"&password="******"dp4u1d") == null || br.getCookie(MAINPAGE, "lastuser") == null) {
     final String lang = System.getProperty("user.language");
     if ("de".equalsIgnoreCase(lang)) {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nSchnellhilfe: \r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen?\r\nFalls dein Passwort Sonderzeichen enthält, ändere es und versuche es erneut!",
           PluginException.VALUE_ID_PREMIUM_DISABLE);
     } else {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "\r\nInvalid username/password!\r\nQuick help:\r\nYou're sure that the username and password you entered are correct?\r\nIf your password contains special characters, change it (remove them) and try again!",
           PluginException.VALUE_ID_PREMIUM_DISABLE);
     }
   }
 }
Exemplo n.º 23
0
 @SuppressWarnings("deprecation")
 @Override
 public AvailableStatus requestFileInformation(final DownloadLink link)
     throws IOException, PluginException {
   this.setBrowserExclusive();
   br.setFollowRedirects(true);
   String filename;
   if (use_oembed_api) {
     br.getPage(
         "http://www.audiomack.com/oembed?format=json&url="
             + Encoding.urlEncode(link.getDownloadURL()));
     if (br.containsHTML(">Did not find any music with url")) {
       throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
     }
     final String artist = getJson("author_name");
     final String songname = getJson("title");
     if (artist == null || songname == null) {
       throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
     }
     filename = artist + " - " + songname;
   } else if (link.getDownloadURL().matches(TYPE_API)) {
     br.getPage(link.getStringProperty("mainlink", null));
     if (br.getHttpConnection().getResponseCode() == 404) {
       throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
     }
     filename = link.getStringProperty("plain_filename", null);
   } else {
     br.getPage(link.getDownloadURL());
     if (br.containsHTML(">Page not found<")) {
       throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
     }
     filename = br.getRegex("<aside class=\"span2\">[\t\n\r ]+<h1>([^<>\"]*?)</h1>").getMatch(0);
     if (filename == null) {
       filename =
           br.getRegex("<title>([^<>\"]*?) \\- download and stream \\| AudioMack</title>")
               .getMatch(0);
     }
     if (filename == null) {
       filename = br.getRegex("name=\"twitter:title\" content=\"([^<>\"]*?)\"").getMatch(0);
     }
   }
   if (filename == null) {
     throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   }
   if (filename != null && link.getFinalFileName() == null) {
     link.setFinalFileName(Encoding.htmlDecode(filename.trim()) + ".mp3");
   }
   return AvailableStatus.TRUE;
 }
Exemplo n.º 24
0
  // @Override
  public void handleFree(DownloadLink downloadLink) throws Exception {
    requestFileInformation(downloadLink);
    /* Link holen */
    HashMap<String, String> submitvalues = HTMLParser.getInputHiddenFields(br.toString());
    postdata = "act=" + Encoding.urlEncode(submitvalues.get("act"));
    postdata = postdata + "&id=" + Encoding.urlEncode(submitvalues.get("id"));
    postdata = postdata + "&fname=" + Encoding.urlEncode(submitvalues.get("fname"));
    if (br.containsHTML("type=\"password\" name=\"password\"")) {
      String password =
          Plugin.getUserInput(
              JDL.L("plugins.hoster.speedysharecom.password", "Enter Password:"******"")) {
        postdata = postdata + "&password=" + Encoding.urlEncode(password);
      }
    }

    /* Zwangswarten, 30seks */
    sleep(30000, downloadLink);

    /* Datei herunterladen */
    jd.plugins.BrowserAdapter.openDownload(
            br, downloadLink, downloadLink.getDownloadURL(), postdata)
        .startDownload();
  }
Exemplo n.º 25
0
  public ArrayList<DownloadLink> decryptIt(CryptedLink param, ProgressController progress)
      throws Exception {
    ArrayList<DownloadLink> decryptedLinks = new ArrayList<DownloadLink>();
    String parameter = param.toString();
    String uid = new Regex(parameter, "([a-z0-9]{7})$").getMatch(0);

    br.getPage(parameter);
    if (br.containsHTML("<div id=\"error\">пакет не найден<")) {
      logger.info("Wrong URL or the package no longer exists.");
      return decryptedLinks;
    }
    String title = br.getRegex("<title>(.*?)</title>").getMatch(0);
    if (title == null) title = "";

    /* Password protected package */
    if (br.containsHTML(">пакет защищен паролем<")) {
      for (int i = 0; i <= 3; i++) {
        final String passCode = Plugin.getUserInput("Enter password for: " + title, param);
        br.postPage(parameter, "put_pwd=" + Encoding.urlEncode(passCode));
        if (br.containsHTML(">пакет защищен паролем<")) continue;
        break;
      }
      if (br.containsHTML(">пакет защищен паролем<"))
        throw new DecrypterException(DecrypterException.PASSWORD);
      if (br.getRedirectLocation() != null) br.getPage(br.getRedirectLocation());
    }

    String domain = new Regex(br.getURL(), "(https?://[^/]+)").getMatch(0);

    String[] links = br.getRegex("href=\"(/download/" + uid + "/[^\"]+)").getColumn(0);
    if (links == null || links.length == 0) {
      logger.warning("Decrypter broken for link: " + parameter);
      return null;
    }

    for (String link : links) {
      decryptedLinks.add(createDownloadlink("directhttp://" + domain + link));
    }

    if (title != null || !title.equals("")) {
      FilePackage fp = FilePackage.getInstance();
      fp.setName(Encoding.htmlDecode(title.trim()));
      fp.addLinks(decryptedLinks);
    }

    return decryptedLinks;
  }
Exemplo n.º 26
0
 private String handlePassword(final Form pwform, final DownloadLink thelink)
     throws PluginException {
   if (passCode == null) passCode = Plugin.getUserInput("Password?", thelink);
   if (passCode == null || passCode.equals("")) {
     logger.info("User has entered blank password, exiting handlePassword");
     passCode = null;
     thelink.setProperty("pass", Property.NULL);
     return null;
   }
   if (pwform == null) {
     // so we know handlePassword triggered without any form
     logger.info("Password Form == null");
   } else {
     logger.info("Put password \"" + passCode + "\" entered by user in the DLForm.");
     pwform.put("password", Encoding.urlEncode(passCode));
   }
   thelink.setProperty("pass", passCode);
   return passCode;
 }
Exemplo n.º 27
0
 private HashMap<String, String> callAPI(
     final Browser brr,
     final String action,
     final Account account,
     final HashMap<String, String> addParams)
     throws Exception {
   if (action == null || action.length() == 0) {
     return null;
   }
   Browser tbr = brr;
   if (tbr == null) {
     tbr = new Browser();
   }
   tbr.setDebug(true);
   final LinkedHashMap<String, String> post = new LinkedHashMap<String, String>();
   post.put("action", action);
   if (account != null) {
     /* do not remove */
     if (account.getPass() == null || account.getUser() == null)
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE);
     final String pwMD5 = JDHash.getMD5(account.getPass().trim());
     post.put("passwordmd5", pwMD5);
     post.put("username", Encoding.urlEncode(account.getUser().trim()));
     // post.put("password",
     // Encoding.urlEncode(account.getPass().trim()));
   }
   if (addParams != null) {
     for (final String param : addParams.keySet()) {
       post.put(param, addParams.get(param));
     }
   }
   tbr.postPage("http://api.hotfile.com", post);
   final HashMap<String, String> ret = new HashMap<String, String>();
   ret.put("httpresponse", tbr.toString());
   final String vars[][] = tbr.getRegex("([^\r\n]*?)=([^\r\n]*?)(&|$)").getMatches();
   for (final String var[] : vars) {
     ret.put(var[0] != null ? var[0].trim() : null, var[1]);
   }
   return ret;
 }
Exemplo n.º 28
0
 private void login(final Account account) throws PluginException, IOException {
   String username = Encoding.urlEncode(account.getUser());
   br.postPage(
       "http://crypt.twojlimit.pl",
       "username="******"&password="******"&info=1&site=twojlimit");
   String adres = br.toString();
   br.getPage(adres);
   adres = br.getRedirectLocation();
   br.getPage(adres);
   if (br.containsHTML("0=Nieprawidlowa nazwa uzytkownika/haslo")) {
     if ("de".equalsIgnoreCase(System.getProperty("user.language"))) {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "\r\nUngültiger Benutzername oder ungültiges Passwort!\r\nDu bist dir sicher, dass dein eingegebener Benutzername und Passwort stimmen? Versuche folgendes:\r\n1. Falls dein Passwort Sonderzeichen enthält, ändere es (entferne diese) und versuche es erneut!\r\n2. Gib deine Zugangsdaten per Hand (ohne kopieren/einfügen) ein.",
           PluginException.VALUE_ID_PREMIUM_DISABLE);
     } else {
       throw new PluginException(
           LinkStatus.ERROR_PREMIUM,
           "\r\nInvalid username/password!\r\nYou're sure that the username and password you entered are correct? Some hints:\r\n1. If your password contains special characters, change it (remove them) and try again!\r\n2. Type in your username/password by hand without copy & paste.",
           PluginException.VALUE_ID_PREMIUM_DISABLE);
     }
   }
   if (this.br.containsHTML("balance")) {
     Info = br.toString();
   }
   if (this.br.containsHTML("expire")) {
     char temp = Info.charAt(Info.length() - 11);
     validUntil = Info.substring(Info.length() - 10);
     expired = temp != '1';
   } else {
     expired = false;
   }
   if (GetTrasferLeft(br.toString()) > 10) {
     expired = false;
   }
 }
Exemplo n.º 29
0
 @Override
 public AvailableStatus requestFileInformation(final DownloadLink parameter) throws Exception {
   this.setBrowserExclusive();
   br.setFollowRedirects(true);
   url = parameter.getStringProperty("directlink");
   if (url != null) {
     checkDirectLink(parameter, url);
     if (url != null) return AvailableStatus.TRUE;
   }
   br.getPage(
       "https://api.sndcdn.com/resolve?url="
           + Encoding.urlEncode(parameter.getDownloadURL())
           + "&_status_code_map%5B302%5D=200&_status_format=json&client_id="
           + CLIENTID);
   if (br.containsHTML("\"404 \\- Not Found\""))
     throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   AvailableStatus status = checkStatus(parameter, this.br.toString());
   if (status.equals(AvailableStatus.FALSE))
     throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
   if (url == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
   checkDirectLink(parameter, url);
   return AvailableStatus.TRUE;
 }
Exemplo n.º 30
0
 private String api_getAccessToken(Account account, boolean liveToken) throws Exception {
   synchronized (account) {
     try {
       String token = account.getStringProperty("token", null);
       if (token != null && liveToken == false) return token;
       br.postPage(
           "http://cloudzer.net/api/user/login",
           "name="
               + Encoding.urlEncode(account.getUser())
               + "&pass="******"UTF-8").toLowerCase(Locale.ENGLISH))
               + "&ishash=1&app=JDownloader");
       token = br.getRegex("access_token\":\"(.*?)\"").getMatch(0);
       if (token == null) handleErrorCode(br, account, token, true);
       account.setProperty("token", token);
       return token;
     } catch (final PluginException e) {
       account.setProperty("token", null);
       account.setProperty("tokenType", null);
       throw e;
     }
   }
 }