How do you do a DNS lookup, like nslookup?
Is there a way to do this easily? I can't seem to get this to work.
Archive: How do you do a DNS lookup, like nslookup?
How do you do a DNS lookup, like nslookup?
Is there a way to do this easily? I can't seem to get this to work.
Anyone have any clue on how to do this? I have an IP address and I want to get back the domain piece...
It seems I want gethostbyaddress() from the ws32_32 API but I don't quite grasp the syntax of the System pluging.
It uses parameters lists to pass pack and forth between NSIS and System32 DLL variables. I appologize, I am new to the Windows world (I'm aUNIX guy).
Alright, the gethostbyaddress() from what I gather can take a string for an IP and return the DNS name (what I want). I realize it has been deprecated by gethostentry() but anyway...
Can someone give me a quick example and EXPLAIN the syntax?
Based on the doc:
System::Call 'CondMgr::CmGetHotSyncExecPath(t, *i) i(.r0, r1r1).r2'
This says CmGetHostSyncExecPath takes a pointer to a string, pointer to an int returns an int. The t is address of r0 with no input/output passing, the *i comes from r1 and whatever is returned in r1 after the call completes and the return value should be placed in r2. Right?
So by that logic for gethostbyaddress() I should have
System::Call 'ws32_32::gethostbyaddress(t) t($IPADDRESS).r5'
Pass a string which is my variable IPADDRESS and the return value (the string I presume) place it in r5. This barfs miserably. Obviously its pilot error but can I get a quick explanation? Maybe I'm looking at the wrong API doc on MSDN...
Whooops...looks like I am looking at the wrong API doc...arrghhh..
System::Call 'ws2_32::WSAStartup(i 514, i r2) i .r3'
# Convert IP to proper format
System::Call 'ws2_32::inet_addr(t "$IPADDRESS") l .r5'
System::Call 'ws2_32::gethostbyaddr(t r5, i 4, i 2) *i .r6'
The above crashes on the gethostbyaddr call. What am I doing wrong? I would think the pointer to the hostent structure would be returned in R6, right?
Again, any help would be much appreciated (I'm starting to get the SystemDLL plugin).
Where is $IPADDRESS coming from, or have you not posted all your code?
-Stu
The first command should be
System::Call 'ws2_32::WSAStartup(i 514, *i .r2) i .r3'
(note the * and the . before r2). It is a pointer (hence the *) and you are getting it out of the function (hence the .).
System::Call '*(t,t,i,i,t)i.s'
Pop $6
System::Call 'ws2_32::gethostbyaddr(t r5, i 4, i ${AF_INET}) i r6'
I am not also sure about the 't r5' on the third call. You get an unsigned long from the second call to $5 and then you place this as a 't' on the third call?This code works:
!define AF_INET 2
!define strhostent '(t,t,i,i,t)i'
StrCpy $IPADDRESS "aaa.xxx.yyy.zzz" ; put your address here
System::Call 'Ws2_32::WSAStartup(i 514, *i .r2) i .r3'
System::Call 'Ws2_32::inet_addr(t "$IPADRESS") l .r5'
System::Call 'Ws2_32::gethostbyaddr(*l r5, i 4, i ${AF_INET}) i .r6'
System::Call '*$6${strhostent}(.R1,,,,)'
DetailPrint 'The full DNS name of "$IPADDRESS" is "$R1"'
System::Call 'Ws2_32::WSACleanup()i.R9'
System::Free $6
Originally posted by CancerFaceThanks dude. I'm sorry for not getting back to you, I'm on vacation!
This code works:
!define AF_INET 2
!define strhostent '(t,t,i,i,t)i'
StrCpy $IPADDRESS "aaa.xxx.yyy.zzz" ; put your address here
System::Call 'Ws2_32::WSAStartup(i 514, *i .r2) i .r3'
System::Call 'Ws2_32::inet_addr(t "$IPADRESS") l .r5'
System::Call 'Ws2_32::gethostbyaddr(*l r5, i 4, i ${AF_INET}) i .r6'
System::Call '*$6${strhostent}(.R1,,,,)'
DetailPrint 'The full DNS name of "$IPADDRESS" is "$R1"'
System::Call 'Ws2_32::WSACleanup()i.R9'
System::Free $6
This gives you the full domain name. For example if $IPADDRESS is '205.188.229.57' $R1 will be 'waforumweb-dtc1l-0.stream.aol.com'
:)
CF
and the gethostname thread I believe is wrong since its not allocating a buffer to store the name (I had to combine the two).:igor: