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

C#: Where to begin with sockets?

Discussion in 'C, C++, C#' started by kytro360, Oct 1, 2011.

Tags:
  1. kytro360

    kytro360 Power Member

    Joined:
    Jan 12, 2010
    Messages:
    703
    Likes Received:
    732
    Hey, I am working with httpwebrequests but Ive been hearing that sockets is a better, faster solution.

    Where are some good tutorials on how to use sockets when it comes to automation (ie: Posting to forms, or sites).

    Any help would be useful, thanks :)
     
  2. ~divinci

    ~divinci Registered Member

    Joined:
    Sep 23, 2009
    Messages:
    51
    Likes Received:
    11
    Occupation:
    Infastructure Reverse Engineer
    Location:
    Liverpool UK
    I am seeing this sockets vs HttpWebrequest question a lot on this forum - its good to see so many programmers around!

    if you delve deep into the .Net HttpWebrequest you see that it uses http.sys which is the nuts and bolts of how windows processes RFC2616. So you can make a get/post with it and hey predto you get a response!

    Years ago i went down the route you are thinking and decided to make some bots with the humble, powerful and complex Socket.

    if you decide to go down this route, you will have to learn:
    1. RFC2616
    2. What RFC2616 doesnt tell you about the real WWW :)

    Number 2. will take you years - for example, try and create a GET request with a socket which accepts a gzip encoded responce. Now with those response byte[] try and decode the gzip data with the .Net GZipStream. If this takes you less than 8 man hours, you should take the dive and enjoy learning to develop your socket based http library!!!
     
    • Thanks Thanks x 5
  3. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,147
    I think he is going to appreciate the httpwebrequests functionality after your post ~divinci :D

    Newcomers in programming take a lot of powerful things for granted and are quick to follow any hype, disregarding efficiency.
     
    • Thanks Thanks x 1
  4. Wolfpack

    Wolfpack Junior Member

    Joined:
    Jul 13, 2011
    Messages:
    166
    Likes Received:
    346
    You forget to mention the best reason of all for using HttpWebRequest in my opinion - Fiddler 2. Go to Google, search it and download it and you have basically solved every single HttpWebRequest you will ever need to compose.

    Simply commit yourself to using Internet Explorer for about 30 seconds (hard, I know, or configure Firefox to use local proxy settings), and submit the request manually (eg fill in a form if that's what you want the request to do). Fiddler will then write out everything you need under the Raw view of the Inspector tab to send the request, and the response from the server is written below seperately, and can be inspected similarly. If you need to decode the response, it will also provide the encoding in the Raw response view so lnog as you have not already decoded the response, so everything is done for you. It's not even programming really, lol.
     
  5. ~divinci

    ~divinci Registered Member

    Joined:
    Sep 23, 2009
    Messages:
    51
    Likes Received:
    11
    Occupation:
    Infastructure Reverse Engineer
    Location:
    Liverpool UK
    Haha Wolfpack i did the same, two years of my custon HTTP dll and i found WatIn
    !! All cookie problems sorted. You can the use the cookie solution to your advantage. Everyone talks about adcns cking which is Banned! But all the GBigtable can look at is the past. If you have a "complete" cookie profile then you can pass the turing test :)

    I am working on a CookieSession class for XP and IE which will take a snapshot of IEs CookieSession dat a and Cache. This save mehod kills explorer so as to free up the index.dat file. It then saves all cookie files and cache files (including index.dat) raw bytes and details to MSSQL. With explorer dead, other CookieSessions can be loaded, explorer restarted! And hey presto a different person for your needs.

    Need to include a proxy server with each CookieSession. But writing WatIn G+ bots is labourious!

    So.... what you working on?
     
    • Thanks Thanks x 1
  6. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,147
    What do you mean by "complete" cookie profile?
     
  7. ~divinci

    ~divinci Registered Member

    Joined:
    Sep 23, 2009
    Messages:
    51
    Likes Received:
    11
    Occupation:
    Infastructure Reverse Engineer
    Location:
    Liverpool UK
    Hey jazzc its like your windows profile. As you browse and click, sign up to websites, check your emails, "remember me" and tweet. All that is tracked by the big sites.

    That is how they target ads to you!

    If i manually went to google for a service of some sort, using my IE, google knows who i am, they have my large surfing history and my usual browsing habits. They trust me.

    If you use a HttpWebrequest to sign up for a google account, they will not have any history, and the won't trust that account.

    So in storing all of XPs temporary internet files and cache files - as a CookieSession - you can switch between these for your bot work, each bot has it's own RICH history with google.

    Ill upload a video today :)
     
    • Thanks Thanks x 1