@SuppressWarnings("unchecked") public void loginWebsite(final Account account) throws IOException, PluginException { setBrowserExclusive(); synchronized (HotFileCom.LOCK) { br.setDebug(true); br.getHeaders().put("User-Agent", ua); br.setCookie("http://hotfile.com", "lang", "en"); final Object ret = account.getProperty("cookies", null); if (ret != null && ret instanceof HashMap<?, ?> && getPluginConfig().getBooleanProperty(HotFileCom.TRY_IWL_BYPASS, false)) { logger.info("Use cookie login"); /* use saved cookies */ final HashMap<String, String> cookies = (HashMap<String, String>) ret; for (final String key : cookies.keySet()) { br.setCookie("http://hotfile.com/", key, cookies.get(key)); } br.setFollowRedirects(true); br.getPage("http://hotfile.com/"); br.setFollowRedirects(false); String isPremium = br.getRegex("Account:.*?label.*?centerSide[^/]*?>(Premium)<").getMatch(0); if (isPremium == null) isPremium = br.getRegex("centerSide\"><p><span>(Premium)</span>").getMatch(0); if (isPremium == null) { account.setProperty("cookies", null); throw new PluginException( LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE); } } else { /* normal login */ br.setFollowRedirects(true); br.getPage("http://hotfile.com/"); br.postPage( "http://hotfile.com/login.php", "returnto=%2F&user="******"&pass="******"<td>Username:"******"cookies", null); throw new PluginException( LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE); } if (br.getCookie("http://hotfile.com/", "auth") == null) { account.setProperty("cookies", null); throw new PluginException( LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE); } String isPremium = br.getRegex("Account:.*?label.*?centerSide[^/]*?>(Premium)<").getMatch(0); if (isPremium == null) isPremium = br.getRegex("centerSide\"><p><span>(Premium)</span>").getMatch(0); if (isPremium == null) { account.setProperty("cookies", null); throw new PluginException( LinkStatus.ERROR_PREMIUM, PluginException.VALUE_ID_PREMIUM_DISABLE); } final HashMap<String, String> cookies = new HashMap<String, String>(); final Cookies add = br.getCookies("http://hotfile.com/"); for (final Cookie c : add.getCookies()) { cookies.put(c.getKey(), c.getValue()); } account.setProperty("cookies", cookies); br.setFollowRedirects(false); } } }
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; } } }
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(); }
@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; } }
private void doFree(final DownloadLink downloadLink) throws Exception { if (br.containsHTML(FILENOTFOUND)) { throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } if (br.containsHTML("There is another download in progress from your IP")) { throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 15 * 60 * 1000l); } if (br.containsHTML(ONLY4PREMIUM)) { throw new PluginException( LinkStatus.ERROR_FATAL, JDL.L("plugins.host.errormsg.only4premium", "Only downloadable for premium users!")); } String wait = br.getRegex("w=\\'(\\d+)\\'").getMatch(0); int waittime = 0; if (wait != null) { waittime = Integer.parseInt(wait.trim()); } if (waittime > 180 && longwait.get()) { /* first time >90 secs, it can be we are country with long waittime */ longwait.set(true); sleep(waittime * 1000l, downloadLink); } else { if (longwait == null) { longwait.set(false); } if (waittime > 90 && longwait.get() == false) { /* * only request reconnect if we dont have to wait long on every download */ throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, waittime * 1000l); } else { if (br.getRegex("Recaptcha\\.create\\(\"(.*?)\"").getMatch(0) == null) { sleep(waittime * 1000l, downloadLink); } } } String id = br.getRegex("Recaptcha\\.create\\(\"(.*?)\"").getMatch(0); if (br.containsHTML("Please wait or buy a Premium membership")) { throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 60 * 60 * 1000l); } if (id == null) { getPage(this.br, downloadLink.getDownloadURL()); } if (br.containsHTML("There is another download in progress from your IP")) { throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 15 * 60 * 1000l); } // br = br; int tries = 0; while (true) { tries++; id = br.getRegex("Recaptcha\\.create\\(\"(.*?)\"").getMatch(0); if (id == null) { logger.warning("crocko.com: plugin broken, reCaptchaID is null"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } final Browser rcBr = br.cloneBrowser(); /* follow redirect needed as google redirects to another domain */ rcBr.setFollowRedirects(true); getPage(rcBr, "http://api.recaptcha.net/challenge?k=" + id); String challenge = rcBr.getRegex("challenge.*?:.*?'(.*?)',").getMatch(0); String server = rcBr.getRegex("server.*?:.*?'(.*?)',").getMatch(0); if (challenge == null || server == null) { logger.severe("crocko.com: Recaptcha Module fails: " + br.getHttpConnection()); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } String captchaAddress = server + "image?c=" + challenge; File cf = getLocalCaptchaFile(); Browser.download(cf, rcBr.openGetConnection(captchaAddress)); Form form = null; Form[] allForms = br.getForms(); if (allForms == null || allForms.length == 0) { logger.warning("crocko.com: plugin broken, no download forms found"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } for (Form singleForm : allForms) { if (singleForm.containsHTML("\"id\"") && !singleForm.containsHTML("lang_select")) { form = singleForm; break; } } if (form == null) { logger.warning("crocko.com: plugin broken, no download forms found #2"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } /* * another as default cause current stable has easy-captcha method that does not work */ String code = getCaptchaCode("recaptcha", cf, downloadLink); form.put("recaptcha_challenge_field", challenge); form.put("recaptcha_response_field", Encoding.urlEncode(code)); form.remove(null); br.setFollowRedirects(true); dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, form, true, 1); if (!dl.getConnection().isContentDisposition()) { br.followConnection(); if (br.containsHTML("There are no more download slots available right now.")) { throw new PluginException( LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE, "There are no more download slots available right now.", 10 * 60 * 1000l); } if (br.containsHTML("There is another download in progress from your IP")) { throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, 15 * 60 * 1000l); } if (br.containsHTML("Entered code is invalid")) { if (tries <= 5) { continue; } else { throw new PluginException(LinkStatus.ERROR_CAPTCHA); } } logger.warning("crocko.com: plugin broken, direct link -> HTML code"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } break; } downloadLink.setFinalFileName(Encoding.htmlDecode(getFileNameFromHeader(dl.getConnection()))); dl.startDownload(); }