mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 483
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Dec 2002
Posts: 483
Hi, I'm trying to make a ip locator using socks.

The script needs to go to http://www.ip-adress.com/ipaddresstolocation/ (maybe change if you have a better side) and enter Ip in the box, and then "hit" the button.

Then return information like: My IP address country, ect.

I'm new to socks. Can someone please help me, just with the basic setup? I would really appreciate that! Thanks.

I found this while searching the forums, and edited it:
Code:
alias locate {
  if ($1 == $null) echo.grey Please enter IP-address | return
  sockmark locate $1
  sockopen locate http://www.ip-adress.com/ipaddresstolocation/ 80
}

on *:SOCKOPEN:locate:{
  sockwrite -n locate GET http://www.ip-adress.com/ipaddresstolocation/ $sock(IP address city).mark http/1.0
  sockwrite -n locate host: http://www.ip-adress.com/ipaddresstolocation/
  sockwrite -n locate $crlf
}

on *:SOCKREAD:locate:{
  var %s
  sockread %s
  echo -s > %s
}

Joined: Mar 2006
Posts: 395
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 395
Code:
alias locate {
 if ($1 == $null) { echo.grey Please enter IP-address }
 else {
  sockmark locate /ipaddresstolocation/ $+ $1
  sockopen locate www.ip-adress.com 80
 }
}

on 1:SOCKOPEN:locate:{
 sockwrite $sockname GET $+ $sock($sockname).mark HTTP/1.0 $+ $crlf
 sockwrite $sockname Host: www.ip-adress.com $+ $crlf $+ $crlf
}

on 1:SOCKREAD:locate:{
 var %s | sockread %s
 echo -st > %s
}


Whilst this should work, I notice other (possible) issues.
1. Address is spelt differently throughout the script (may be on purpose)
2. You may need to encode the "." charachter in the IP address for the GET request.
3. You need to have an alias named "echo.grey" for the echo to work. Otherwise use something like "echo -at 14 <message>"

This should work, allthough I havnt tested it.

Hope it helps, JD

Edit: added possible error #3

Last edited by The_JD; 29/01/08 02:03 AM.

[02:16] * Titanic has quit IRC (Excess Flood)
Joined: Dec 2002
Posts: 483
Deep3D Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Dec 2002
Posts: 483
Thanks, but how to get it to read the site correct? And put the ip in the box, and hit the button. And collect the information like city,state ect about the ip?

Quote:
(Jan 29 03:40:16) > <HTML>
(Jan 29 03:40:16) > <HEAD>
(Jan 29 03:40:16) > <TITLE>400 Bad Request</TITLE>
(Jan 29 03:40:16) > </HEAD>
(Jan 29 03:40:16) > <BODY>
(Jan 29 03:40:16) > <H1>Bad Request</H1>
(Jan 29 03:40:16) > Your browser sent a request that this server could not understand.
(Jan 29 03:40:16) > <P>
(Jan 29 03:40:16) > Client sent malformed Host header
(Jan 29 03:40:16) > <P>
(Jan 29 03:40:16) > <HR>
(Jan 29 03:40:16) > <ADDRESS>
(Jan 29 03:40:16) > Web Server at ip-adress.com
(Jan 29 03:40:16) > </ADDRESS>
(Jan 29 03:40:16) > </BODY>
(Jan 29 03:40:16) > </HTML>
(Jan 29 03:40:16) >
(Jan 29 03:40:16) > <!--
(Jan 29 03:40:16) > - Unfortunately, Microsoft has added a clever new
(Jan 29 03:40:16) > - "feature" to Internet Explorer. If the text of
(Jan 29 03:40:16) > - an error's message is "too small", specifically
(Jan 29 03:40:16) > - less than 512 bytes, Internet Explorer returns
(Jan 29 03:40:16) > - its own error message. You can turn that off,
(Jan 29 03:40:16) > - but it's pretty tricky to find switch called
(Jan 29 03:40:16) > - "smart error messages". That means, of course,
(Jan 29 03:40:16) > - that short error messages are censored by default.
(Jan 29 03:40:16) > - IIS always returns error messages that are long
(Jan 29 03:40:16) > - enough to make Internet Explorer happy. The
(Jan 29 03:40:16) > - workaround is pretty simple: pad the error
(Jan 29 03:40:16) > - message with a big comment like this to push it
(Jan 29 03:40:16) > - over the five hundred and twelve bytes minimum.
(Jan 29 03:40:16) > - Of course, that's exactly what you're reading
(Jan 29 03:40:16) > - right now.
(Jan 29 03:40:16) > -->

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
you need to parse the html and figure it out... its not really a sockets question at that point.. once you have the data it's just string manipulation, $regex, $gettok, etc.

on a sidenote, you seem to have sent a malformed request to the server, you might want to check your GET request


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Mar 2006
Posts: 395
T
Pan-dimensional mouse
Offline
Pan-dimensional mouse
T
Joined: Mar 2006
Posts: 395
Yes, parsing it is what you need to do yourself.

To get it to ask you to enter an IP address, you would use this command

//locate $?="Enter IP Address to lookup"

But it would be simpler to use:
/locate 127.0.0.1

(example)


[02:16] * Titanic has quit IRC (Excess Flood)

Link Copied to Clipboard