Announcement

Collapse
No announcement yet.

How to FTP connect via non-transparent proxy?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to FTP connect via non-transparent proxy?

    For example, I have data for ftp connection:
    szFtpServer = ftp.server.com
    szFtpUsername = test_pc
    szFtpPassword = go_connect

    Ftp connection runs without problem.

    normal connection:
    Code:
    hInetConnect = InternetConnect(BYVAL hInetOpen, _
                                   BYVAL VARPTR(szFtpServer), _
                                   BYVAL %INTERNET_DEFAULT_FTP_PORT, _
                                   BYVAL VARPTR(szFtpUsername), _
                                   BYVAL VARPTR(szFtpPassword), _
                                   BYVAL %INTERNET_SERVICE_FTP, _
                                   BYVAL %INTERNET_FLAG_PASSIVE, _
                                   BYVAL 0)
    How are the dates of connection to look, if it is to go over non-transparent proxy (firewall-proxy)?
    e.g. in Total-Commander - connect to ftp, host name.., user name, password + option "Use firewall (proxy server)" -> connect method ...., host name, user name, password. How can it realize in PBWin?

    Example please.

    Thanks.
    Last edited by Alexander Holzer; 11 Dec 2008, 04:35 AM.
    Yours sincerely

  • #2
    Does someone know non-transparent proxy? for a test… (servername, username, password)

    Thanks.
    Yours sincerely

    Comment


    • #3
      If your 'regular' connection code fails, you can get an error message; maybe that would help.

      You can steal.. er, 'find an example of ' the error handling code in this demo:

      WinInet FTP Upload (Overwrite or Append) Demo 3-10-08
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Thanks, Michael,
        my FTP-program works fine.

        Question in a firewall proxy!
        For example, if it I need a connection to a FTP-server through a non-transparent proxy (firewall-proxy).
        There is a problem.
        Yours sincerely

        Comment


        • #5
          The only "FTP Firewalls" I have worked with work by checking the IP address of the "connect-or". Either your computer is allowed in or it ain't.

          E.g, when I am logged on to my client's computer I can access an internal FTP site he has set up to exchange data amongst his systems; but from my office computer I cannot get in.

          Several major retailers (eg, "the big W") do exactly the same thing with their electronic trading parters: if your IP address is on the good list, you can get in, if it ain't you "Go Fish!"
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Originally posted by Alexander Holzer View Post
            Thanks, Michael,
            my FTP-program works fine.

            Question in a firewall proxy!
            For example, if it I need a connection to a FTP-server through a non-transparent proxy (firewall-proxy).
            There is a problem.
            If its truly a transparent firewall, then there isn't a difference as far as your software is concerned, but you may need to initiate the connection in passive mode.

            If you're trying to reach an FTP server via an FTP Proxy then you will need to find what format the proxy requires. There are no standard methods per-say, although many take the form [email protected] If you need to pass a user name and password, you will need to check the proxy docs to find out what method they require for that. FTP proxies are a bit trickier than http proxies because you are actually authenticating to a server instead of simply passing unsecured pages back and forth.
            Software makes Hardware Happen

            Comment


            • #7
              Originally posted by Joe Byrne View Post
              ...
              If you're trying to reach an FTP server via an FTP Proxy then you will need to find what format the proxy requires. There are no standard methods per-say, although many take the form [email protected] If you need to pass a user name and password, you will need to check the proxy docs to find out what method they require for that. FTP proxies are a bit trickier than http proxies because you are actually authenticating to a server instead of simply passing unsecured pages back and forth.
              Quite right,
              It would be desirable to give in the program a similar opportunity, as in Total Commander (ftp connection).
              First through a firewall-proxy with: servername, username and password.
              Method: USER [email protected]@hostname / PASS [email protected]

              Thanks.
              Yours sincerely

              Comment


              • #8
                I try this, but InternetConnect with error:
                Code:
                LOCAL hInetOpen       AS LONG
                LOCAL hInetConnect    AS LONG
                LOCAL szAgent         AS ASCIIZ * 64
                LOCAL szProxyAddrPort AS ASCIIZ * 1024
                LOCAL szProxyUser     AS ASCIIZ * 1024
                LOCAL szProxyPass     AS ASCIIZ * 1024
                LOCAL szFtpServer     AS ASCIIZ * 1024
                LOCAL szFtpUsername   AS ASCIIZ * 1024
                LOCAL szFtpPassword   AS ASCIIZ * 1024
                LOCAL szFtpUserStr    AS ASCIIZ * 1024
                LOCAL szFtpPassStr    AS ASCIIZ * 1024
                LOCAL dwConnectType   AS DWORD
                LOCAL dwConnectPara   AS DWORD
                
                
                szAgent         = "Proxy_Test"
                hInetOpen       = 0
                hInetConnect    = 0
                dwConnectType   = %INTERNET_OPEN_TYPE_PRECONFIG
                dwConnectPara   = %NULL
                szProxyAddrPort = "test_proxy.com"
                szProxyUser     = "proxy_user"
                szProxyPass     = "proxy_pass"
                szFtpServer     = "ftp.test.com"
                szFtpUsername   = "test_user"
                szFtpPassword   = "password"
                
                szFtpUserStr  = szFtpUsername + "@" + szProxyUser + "@" + szFtpServer [COLOR="Red"]'<- or here szProxyAddrPort ???[/COLOR]
                szFtpPassStr  = szFtpPassword + "@" + szProxyPass
                dwConnectType = %INTERNET_OPEN_TYPE_PROXY
                dwConnectPara = VARPTR(szProxyAddrPort)
                
                hInetOpen = InternetOpen(BYVAL VARPTR(szAgent), _
                                         BYVAL dwConnectType, _
                                         BYVAL dwConnectPara, _
                                         BYVAL %NULL, _
                                         BYVAL 0)
                
                IF hInetOpen = %FALSE THEN MSGBOX "internet connection failed"
                
                hInetConnect = InternetConnect(BYVAL hInetOpen, _
                                               BYVAL VARPTR(szFtpServer), _     [COLOR="Red"]'<- or here szProxyAddrPort ???[/COLOR]
                                               BYVAL %INTERNET_DEFAULT_FTP_PORT, _
                                               BYVAL VARPTR(szFtpUserStr), _
                                               BYVAL VARPTR(szFtpPassStr), _
                                               BYVAL %INTERNET_SERVICE_FTP, _
                                               BYVAL %INTERNET_FLAG_PASSIVE, _
                                               BYVAL 0)
                
                IF hInetConnect = %FALSE THEN MSGBOX "connection to FTP-server failed"
                Where a mistake?

                Thanks.
                Last edited by Alexander Holzer; 2 Mar 2009, 04:33 PM.
                Yours sincerely

                Comment


                • #9
                  I think so will be correct:
                  Code:
                  szFtpUserStr  = szFtpUsername + "@" + sProxyUser + "@" + [B]szProxyAddrPort[/B]
                  it was wrong:
                  Code:
                  szFtpUserStr  = szFtpUsername + "@" + szProxyUser + "@" + szFtpServer
                  Last edited by Alexander Holzer; 2 Mar 2009, 05:23 PM.
                  Yours sincerely

                  Comment


                  • #10
                    Code:
                    IF hInetOpen = %FALSE THEN 
                    
                    IF hInetConnect = %FALSE THEN
                    THEN = (as per posted demo)
                    Code:
                    ' Query the last response info.....
                        LE   = GetLastError
                        CALL  InternetGetLastResponseInfo (iErrLastResponse, szLastResponseInfo, cchLastResponseInfo)
                    AND THEN...
                    Code:
                       MSGBOX USING$( "ERROR #  *",  iErrLastResponse, szLastResponseInfo),, _ 
                                    "Opening or Conecting"
                    MCM
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Thanks Michael,
                      know you working non-transparent (firewall-proxy) server for the tests? ..host name, user, pass
                      Last edited by Alexander Holzer; 3 Mar 2009, 05:05 AM.
                      Yours sincerely

                      Comment


                      • #12
                        No, I don't know about proxies or firewalls at all.

                        What I do know is that when there is an error explanation available for the asking it should be taken. It might not tell you much; then again, it might tell you exactly what you need to know.
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Originally posted by Michael Mattias View Post
                          No, I don't know about proxies or firewalls at all.
                          Oh I am surprised!!
                          Alexander
                          From your description it would appear that you have on your computer a program that is able to successfully do the FTP connection so why not just install a packet sniffer and capture the formats used by that program.
                          I note you are using a passive connection which I thought needed you to create a second connection, the first merely giving the IP and Port for you to use on the second connection.
                          John

                          Comment


                          • #14
                            >>No, I don't know about proxies or firewalls at all.
                            > Oh I am surprised!!

                            Well, that's an interesting comment. Especially coming from someone who has shared HIS wisdom with us with demos in the Source Code Forum precisely zero times.

                            Them that can, do.

                            MCM
                            Michael Mattias
                            Tal Systems (retired)
                            Port Washington WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              Originally posted by Michael Mattias View Post
                              >>No, I don't know about proxies or firewalls at all.
                              > Oh I am surprised!!

                              Well, that's an interesting comment. Especially coming from someone who has shared HIS wisdom with us with demos in the Source Code Forum precisely zero times.

                              Them that can, do.

                              MCM
                              Then again I don't bother to make posts on subjects I admit I know absolutely nothing about. If I were to post to the source code forum I would have to be sure that I had tested it in all conditions which I just don't have time to do. It seems you will post there with the heading "untried and untested" and claim another great example.

                              Comment


                              • #16
                                Originally posted by Michael Mattias View Post
                                Code:
                                IF hInetOpen = %FALSE THEN 
                                
                                IF hInetConnect = %FALSE THEN
                                THEN = (as per posted demo)
                                Code:
                                ' Query the last response info.....
                                    LE   = GetLastError
                                    CALL  InternetGetLastResponseInfo (iErrLastResponse, szLastResponseInfo, cchLastResponseInfo)
                                AND THEN...
                                Code:
                                   MSGBOX USING$( "ERROR #  *",  iErrLastResponse, szLastResponseInfo),, _ 
                                                "Opening or Conecting"
                                MCM
                                InternetGetLastResponseInfo does not work at connection by InternetConnect(...)

                                InternetOpen - OK, InternetConnect - failed
                                Yours sincerely

                                Comment


                                • #17
                                  Originally posted by John Petty View Post
                                  Oh I am surprised!!
                                  Alexander
                                  From your description it would appear that you have on your computer a program that is able to successfully do the FTP connection so why not just install a packet sniffer and capture the formats used by that program.
                                  I note you are using a passive connection which I thought needed you to create a second connection, the first merely giving the IP and Port for you to use on the second connection.
                                  John
                                  Unfortunately not I do tests. I do not know the proxies data (host, user, pass).
                                  Therefore I also asked - who knows firewall-proxy for testing.
                                  Yours sincerely

                                  Comment


                                  • #18
                                    I need a firewall-proxy for testing of my app! (host name, user name, password)
                                    Can knows somebody?
                                    Yours sincerely

                                    Comment


                                    • #19
                                      I install "Proxy+" local, with FTP Gateway active (require authentication account/user), active USER "proxy_test" with PASS "proxytest".
                                      And Ftp-server test account USER "ftp_test", PASS "ftptest".

                                      Now I come to the Proxy with:

                                      Code:
                                      LOCAL hInetOpen        AS DWORD
                                      LOCAL hInetConnect     AS DWORD
                                      LOCAL szAgent          AS ASCIIZ*128
                                      LOCAL szFtpServer      AS ASCIIZ*128
                                      LOCAL szProxyAddrPort  AS ASCIIZ*128
                                      LOCAL URL              AS ASCIIZ*128
                                      LOCAL szFtpUser        AS ASCIIZ*128
                                      LOCAL szFtpPass        AS ASCIIZ*128
                                      LOCAL szProxyUser      AS ASCIIZ*128
                                      LOCAL szProxyPass      AS ASCIIZ*128
                                      
                                      szAgent         = "Test_secure_server"
                                      szProxyAddrPort = "127.0.0.1.4421"
                                      szProxyUser     = "proxy_test"
                                      szProxyPass     = "proxytest"
                                      szFtpServer     = "ftp.test.com"
                                      szFtpUser       = "ftp_test"
                                      szFtpPass       = "ftptest"
                                      
                                      hInetOpen = InternetOpen(BYVAL VARPTR(szAgent), _
                                                               BYVAL %INTERNET_OPEN_TYPE_PROXY, _
                                                               BYVAL VARPTR(szProxyAddrPort), _
                                                               BYVAL %NULL, _
                                                               BYVAL 0)
                                      
                                      URL = "ftp://" & szProxyAddrPort
                                      
                                      hInetConnect = InternetOpenUrl(hInetOpen, _
                                                                     URL, _
                                                                     "", _
                                                                     0, _
                                                                     %INTERNET_FLAG_RAW_DATA OR _
                                                                     %INTERNET_FLAG_RELOAD OR _
                                                                     %INTERNET_FLAG_DONT_CACHE, _
                                                                     0)

                                      InternetGetLastResponseInfo say:
                                      220 Proxy+ FTP Gateway ready. Start with command USER [email protected]
                                      331 [gateway] Enter your password (if you wanted to specify remote host use
                                      USER [email protected] command)
                                      530 [gateway] login incorrect

                                      I tried the following without success:
                                      Code:
                                      InternetSetOption(hInetOpen, %INTERNET_OPTION_PROXY_USERNAME, VARPTR(szProxyUser), LEN(szProxyUser) +1)
                                      InternetSetOption(hInetOpen, %INTERNET_OPTION_PROXY_PASSWORD, VARPTR(szProxyPass), LEN(szProxyPass) +1)
                                      Problem logging into proxy. Help me please!

                                      Thanks.
                                      Yours sincerely

                                      Comment


                                      • #20
                                        Sometimes these "gateways" don't use the 'standard' FTP command set command.. i.e., they are like another application running on top of a standard FTP server.

                                        Sometimes when a password is required it is entered in format "username/password" or "usename(password)"

                                        So you can try
                                        Code:
                                           szProxyUser = "username/[email protected]" 
                                           or 
                                           szProxyUser = "username(password)@hostname"
                                        .. with a login command.

                                        BTW...

                                        >I tried the following without success
                                        > InternetSetOption ....

                                        MCM


                                        What did InternetGetLastResponseINfo tell you here?

                                        BTW, you might just want to try firing up the Microsoft FTP.EXE program and seeing if you can log in using manual commands. I've found that's a good way to figure out what it is the server realluy wants.

                                        e.g,
                                        Code:
                                        C:\> FTP.EXE 
                                        open   <sitename> or <IP address>
                                        FTP> Site open. (sometimes more message asking for username password 
                                        
                                        FTP> username/[email protected]  (if prompted)
                                        OR 
                                        FTP>  USER username/[email protected]  (if not prompted) 
                                        ...
                                        Something like that.



                                        Be prepared, some of these things give you one (1) try and then disconnect you.
                                        Michael Mattias
                                        Tal Systems (retired)
                                        Port Washington WI USA
                                        [email protected]
                                        http://www.talsystems.com

                                        Comment

                                        Working...
                                        X