Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


getting an ip
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Tue Jul 08, 2008 5:04 am    Post subject: Reply with quote

Guess there's no point getting the IP if the connection is NAT'ed? Anyway, if the connection isn't NAT'ed, probably the best way to get the IP is make a connection to any external host (which uptime is ~100%) and then read the IP address from the socket. I don't know about WSock, but in wxWidgets it'd be done like this:
Code:
wxIPV4address *ipaRemote = new wxIPV4address(); // IP addy objects..
wxIPV4address *ipaLocal = new wxIPV4address();
ipaRemote->Hostname( wxT("www.google.com") ); // Remote host
ipaRemote->Service(80); // Remote port

wxSocketClient *sClient = new wxSocketClient(); // Make a socket
if( sClient->Connect(*ipaRemote) ) { // Connect the socket to the remote host
   sClient->GetLocal(*ipaLocal); // Fill the object
   wxString sIP = ipaLocal->IPAddress(); // Get the IP address.
}

// Clean-up
delete ipaRemote;
delete ipaLocal;
delete sClient;
This way there's no need to send any data or parse any data received from the host.

EDIT: more comments :)


Last edited by Jani on Thu Jul 10, 2008 4:33 am; edited 1 time in total
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Tue Jul 08, 2008 10:14 am    Post subject: Reply with quote

NATed?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Wed Jul 09, 2008 7:29 am    Post subject: Reply with quote

oib111 wrote:
NATed?
NAT as Network Address Translation.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Wed Jul 09, 2008 10:09 am    Post subject: Reply with quote

I don't know atm, the equivalent function for GetLocal. But I think this is what you're doing before it.

Code:

host = gethostbyname("google.com");
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_addr.s_addr = ((struct in_addr *)(host->h_addr))->s_addr;
sin.sin_family = AF_INET;
sin.sin_port = htons(80);
connect(sock, (SOCKADDR *)&sin, sizeof(sin));

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Thu Jul 10, 2008 4:35 am    Post subject: Reply with quote

oib111 wrote:
I don't know atm, the equivalent function for GetLocal.
It's only used for initializing the IP address object, so I could read the IP from there. You might not need it when you're using WSock. Anyway, you should somehow be able to read the local IP stored by TCP.

oib111 wrote:
But I think this is what you're doing before it.
Probably. Well, you just connect to the remote host, and since TCP stores also the local ip, you read it and that's how you get your IP.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 10, 2008 7:55 am    Post subject: Reply with quote

Local IP is a private or public IP? Just because it has local in it makes it sound like it pertains to LAN addresses, which would be private.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Thu Jul 10, 2008 8:05 am    Post subject: Reply with quote

oib111 wrote:
Local IP is a private or public IP? Just because it has local in it makes it sound like it pertains to LAN addresses, which would be private.
Local meaning that IP address on YOUR comp. Talking about a socket, it refers to the IP address on your comp, which was used to establish the socket connection.

Remote as the other host. If you're looking from the other host, then your local IP is their remote and the one you think it's remote, it's their local.

Private is different than local. Private is eg. 10.0.0.0/24. It's size is defined by the subnet(/24 -> as bits). Private means that no one in teh Internets can see it, only people in your intranet can see it.

So, in conclusion, I'll say that local means just that it's at your side, close to you. Check for acronyms from thesaurus or some other dictionary. Local can be either private or public IP, it depends on which IP was used when the socket (connection) was made. So if you're connecting to an _external_ host, outside your intranet, your public IP address will be used as long as you're not NAT'ed.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 10, 2008 8:18 am    Post subject: Reply with quote

Ok. Well, first problem here is that you're connecting to a host to get their IP address. Me on the other hand need the program itself to get the IP address when they start it. I just realized, there must be some modem APIs or something. Isn't it very probable, that if there are APIs pertaining to modems, their would be one that gets the IP address?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Thu Jul 10, 2008 8:35 am    Post subject: Reply with quote

Obviously you need an IP to connect to them, so you already have the IP?
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Thu Jul 10, 2008 8:38 am    Post subject: Reply with quote

oib111 wrote:
Ok. Well, first problem here is that you're connecting to a host to get their IP address.
No. I just make a connection to a host to know which interface does the comp use when accessing teh Internets.

oib111 wrote:
Me on the other hand need the program itself to get the IP address when they start it.
Hmm? Do you mean that you're on a eg. PPPoE dialup? That's why you need to make the connection and then read the TCP/IP properties. Looping interfaces would work too, but then you'd have to chose which one will be used.

oib111 wrote:
I just realized, there must be some modem APIs or something. Isn't it very probable, that if there are APIs pertaining to modems, their would be one that gets the IP address?
Good luck.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 10, 2008 8:47 am    Post subject: Reply with quote

Nah because I want to make an instant messenger lol. Anyway I need them to get their IP Address whey they start the program so I can store it in my computer so when they someone sends an IM to them I can forward them the message.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Thu Jul 10, 2008 9:02 am    Post subject: Reply with quote

Anyway.. Here's a lil console proggie. It's a bit large since wxWidgets is linked statically:
Code:
#include <wx/socket.h>
#include <wx/string.h>

int main(int argc, char **argv)
{
   wxIPV4address *ipaRemote = new wxIPV4address(); // IP addy objects..
   wxIPV4address *ipaLocal = new wxIPV4address();
   ipaRemote->Hostname( wxT("www.google.com") ); // Remote host
   ipaRemote->Service(80); // Remote port

   wxSocketClient *sClient = new wxSocketClient(); // Make a socket
   if( sClient->Connect(*ipaRemote) ) { // Connect the socket to the remote host
      sClient->GetLocal(*ipaLocal); // Fill the object
      wxPuts( ipaLocal->IPAddress() ); // Get the IP address AND DISPLAY IT.
   }

   // Clean-up
   delete ipaRemote;
   delete ipaLocal;
   delete sClient;

   return 0;
}


Compiled. UPX'ed. Requires VS2008 runtime libraries. That should be all. Refresh if not seen. This is to prove you that it's not getting their IP, but your local, public one.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sat Jul 12, 2008 1:23 am    Post subject: Reply with quote

I installed wxWidgets-2.8.8 for windows and set up the directories but it keeps getting an error that it can't include file wx/defs.h. But I looked in the include folder and it was in there...so yeah....
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites