#1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154

    Connecting to Proxies


    I know that if you want to connect to a server using a proxy, you must connect to the proxy first. I'm a little confused on how this actually works. Would I just do something like:
    Code:
    s.connect((proxy, proxyport))
    s.connect((server, port))
    ?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    461
    Rep Power
    25
    i beleave, you are going to have to send all your command to the proxy. from there the proxy forwards where it goes. So you are going to have to look up what commands the proxy needs to be able to do its work. Like i think you will have to include in ever command where it goes and what you should be getting back form the client

    im not 100% sure but i do know you have to interact with the proxy and the proxy then pretends to be u and it interacts with whowever you are trying to get to.

    if you do figure it out, i would love to see the source.
  4. #3
  5. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    I found a SOCKS 4/5 tutorial, its written for VB6. So it looks like it might take some work to convert the code. When I get some time I might try and get proxy connecting to work through this tutorial:
    http://pianka.net/tutorials/Socks.txt
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    461
    Rep Power
    25
    hmm, that sucks. I wouldn't be surprised tho if there are python tuts out there that help with proxying.

    but i don't think that tutorial should be to difficult to translate to python. I was reading through it a bit, i know very little vb and i could get the jists of what needed to happen.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Posts
    78
    Rep Power
    10
    Assuming you mean a webserver, use urllib:
    Code:
    import urllib
    
    PAGE = "http://example.com/somepage.html"
    PROXY = "http://myproxy.localhost.com:5678"
    
    class MyURLopener(urllib.FancyURLopener):
        def prompt_user_passwd(self, host, realm):
            return "MyName", "MyPassword"
    
    def main():
        opener = MyURLopener({'http': PROXY})
        f = opener.open(PAGE)
        data = f.read().upper().split("HREF")
                    
    if __name__ == '__main__':
        main()
    --OH.

IMN logo majestic logo threadwatch logo seochat tools logo