dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 28

Thread: How to make TOR configured application?

  1. #1
    Join Date
    Aug 2019
    Posts
    56

    How to make TOR configured application?

    I found a code which should work, but it doesn't for me on Visual Studio 2017. It returns me "Error" (return(-1) and some weird symbol after. Maybe for somebody else this code worked? https://gist.github.com/anhldbk/f62f...6959e3e0907c81
    Last edited by prako2; August 31st, 2019 at 09:52 AM.

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,814

    Re: How to make TOR configured application?

    I suspect your issue is here:

    Code:
    char Resp2[10];
        recv(Socket, Resp2, 10, 0);
        if(Resp2[1] != 0x00)
        {
          std::cout << "[*] Error : " << Resp2[1] << std::endl;
          return(-1); // ERROR
        }
    You can verify this by changing the error message here. If this is the issue, then you are not receiving the expected data.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

  3. #3
    Join Date
    Aug 2019
    Posts
    56

    Re: How to make TOR configured application?

    I know that issue is here, but how to fix it?

  4. #4
    Join Date
    Aug 2019
    Posts
    56

    Re: How to make TOR configured application?

    I see some problems in the code: https://imgur.com/a/t1L5B72

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,814

    Re: How to make TOR configured application?

    Well, for a start the code is not checking the return values from any function calls. For recv(), a bad return value is SOCKET_ERROR. If the return value is this, then call WSAGetLastError() to determine the error. See https://docs.microsoft.com/en-us/win...f-winsock-recv

    When you call an API function, you should check the return value everytime. If this isn't an OK value, then you need to determine the error and deal with it. The documentation for each API states the return value, what is a good return and what possible errors could occur.

    All the other API calls in the TOR code should also be checked as per their documentation.

    PS Just because you found some code on githib, this does not mean that the code is well written - or even correct!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,814

    Re: How to make TOR configured application?

    Quote Originally Posted by prako2 View Post
    I see some problems in the code: https://imgur.com/a/t1L5B72
    Don't get too worked up about undefined. AF_INET etc are macro definitions with which intellisense has some problems. If they weren't defined the code wouldn't compile. You can see that they are defined because it shows their value and the #define statement.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

  7. #7
    Join Date
    Aug 2019
    Posts
    56

    Re: How to make TOR configured application?

    I'm getting https://imgur.com/a/2ftdaGy Do you know how to enable sdl warnings? Mine is enabled in C++/General/SDL checks. But it overrides anyway. As I remember I did something with command line to override SDL but I don't know how to revert it back. I'm getting warnings: Command line warning D9025: overriding '/sdl' with '/sdl-'
    Last edited by prako2; August 31st, 2019 at 11:17 AM.

  8. #8
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,814

    Re: How to make TOR configured application?

    Error 10093 is WSANOTINITIALISED, which means WSAStartup() has not been called yet. See https://docs.microsoft.com/en-us/win...-error-codes-2

    I don't see any reference to WSAStartup() in the github code? See https://docs.microsoft.com/en-us/win...ock-wsastartup
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

  9. #9
    Join Date
    Aug 2019
    Posts
    56

    Re: How to make TOR configured application?


  10. #10
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,814

    Re: How to make TOR configured application?

    and if you look up that error code you get

    Socket is not connected.
    A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied.
    From which API are you getting 10057? Are you now checking the return value from every API?

    I suspect
    Code:
    connect(Socket, (SOCKADDR*)&SocketAddr, sizeof(SOCKADDR_IN));
    is failing. What's the return value? If it's not 0, there is a problem here.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

  11. #11
    Join Date
    Aug 2019
    Posts
    56

    Re: How to make TOR configured application?

    Return value is -1. I use console application. I get 10057 from console application.
    Last edited by prako2; August 31st, 2019 at 11:59 AM.

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,456

    Re: How to make TOR configured application?

    Quote Originally Posted by prako2 View Post
    Return value is -1. I use console application
    What function does return this (-1) value?
    Victor Nijegorodov

  13. #13
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,814

    Re: How to make TOR configured application?

    Right, then you know the issue is with connect() and WSAGetLastError() will give you the reason for the error - as per post #5.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

  14. #14
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,814

    Re: How to make TOR configured application?

    It looks like the code is using port 9050. Is this port enabled on your firewall?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

  15. #15
    Join Date
    Aug 2019
    Posts
    56

    Re: How to make TOR configured application?

    VictorN WSAGetLastError(). 2kaud Is this problem has a solution?

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)