Thread: IP logging

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    7

    IP logging

    How would I log IP connections to a game server that I am running thats using winsocks. Ive have used 3rd IP loggers for games such as delta force and quake but have no idea how the authors did this.

    Ive logged connections in simple winsock chat programs by including the logging code into the exe of the server. But logging conections to a server that I didnt write or have source code stumps me. How is this be done.

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    http://www.tamos.com/products/commview/
    This program can capture network traffic.

    There are tons of free programs as well.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You accept() a connection, then you know the IP of the other end.
    Log it to a file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    You accept() a connection, then you know the IP of the other end.
    Log it to a file.
    He didnt write the server code.

    But logging conections to a server that I didnt write or have source code stumps me. How is this be done.
    There are two easy ways I can think of doing this, and several hard ways. I'm going to assume that you are on the windows platform (if you are not using windows, then pretty much disregard my entire post).

    I'll list the two easy ways to do what you are trying to do (since the hard ways are pretty much an overkill for this sort of task).

    1) LSP. This will allow you to see every time the accept() function in the winsock2 dll is called. The best thing about this method, is that it wont break any other applications, and it is far more accepted than the second method I am about to suggest.

    2) Replace the winsock DLL. This will be a little time consuming since you have to rewrite every function that the winsock DLL exports. The good news is that you dont have to rewrite the entire function. All you have to do is load the original winsock dll from your fake winsock dll. Then call the original winsock function from your fake winsock function, and return the same thing. You can put your fake winsock dll in the same directory as your game, and it should get loaded by default instead of the real winsock dll.

    Let me know if you need any more information on either of these methods

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Other (easier) options:

    - Use the API function GetTcpTable(). - Assumes server uses TCP.
    - Parse the results of netstat. - Assumes server uses TCP.
    - Create a proxy tunnel server.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Posts
    7
    Thanks for replies, I have solved the prolem using madCodeHook and using system hooking to inject my code into the games own server. Heres a very freeware hook code and documentation for those interested.

    http://www.madshi.net/oldc++0.htm

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 32 bit binary IP to decimal IP (vice-versa)
    By Mankthetank19 in forum C Programming
    Replies: 15
    Last Post: 12-28-2009, 07:17 PM
  2. Ip adresses
    By Da-Nuka in forum Networking/Device Communication
    Replies: 8
    Last Post: 02-27-2005, 02:25 PM
  3. Logging IP addresses
    By paladin217 in forum C++ Programming
    Replies: 4
    Last Post: 10-06-2002, 11:11 AM
  4. Logging IP's
    By DanMan in forum C++ Programming
    Replies: 2
    Last Post: 10-16-2001, 03:32 PM