EvilZone
Programming and Scripting => Java => : Fam5AHcno5 July 30, 2015, 09:15:32 PM
-
First of all, I checked this link:
http://stackoverflow.com/questions/7797386/how-to-mimic-a-web-browser-from-java-using-jsoup (http://stackoverflow.com/questions/7797386/how-to-mimic-a-web-browser-from-java-using-jsoup)
But I don't think this question has a complete answer. I'm writing a bot for an online game, and I want to mimic Firefox exactly. Right now the methods that I'm utilizing are:
browsedCon = Jsoup.connect(myURL)
.userAgent(firefoxUserAgent)
.referrer(myCurrentURL)
.cookies(myCookies)
.followRedirects(true)
.timeout(1000)
.method(Connection.Method.GET)
.execute();
myCookies are the cookies from he previous page. I'm fairly certain that this is not how Firefox works, so I definitely need some improvement there. I think I might be missing the cookies from the redirected page.
Also, I'm downloading images referred in the html document, at the beginning of my browsing session. What else should I consider to make my code completely unnoticeable?
-
I think you'll find the HtmlUtil library useful:
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setRedirectEnabled(true);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.getCookieManager().setCookiesEnabled(true);
final HtmlPage facebook = webClient.getPage("http://www.facebook.com");
final HtmlForm form = (HtmlForm) facebook.getElementById("login_form");
//Filling out the form
final HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue("Log In").get(0);
final HtmlTextInput textField = (HtmlTextInput) facebook.getElementById("email");
textField.setValueAttribute("email@email.com");
final HtmlPasswordInput textField2 = (HtmlPasswordInput) facebook.getElementById("pass");
textField2.setValueAttribute("password");
//Logging in:
HtmlPage loggedin = button.click();
System.out.println("logged in");
-
What else should I consider to make my code completely unnoticeable?
Well timing is one thing, a human being can only click/type/read/decide so fast and to what appears to be random timing.
If it is human behaviour you are seeking to mimic I suggest you randomize timing on certain functions.
Google is a great example of such an effect, ever had to fill in capcha's ?
Too many ,what might be recognized as automated requests, either too frequent or with too short a interval, it is detectable.