1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C# MultiThreaded MultiProxy Support browser?

Discussion in 'C, C++, C#' started by ilPatrino, May 12, 2012.

  1. ilPatrino

    ilPatrino Junior Member

    Joined:
    Sep 6, 2011
    Messages:
    130
    Likes Received:
    15
    I've been doing lots of botting recently & I am now in need of a web browser that supports multiple proxies(You can open multiple browsers & assign a different proxy to each). I'm already using Watin and it's awesome but it can only accept one proxy at a time so cannot be multithreaded. Any of you guys know of a C# library that can do this?
     
  2. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,059
    The short answer is, you can't.

    As far as I'm aware you can't use multiple web browsers on multiple. The web browser control is an ActiveX component that can only work on a singular threaded application. The work around to this would probably be to spawn each browser instance off as it's own process and use a named pipe server to communicate to each instance (more hassle than it's worth for what you're trying to do).

    The proxy that the web browser control is using comes from the registry, for the internet explorer settings. You will have to derive your own browser object and handle the connection yourself.

    But to be honest with you, you are FAR better off using HttpWebRequest.
     
    Last edited: May 12, 2012
  3. Dally

    Dally Junior Member

    Joined:
    Dec 9, 2010
    Messages:
    151
    Likes Received:
    64
    Location:
    UK
    I'm not sure if it's possible, but may I ask, why would you want to? A web browser in c# is very clunky and takes up a lot of ram and bandwidth. Much better just to use httpwebrequests, they are much faster and you can easily create multiple threads with them.
     
  4. kokoloko75

    kokoloko75 Elite Member

    Joined:
    Jan 1, 2011
    Messages:
    1,628
    Likes Received:
    1,935
    Occupation:
    Design director
    Location:
    Paris (France)
    Maybe with another web browser component, like Chrome (eg. delphi chromium embedded component).
    I have not tried.

    Beny
     
  5. smack

    smack Junior Member

    Joined:
    Feb 1, 2010
    Messages:
    182
    Likes Received:
    78
    Occupation:
    Software Engineer/Evil Genius
    Location:
    inside .NET
    No.

    check out some of my past posts about this for more detail.
     
  6. ilPatrino

    ilPatrino Junior Member

    Joined:
    Sep 6, 2011
    Messages:
    130
    Likes Received:
    15
    I would use httpwebrequest but the registration processes on most websites are using ajax nowadays and its a pain in the ass to make it work using httpwebrequest
     
  7. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,059
    It's easier than you think.

    Just add the header "X-Requested-With: XMLHttpRequest"
     
  8. ilPatrino

    ilPatrino Junior Member

    Joined:
    Sep 6, 2011
    Messages:
    130
    Likes Received:
    15
    but let's say for example there's a captcha that's being generated by the use of ajax, taking a value from the page, then making the call & receiving the captcha, what would you do?
     
  9. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,059
    Look at your fiddler trace, note what order the requests are in. If they are sending data thats generated from the page you need to either A: scrape that data and send it in your requests, B: mimic whatever function is generating it.
     
  10. smack

    smack Junior Member

    Joined:
    Feb 1, 2010
    Messages:
    182
    Likes Received:
    78
    Occupation:
    Software Engineer/Evil Genius
    Location:
    inside .NET
    at the end of the day be it normal requests, json, ajax, or whatever it all follows a standard request/response model and can be spoofed. it's just a matter of diligent packet logging and replication.
     
    • Thanks Thanks x 1
  11. The Doctor

    The Doctor Jr. VIP Jr. VIP

    Joined:
    Dec 18, 2010
    Messages:
    612
    Likes Received:
    188
    Occupation:
    Computer Scientist, Engineer, Programmer.
    Location:
    ☆☆☆☆☆☆
    It is possible to manually specify a proxy setting for each instance of the internet explorer process. This way, it is possible to have multiple browser windows, each using their own unique proxy. You must use the DLL urlmon.dll.
     
  12. RottenYellow

    RottenYellow BANNED BANNED

    Joined:
    Sep 10, 2010
    Messages:
    68
    Likes Received:
    16
    Check out http://jint.codeplex.com. You can also use dynatrace to analyze JS, very cool tool.
     
    • Thanks Thanks x 1
  13. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,059
    Thanks for sharing that dude, looks really useful :d
     
  14. goodseoman

    goodseoman Power Member Premium Member

    Joined:
    Jul 1, 2010
    Messages:
    556
    Likes Received:
    247
    This.
    @OP if you knew C#, HttpWebRequest is a must to solve all the problems which are going to happen
     
  15. gacon.lonton

    gacon.lonton Newbie

    Joined:
    Aug 21, 2010
    Messages:
    14
    Likes Received:
    0
    the best choice is HttpWebRequest :)
    WebBrowser Control is not for multi thread purposes , or deep tasks in web.
     
  16. theMagicNumber

    theMagicNumber Regular Member

    Joined:
    May 13, 2010
    Messages:
    345
    Likes Received:
    195
    HttpWebRequest/HttpWebResponse have bugs, but are better than the browser.
    There are some things that will be very hard to achieve with the above classes, for example some websites generate complex strings with java script for example registering an yahoo account. I have an utility class that extends WebClient, it handles the HttpWebRequest/HttpWebResponse logic, but it is easier to work with.
    Code:
    sing System;
    using System.Net;
    using System.Net.Security;
    using System.Security.Cryptography.X509Certificates;
    
    
    namespace Utility
    {
        public class WebClientEx : WebClient
        {
            static WebClientEx()
            {
                ServicePointManager.Expect100Continue = false;
                ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)((object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => true);
                ServicePointManager.DefaultConnectionLimit = 1000;
            }
    
    
            public WebClientEx()
                : base()
            {
                this.AllowAutoRedirect = true;
                this.Cookies = new CookieContainer();
            }
    
    
            protected override WebRequest GetWebRequest(Uri address)
            {
                HttpWebRequest request = base.GetWebRequest(address) as HttpWebRequest;
                if (request.Method == "POST")
                {
                    request.ContentType = "application/x-www-form-urlencoded";
                }
                request.AutomaticDecompression = DecompressionMethods.GZip;
                request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12";
                request.CookieContainer = this.Cookies;
                request.AllowAutoRedirect = this.AllowAutoRedirect;
                request.Timeout = 10000;
                return request;
            }
    
    
            public bool AllowAutoRedirect { get; set; }
            public CookieContainer Cookies { get; set; }
        }
    }
    
    More functionallity can be added too, the only problem is handling multipart/form-data.
     
    Last edited: Jun 18, 2012
  17. ilPatrino

    ilPatrino Junior Member

    Joined:
    Sep 6, 2011
    Messages:
    130
    Likes Received:
    15
    The thing with httpwebrequest sometimes is that you need variables from javascript functions. This is especially problematic when creating a bot to create accounts so a web browser based bot would be better. I'm sure that a multithreaded & multi proxy browser is possible as zennoposter is doing this.
     
  18. hatemachine

    hatemachine Regular Member

    Joined:
    Jan 14, 2011
    Messages:
    271
    Likes Received:
    1,138
    Zennoposter's browser is not multithreaded, for each 'thread' they start a new process which has the browser control. Then the new process communicates with zennoposter via WCF to share the required automation data. They recently switched to https://bitbucket.org/geckofx/geckofx-8.0/ it seems though, so play around with that. Or http://awesomium.com/ is a possibility too(ubot uses it)
     
    • Thanks Thanks x 2
  19. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    So they sell a library witch has webkit statically linked. This is against webkit's LGPL license if they don't provide the source code or the binary files that allows you to link the library with webkit yourself.
    I would not throw money at this.
     
  20. hatemachine

    hatemachine Regular Member

    Joined:
    Jan 14, 2011
    Messages:
    271
    Likes Received:
    1,138
    Well it's free unless you make over $100k in a year. :)