git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@32421 ebf7c1c2-ba36-0410-9fe8-c592906822b4

Former-commit-id: 9fbbc0f5c363160db4abc5966558300d641b0987
This commit is contained in:
coalado 2016-01-11 15:47:01 +00:00
parent f89a37acbb
commit a1c4965705
28 changed files with 1169 additions and 328 deletions

View File

@ -1,4 +1,15 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=true
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0

View File

@ -2,12 +2,6 @@ package jd.controlling.captcha;
import javax.swing.SwingUtilities;
import jd.gui.swing.dialog.DialogType;
import jd.gui.swing.jdgui.JDGui;
import jd.plugins.Plugin;
import jd.plugins.PluginForDecrypt;
import jd.plugins.PluginForHost;
import org.appwork.storage.config.JsonConfig;
import org.appwork.uio.UIOManager;
import org.appwork.utils.logging2.LogInterface;
@ -26,6 +20,12 @@ import org.jdownloader.logging.LogController;
import org.jdownloader.settings.SilentModeSettings.CaptchaDuringSilentModeAction;
import org.jdownloader.settings.staticreferences.CFG_SILENTMODE;
import jd.gui.swing.dialog.DialogType;
import jd.gui.swing.jdgui.JDGui;
import jd.plugins.Plugin;
import jd.plugins.PluginForDecrypt;
import jd.plugins.PluginForHost;
public abstract class ChallengeDialogHandler<T extends Challenge<?>> {
private DomainInfo host;
@ -221,6 +221,11 @@ public abstract class ChallengeDialogHandler<T extends Challenge<?>> {
countdown = pluginTimeout;
}
}
int pluginCaptchaChallengeTimout = captchaChallenge.getPlugin().getChallengeTimeout(captchaChallenge);
if (pluginCaptchaChallengeTimout > 0 && pluginCaptchaChallengeTimout < countdown) {
countdown = pluginCaptchaChallengeTimout;
}
return countdown;
}

View File

@ -24,9 +24,6 @@ import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.Timer;
import jd.captcha.utils.GifDecoder;
import net.miginfocom.swing.MigLayout;
import org.appwork.utils.URLStream;
import org.appwork.utils.images.IconIO;
import org.appwork.utils.images.Interpolation;
@ -35,6 +32,11 @@ import org.jdownloader.captcha.v2.AbstractCaptchaDialog;
import org.jdownloader.settings.staticreferences.CFG_GUI;
import org.jdownloader.updatev2.gui.LAFOptions;
import com.sun.javafx.geom.Rectangle;
import jd.captcha.utils.GifDecoder;
import net.miginfocom.swing.MigLayout;
public abstract class AbstractImageCaptchaDialog extends AbstractCaptchaDialog<Object> {
public static Image[] getGifImages(InputStream openStream) {
@ -79,15 +81,15 @@ public abstract class AbstractImageCaptchaDialog extends AbstractCaptchaDialog<O
return null;
}
int fps;
int fps;
Image[] images;
Image[] images;
protected Point offset;
private int frame = 0;
Timer paintTimer;
protected double scaleFaktor;
protected Point offset;
private int frame = 0;
Timer paintTimer;
protected Rectangle bounds;
protected double scaleFaktor;
public AbstractImageCaptchaDialog(int flags, String title, DialogType type, DomainInfo domainInfo, String explain, Image... images) {
super(flags, title, type, domainInfo, explain);
@ -156,6 +158,8 @@ public abstract class AbstractImageCaptchaDialog extends AbstractCaptchaDialog<O
g.drawImage(scaled, (getWidth() - scaled.getWidth()) / 2, (getHeight() - scaled.getHeight()) / 2, col, null);
scaleFaktor = images[frame].getWidth(null) / (double) scaled.getWidth();
offset = new Point((getWidth() - scaled.getWidth()) / 2, (getHeight() - scaled.getHeight()) / 2);
AbstractImageCaptchaDialog.this.bounds = new Rectangle((getWidth() - scaled.getWidth()) / 2, (getHeight() - scaled.getHeight()) / 2, scaled.getWidth(), scaled.getHeight());
paintIconComponent(g, getWidth(), getHeight(), (getWidth() - scaled.getWidth()) / 2, (getHeight() - scaled.getHeight()) / 2, scaled);
}
@ -171,6 +175,9 @@ public abstract class AbstractImageCaptchaDialog extends AbstractCaptchaDialog<O
return iconPanel;
}
protected void paintIconComponent(Graphics g, int width, int height, int xOsset, int yOffset, BufferedImage scaled) {
}
@Override
public void dispose() {
if (paintTimer != null) {

View File

@ -30,6 +30,29 @@ import java.util.regex.Pattern;
import javax.swing.Icon;
import org.appwork.net.protocol.http.HTTPConstants;
import org.appwork.storage.config.ConfigInterface;
import org.appwork.uio.CloseReason;
import org.appwork.uio.UIOManager;
import org.appwork.utils.Exceptions;
import org.appwork.utils.StringUtils;
import org.appwork.utils.logging2.LogInterface;
import org.appwork.utils.net.httpconnection.HTTPConnectionUtils;
import org.appwork.utils.net.httpconnection.HTTPProxy;
import org.jdownloader.auth.Login;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.gui.dialog.AskCrawlerPasswordDialogInterface;
import org.jdownloader.gui.dialog.AskDownloadPasswordDialogInterface;
import org.jdownloader.gui.dialog.AskForCryptedLinkPasswordDialog;
import org.jdownloader.gui.dialog.AskForPasswordDialog;
import org.jdownloader.gui.dialog.AskForUserAndPasswordDialog;
import org.jdownloader.gui.dialog.AskUsernameAndPasswordDialogInterface;
import org.jdownloader.images.NewTheme;
import org.jdownloader.logging.LogController;
import org.jdownloader.plugins.UserIOProgress;
import org.jdownloader.settings.staticreferences.CFG_CAPTCHA;
import org.jdownloader.translate._JDT;
import jd.PluginWrapper;
import jd.config.ConfigContainer;
import jd.config.SubConfiguration;
@ -51,28 +74,6 @@ import jd.nutils.encoding.Encoding;
import jd.plugins.components.SiteType.SiteTemplate;
import jd.utils.JDUtilities;
import org.appwork.net.protocol.http.HTTPConstants;
import org.appwork.storage.config.ConfigInterface;
import org.appwork.uio.CloseReason;
import org.appwork.uio.UIOManager;
import org.appwork.utils.Exceptions;
import org.appwork.utils.StringUtils;
import org.appwork.utils.logging2.LogInterface;
import org.appwork.utils.net.httpconnection.HTTPConnectionUtils;
import org.appwork.utils.net.httpconnection.HTTPProxy;
import org.jdownloader.auth.Login;
import org.jdownloader.gui.dialog.AskCrawlerPasswordDialogInterface;
import org.jdownloader.gui.dialog.AskDownloadPasswordDialogInterface;
import org.jdownloader.gui.dialog.AskForCryptedLinkPasswordDialog;
import org.jdownloader.gui.dialog.AskForPasswordDialog;
import org.jdownloader.gui.dialog.AskForUserAndPasswordDialog;
import org.jdownloader.gui.dialog.AskUsernameAndPasswordDialogInterface;
import org.jdownloader.images.NewTheme;
import org.jdownloader.logging.LogController;
import org.jdownloader.plugins.UserIOProgress;
import org.jdownloader.settings.staticreferences.CFG_CAPTCHA;
import org.jdownloader.translate._JDT;
/**
* Diese abstrakte Klasse steuert den Zugriff auf weitere Plugins. Alle Plugins müssen von dieser Klasse abgeleitet werden.
*
@ -693,4 +694,8 @@ public abstract class Plugin implements ActionListener {
return null;
}
public int getChallengeTimeout(Challenge<?> captchaChallenge) {
return -1;
}
}

View File

@ -35,7 +35,9 @@ import jd.nutils.JDHash;
import jd.nutils.encoding.Encoding;
import jd.parser.Regex;
import jd.parser.html.Form;
import jd.plugins.CaptchaException;
import jd.plugins.CryptedLink;
import jd.plugins.DecrypterException;
import jd.plugins.DecrypterPlugin;
import jd.plugins.DownloadLink;
import jd.plugins.PluginForDecrypt;
@ -410,11 +412,25 @@ public class Srnnks extends PluginForDecrypt {
}
} else if (form.containsHTML("=\"g-recaptcha\"")) {
final String recaptchaV2Response = new CaptchaHelperCrawlerPluginRecaptchaV2(this, br).getToken();
form.put("g-recaptcha-response", Encoding.urlEncode(recaptchaV2Response));
synchronized (Srnnks.GLOBAL_LOCK) {
Thread.sleep(FW_WAIT);
this.br.submitForm(form);
try {
final String recaptchaV2Response = new CaptchaHelperCrawlerPluginRecaptchaV2(this, br).getToken();
form.put("g-recaptcha-response", Encoding.urlEncode(recaptchaV2Response));
synchronized (Srnnks.GLOBAL_LOCK) {
Thread.sleep(FW_WAIT);
this.br.submitForm(form);
if (br.containsHTML("class=\"g-recaptcha\"")) {
// it took too long to solve. try again
continue;
}
}
} catch (CaptchaException de) {
getLogger().log(de);
continue;
} catch (DecrypterException de) {
getLogger().log(de);
continue;
}
} else {
System.out.println("CAPTCHA SKIP!!!");

View File

@ -2,8 +2,6 @@ package org.jdownloader.api.captcha;
import java.util.List;
import jd.controlling.captcha.SkipRequest;
import org.appwork.net.protocol.http.HTTPConstants.ResponseCode;
import org.appwork.remoteapi.RemoteAPIInterface;
import org.appwork.remoteapi.RemoteAPIRequest;
@ -13,6 +11,8 @@ import org.appwork.remoteapi.annotations.ApiNamespace;
import org.appwork.remoteapi.exceptions.APIError;
import org.appwork.remoteapi.exceptions.InternalApiException;
import jd.controlling.captcha.SkipRequest;
@ApiNamespace("captcha")
public interface CaptchaAPI extends RemoteAPIInterface {
public static enum ABORT {
@ -44,13 +44,16 @@ public interface CaptchaAPI extends RemoteAPIInterface {
@ApiDoc("Returns Captcha Image as Base64 encoded data url")
public void get(RemoteAPIRequest request, final RemoteAPIResponse response, final long id) throws InternalApiException, InvalidCaptchaIDException;
@ApiDoc("Returns Captcha Image as Base64 encoded data url")
public void get(RemoteAPIRequest request, final RemoteAPIResponse response, final long id, String format) throws InternalApiException, InvalidCaptchaIDException;
@ApiDoc("Returns CaptchaJob Object for the given id")
public CaptchaJob getCaptchaJob(final long id) throws InvalidCaptchaIDException;
public boolean solve(final long id, String result) throws InvalidCaptchaIDException, InvalidChallengeTypeException;
@Deprecated
/**
/**
* @deprecated use #skip(id,type) instead
* @param id
* @return

View File

@ -5,10 +5,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import jd.controlling.captcha.SkipException;
import jd.controlling.captcha.SkipRequest;
import jd.plugins.DownloadLink;
import org.appwork.remoteapi.RemoteAPI;
import org.appwork.remoteapi.RemoteAPIRequest;
import org.appwork.remoteapi.RemoteAPIResponse;
@ -17,7 +13,6 @@ import org.appwork.storage.JSonStorage;
import org.appwork.storage.config.JsonConfig;
import org.appwork.utils.Application;
import org.appwork.utils.StringUtils;
import org.jdownloader.api.myjdownloader.MyJDownloaderController;
import org.jdownloader.api.myjdownloader.MyJDownloaderRequestInterface;
import org.jdownloader.captcha.event.ChallengeResponseListener;
@ -28,6 +23,8 @@ import org.jdownloader.captcha.v2.ChallengeSolver;
import org.jdownloader.captcha.v2.JobRunnable;
import org.jdownloader.captcha.v2.challenge.keycaptcha.KeyCaptchaCategoryChallenge;
import org.jdownloader.captcha.v2.challenge.keycaptcha.KeyCaptchaPuzzleChallenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.ImageCaptchaChallenge;
import org.jdownloader.captcha.v2.solver.browser.BrowserSolver;
import org.jdownloader.captcha.v2.solver.gui.DialogBasicCaptchaSolver;
@ -36,6 +33,10 @@ import org.jdownloader.captcha.v2.solver.jac.SolverException;
import org.jdownloader.captcha.v2.solver.service.DialogSolverService;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import jd.controlling.captcha.SkipException;
import jd.controlling.captcha.SkipRequest;
import jd.plugins.DownloadLink;
public class CaptchaAPISolver extends ChallengeSolver<Object> implements CaptchaAPI, ChallengeResponseListener {
private static final CaptchaAPISolver INSTANCE = new CaptchaAPISolver();
@ -54,12 +55,19 @@ public class CaptchaAPISolver extends ChallengeSolver<Object> implements Captcha
@Override
public boolean canHandle(Challenge<?> c) {
if (!validateBlackWhite(c)) {
return false;
}
if (c instanceof KeyCaptchaPuzzleChallenge && super.canHandle(c)) {
return true;
}
if (c instanceof KeyCaptchaCategoryChallenge && super.canHandle(c)) {
return true;
}
if (c instanceof RecaptchaV2Challenge || c instanceof Recaptcha2FallbackChallenge) {
return true;
}
return c instanceof ImageCaptchaChallenge && super.canHandle(c);
}
@ -122,19 +130,19 @@ public class CaptchaAPISolver extends ChallengeSolver<Object> implements Captcha
if (entry.isDone()) {
continue;
}
if (entry.getChallenge() instanceof ImageCaptchaChallenge) {
if (getChallenge(entry) instanceof ImageCaptchaChallenge) {
final CaptchaJob job = new CaptchaJob();
final Challenge<?> challenge = entry.getChallenge();
final Challenge<?> challenge = getChallenge(entry);
Class<?> cls = challenge.getClass();
while (cls != null && StringUtils.isEmpty(job.getType())) {
job.setType(cls.getSimpleName());
cls = cls.getSuperclass();
}
job.setID(entry.getChallenge().getId().getID());
job.setHoster(((ImageCaptchaChallenge) entry.getChallenge()).getPlugin().getHost());
job.setCaptchaCategory(entry.getChallenge().getTypeID());
job.setTimeout(entry.getChallenge().getTimeout());
job.setCreated(entry.getChallenge().getCreated());
job.setID(getChallenge(entry).getId().getID());
job.setHoster(getChallenge(entry).getPlugin().getHost());
job.setCaptchaCategory(getChallenge(entry).getTypeID());
job.setTimeout(getChallenge(entry).getTimeout());
job.setCreated(getChallenge(entry).getCreated());
ret.add(job);
}
}
@ -142,14 +150,19 @@ public class CaptchaAPISolver extends ChallengeSolver<Object> implements Captcha
}
public void get(RemoteAPIRequest request, RemoteAPIResponse response, long id) throws InternalApiException, InvalidCaptchaIDException {
get(request, response, id, null);
}
public void get(RemoteAPIRequest request, RemoteAPIResponse response, long id, String format) throws InternalApiException, InvalidCaptchaIDException {
final SolverJob<?> job = ChallengeResponseController.getInstance().getJobById(id);
if (job == null || job.isDone()) {
throw new InvalidCaptchaIDException();
}
try {
final Challenge<?> challenge = job.getChallenge();
Challenge<?> challenge = getChallenge(job);
final OutputStream out = RemoteAPI.getOutputStream(response, request, RemoteAPI.gzip(request), true);
try {
final HashMap<String, Object> captchaResponseData = new HashMap<String, Object>();
captchaResponseData.put("data", challenge.getAPIStorable());
if (request.getHttpRequest() instanceof MyJDownloaderRequestInterface) {
@ -170,6 +183,15 @@ public class CaptchaAPISolver extends ChallengeSolver<Object> implements Captcha
}
}
private Challenge<?> getChallenge(SolverJob<?> job) {
Challenge<?> challenge = job.getChallenge();
if (challenge instanceof RecaptchaV2Challenge) {
challenge = ((RecaptchaV2Challenge) challenge).createBasicCaptchaChallenge();
}
return challenge;
}
public boolean isJobDone(final SolverJob<?> job) {
if (isMyJDownloaderActive()) {
synchronized (map) {
@ -202,7 +224,8 @@ public class CaptchaAPISolver extends ChallengeSolver<Object> implements Captcha
if (job == null || job.isDone()) {
throw new InvalidCaptchaIDException();
}
final Challenge<?> challenge = job.getChallenge();
Challenge<?> challenge = getChallenge(job);
final AbstractResponse<?> ret = challenge.parseAPIAnswer(result, this);
if (ret != null) {
((SolverJob<Object>) job).addAnswer((AbstractResponse<Object>) ret);
@ -223,7 +246,9 @@ public class CaptchaAPISolver extends ChallengeSolver<Object> implements Captcha
if (job == null) {
throw new InvalidCaptchaIDException();
}
ChallengeResponseController.getInstance().setSkipRequest(type, this, job.getChallenge());
Challenge<Object> challenge = job.getChallenge();
ChallengeResponseController.getInstance().setSkipRequest(type, this, challenge);
return true;
}
@ -239,17 +264,17 @@ public class CaptchaAPISolver extends ChallengeSolver<Object> implements Captcha
return null;
}
final CaptchaJob ret = new CaptchaJob();
final Challenge<?> challenge = entry.getChallenge();
final Challenge<?> challenge = getChallenge(entry);
Class<?> cls = challenge.getClass();
while (cls != null && StringUtils.isEmpty(ret.getType())) {
ret.setType(cls.getSimpleName());
cls = cls.getSuperclass();
}
ret.setID(entry.getChallenge().getId().getID());
ret.setHoster(entry.getChallenge().getHost());
ret.setCaptchaCategory(entry.getChallenge().getTypeID());
ret.setExplain(entry.getChallenge().getExplain());
final DownloadLink link = entry.getChallenge().getDownloadLink();
ret.setID(getChallenge(entry).getId().getID());
ret.setHoster(getChallenge(entry).getHost());
ret.setCaptchaCategory(getChallenge(entry).getTypeID());
ret.setExplain(getChallenge(entry).getExplain());
final DownloadLink link = getChallenge(entry).getDownloadLink();
if (link != null) {
ret.setLink(link.getUniqueID().getID());
}

View File

@ -35,13 +35,6 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;
import jd.gui.swing.dialog.DialogType;
import jd.gui.swing.jdgui.JDGui;
import jd.plugins.Plugin;
import jd.plugins.PluginForDecrypt;
import jd.plugins.PluginForHost;
import net.miginfocom.swing.MigLayout;
import org.appwork.storage.config.JsonConfig;
import org.appwork.swing.MigPanel;
import org.appwork.swing.components.ExtButton;
@ -73,6 +66,13 @@ import org.jdownloader.settings.staticreferences.CFG_CAPTCHA;
import org.jdownloader.settings.staticreferences.CFG_GUI;
import org.jdownloader.updatev2.gui.LAFOptions;
import jd.gui.swing.dialog.DialogType;
import jd.gui.swing.jdgui.JDGui;
import jd.plugins.Plugin;
import jd.plugins.PluginForDecrypt;
import jd.plugins.PluginForHost;
import net.miginfocom.swing.MigLayout;
public abstract class AbstractCaptchaDialog<T> extends AbstractDialog<T> implements MouseListener, MouseMotionListener {
private LocationStorage config;
@ -303,6 +303,7 @@ public abstract class AbstractCaptchaDialog<T> extends AbstractDialog<T> impleme
} else {
setLocator(new RememberAbsoluteDialogLocator("CaptchaDialog"));
}
this.explain = explain;
this.hosterInfo = domainInfo;
this.type = type;
@ -415,11 +416,15 @@ public abstract class AbstractCaptchaDialog<T> extends AbstractDialog<T> impleme
if (!isInitialized()) {
return;
}
if (dialog != null) {
// setx and sety store the dimension/size!
config.setX(getDialog().getWidth());
config.setValid(true);
config.setY(getDialog().getHeight());
}
super.dispose();
}
@ -591,6 +596,7 @@ public abstract class AbstractCaptchaDialog<T> extends AbstractDialog<T> impleme
if (!config.isValid()) {
return super.getPreferredWidth();
}
System.out.println(config.getX());
return config.getX();
}
@ -786,8 +792,9 @@ public abstract class AbstractCaptchaDialog<T> extends AbstractDialog<T> impleme
headerPanel.add(header);
}
System.out.println("File " + Application.getResource("cfg/CaptchaDialogDimensions_" + Hash.getMD5(getHost())) + " _ " + getHost());
config = JsonConfig.create(Application.getResource("cfg/CaptchaDialogDimensions_" + Hash.getMD5(getHost())), LocationStorage.class);
System.out.println(config);
HeaderScrollPane sp;
iconPanel = createCaptchaPanel();

View File

@ -27,6 +27,7 @@ import org.jdownloader.captcha.v2.solver.dbc.DeathByCaptchaSolver;
import org.jdownloader.captcha.v2.solver.endcaptcha.EndCaptchaSolver;
import org.jdownloader.captcha.v2.solver.gui.DialogBasicCaptchaSolver;
import org.jdownloader.captcha.v2.solver.gui.DialogClickCaptchaSolver;
import org.jdownloader.captcha.v2.solver.gui.RecaptchaChooseFrom3x3Solver;
import org.jdownloader.captcha.v2.solver.imagetyperz.ImageTyperzCaptchaSolver;
import org.jdownloader.captcha.v2.solver.jac.JACSolver;
import org.jdownloader.captcha.v2.solver.myjd.CaptchaMyJDSolver;
@ -140,10 +141,13 @@ public class ChallengeResponseController {
if (!Application.isHeadless()) {
addSolver(DialogClickCaptchaSolver.getInstance());
}
if (!Application.isHeadless()) {
addSolver(BrowserSolver.getInstance());
}
if (!Application.isHeadless()) {
addSolver(RecaptchaChooseFrom3x3Solver.getInstance());
}
addSolver(KeyCaptchaJACSolver.getInstance());
if (!Application.isHeadless()) {
addSolver(KeyCaptchaDialogSolver.getInstance());

View File

@ -13,13 +13,14 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import jd.controlling.captcha.SkipException;
import org.appwork.utils.StringUtils;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.solver.browser.AbstractBrowserChallenge;
import org.jdownloader.captcha.v2.solver.jac.SolverException;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import jd.controlling.captcha.SkipException;
public abstract class ChallengeSolver<T> {
protected ThreadPoolExecutor threadPool;
@ -181,6 +182,9 @@ public abstract class ChallengeSolver<T> {
if (c instanceof AbstractBrowserChallenge) {
return false;
}
if (c instanceof Recaptcha2FallbackChallenge) {
return false;
}
if (!getResultType().isAssignableFrom(c.getResultType())) {
return false;
}
@ -190,7 +194,7 @@ public abstract class ChallengeSolver<T> {
return true;
}
protected boolean validateBlackWhite(Challenge<?> c) {
public boolean validateBlackWhite(Challenge<?> c) {
if (getService().getConfig().isBlackWhiteListingEnabled()) {
String host = c.getHost();
ArrayList<String> whitelist = getService().getConfig().getWhitelistEntries();

View File

@ -1,5 +1,16 @@
package org.jdownloader.captcha.v2.challenge.recaptcha.v2;
import java.io.IOException;
import org.appwork.utils.logging2.LogSource;
import org.jdownloader.captcha.blacklist.BlacklistEntry;
import org.jdownloader.captcha.blacklist.BlockAllCrawlerCaptchasEntry;
import org.jdownloader.captcha.blacklist.BlockCrawlerCaptchasByHost;
import org.jdownloader.captcha.blacklist.BlockCrawlerCaptchasByPackage;
import org.jdownloader.captcha.blacklist.CaptchaBlackList;
import org.jdownloader.captcha.v2.ChallengeResponseController;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import jd.controlling.captcha.SkipException;
import jd.controlling.downloadcontroller.SingleDownloadController;
import jd.controlling.linkcollector.LinkCollector;
@ -13,14 +24,6 @@ import jd.plugins.LinkStatus;
import jd.plugins.PluginException;
import jd.plugins.PluginForDecrypt;
import org.appwork.utils.logging2.LogSource;
import org.jdownloader.captcha.blacklist.BlacklistEntry;
import org.jdownloader.captcha.blacklist.BlockAllCrawlerCaptchasEntry;
import org.jdownloader.captcha.blacklist.BlockCrawlerCaptchasByHost;
import org.jdownloader.captcha.blacklist.BlockCrawlerCaptchasByPackage;
import org.jdownloader.captcha.blacklist.CaptchaBlackList;
import org.jdownloader.captcha.v2.ChallengeResponseController;
public class CaptchaHelperCrawlerPluginRecaptchaV2 extends AbstractCaptchaHelperRecaptchaV2<PluginForDecrypt> {
public CaptchaHelperCrawlerPluginRecaptchaV2(PluginForDecrypt plugin, Browser br, String siteKey) {
@ -58,9 +61,27 @@ public class CaptchaHelperCrawlerPluginRecaptchaV2 extends AbstractCaptchaHelper
}
try {
ChallengeResponseController.getInstance().handle(c);
if (c.getResult().size() == 1 && c.getResult().get(0).getChallenge() instanceof Recaptcha2FallbackChallenge) {
Recaptcha2FallbackChallenge challenge = ((Recaptcha2FallbackChallenge) c.getResult().get(0).getChallenge());
try {
challenge.reload(2, c.getResult().get(0).getValue());
ChallengeResponseController.getInstance().handle(challenge);
if (challenge.getToken() != null) {
return challenge.getToken();
// challenge.evaluate()
} else {
throw new DecrypterException(DecrypterException.CAPTCHA);
}
} catch (IOException e) {
throw new DecrypterException(DecrypterException.CAPTCHA);
}
}
if (!c.isSolved()) {
throw new DecrypterException(DecrypterException.CAPTCHA);
}
if (!c.isCaptchaResponseValid()) {
throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT, "Captcha reponse value did not validate!");
}

View File

@ -1,5 +1,24 @@
package org.jdownloader.captcha.v2.challenge.recaptcha.v2;
import java.io.IOException;
import org.appwork.utils.logging2.LogSource;
import org.appwork.utils.swing.dialog.Dialog;
import org.jdownloader.captcha.blacklist.BlacklistEntry;
import org.jdownloader.captcha.blacklist.BlockAllDownloadCaptchasEntry;
import org.jdownloader.captcha.blacklist.BlockDownloadCaptchasByHost;
import org.jdownloader.captcha.blacklist.BlockDownloadCaptchasByLink;
import org.jdownloader.captcha.blacklist.BlockDownloadCaptchasByPackage;
import org.jdownloader.captcha.blacklist.CaptchaBlackList;
import org.jdownloader.captcha.v2.ChallengeResponseController;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import org.jdownloader.gui.helpdialogs.HelpDialog;
import org.jdownloader.gui.translate._GUI;
import org.jdownloader.images.NewTheme;
import org.jdownloader.plugins.CaptchaStepProgress;
import org.jdownloader.settings.staticreferences.CFG_GUI;
import jd.controlling.accountchecker.AccountCheckerThread;
import jd.controlling.captcha.SkipException;
import jd.controlling.downloadcontroller.DownloadWatchDog;
@ -13,22 +32,6 @@ import jd.plugins.LinkStatus;
import jd.plugins.PluginException;
import jd.plugins.PluginForHost;
import org.appwork.utils.logging2.LogSource;
import org.appwork.utils.swing.dialog.Dialog;
import org.jdownloader.captcha.blacklist.BlacklistEntry;
import org.jdownloader.captcha.blacklist.BlockAllDownloadCaptchasEntry;
import org.jdownloader.captcha.blacklist.BlockDownloadCaptchasByHost;
import org.jdownloader.captcha.blacklist.BlockDownloadCaptchasByLink;
import org.jdownloader.captcha.blacklist.BlockDownloadCaptchasByPackage;
import org.jdownloader.captcha.blacklist.CaptchaBlackList;
import org.jdownloader.captcha.v2.ChallengeResponseController;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import org.jdownloader.gui.helpdialogs.HelpDialog;
import org.jdownloader.gui.translate._GUI;
import org.jdownloader.images.NewTheme;
import org.jdownloader.plugins.CaptchaStepProgress;
import org.jdownloader.settings.staticreferences.CFG_GUI;
public class CaptchaHelperHostPluginRecaptchaV2 extends AbstractCaptchaHelperRecaptchaV2<PluginForHost> {
/* Most likely used for login captchas. */
@ -80,6 +83,24 @@ public class CaptchaHelperHostPluginRecaptchaV2 extends AbstractCaptchaHelperRec
throw new CaptchaException(blackListEntry);
}
final SolverJob<String> job = ChallengeResponseController.getInstance().handle(c);
if (c.getResult().size() == 1 && c.getResult().get(0).getChallenge() instanceof Recaptcha2FallbackChallenge) {
Recaptcha2FallbackChallenge challenge = ((Recaptcha2FallbackChallenge) c.getResult().get(0).getChallenge());
try {
challenge.reload(2, c.getResult().get(0).getValue());
ChallengeResponseController.getInstance().handle(challenge);
if (challenge.getToken() != null) {
return challenge.getToken();
// challenge.evaluate()
} else {
throw new PluginException(LinkStatus.ERROR_CAPTCHA);
}
} catch (IOException e) {
throw new PluginException(LinkStatus.ERROR_CAPTCHA);
}
}
if (!c.isSolved()) {
throw new PluginException(LinkStatus.ERROR_CAPTCHA);
}

View File

@ -1,15 +1,52 @@
package org.jdownloader.captcha.v2.challenge.recaptcha.v2;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.HashSet;
import java.util.LinkedHashMap;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import org.appwork.exceptions.WTFException;
import org.appwork.net.protocol.http.HTTPConstants;
import org.appwork.net.protocol.http.HTTPConstants.ResponseCode;
import org.appwork.remoteapi.exceptions.RemoteAPIException;
import org.appwork.txtresource.TranslationFactory;
import org.appwork.uio.InputDialogInterface;
import org.appwork.uio.UIOManager;
import org.appwork.utils.Application;
import org.appwork.utils.IO;
import org.appwork.utils.images.IconIO;
import org.appwork.utils.net.HTTPHeader;
import org.appwork.utils.net.httpserver.requests.GetRequest;
import org.appwork.utils.net.httpserver.responses.FileResponse;
import org.appwork.utils.net.httpserver.responses.HttpResponse;
import org.appwork.utils.swing.dialog.Dialog;
import org.appwork.utils.swing.dialog.DialogCanceledException;
import org.appwork.utils.swing.dialog.DialogClosedException;
import org.appwork.utils.swing.dialog.InputDialog;
import org.jdownloader.captcha.v2.AbstractResponse;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.ChallengeSolver;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.BasicCaptchaChallenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.CaptchaResponse;
import org.jdownloader.captcha.v2.solver.browser.AbstractBrowserChallenge;
import org.jdownloader.captcha.v2.solver.browser.BrowserReference;
import org.jdownloader.captcha.v2.solver.browser.BrowserViewport;
import org.jdownloader.captcha.v2.solver.browser.BrowserWindow;
import org.jdownloader.controlling.UniqueAlltimeID;
import jd.controlling.captcha.SkipRequest;
import jd.http.Browser;
@ -18,27 +55,6 @@ import jd.nutils.encoding.Encoding;
import jd.parser.html.Form;
import jd.plugins.Plugin;
import org.appwork.exceptions.WTFException;
import org.appwork.net.protocol.http.HTTPConstants;
import org.appwork.net.protocol.http.HTTPConstants.ResponseCode;
import org.appwork.remoteapi.exceptions.RemoteAPIException;
import org.appwork.utils.Application;
import org.appwork.utils.IO;
import org.appwork.utils.images.IconIO;
import org.appwork.utils.net.HTTPHeader;
import org.appwork.utils.net.httpserver.requests.GetRequest;
import org.appwork.utils.net.httpserver.responses.HttpResponse;
import org.appwork.utils.swing.dialog.Dialog;
import org.jdownloader.captcha.v2.AbstractResponse;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.ChallengeSolver;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.BasicCaptchaChallenge;
import org.jdownloader.captcha.v2.solver.browser.AbstractBrowserChallenge;
import org.jdownloader.captcha.v2.solver.browser.BrowserReference;
import org.jdownloader.captcha.v2.solver.browser.BrowserViewport;
import org.jdownloader.captcha.v2.solver.browser.BrowserWindow;
import org.jdownloader.captcha.v2.solver.gui.DialogBasicCaptchaSolver;
public class RecaptchaV2Challenge extends AbstractBrowserChallenge {
public static final String RECAPTCHAV2 = "recaptchav2";
@ -47,8 +63,80 @@ public class RecaptchaV2Challenge extends AbstractBrowserChallenge {
private RecaptchaV2Challenge owner;
private Browser iframe;
private String challenge;
private Form responseForm;
private LinkedHashMap<String, String> responseMap;
private String payload;
private String token;
@Override
public Object getAPIStorable() throws Exception {
String mime = FileResponse.getMimeType(getImageFile().getName());
BufferedImage newImage = getAnnotatedImage();
String du = IconIO.toDataUrl(newImage, mime);
return du;
}
public BufferedImage getAnnotatedImage() throws IOException {
BufferedImage img = ImageIO.read(getImageFile());
Font font = new Font("Arial", 0, 12);
String instructions = "Type 145 if image 1,4 and 5 match the question above.";
int explainWidth = img.getGraphics().getFontMetrics(font.deriveFont(Font.BOLD)).stringWidth(getExplain()) + 10;
int solutionWidth = img.getGraphics().getFontMetrics(font).stringWidth(instructions) + 10;
BufferedImage newImage = IconIO.createEmptyImage(Math.max(Math.max(explainWidth, solutionWidth), img.getWidth()), img.getHeight() + 4 * 20);
Graphics2D g = (Graphics2D) newImage.getGraphics();
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g.setColor(Color.BLACK);
g.fillRect(0, 0, newImage.getWidth(), newImage.getHeight());
g.setColor(Color.WHITE);
g.setFont(font.deriveFont(Font.BOLD));
int y = 0;
g.drawString(getExplain(), 5, y += 20);
g.setFont(font);
g.drawString("Instructions:", 5, y += 20);
g.drawString(instructions, 5, y += 20);
y += 15;
int xOffset;
g.drawImage(img, xOffset = (newImage.getWidth() - img.getWidth()) / 2, y, null);
g.setFont(new Font("Arial", 0, 16).deriveFont(Font.BOLD));
int columnWidth = img.getWidth() / 3;
int rowHeight = img.getHeight() / 3;
for (int yslot = 0; yslot < 3; yslot++) {
for (int xslot = 0; xslot < 3; xslot++) {
int xx = (xslot) * columnWidth;
int yy = (yslot) * rowHeight;
int num = xslot + yslot * 3 + 1;
g.setColor(Color.WHITE);
g.fillRect(xx + columnWidth - 20 + xOffset, yy + y, 20, 20);
g.setColor(Color.BLACK);
g.drawString(num + "", xx + columnWidth - 20 + xOffset + 5, yy + y + 15);
}
}
g.dispose();
return newImage;
}
@Override
public AbstractResponse<String> parseAPIAnswer(String json, ChallengeSolver<?> solver) {
json = json.replaceAll("[^\\d]+", "");
StringBuilder sb = new StringBuilder();
HashSet<String> dupe = new HashSet<String>();
for (int i = 0; i < json.length(); i++) {
if (dupe.add(json.charAt(i) + "")) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(Integer.parseInt(json.charAt(i) + "") - 1);
}
}
return new CaptchaResponse(this, solver, sb.toString(), 100);
}
public Recaptcha2FallbackChallenge(RecaptchaV2Challenge challenge) {
super(challenge.getTypeID(), null, null, challenge.getExplain(), challenge.getPlugin(), 0);
@ -59,97 +147,172 @@ public class RecaptchaV2Challenge extends AbstractBrowserChallenge {
iframe = owner.getBr().cloneBrowser();
load();
}
@Override
public UniqueAlltimeID getId() {
return owner.getId();
}
public boolean handle(String challenge, String payload, String message) throws IOException, DialogClosedException, DialogCanceledException {
System.out.println(challenge);
System.out.println("Challenge length: " + challenge.length());
final File file = Application.getResource("rc_" + System.currentTimeMillis() + ".jpg");
FileOutputStream fos = null;
URLConnectionAdapter con = null;
try {
con = iframe.cloneBrowser().openGetConnection("http://www.google.com" + payload);
fos = new FileOutputStream(file);
IO.readStreamToOutputStream(-1, con.getInputStream(), fos, true);
} finally {
try {
fos.close();
} catch (final Throwable ignore) {
}
try {
con.disconnect();
} catch (final Throwable ignore) {
}
}
String dataSiteKey = owner.getSiteKey();
BufferedImage img = ImageIO.read(file);
// iframe.getHeaders().remove("Cookie");
InputDialog d = new InputDialog(0, "Recaptcha", "Please Enter..." + message, null, new ImageIcon(IconIO.getScaledInstance(img, img.getWidth() * 2, img.getHeight() * 2)), null, null) {
@Override
protected JComponent getIconComponent() {
final JComponent ret = super.getIconComponent();
ret.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int x = e.getX() / (ret.getWidth() / 3);
int y = e.getY() / (ret.getHeight() / 3);
int num = x + y * 3;
System.out.println("pressed " + num);
input.setText(input.getText() + (input.getText().length() == 0 ? "" : ",") + (num));
}
});
return ret;
}
};
String response = UIOManager.I().show(InputDialogInterface.class, d).getText();
Form form = iframe.getFormbyKey("c");
String responses = "";
for (String s : response.split(",")) {
responses += "&response=" + s;
}
// iframe.getHeaders().put(new HTTPHeader("Origin", "http://www.google.com"));
iframe.postPageRaw("http://www.google.com/recaptcha/api/fallback?k=" + dataSiteKey, "c=" + Encoding.urlEncode(form.getInputField("c").getValue()) + responses);
System.out.println(iframe);
String token = iframe.getRegex("\"this\\.select\\(\\)\">(.*?)</textarea>").getMatch(0);
if (token != null) {
Dialog.getInstance().showConfirmDialog(0, "Result", "OK: " + response, new ImageIcon(IconIO.getScaledInstance(img, img.getWidth() * 2, img.getHeight() * 2)), null, null);
return true;
}
Dialog.getInstance().showConfirmDialog(0, "Result", "WRONG: " + response, new ImageIcon(IconIO.getScaledInstance(img, img.getWidth() * 2, img.getHeight() * 2)), null, null);
return false;
}
private void load() {
try {
iframe.getPage("http://www.google.com/recaptcha/api2/demo");
String dataSiteKey = owner.getSiteKey();
iframe.getHeaders().put(new HTTPHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"));
iframe.getHeaders().put(new HTTPHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
HTTPHeader cookie;
iframe.getPage("http://www.google.com/recaptcha/api/fallback?k=" + dataSiteKey);
if (round == 1) {
iframe.getPage("http://www.google.com/recaptcha/api2/demo");
boolean first = true;
while (true) {
String payload = Encoding.htmlDecode(iframe.getRegex("<img src=\"(/recaptcha/api2/payload[^\"]+)").getMatch(0));
iframe.getHeaders().put(new HTTPHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"));
iframe.getHeaders().put(new HTTPHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
iframe.getHeaders().put(new HTTPHeader("Accept-Language", TranslationFactory.getDesiredLanguage()));
String challenge = iframe.getRegex("name=\"c\"\\s+value=\\s*\"([^\"]+)").getMatch(0);
System.out.println(challenge);
System.out.println("Challenge length: " + challenge.length());
final File file = Application.getResource("rc_" + System.currentTimeMillis() + ".jpg");
FileOutputStream fos = null;
URLConnectionAdapter con = null;
try {
con = iframe.cloneBrowser().openGetConnection("http://www.google.com" + payload);
fos = new FileOutputStream(file);
IO.readStreamToOutputStream(-1, con.getInputStream(), fos, true);
} finally {
try {
fos.close();
} catch (final Throwable ignore) {
}
try {
con.disconnect();
} catch (final Throwable ignore) {
}
}
BufferedImage img = ImageIO.read(file);
// iframe.getHeaders().remove("Cookie");
String response = Dialog.getInstance().showInputDialog(0, "Recaptcha", first ? "Please Enter..." : "Wrong Captcha Input. Try again...", null, new ImageIcon(IconIO.getScaledInstance(img, img.getWidth() * 2, img.getHeight() * 2)), null, null);
Form form = iframe.getFormByInputFieldKeyValue("reason", "r");
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
map.put("c", Encoding.urlEncode(form.getInputField("c").getValue()));
map.put("response", Encoding.urlEncode(response));
// iframe.getHeaders().put(new HTTPHeader("Origin", "http://www.google.com"));
iframe.postPage("http://www.google.com/recaptcha/api/fallback?k=" + dataSiteKey, map);
System.out.println(iframe);
String token = iframe.getRegex("\"this\\.select\\(\\)\">(.*?)</textarea>").getMatch(0);
if (token != null) {
Dialog.getInstance().showConfirmDialog(0, "Result", "OK: " + response, new ImageIcon(IconIO.getScaledInstance(img, img.getWidth() * 2, img.getHeight() * 2)), null, null);
break;
}
Dialog.getInstance().showConfirmDialog(0, "Result", "WRONG: " + response, new ImageIcon(IconIO.getScaledInstance(img, img.getWidth() * 2, img.getHeight() * 2)), null, null);
first = false;
iframe.getPage("http://www.google.com/recaptcha/api/fallback?k=" + dataSiteKey);
}
System.out.println(1);
// while (true) {
payload = Encoding.htmlDecode(iframe.getRegex("\"(/recaptcha/api2/payload[^\"]+)").getMatch(0));
String message = Encoding.htmlDecode(iframe.getRegex("<label .*?class=\"fbc-imageselect-message-text\">(.*?)</label>").getMatch(0));
if (message == null) {
message = Encoding.htmlDecode(iframe.getRegex("<div .*?class=\"fbc-imageselect-message-error\">(.*?)</div>").getMatch(0));
}
if (message != null) {
setExplain("Round #" + round + "/2: " + message.replaceAll("<.*?>", "").replaceAll("\\s+", " "));
}
challenge = iframe.getRegex("name=\"c\"\\s+value=\\s*\"([^\"]+)").getMatch(0);
setImageFile(Application.getResource("rc_" + System.currentTimeMillis() + ".jpg"));
FileOutputStream fos = null;
URLConnectionAdapter con = null;
try {
con = iframe.cloneBrowser().openGetConnection("http://www.google.com" + payload);
fos = new FileOutputStream(getImageFile());
IO.readStreamToOutputStream(-1, con.getInputStream(), fos, true);
} finally {
try {
fos.close();
} catch (final Throwable ignore) {
}
try {
con.disconnect();
} catch (final Throwable ignore) {
}
}
// }
} catch (Throwable e) {
throw new WTFException(e);
}
}
public String getChallenge() {
return challenge;
}
@Override
public boolean validateResponse(AbstractResponse<String> response) {
try {
responseMap.put("response", Encoding.urlEncode(response.getValue()));
// iframe.getHeaders().put(new HTTPHeader("Origin", "http://www.google.com"));
iframe.postPage("http://www.google.com/recaptcha/api/fallback?k=" + owner.getSiteKey(), responseMap);
System.out.println(iframe.toString());
String token = iframe.getRegex("\"this\\.select\\(\\)\">(.*?)</textarea>").getMatch(0);
if (token != null) {
return true;
String dataSiteKey = owner.getSiteKey();
Form form = iframe.getFormbyKey("c");
String responses = "";
for (String s : response.getValue().split(",")) {
responses += "&response=" + s;
}
// iframe.getHeaders().put(new HTTPHeader("Origin", "http://www.google.com"));
iframe.postPageRaw("http://www.google.com/recaptcha/api/fallback?k=" + dataSiteKey, "c=" + Encoding.urlEncode(form.getInputField("c").getValue()) + responses);
System.out.println(iframe);
token = iframe.getRegex("\"this\\.select\\(\\)\">(.*?)</textarea>").getMatch(0);
} catch (Throwable e) {
throw new WTFException(e);
}
return false;
// always return true. recaptchav2 fallback requires several captchas. we need to accept all answers. validation will be done
// later
return true;
}
public String getToken() {
return token;
}
@Override
public boolean canBeSkippedBy(SkipRequest skipRequest, ChallengeSolver<?> solver, Challenge<?> challenge) {
return owner.canBeSkippedBy(skipRequest, solver, challenge);
}
}
public static final boolean FALLBACK_ENABLED = false;
private int round = 1;
public void reload(int i, String lastResponse) throws IOException {
round = i;
load();
}
}
private String siteKey;
private BasicCaptchaChallenge basicChallenge;
@ -235,9 +398,7 @@ public class RecaptchaV2Challenge extends AbstractBrowserChallenge {
@Override
public boolean validateResponse(AbstractResponse<String> response) {
if (response.getSolver() instanceof DialogBasicCaptchaSolver) {
return basicChallenge.validateResponse(response);
}
return true;
}

View File

@ -1,9 +1,5 @@
package org.jdownloader.captcha.v2.solver.browser;
import jd.controlling.captcha.SkipException;
import jd.controlling.captcha.SkipRequest;
import jd.gui.swing.jdgui.JDGui;
import org.jdownloader.captcha.v2.AbstractResponse;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.ChallengeResponseController;
@ -15,6 +11,10 @@ import org.jdownloader.captcha.v2.solverjob.ResponseList;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import org.jdownloader.settings.staticreferences.CFG_SILENTMODE;
import jd.controlling.captcha.SkipException;
import jd.controlling.captcha.SkipRequest;
import jd.gui.swing.jdgui.JDGui;
public abstract class AbstractBrowserSolver extends ChallengeSolver<String> {
protected BrowserCaptchaSolverConfig config;
@ -73,8 +73,11 @@ public abstract class AbstractBrowserSolver extends ChallengeSolver<String> {
@Override
public void solve(final SolverJob<String> job) throws InterruptedException, SkipException {
System.out.println("Browser solver start");
synchronized (DialogBasicCaptchaSolver.getInstance()) {
if (job.isDone()) {
return;
}
if (job.getChallenge() instanceof AbstractBrowserChallenge) {
ChallengeSolverJobListener jacListener = null;

View File

@ -42,15 +42,6 @@ import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import jd.gui.swing.dialog.AbstractImageCaptchaDialog;
import jd.gui.swing.dialog.DialogType;
import jd.gui.swing.jdgui.JDGui;
import jd.gui.swing.jdgui.views.settings.components.Checkbox;
import jd.plugins.Plugin;
import jd.plugins.PluginForDecrypt;
import jd.plugins.PluginForHost;
import net.miginfocom.swing.MigLayout;
import org.appwork.storage.config.JsonConfig;
import org.appwork.swing.MigPanel;
import org.appwork.swing.components.ExtButton;
@ -85,6 +76,15 @@ import org.jdownloader.settings.staticreferences.CFG_GUI;
import org.jdownloader.statistics.StatsManager;
import org.jdownloader.updatev2.gui.LAFOptions;
import jd.gui.swing.dialog.AbstractImageCaptchaDialog;
import jd.gui.swing.dialog.DialogType;
import jd.gui.swing.jdgui.JDGui;
import jd.gui.swing.jdgui.views.settings.components.Checkbox;
import jd.plugins.Plugin;
import jd.plugins.PluginForDecrypt;
import jd.plugins.PluginForHost;
import net.miginfocom.swing.MigLayout;
/**
* This Dialog is used to display a Inputdialog for the captchas
*/
@ -706,7 +706,7 @@ public class BrowserCaptchaDialog extends AbstractDialog<String> {
headerPanel.add(header);
}
config = JsonConfig.create(Application.getResource("cfg/CaptchaDialogDimensions_" + Hash.getMD5(getHost())), LocationStorage.class);
config = JsonConfig.create(Application.getResource("cfg/CaptchaDialogSize/" + Hash.getMD5(getHost() + "." + challenge.getClass().getSimpleName() + "." + challenge.getTypeID())), LocationStorage.class);
HeaderScrollPane sp;

View File

@ -24,7 +24,9 @@ import org.appwork.utils.net.httpserver.responses.HttpResponse;
import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.processes.ProcessBuilderFactory;
import org.jdownloader.api.DeprecatedAPIHttpServerController;
import org.jdownloader.captcha.v2.ChallengeResponseController;
import org.jdownloader.captcha.v2.solver.service.BrowserSolverService;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import org.jdownloader.controlling.UniqueAlltimeID;
public abstract class BrowserReference implements HttpRequestHandler {
@ -38,6 +40,7 @@ public abstract class BrowserReference implements HttpRequestHandler {
private BrowserViewport viewport;
private final HashMap<String, URL> resourceIds;
private final HashMap<String, String> types;
{
resourceIds = new HashMap<String, URL>();
resourceIds.put("style.css", BrowserReference.class.getResource("html/style.css"));
@ -111,6 +114,7 @@ public abstract class BrowserReference implements HttpRequestHandler {
// }
// }
}
if (browserCmd == null || browserCmd.length == 0) {
CrossSystem.openURL(url);
} else {
@ -204,6 +208,11 @@ public abstract class BrowserReference implements HttpRequestHandler {
}
return true;
} else if ("canClose".equals(pDo)) {
SolverJob<?> job = ChallengeResponseController.getInstance().getJobById(challenge.getId().getID());
if (challenge.isSolved() || job == null || job.isDone()) {
response.getOutputStream(true).write("true".getBytes("UTF-8"));
return true;
}
response.getOutputStream(true).write("false".getBytes("UTF-8"));
} else if (pDo == null) {
response.getOutputStream(true).write(challenge.getHTML().getBytes("UTF-8"));

View File

@ -1,17 +1,14 @@
package org.jdownloader.captcha.v2.solver.cheapcaptcha;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.LinkedHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import jd.http.Browser;
import jd.http.Request;
import jd.http.URLConnectionAdapter;
import jd.http.requests.FormData;
import jd.http.requests.PostFormDataRequest;
import jd.nutils.encoding.Encoding;
import javax.imageio.ImageIO;
import org.appwork.exceptions.WTFException;
import org.appwork.storage.config.JsonConfig;
@ -23,6 +20,8 @@ import org.jdownloader.captcha.v2.AbstractResponse;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.ChallengeResponseValidation;
import org.jdownloader.captcha.v2.SolverStatus;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.BasicCaptchaChallenge;
import org.jdownloader.captcha.v2.solver.CESChallengeSolver;
import org.jdownloader.captcha.v2.solver.CESSolverJob;
@ -34,6 +33,13 @@ import org.jdownloader.images.NewTheme;
import org.jdownloader.logging.LogController;
import org.jdownloader.settings.staticreferences.CFG_CHEAP_CAPTCHA;
import jd.http.Browser;
import jd.http.Request;
import jd.http.URLConnectionAdapter;
import jd.http.requests.FormData;
import jd.http.requests.PostFormDataRequest;
import jd.nutils.encoding.Encoding;
public class CheapCaptchaSolver extends CESChallengeSolver<String> implements ChallengeResponseValidation {
private CheapCaptchaConfigInterface config;
@ -67,12 +73,24 @@ public class CheapCaptchaSolver extends CESChallengeSolver<String> implements Ch
@Override
public boolean canHandle(Challenge<?> c) {
if (!validateBlackWhite(c)) {
return false;
}
if (c instanceof RecaptchaV2Challenge || c instanceof Recaptcha2FallbackChallenge) {
// does not accept this annoted image yet
return false;
}
return c instanceof BasicCaptchaChallenge && super.canHandle(c);
}
protected void solveCES(CESSolverJob<String> job) throws InterruptedException, SolverException {
Challenge<?> challenge = job.getChallenge();
if (challenge instanceof RecaptchaV2Challenge) {
challenge = ((RecaptchaV2Challenge) challenge).createBasicCaptchaChallenge();
solveBasicCaptchaChallenge(job, (BasicCaptchaChallenge) job.getChallenge());
}
solveBasicCaptchaChallenge(job, (BasicCaptchaChallenge) challenge);
}
@ -92,7 +110,17 @@ public class CheapCaptchaSolver extends CESChallengeSolver<String> implements Ch
r.addFormData(new FormData("username", (config.getUserName())));
r.addFormData(new FormData("password", (config.getPassword())));
r.addFormData(new FormData("captchafile", "ByteData.captcha", IO.readFile(challenge.getImageFile())));
if (challenge instanceof Recaptcha2FallbackChallenge) {
BufferedImage img = ((Recaptcha2FallbackChallenge) challenge).getAnnotatedImage();
ByteArrayOutputStream bao;
// Dialog.getInstance().showConfirmDialog(0, "", "", new ImageIcon(img), null, null);
ImageIO.write(img, "jpeg", bao = new ByteArrayOutputStream());
r.addFormData(new FormData("captchafile", "ByteData.captcha", bao.toByteArray()));
} else {
r.addFormData(new FormData("captchafile", "ByteData.captcha", IO.readFile(challenge.getImageFile())));
}
URLConnectionAdapter conn = br.openRequestConnection(r);
// 303 See Other if your CAPTCHA was successfully uploaded: Location HTTP header will point you to the uploaded CAPTCHA status

View File

@ -1,14 +1,13 @@
package org.jdownloader.captcha.v2.solver.endcaptcha;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import jd.http.Browser;
import jd.http.URLConnectionAdapter;
import jd.http.requests.FormData;
import jd.http.requests.PostFormDataRequest;
import javax.imageio.ImageIO;
import org.appwork.exceptions.WTFException;
import org.appwork.storage.config.JsonConfig;
@ -19,6 +18,8 @@ import org.jdownloader.captcha.v2.AbstractResponse;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.ChallengeResponseValidation;
import org.jdownloader.captcha.v2.SolverStatus;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.BasicCaptchaChallenge;
import org.jdownloader.captcha.v2.solver.CESChallengeSolver;
import org.jdownloader.captcha.v2.solver.CESSolverJob;
@ -30,6 +31,11 @@ import org.jdownloader.images.NewTheme;
import org.jdownloader.logging.LogController;
import org.jdownloader.settings.staticreferences.CFG_END_CAPTCHA;
import jd.http.Browser;
import jd.http.URLConnectionAdapter;
import jd.http.requests.FormData;
import jd.http.requests.PostFormDataRequest;
public class EndCaptchaSolver extends CESChallengeSolver<String> implements ChallengeResponseValidation {
private EndCaptchaConfigInterface config;
@ -63,12 +69,24 @@ public class EndCaptchaSolver extends CESChallengeSolver<String> implements Chal
@Override
public boolean canHandle(Challenge<?> c) {
if (!validateBlackWhite(c)) {
return false;
}
if (c instanceof RecaptchaV2Challenge || c instanceof Recaptcha2FallbackChallenge) {
// endcaptcha does not support them
return false;
}
return c instanceof BasicCaptchaChallenge && super.canHandle(c);
}
protected void solveCES(CESSolverJob<String> job) throws InterruptedException, SolverException {
Challenge<?> challenge = job.getChallenge();
if (challenge instanceof RecaptchaV2Challenge) {
challenge = ((RecaptchaV2Challenge) challenge).createBasicCaptchaChallenge();
solveBasicCaptchaChallenge(job, (BasicCaptchaChallenge) job.getChallenge());
}
solveBasicCaptchaChallenge(job, (BasicCaptchaChallenge) challenge);
}
@ -88,7 +106,18 @@ public class EndCaptchaSolver extends CESChallengeSolver<String> implements Chal
r.addFormData(new FormData("username", (config.getUserName())));
r.addFormData(new FormData("password", (config.getPassword())));
r.addFormData(new FormData("image", "ByteData.captcha", IO.readFile(challenge.getImageFile())));
if (challenge instanceof Recaptcha2FallbackChallenge) {
BufferedImage img = ((Recaptcha2FallbackChallenge) challenge).getAnnotatedImage();
ByteArrayOutputStream bao;
// Dialog.getInstance().showConfirmDialog(0, "", "", new ImageIcon(img), null, null);
ImageIO.write(img, "jpeg", bao = new ByteArrayOutputStream());
r.addFormData(new FormData("image", "ByteData.captcha", bao.toByteArray()));
} else {
r.addFormData(new FormData("image", "ByteData.captcha", IO.readFile(challenge.getImageFile())));
}
URLConnectionAdapter conn = br.openRequestConnection(r);
br.loadConnection(conn);

View File

@ -1,14 +1,9 @@
package org.jdownloader.captcha.v2.solver.gui;
import jd.controlling.captcha.BasicCaptchaDialogHandler;
import jd.controlling.captcha.CaptchaSettings;
import jd.controlling.captcha.SkipException;
import org.appwork.storage.config.JsonConfig;
import org.jdownloader.captcha.v2.AbstractResponse;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.ChallengeSolver;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.BasicCaptchaChallenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.CaptchaResponse;
import org.jdownloader.captcha.v2.solver.jac.JACSolver;
@ -17,6 +12,10 @@ import org.jdownloader.captcha.v2.solverjob.ResponseList;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import org.jdownloader.settings.advanced.AdvancedConfigManager;
import jd.controlling.captcha.BasicCaptchaDialogHandler;
import jd.controlling.captcha.CaptchaSettings;
import jd.controlling.captcha.SkipException;
public class DialogBasicCaptchaSolver extends AbstractDialogSolver<String> {
private CaptchaSettings config;
@ -40,13 +39,12 @@ public class DialogBasicCaptchaSolver extends AbstractDialogSolver<String> {
if (job.getChallenge() instanceof BasicCaptchaChallenge) {
super.enqueue(job);
}
if (RecaptchaV2Challenge.FALLBACK_ENABLED && job.getChallenge() instanceof RecaptchaV2Challenge) {
super.enqueue(job);
}
}
@Override
public boolean canHandle(Challenge<?> c) {
return super.canHandle(c);
}
@ -60,19 +58,15 @@ public class DialogBasicCaptchaSolver extends AbstractDialogSolver<String> {
@Override
public void solve(final SolverJob<String> job) throws InterruptedException, SkipException {
synchronized (this) {
if (job.isDone()) {
return;
}
if (job.getChallenge() instanceof BasicCaptchaChallenge) {
BasicCaptchaChallenge captchaChallenge = (BasicCaptchaChallenge) job.getChallenge();
String result = solveBasicCaptchaChallenge(job, captchaChallenge);
if (result != null) {
job.addAnswer(new CaptchaResponse(captchaChallenge, this, result, 100));
}
} else if (RecaptchaV2Challenge.FALLBACK_ENABLED && job.getChallenge() instanceof RecaptchaV2Challenge) {
RecaptchaV2Challenge captchaChallenge = (RecaptchaV2Challenge) job.getChallenge();
String result = solveBasicCaptchaChallenge(job, captchaChallenge.createBasicCaptchaChallenge());
if (result != null) {
job.addAnswer(new CaptchaResponse(captchaChallenge, this, result, 100));
}
}
}

View File

@ -1,9 +1,5 @@
package org.jdownloader.captcha.v2.solver.gui;
import jd.controlling.captcha.CaptchaSettings;
import jd.controlling.captcha.ClickCaptchaDialogHandler;
import jd.controlling.captcha.SkipException;
import org.appwork.storage.config.JsonConfig;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.challenge.clickcaptcha.ClickCaptchaChallenge;
@ -14,6 +10,10 @@ import org.jdownloader.captcha.v2.solver.solver9kw.Captcha9kwSettings;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import org.jdownloader.settings.advanced.AdvancedConfigManager;
import jd.controlling.captcha.CaptchaSettings;
import jd.controlling.captcha.ClickCaptchaDialogHandler;
import jd.controlling.captcha.SkipException;
public class DialogClickCaptchaSolver extends AbstractDialogSolver<ClickedPoint> {
private CaptchaSettings config;
@ -70,6 +70,9 @@ public class DialogClickCaptchaSolver extends AbstractDialogSolver<ClickedPoint>
@Override
public void solve(SolverJob<ClickedPoint> solverJob) throws InterruptedException, SkipException {
synchronized (DialogBasicCaptchaSolver.getInstance()) {
if (solverJob.isDone()) {
return;
}
if (solverJob.getChallenge() instanceof ClickCaptchaChallenge) {
solverJob.getLogger().info("Waiting for JAC (Click/Mouse)");
solverJob.waitFor(9, JACSolver.getInstance());

View File

@ -0,0 +1,144 @@
// jDownloader - Downloadmanager
// Copyright (C) 2008 JD-Team support@jdownloader.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package org.jdownloader.captcha.v2.solver.gui;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.util.HashSet;
import javax.swing.JComponent;
import org.appwork.swing.components.CheckBoxIcon;
import org.appwork.swing.components.ExtTextField;
import org.appwork.utils.swing.dialog.Dialog;
import org.jdownloader.DomainInfo;
import org.jdownloader.gui.translate._GUI;
import jd.gui.swing.dialog.AbstractImageCaptchaDialog;
import jd.gui.swing.dialog.DialogType;
/**
* This Dialog is used to display a Inputdialog for the captchas
*/
public class RecaptchaChooseFrom3x3Dialog extends AbstractImageCaptchaDialog {
private HashSet<Integer> selected;
public RecaptchaChooseFrom3x3Dialog(final int flag, DialogType type, final DomainInfo DomainInfo, final Image image, final String explain) {
this(flag, type, DomainInfo, new Image[] { image }, explain);
}
public RecaptchaChooseFrom3x3Dialog(int flag, DialogType type, DomainInfo domainInfo, Image[] images, String explain) {
super(flag | Dialog.STYLE_HIDE_ICON, _GUI._.gui_captchaWindow_askForInput(domainInfo.getTld()), type, domainInfo, explain, images);
}
protected void paintIconComponent(Graphics g, int width, int height, int xOffset, int yOffset, BufferedImage scaled) {
if (bounds == null) {
return;
}
int columnWidth = bounds.width / 3;
int rowHeight = bounds.height / 3;
for (int yslot = 0; yslot < 3; yslot++) {
for (int xslot = 0; xslot < 3; xslot++) {
int x = (1 + xslot) * columnWidth;
int y = (1 + yslot) * rowHeight;
int num = xslot + yslot * 3;
// Color color = Color.RED;
if (selected.contains(num)) {
CheckBoxIcon.TRUE.paintIcon(iconPanel, g, xOffset + x - CheckBoxIcon.TRUE.getIconWidth() - 5, yOffset + y - CheckBoxIcon.TRUE.getIconHeight() - 5);
g.setColor(Color.GREEN);
((Graphics2D) g).setStroke(new BasicStroke(2));
g.drawRect(bounds.x + xslot * columnWidth + 1, bounds.y + yslot * rowHeight + 1, columnWidth - 2, rowHeight - 2);
} else {
CheckBoxIcon.FALSE.paintIcon(iconPanel, g, xOffset + x - CheckBoxIcon.TRUE.getIconWidth() - 5, yOffset + y - CheckBoxIcon.TRUE.getIconHeight() - 5);
}
}
}
}
@Override
public JComponent layoutDialogContent() {
JComponent ret = super.layoutDialogContent();
this.selected = new HashSet<Integer>();
iconPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
iconPanel.setToolTipText(getHelpText());
iconPanel.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent e) {
int x = (e.getX() - bounds.x) / (bounds.width / 3);
int y = (e.getY() - bounds.y) / (bounds.height / 3);
int num = x + y * 3;
System.out.println("pressed " + num);
if (!selected.remove(num)) {
selected.add(num);
}
iconPanel.repaint();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseClicked(MouseEvent e) {
}
});
return ret;
}
@Override
protected JComponent createInputComponent() {
ExtTextField ret = new ExtTextField();
ret.setText(getHelpText());
ret.setEditable(false);
return ret;
}
public String getResult() {
StringBuilder sb = new StringBuilder();
for (Integer s : selected) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(s);
}
return sb.toString();
}
}

View File

@ -0,0 +1,185 @@
package org.jdownloader.captcha.v2.solver.gui;
import java.awt.Image;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.image.BufferedImage;
import java.net.MalformedURLException;
import org.appwork.exceptions.WTFException;
import org.appwork.uio.CloseReason;
import org.appwork.utils.images.IconIO;
import org.appwork.utils.swing.EDTHelper;
import org.appwork.utils.swing.EDTRunner;
import org.appwork.utils.swing.dialog.Dialog;
import org.appwork.utils.swing.dialog.DialogCanceledException;
import org.appwork.utils.swing.dialog.DialogClosedException;
import org.appwork.utils.swing.dialog.InternDialog;
import org.appwork.utils.swing.windowmanager.WindowManager;
import org.appwork.utils.swing.windowmanager.WindowManager.FrameState;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import jd.controlling.captcha.ChallengeDialogHandler;
import jd.controlling.captcha.HideAllCaptchasException;
import jd.controlling.captcha.HideCaptchasByHostException;
import jd.controlling.captcha.HideCaptchasByPackageException;
import jd.controlling.captcha.RefreshException;
import jd.controlling.captcha.StopCurrentActionException;
import jd.gui.swing.dialog.DialogType;
public class RecaptchaChooseFrom3x3DialogHandler extends ChallengeDialogHandler<Recaptcha2FallbackChallenge> {
private String result;
private RecaptchaChooseFrom3x3Dialog dialog;
public String getResult() {
return result;
}
public RecaptchaChooseFrom3x3DialogHandler(Recaptcha2FallbackChallenge captchaChallenge) {
super(captchaChallenge.getDomainInfo(), captchaChallenge);
}
@Override
protected void showDialog(DialogType dialogType, int flag) throws DialogClosedException, DialogCanceledException, HideCaptchasByHostException, HideCaptchasByPackageException, StopCurrentActionException, HideAllCaptchasException, RefreshException {
Image[] images = null;
try {
BufferedImage img = IconIO.getImage(captchaChallenge.getImageFile().toURI().toURL(), false);
if (img != null) {
images = new Image[] { img };
}
RecaptchaChooseFrom3x3Dialog d = new RecaptchaChooseFrom3x3Dialog(flag, dialogType, getHost(), images, captchaChallenge.getExplain());
d.setPlugin(captchaChallenge.getPlugin());
d.setTimeout(getTimeoutInMS());
if (getTimeoutInMS() == captchaChallenge.getTimeout()) {
// no reason to let the user stop the countdown if the result cannot be used after the countdown anyway
d.setCountdownPausable(false);
}
dialog = d;
// don't put this in the edt
showDialog(dialog);
new EDTHelper<Object>() {
@Override
public Object edtRun() {
dialog.getDialog().addWindowListener(new WindowListener() {
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
synchronized (RecaptchaChooseFrom3x3DialogHandler.this) {
boolean v = dialog.getDialog().isVisible();
RecaptchaChooseFrom3x3DialogHandler.this.notifyAll();
}
}
@Override
public void windowClosed(WindowEvent e) {
synchronized (RecaptchaChooseFrom3x3DialogHandler.this) {
boolean v = dialog.getDialog().isVisible();
RecaptchaChooseFrom3x3DialogHandler.this.notifyAll();
}
}
@Override
public void windowActivated(WindowEvent e) {
}
});
return null;
}
}.waitForEDT();
try {
while (dialog.getDialog().isVisible()) {
synchronized (this) {
this.wait();
}
}
} catch (InterruptedException e) {
throw new DialogClosedException(Dialog.RETURN_INTERRUPT);
} finally {
try {
if (!dialog.isDisposed()) {
dialog.dispose();
}
} catch (Exception e) {
}
}
result = dialog.getResult();
try {
if (dialog.getCloseReason() != CloseReason.OK) {
if (dialog.isHideCaptchasForHost()) {
throw new HideCaptchasByHostException();
}
if (dialog.isHideCaptchasForPackage()) {
throw new HideCaptchasByPackageException();
}
if (dialog.isStopDownloads()) {
throw new StopCurrentActionException();
}
if (dialog.isHideAllCaptchas()) {
throw new HideAllCaptchasException();
}
if (dialog.isStopCrawling()) {
throw new StopCurrentActionException();
}
if (dialog.isStopShowingCrawlerCaptchas()) {
throw new HideAllCaptchasException();
}
if (dialog.isRefresh()) {
throw new RefreshException();
}
dialog.throwCloseExceptions();
throw new DialogClosedException(Dialog.RETURN_CLOSED);
}
} catch (IllegalStateException e) {
// Captcha has been solved externally
}
} catch (MalformedURLException e) {
throw new WTFException(e);
}
}
public void requestFocus() {
new EDTRunner() {
@Override
protected void runInEDT() {
RecaptchaChooseFrom3x3Dialog d = dialog;
if (d != null) {
InternDialog<Object> win = d.getDialog();
if (win != null) {
WindowManager.getInstance().setZState(win, FrameState.TO_FRONT_FOCUSED);
}
}
}
};
}
}

View File

@ -0,0 +1,96 @@
package org.jdownloader.captcha.v2.solver.gui;
import org.appwork.utils.Application;
import org.jdownloader.captcha.v2.AbstractResponse;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.solver.browser.BrowserSolver;
import org.jdownloader.captcha.v2.solver.jac.SolverException;
import org.jdownloader.captcha.v2.solverjob.SolverJob;
import jd.controlling.captcha.SkipException;
public class RecaptchaChooseFrom3x3Solver extends AbstractDialogSolver<String> {
private static final RecaptchaChooseFrom3x3Solver INSTANCE = new RecaptchaChooseFrom3x3Solver();
public static RecaptchaChooseFrom3x3Solver getInstance() {
return INSTANCE;
}
private RecaptchaChooseFrom3x3DialogHandler handler;
private RecaptchaChooseFrom3x3Solver() {
super(1);
// AdvancedConfigManager.getInstance().register(BrowserSolverService.getInstance().getConfig());
}
@Override
public boolean canHandle(Challenge<?> c) {
if (!validateBlackWhite(c)) {
return false;
}
if (isBrowserSolverEnabled(c)) {
return false;
}
if (c instanceof RecaptchaV2Challenge || c instanceof Recaptcha2FallbackChallenge) {
return true;
}
return false;
}
private boolean isBrowserSolverEnabled(Challenge<?> c) {
if (!BrowserSolver.getInstance().isEnabled()) {
return false;
}
if (Application.isHeadless()) {
return false;
}
if (!BrowserSolver.getInstance().validateBlackWhite(c)) {
return false;
}
return true;
}
@Override
public void solve(SolverJob<String> solverJob) throws InterruptedException, SolverException, SkipException {
synchronized (DialogBasicCaptchaSolver.getInstance()) {
if (solverJob.isDone()) {
return;
}
if (isBrowserSolverEnabled(solverJob.getChallenge())) {
return;
}
if (solverJob.getChallenge() instanceof RecaptchaV2Challenge) {
checkSilentMode(solverJob);
Recaptcha2FallbackChallenge captchaChallenge = (Recaptcha2FallbackChallenge) ((RecaptchaV2Challenge) solverJob.getChallenge()).createBasicCaptchaChallenge();
checkInterruption();
handler = new RecaptchaChooseFrom3x3DialogHandler(captchaChallenge);
handler.run();
if (handler.getResult() != null) {
solverJob.addAnswer(new AbstractResponse<String>(captchaChallenge, this, 100, handler.getResult()));
}
} else if (solverJob.getChallenge() instanceof Recaptcha2FallbackChallenge) {
checkSilentMode(solverJob);
Recaptcha2FallbackChallenge captchaChallenge = (Recaptcha2FallbackChallenge) solverJob.getChallenge();
checkInterruption();
handler = new RecaptchaChooseFrom3x3DialogHandler(captchaChallenge);
handler.run();
if (handler.getResult() != null) {
solverJob.addAnswer(new AbstractResponse<String>(captchaChallenge, this, 100, handler.getResult()));
}
}
}
}
}

View File

@ -1,14 +1,13 @@
package org.jdownloader.captcha.v2.solver.imagetyperz;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import jd.http.Browser;
import jd.http.URLConnectionAdapter;
import jd.http.requests.FormData;
import jd.http.requests.PostFormDataRequest;
import javax.imageio.ImageIO;
import org.appwork.exceptions.WTFException;
import org.appwork.storage.config.JsonConfig;
@ -19,6 +18,8 @@ import org.jdownloader.captcha.v2.AbstractResponse;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.ChallengeResponseValidation;
import org.jdownloader.captcha.v2.SolverStatus;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.BasicCaptchaChallenge;
import org.jdownloader.captcha.v2.solver.CESChallengeSolver;
import org.jdownloader.captcha.v2.solver.CESSolverJob;
@ -27,6 +28,11 @@ import org.jdownloader.captcha.v2.solverjob.SolverJob;
import org.jdownloader.logging.LogController;
import org.jdownloader.settings.staticreferences.CFG_IMAGE_TYPERZ;
import jd.http.Browser;
import jd.http.URLConnectionAdapter;
import jd.http.requests.FormData;
import jd.http.requests.PostFormDataRequest;
public class ImageTyperzCaptchaSolver extends CESChallengeSolver<String> implements ChallengeResponseValidation {
private ImageTyperzConfigInterface config;
@ -60,13 +66,22 @@ public class ImageTyperzCaptchaSolver extends CESChallengeSolver<String> impleme
@Override
public boolean canHandle(Challenge<?> c) {
if (c instanceof RecaptchaV2Challenge || c instanceof Recaptcha2FallbackChallenge) {
// does not accept this annoted image yet
return true;
}
return c instanceof BasicCaptchaChallenge && super.canHandle(c);
}
protected void solveCES(CESSolverJob<String> job) throws InterruptedException, SolverException {
solveBasicCaptchaChallenge(job, (BasicCaptchaChallenge) job.getChallenge());
Challenge<?> challenge = job.getChallenge();
if (challenge instanceof RecaptchaV2Challenge) {
challenge = ((RecaptchaV2Challenge) challenge).createBasicCaptchaChallenge();
}
solveBasicCaptchaChallenge(job, (BasicCaptchaChallenge) challenge);
}
private void solveBasicCaptchaChallenge(CESSolverJob<String> job, BasicCaptchaChallenge challenge) throws InterruptedException {
@ -101,13 +116,28 @@ public class ImageTyperzCaptchaSolver extends CESChallengeSolver<String> impleme
// or vector of bytes here:
job.setStatus(SolverStatus.SOLVING);
long startTime = System.currentTimeMillis();
PostFormDataRequest r = new PostFormDataRequest("http://captchatypers.com/Forms/UploadFileAndGetTextNew.ashx");
PostFormDataRequest r = null;
if (challenge instanceof Recaptcha2FallbackChallenge) {
r = new PostFormDataRequest("http://captchatypers.com/Forms/UploadGoogleCaptcha.ashx");
} else {
r = new PostFormDataRequest("http://captchatypers.com/Forms/UploadFileAndGetTextNew.ashx");
}
r.addFormData(new FormData("action", "UPLOADCAPTCHA"));
r.addFormData(new FormData("username", (config.getUserName())));
r.addFormData(new FormData("password", (config.getPassword())));
r.addFormData(new FormData("chkCase", "0"));
r.addFormData(new FormData("file", org.appwork.utils.encoding.Base64.encodeToString(IO.readFile(challenge.getImageFile()), false)));
if (challenge instanceof Recaptcha2FallbackChallenge) {
BufferedImage img = ((Recaptcha2FallbackChallenge) challenge).getAnnotatedImage();
ByteArrayOutputStream bao;
// Dialog.getInstance().showConfirmDialog(0, "", "", new ImageIcon(img), null, null);
ImageIO.write(img, "png", bao = new ByteArrayOutputStream());
r.addFormData(new FormData("file", org.appwork.utils.encoding.Base64.encodeToString(bao.toByteArray(), false)));
} else {
r.addFormData(new FormData("file", org.appwork.utils.encoding.Base64.encodeToString(IO.readFile(challenge.getImageFile()), false)));
}
URLConnectionAdapter conn = br.openRequestConnection(r);
// ERROR: INVALID_REQUEST = It will be returned when the program tries to send the invalid request.
@ -129,9 +159,16 @@ public class ImageTyperzCaptchaSolver extends CESChallengeSolver<String> impleme
}
String[] result = br.getRegex("(\\d+)\\|(.*)").getRow(0);
if (result != null) {
job.getLogger().info("CAPTCHA " + challenge.getImageFile() + " solved: " + br.toString());
job.setAnswer(new ImageTyperzResponse(challenge, this, result[0], result[1]));
if (challenge instanceof Recaptcha2FallbackChallenge) {
result[1] = challenge.parseAPIAnswer(result[1], this).getValue();
job.getLogger().info("CAPTCHA " + challenge.getImageFile() + " solved: " + br.toString());
job.setAnswer(new ImageTyperzResponse(challenge, this, result[0], result[1]));
} else {
job.getLogger().info("CAPTCHA " + challenge.getImageFile() + " solved: " + br.toString());
job.setAnswer(new ImageTyperzResponse(challenge, this, result[0], result[1]));
}
} else {
job.getLogger().info("Failed solving CAPTCHA");
throw new SolverException("Failed:" + br.toString());

View File

@ -1,5 +1,7 @@
package org.jdownloader.captcha.v2.solver.solver9kw;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@ -13,9 +15,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import jd.http.Browser;
import jd.nutils.encoding.Encoding;
import jd.plugins.DownloadLink;
import javax.imageio.ImageIO;
import org.appwork.utils.IO;
import org.appwork.utils.StringUtils;
@ -26,6 +26,8 @@ import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.ChallengeResponseValidation;
import org.jdownloader.captcha.v2.SolverService;
import org.jdownloader.captcha.v2.SolverStatus;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.BasicCaptchaChallenge;
import org.jdownloader.captcha.v2.solver.CESChallengeSolver;
import org.jdownloader.captcha.v2.solver.CESSolverJob;
@ -35,6 +37,10 @@ import org.jdownloader.gui.translate._GUI;
import org.jdownloader.logging.LogController;
import org.jdownloader.settings.staticreferences.CFG_CAPTCHA;
import jd.http.Browser;
import jd.nutils.encoding.Encoding;
import jd.plugins.DownloadLink;
public class Captcha9kwSolver extends CESChallengeSolver<String> implements ChallengeResponseValidation {
private static final Captcha9kwSolver INSTANCE = new Captcha9kwSolver();
@ -77,6 +83,10 @@ public class Captcha9kwSolver extends CESChallengeSolver<String> implements Chal
@Override
public boolean canHandle(Challenge<?> c) {
if (c instanceof RecaptchaV2Challenge || c instanceof Recaptcha2FallbackChallenge) {
return true;
}
return c instanceof BasicCaptchaChallenge && super.canHandle(c);
}
@ -107,9 +117,18 @@ public class Captcha9kwSolver extends CESChallengeSolver<String> implements Chal
job.getLogger().info(logdata);
}
private Challenge<?> getChallenge(SolverJob<?> job) {
Challenge<?> challenge = job.getChallenge();
if (challenge instanceof RecaptchaV2Challenge) {
challenge = ((RecaptchaV2Challenge) challenge).createBasicCaptchaChallenge();
}
return challenge;
}
@Override
protected void solveCES(CESSolverJob<String> job) throws InterruptedException, SolverException {
BasicCaptchaChallenge challenge = (BasicCaptchaChallenge) job.getChallenge();
BasicCaptchaChallenge challenge = (BasicCaptchaChallenge) getChallenge(job.getJob());
int cph = config.gethour();
int cpm = config.getminute();
@ -370,7 +389,19 @@ public class Captcha9kwSolver extends CESChallengeSolver<String> implements Chal
job.showBubble(this, getBubbleTimeout(challenge));
checkInterruption();
byte[] data = IO.readFile(challenge.getImageFile());
byte[] data = null;
if (challenge instanceof Recaptcha2FallbackChallenge) {
BufferedImage img = ((Recaptcha2FallbackChallenge) challenge).getAnnotatedImage();
ByteArrayOutputStream bao;
ImageIO.write(img, "png", bao = new ByteArrayOutputStream());
data = bao.toByteArray();
} else {
data = IO.readFile(challenge.getImageFile());
}
Browser br = new Browser();
br.setAllowedResponseCodes(new int[] { 500 });
String ret = "";
@ -431,7 +462,23 @@ public class Captcha9kwSolver extends CESChallengeSolver<String> implements Chal
return;
} else if (ret.startsWith("OK-answered-")) {
counterSolved.incrementAndGet();
job.setAnswer(new Captcha9kwResponse(challenge, this, ret.substring("OK-answered-".length()), 100, captchaID));
ret = ret.substring("OK-answered-".length());
if (challenge instanceof Recaptcha2FallbackChallenge) {
ret = challenge.parseAPIAnswer(ret, this).getValue();
if (ret.length() > 0) {
job.setAnswer(new Captcha9kwResponse(challenge, this, ret, 100, captchaID));
} else {
setInvalid(new Captcha9kwResponse(challenge, this, ret, 100, captchaID), job.getJob());
}
} else {
if (ret.length() > 0) {
job.setAnswer(new Captcha9kwResponse(challenge, this, ret, 100, captchaID));
} else {
setInvalid(new Captcha9kwResponse(challenge, this, ret, 100, captchaID), job.getJob());
}
}
return;
} else if (((System.currentTimeMillis() - startTime) / 1000) > (timeoutthing + 10)) {
counterInterrupted.incrementAndGet();

View File

@ -14,18 +14,6 @@ import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.filechooser.FileFilter;
import jd.controlling.ClipboardMonitoring;
import jd.gui.swing.jdgui.views.settings.components.Checkbox;
import jd.gui.swing.jdgui.views.settings.components.SettingsButton;
import jd.gui.swing.jdgui.views.settings.components.SettingsComponent;
import jd.gui.swing.jdgui.views.settings.components.Spinner;
import jd.gui.swing.jdgui.views.settings.components.StateUpdateListener;
import jd.gui.swing.jdgui.views.settings.components.TextInput;
import jd.gui.swing.jdgui.views.settings.panels.anticaptcha.AbstractCaptchaSolverConfigPanel;
import jd.gui.swing.jdgui.views.settings.panels.anticaptcha.CaptchaRegexListTextPane;
import jd.http.Browser;
import net.miginfocom.swing.MigLayout;
import org.appwork.storage.config.JsonConfig;
import org.appwork.storage.config.handler.BooleanKeyHandler;
import org.appwork.swing.MigPanel;
@ -47,13 +35,21 @@ import org.jdownloader.gui.IconKey;
import org.jdownloader.gui.settings.Pair;
import org.jdownloader.gui.translate._GUI;
import org.jdownloader.images.NewTheme;
import org.jdownloader.plugins.controller.crawler.CrawlerPluginController;
import org.jdownloader.plugins.controller.crawler.LazyCrawlerPlugin;
import org.jdownloader.plugins.controller.host.HostPluginController;
import org.jdownloader.plugins.controller.host.LazyHostPlugin;
import org.jdownloader.settings.staticreferences.CFG_9KWCAPTCHA;
import org.jdownloader.updatev2.gui.LAFOptions;
import jd.controlling.ClipboardMonitoring;
import jd.gui.swing.jdgui.views.settings.components.Checkbox;
import jd.gui.swing.jdgui.views.settings.components.SettingsButton;
import jd.gui.swing.jdgui.views.settings.components.SettingsComponent;
import jd.gui.swing.jdgui.views.settings.components.Spinner;
import jd.gui.swing.jdgui.views.settings.components.StateUpdateListener;
import jd.gui.swing.jdgui.views.settings.components.TextInput;
import jd.gui.swing.jdgui.views.settings.panels.anticaptcha.AbstractCaptchaSolverConfigPanel;
import jd.gui.swing.jdgui.views.settings.panels.anticaptcha.CaptchaRegexListTextPane;
import jd.http.Browser;
import net.miginfocom.swing.MigLayout;
public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
private ExtButton btnRegister;
private ExtButton btnApi;
@ -71,8 +67,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
private ExtButton btnUserDebug1file;
private ExtButton btnUserDebug2;
private ExtButton btnUserDebug3;
private ExtButton btnUserDebug3hoster;
private ExtButton btnUserDebug3crawler;
private ExtButton btnUserDebugStatReset;
private ExtButton btnUserDebugBlacklistReset;
private ExtButton btnUserDebugStatShow;
@ -107,6 +102,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
Tab1_9kw.add(new SettingsButton(new AppAction() {
private static final long serialVersionUID = 8804949739472915394L;
{
setName(_GUI._.lit_open_website());
}
@ -208,6 +204,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserCheck = new ExtButton(new AppAction() {
private static final long serialVersionUID = -103695205004891917L;
{
setName(_GUI._.NinekwService_createPanel_btnUserCheck());
}
@ -506,6 +503,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserDebug1 = new ExtButton(new AppAction() {
private static final long serialVersionUID = 1700532687116057633L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebug1());
}
@ -530,6 +528,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserDebug1clipboard = new ExtButton(new AppAction() {
private static final long serialVersionUID = 1700532687116057633L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebug1clipboard());
}
@ -551,6 +550,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
* Save debuglog as file
*/
private static final long serialVersionUID = 1700542687116057633L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebug1file());
}
@ -602,6 +602,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserDebug2 = new ExtButton(new AppAction() {
private static final long serialVersionUID = -4020410143121908004L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebug2());
}
@ -619,6 +620,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
MigPanel toolbardebug1ex = new MigPanel("ins 0", "[][][][]", "[]");
btnUserDebug3 = new ExtButton(new AppAction() {
private static final long serialVersionUID = -622574297401313782L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebug3());
}
@ -641,61 +643,11 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserDebug3.setToolTipText(_GUI._.NinekwService_createPanel_btnUserDebug3());
toolbardebug1ex.add(btnUserDebug3);
btnUserDebug3hoster = new ExtButton(new AppAction() {
private static final long serialVersionUID = 1700532687116057633L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebug3hoster());
}
@Override
public void actionPerformed(ActionEvent e) {
String crazylonglist_hoster = "";
crazylonglist_hoster += "Hoster:\n";
for (LazyHostPlugin plg : HostPluginController.getInstance().list()) {
crazylonglist_hoster += plg.getDisplayName() + "\n";// plg.getAverageParseRuntime()
}
try {
Dialog.getInstance().showInputDialog(Dialog.STYLE_LARGE | UIOManager.BUTTONS_HIDE_CANCEL, "9kw list", null, crazylonglist_hoster, NewTheme.getInstance().getIcon("proxy", 32), null, null);
} catch (DialogClosedException e2) {
e2.printStackTrace();
} catch (DialogCanceledException e2) {
e2.printStackTrace();
}
}
});
btnUserDebug3hoster.setToolTipText(_GUI._.NinekwService_createPanel_btnUserDebug3hoster_tooltiptext());
toolbardebug1ex.add(btnUserDebug3hoster);
btnUserDebug3crawler = new ExtButton(new AppAction() {
private static final long serialVersionUID = 1300532687116057633L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebug3crawler());
}
@Override
public void actionPerformed(ActionEvent e) {
String crazylonglist_hoster = "";
crazylonglist_hoster += "Crawler:\n";
for (LazyCrawlerPlugin plg : CrawlerPluginController.getInstance().list()) {
crazylonglist_hoster += plg.getDisplayName() + "\n";// plg.getAverageCrawlRuntime()
}
try {
Dialog.getInstance().showInputDialog(Dialog.STYLE_LARGE | UIOManager.BUTTONS_HIDE_CANCEL, "9kw list", null, crazylonglist_hoster, NewTheme.getInstance().getIcon("proxy", 32), null, null);
} catch (DialogClosedException e2) {
e2.printStackTrace();
} catch (DialogCanceledException e2) {
e2.printStackTrace();
}
}
});
btnUserDebug3crawler.setToolTipText(_GUI._.NinekwService_createPanel_btnUserDebug3crawler_tooltiptext());
toolbardebug1ex.add(btnUserDebug3crawler);
Tab4_9kw.add(toolbardebug1ex, "gapleft 33,spanx,pushx,growx");
btnUserDebugStatReset = new ExtButton(new AppAction() {
private static final long serialVersionUID = -4020410143121908004L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebugStatReset());
}
@ -728,6 +680,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserDebugBlacklistReset = new ExtButton(new AppAction() {
private static final long serialVersionUID = -4020410143121908004L;
{
setName(_GUI._.NinekwService_createPanel_btnUserDebugBlacklistReset());
}
@ -744,6 +697,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserDebugStatShow = new ExtButton(new AppAction() {
private static final long serialVersionUID = -4020410143121908004L;
{
setName("Show Stats");
}
@ -773,6 +727,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserDebugBlacklistShow = new ExtButton(new AppAction() {
private static final long serialVersionUID = -4020410143121908004L;
{
setName("Show Blacklist");
}
@ -794,6 +749,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
btnUserDebugBubbleShow = new ExtButton(new AppAction() {
private static final long serialVersionUID = -4020410143121908004L;
{
setName("Show BubbleMap");
}
@ -853,6 +809,7 @@ public final class NineKwConfigPanel extends AbstractCaptchaSolverConfigPanel {
private ExtButton addClickButton9kw(ExtButton btnTemp, final String title, final String url, String tooltext) {
btnTemp = new ExtButton(new AppAction() {
private static final long serialVersionUID = 7195034001951861669L;
{
setName(title);
}

View File

@ -34,10 +34,14 @@ public class BasicMousePointerIdleGetter extends IdleGetter implements AWTEventL
@Override
public void actionPerformed(ActionEvent e) {
Point location = MouseInfo.getPointerInfo().getLocation();
if (lastLocation == null || !lastLocation.equals(location)) {
lastChange = System.currentTimeMillis();
lastLocation = location;
try {
Point location = MouseInfo.getPointerInfo().getLocation();
if (lastLocation == null || !lastLocation.equals(location)) {
lastChange = System.currentTimeMillis();
lastLocation = location;
}
} catch (Throwable e1) {
// MouseInfo.getPointerInfo().getLocation(); may throw a Nullpointer!
}
}

View File

@ -10,8 +10,6 @@ import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import net.miginfocom.swing.MigLayout;
import org.appwork.swing.MigPanel;
import org.appwork.swing.components.ExtButton;
import org.appwork.utils.StringUtils;
@ -20,7 +18,10 @@ import org.appwork.utils.formatter.TimeFormatter;
import org.appwork.utils.images.IconIO;
import org.appwork.utils.swing.SwingUtils;
import org.jdownloader.actions.AppAction;
import org.jdownloader.captcha.v2.Challenge;
import org.jdownloader.captcha.v2.SolverStatus;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge;
import org.jdownloader.captcha.v2.challenge.recaptcha.v2.RecaptchaV2Challenge.Recaptcha2FallbackChallenge;
import org.jdownloader.captcha.v2.challenge.stringcaptcha.ImageCaptchaChallenge;
import org.jdownloader.captcha.v2.solver.CESChallengeSolver;
import org.jdownloader.captcha.v2.solver.CESSolverJob;
@ -31,6 +32,8 @@ import org.jdownloader.gui.notify.Element;
import org.jdownloader.gui.translate._GUI;
import org.jdownloader.updatev2.gui.LAFOptions;
import net.miginfocom.swing.MigLayout;
public class CESBubbleContent extends AbstractBubbleContentPanel {
private JLabel status;
@ -82,9 +85,21 @@ public class CESBubbleContent extends AbstractBubbleContentPanel {
east.add(status = new JLabel(""), "hidemode 3");
add(progressCircle, "width 32!,height 32!,pushx,growx,pushy,growy,aligny top");
add(east);
if (cesSolverJob.getChallenge() instanceof ImageCaptchaChallenge) {
Challenge<?> ic = cesSolverJob.getChallenge();
if (ic instanceof RecaptchaV2Challenge) {
ic = ((RecaptchaV2Challenge) ic).createBasicCaptchaChallenge();
}
if (ic instanceof ImageCaptchaChallenge) {
try {
ImageIcon icon = new ImageIcon(ImageProvider.read(((ImageCaptchaChallenge) cesSolverJob.getChallenge()).getImageFile()));
ImageIcon icon = null;
if (ic instanceof Recaptcha2FallbackChallenge) {
icon = new ImageIcon(((Recaptcha2FallbackChallenge) ic).getAnnotatedImage());
;
} else {
icon = new ImageIcon(ImageProvider.read(((ImageCaptchaChallenge) cesSolverJob.getChallenge()).getImageFile()));
;
}
if (icon.getIconWidth() > 300 || icon.getIconHeight() > 300) {
icon = new ImageIcon(IconIO.getScaledInstance(icon.getImage(), 300, 300));