This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Public IP Information Checker [SOLVED]

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:Is it possible the server I'm running on masked the trailing digits of the IP address and is messing with the code?
Of course this is possible. If the server is masking any portion of the address (to prevent irc kiddy ddos wars on each other) then this part of your request becomes impossible. The entire reason for the network masking it's user's hosts is to prevent us from resolving them to IP addresses. So exactly what your thinking is happening.
holycrap wrote:I tried "variable whereisFilter [list "city:" "country:"]" to "country city", didn't quite work. Sorry, but can you make it so that output is Country then City, in that order. Sorry for keep asking you stupid questions.
Don't change the order of the list or the hard-coding you silly. Those are now set in stone as told above. You simply change the puthelp, or the output line:

Code: Select all

puthelp "privmsg $chan :City: $city ~ Country: $country" 
Use the vars $city and $country where you want these to be, the rest of the text is static. Shovel color in there some bold, what have you. This is all you can change now, since the rest is hard-coded and dependent on assumptions.

Code: Select all

puthelp "privmsg $chan :\00304Country\003: \00302\002$country\002\003 ~ \00304City\003: \00302\002$city\002\003" 
Understand? ;)
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Cool, understood now. :D If you only had a dime for every time you helped someone, you'll be a really rich dude, speechles. :D

I'm not getting the "city" to output... are you getting it?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:Cool, understood now. :D If you only had a dime for every time you helped someone, you'll be a really rich dude, speechles. :D

I'm not getting the "city" to output... are you getting it?
The site limits queries to a certain amount within a given interval. What that given interval is I have no idea, but it appears at least in testing to be 15minute-ish. So after X queries in that 15 minute period, it defaults to a different page. One that only includes the country field filled in. This is why your seeing just the country. The script doesn't have a method to detect when this happens, so will display only the country at those times.
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Ok, gotcha. And again, thanks for all of your help. Have a good afternoon! :D
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# Whereis IP geolocation scrape script
# by speechles via egghelp.org forums
# if you like this script donate to slennox. ;P

# --> CONFIG start

# This will allow you to customize your output.
# To see everything, only put "*" in the list below.
# Otherwise, put the tags you wish to see in the list
# and keep in mind the order you use is the order
# they will appear during output.
# Wildcards are acceptable, this is done using [string match]
# Case is irrelevant, we are using -nocase.
#
# examples below:
# variable whereisFilter [list "*city:" "*state:" "*country:" "*isp*"]
# this would show the city, state, country and isp of the user.
#
# variable whereisFilter [list "*city:" "*country:"]
# this would show the city and country of the user.
# --
variable whereisFilter [list "*"]

# What symbols/text should seperate your output?
# --
variable whereisDivider ", "

# How would you like your output to be rendered?
# There are two fields to each entry, Name and Value.
# You can put spaces, color, and other things here
# and they will be prefixed to the name/value
# when displayed
# --
variable whereisPrefix "\037Location\037 - "
variable whereisName "\002"
variable whereisValue "\00304"

# --< CONFIG end

bind pub -|- !whereis whereis
setudef flag whereis
package require http

proc whereis {nick uhost hand chan text} {
   # flag
   if {![channel get $chan whereis]} { return }
   # resolve nicknames to their irc hostmasks
   # this won't work correctly for cloaked (+x) users
   if {![string match "*.*" $text]} {
      set wnick [lindex [split [getchanhost [lindex [split $text] 0] $chan] @] 1]
      if {[string length $wnick]} { set text $wnick }
   }
   # useragent
   ::http::config -useragent "Mozilla/5.0 ; Gecko"
   # geturl, with error handler
   catch { set http [::http::geturl "http://www.ip-adress.com/ip_tracer/$text" -timeout 5000] } error
   # error condition 1: invalid http session
   if {![string match -nocase "::http::*" $error]} {
      putserv "privmsg $chan :[string totitle $error] \( http://www.ip-adress.com/ip_tracer/$text \)"
      return 0
   }
   # error condition 2: http error
   if {![string equal -nocase [::http::status $http] "ok"]} {
      putserv "privmsg $chan :[string totitle [::http::status $http]] \( http://www.ip-adress.com/ip_tracer/$text \)"
      return 0
   }
   # no error, get data
   set data [::http::data $http]
   # cleanup http token
   ::http::cleanup $http
   # cleanse html for parsing
   regsub -all {\[<.*?>\]} $data "" data
   regsub -all "<script.*?>.*?</script>" $data "" data
   regsub -all "<a href.*?</a>" $data "" data
   regsub -all "<img src=.*?>" $data "" data
   regsub -all {(?:\n|\t|\v|\r|</span>)} $data "" data
   regsub -all {<span.*?>} $data "" data
   # can we retrieve table fields?
   while {[regexp -nocase -- {<th>(.*?)</th>.*?<td>(.*?)</td>} $data -> type attrib]} {
      # yes, add the elements to the output list
      lappend output "[string totitle [string trim [string map {"IP country code" "country code" "IP address" " "} $type]]]|[string trim $attrib]"
      # remove scraped table fields and loop
      regsub -nocase -- {<th>.*?</th>.*?<td>.*?</td>} $data "" data
   }
   # do we have output?
   if {[info exists output]} {
     # yes, determine what exactly to output...
     foreach entry $::whereisFilter {
        foreach attribute $output {
           # does the attribute match any filter masks?
           if {[string match -nocase $entry [lindex [split $attribute |] 0]]} {
              # yes, add to spam list
              lappend spamline "$::whereisName[string trim [lindex [split $attribute |] 0]]\017$::whereisValue[string trim [lindex [split $attribute |] 1]]\017"
           }
        }
      }
      # was a spam list created?
      if {[info exists spamline]} {
         # if created, does it have any contents?
         if {[llength $spamline]} {
           # yes, spam first 9
           puthelp "privmsg $chan :$::whereisPrefix[join [lrange $spamline 0 8] $::whereisDivider]"
           # more than 9?
           if {[llength $spamline] > 8} {
              # yes, spam the rest
              puthelp "privmsg $chan :[join [lrange $spamline 9 [llength $spamline]] $::whereisDivider]"
           }
         }
      } else {
         # we have output but nothing in the spam list, declare
         puthelp "privmsg $chan :$text returns some useful information for me to reply with, but filtering is preventing me from showing you... ;/"
      }
   } else {
      # we have no output at all, declare
      puthelp "privmsg $chan :$text returns no useful information for me to reply with... ;/"
   }
# eof
}
Here is an enhanced version of the prior script. This corrects a small bug in the whereisFilter allowing it to work as designed now. Also adds a few new config options for the output as well in case you like bold, or color now it's an option. Just figured since I'm using it myself with these enhancements others might like them too. ;)

Edit: Added new option for working without output suggested below. ;)
Last edited by speechles on Sun Jun 07, 2009 10:39 am, edited 2 times in total.
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

You rock!
Thanks a bunch

:)

Is it possible for me just to paste this in there and everything works?

Code: Select all

puthelp "privmsg $chan :\00304Country\003: \00302\002$country\002\003 ~ \00304City\003: \00302\002$city\002\003" 
Seems like I have more control with the output this way.
As of right now this is how I output it:

Code: Select all

puthelp "privmsg $chan :\037Location\037 - \002Country:\002 \00304$country\003, \002City:\002 \00304$city\003"
Don't ask me why, but I think scripts are like cars, if you can play around with it and be able to modify a few things your way, it's more fun.

:D
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:Seems like I have more control with the output this way.
As of right now this is how I output it:

Code: Select all

puthelp "privmsg $chan :\037Location\037 - \002Country:\002 \00304$country\003, \002City:\002 \00304$city\003"
Don't ask me why, but I think scripts are like cars, if you can play around with it and be able to modify a few things your way, it's more fun.

:D
Check the new variable "whereisPrefix" this will now be added to the beginning of the line and if you use the script as pasted above verbatim it should work as you want. Simply change the "whereisFilter" list to "*country:" and "*city:" ... Enjoy ;D
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

The site allowed only x amount of times to get the info. Can you please modify it so the bot can log into the site? Cause they have an option where you can register and get unlimited amount of locations. 25 times for free and paid amount for unlimited. Just need a way for the bot to login.

Thanks much!

http://www.ip-adress.com/ip_tracer/

:D
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:The site allowed only x amount of times to get the info. Can you please modify it so the bot can log into the site? Cause they have an option where you can register and get unlimited amount of locations. 25 times for free and paid amount for unlimited. Just need a way for the bot to login.

Thanks much!

http://www.ip-adress.com/ip_tracer/

:D
There is a small problem regsitering for that site...
Wait! Just one more step before we create your FREE account.


To get your free account now follow this easy steps. It takes only 30 seconds.

1. Click here and join the free Black MacBook Air sweepstake.

2. Enter your email address there and copy and paste the confirmation message that appears.
Fill in this confirmation message from the Black MacBook Air sweepstake below.
3. Thats it. Your free account will be instantly created.

confirmation message
It's a frikkin spam trap. Hop through loops and find some confirmation message. But wait, first lets cycle you through endless registrations for everything you can think of.

I won't go through this hassle just to get an idiotic confirmation message to give that site so it knows I went through all that bullshit. If you go through this hassle and have gotten the confirmation message and registered yourself then simply paste whatever that was here to me. So i can register an account using the confirmation. Otherwise I have no plans to do this as it's a spam trap bullshit-fest.

But anyways, here is a newer better version of the script: Whereis.tcl .. Enjoy and have a fun ;)
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Sorry about that. I didn't know there were all these spam stuff. But I registered along time ago, and here are the info to login. I'll change the password once you've tested it out.

email: [removed]
password: [removed]
I've been using the version I tweaked below. The output as I wanted and such. If you could modify that it would be awesome. I saw the latest version you had there and it's giving me a headache to try to cross reference it to match the one I'm using. :cry: Please modify the one I'm using to match the better version you had there, but keep all the output settings. :)

Thanks a bunch speechles! :D

Code: Select all

# MAKE SURE TO .chanset #yourchan +whereis

# Whereis IP geolocation scrape script
# by speechles via egghelp.org forums
# if you like this script donate to slennox. ;P

# --> CONFIG start

# This will allow you to customize your output.
# To see everything, only put "*" in the list below.
# Otherwise, put the tags you wish to see in the list
# and keep in mind the order you use is the order
# they will appear during output.
# Wildcards are acceptable, this is done using [string match]
# Case is irrelevant, we are using -nocase.
#
# examples below:
# variable whereisFilter [list "*city:" "*state:" "*country:" "*isp*"]
# this would show the city, state, country and isp of the user.
#
# variable whereisFilter [list "*city:" "*country:"]
# this would show the city and country of the user.
# --
variable whereisFilter [list "*country:" "*city:"]

# What symbols/text should seperate your output?
# --
variable whereisDivider ", "

# How would you like your output to be rendered?
# There are two fields to each entry, Name and Value.
# You can put spaces, color, and other things here
# and they will be prefixed to the name/value
# when displayed
# --
variable whereisPrefix "\037Location\037 - "
variable whereisName "\002"
variable whereisValue " \00304"

# --< CONFIG end

bind pub -|- !whereis whereis
setudef flag whereis
package require http

proc whereis {nick uhost hand chan text} {
   # flag
   if {![channel get $chan whereis]} { return }
   # resolve nicknames to their irc hostmasks
   # this won't work correctly for cloaked (+x) users
   if {![string match "*.*" $text]} {
      set wnick [lindex [split [getchanhost [lindex [split $text] 0] $chan] @] 1]
      if {[string length $wnick]} { set text $wnick }
   }
   # useragent
   ::http::config -useragent "Mozilla/5.0 ; Gecko"
   # geturl, with error handler
   catch { set http [::http::geturl "http://www.ip-adress.com/ip_tracer/$text" -timeout 15000] } error
   # error condition 1: invalid http session
   if {![string match -nocase "::http::*" $error]} {
      putserv "NOTICE $nick :\002Time-Out Error\002. Please try again later."
      return 0
   }
   # error condition 2: http error
   if {![string equal -nocase [::http::status $http] "ok"]} {
      putserv "NOTICE $nick :\002Time-Out Error\002. Please try again later."
      return 0
   }
   # no error, get data
   set data [::http::data $http]
   # cleanup http token
   ::http::cleanup $http
   # cleanse html for parsing
   regsub -all {\[<.*?>\]} $data "" data
   regsub -all "<script.*?>.*?</script>" $data "" data
   regsub -all "<a href.*?</a>" $data "" data
   regsub -all "<img src=.*?>" $data "" data
   regsub -all {(?:\n|\t|\v|\r|</span>)} $data "" data
   regsub -all {<span.*?>} $data "" data
   # can we retrieve table fields?
   while {[regexp -nocase -- {<th>(.*?)</th>.*?<td>(.*?)</td>} $data -> type attrib]} {
      # yes, add the elements to the output list
      lappend output "[string totitle [string trim [string map {"IP country code" "country code" "IP address" " "} $type]]]|[string trim $attrib]"
      # remove scraped table fields and loop
      regsub -nocase -- {<th>.*?</th>.*?<td>.*?</td>} $data "" data
   }
   # do we have output?
   if {[info exists output]} {
     # yes, determine what exactly to output...
     foreach entry $::whereisFilter {
        foreach attribute $output {
           # does the attribute match any filter masks?
           if {[string match -nocase $entry [lindex [split $attribute |] 0]]} {
              # yes, add to spam list
              lappend spamline "$::whereisName[string trim [lindex [split $attribute |] 0]]\017$::whereisValue[string trim [lindex [split $attribute |] 1]]\017"
           }
        }
      }
      # was a spam list created?
      if {[info exists spamline]} {
         # if created, does it have any contents?
         if {[llength $spamline]} {
           # yes, spam first 9
           puthelp "privmsg $chan :$::whereisPrefix[join [lrange $spamline 0 8] $::whereisDivider]"
           # more than 9?
           if {[llength $spamline] > 8} {
              # yes, spam the rest
              puthelp "privmsg $chan :[join [lrange $spamline 9 [llength $spamline]] $::whereisDivider]"
           }
         }
      } else {
         # we have output but nothing in the spam list, declare
         puthelp "NOTICE $nick :\037Syntax\037: \002!whereis\002 <xxx.xxx.xxx.xxx>"
      }
   } else {
      # we have no output at all, declare
      puthelp "NOTICE $nick :\037Syntax\037: \002!whereis\002 <xxx.xxx.xxx.xxx>"
   }
# eof
}

putlog "*.Ip Information v1.0* Loaded"
Moderated: Posting passwords in a publically readable forum is usually a very bad idea. I've removed the password, but I strongly suggest you use whatever means available to immediately change it to something new. If you really need to disclose this kind of information to another member of this forum, do so in a PM - This does not, however, mean we encourage disclosing any such information in any way, and we will not be held responsible for any abuse of such disclosed information being used without your consent.

/NML_375
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:Sorry about that. I didn't know there were all these spam stuff. But I registered along time ago, and here are the info to login. I'll change the password once you've tested it out.

email: <snipped do-not-index>
password: <snipped too>

I've been using the version I tweaked below. The output as I wanted and such. If you could modify that it would be awesome. I saw the latest version you had there and it's giving me a headache to try to cross reference it to match the one I'm using. :cry: Please modify the one I'm using to match the better version you had there, but keep all the output settings. :)

Thanks a bunch speechles! :D
Well, after trying this out it seems pretty simple. So check out what I've done:
<speechles> !wlogin
<sp33chy> Whereis: Login Successful!
<speechles> !wlogout
<sp33chy> Whereis: Logout Successful!
<speechles> !whereis cpe-76-185-234-26.tx.res.rr.com
<sp33chy> Ip: 76.185.234.26, Country code: US, Ip country: United States, Ip state: , Ip city: , Ip latitude: , Ip longitude: , Isp of this ip: , Organization:
<speechles> !wlogin
<sp33chy> Whereis: Login Successful!
<speechles> !whereis cpe-76-185-234-26.tx.res.rr.com
<sp33chy> Ip: 76.185.234.26, Country code: US, Ip country: United States, Ip state: Texas, Ip city: Euless, Ip postcode: 76040, Ip latitude: 32.8101, Ip longitude: -97.1061, Isp of this ip: Road Runner
<sp33chy> Organization: Road Runner, Host of this ip: cpe-76-185-234-26.tx.res.rr.com, Local time in united states: 2009-11-15 12:04
<speechles> !wlogout
<sp33chy> Whereis: Logout Successful!
As you can see to initiate the script to begin using your account you must have an owner/master type !wlogin. Then to stop it using your account and default back to free mode simply have them issue !wlogout. If the script becomes unlogged, and stops attaching to your account simply reissue the !wlogin command. Hopefully this is what you had in mind, shout out if you experience any problems. As you see above it works perfectly for me.. keke ;P

Grab the latest here: Whereis.tcl

Note to Holycrap:
-------------------------
Sorry, I ate up two of your alloted quota adding this feature.. :) Remember to change the password, and edit your previous post to obfuscate that email. :D
Also...This isn't exactly the version you pasted as it has flaws since corrected in my newest version. This new version re-includes the whereisPrefix variable, which was the only difference between the two other than it still having the problem of excessive spacing at times. This new version does not have that problem with excessive spacing at all and now works with full authentication, cookies, and redirects. So enjoy and have a fun. Dance like an robot. Etc.. ;D

Btw, put together the 25 you get logged in and the 5 you get logged out. Using both together you can potentially get 30 a day.. lmao :P

Code: Select all

puthelp "NOTICE $nick :\037Syntax\037: \002!whereis\002 <xxx.xxx.xxx.xxx>" 
Using that as both your error messages is also incorrect. This will work on ip's, host's and/or nicknames (those in same channel command is issued in) unless your using a network with cloaked (+x) users. Which you might be and is why you crafted the message the way you have. But both don't mean no results were found. The first message means output was found, but depending on how you craft your filter list the message there is output but filtering prevents it appears. The second message means no output was found at all. There is a slight difference. ;)
-------------------------
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Thank you speechles! :D

Code: Select all

variable whereisPrefix "\037Location\037 - " 
variable whereisName "\002"
variable whereisValue " \00304"
With the top code, I'm getting this output.

Location - Ip country: United States, Ip city: Edmonds

Where do I need to modify to get this output?

Location - Country: United States, City: Edmonds

I looked up and down numerous times trying the find Ip city and Ip country, but couldn't find it.

The login and logout work gret by the way. :D
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:Thank you speechles! :D

Code: Select all

variable whereisPrefix "\037Location\037 - " 
variable whereisName "\002"
variable whereisValue " \00304"
With the top code, I'm getting this output.

Location - Ip country: United States, Ip city: Edmonds

Where do I need to modify to get this output?

Location - Country: United States, City: Edmonds

I looked up and down numerous times trying the find Ip city and Ip country, but couldn't find it.

The login and logout work gret by the way. :D
Change this:

Code: Select all

      # yes, add them to variables and partially cleanse them.
      set type [string map {"::" ":"} [string totitle [string trim [string map {"IP country code" "country code" "IP address" "IP" " :" ":" " :" ":"} $type]]]]
To this:

Code: Select all

      # yes, add them to variables and partially cleanse them.
      set type [string map {"::" ":"} [string totitle [string trim [string map {"IP country code" "country code" "IP address" "" " :" ":" " :" ":"} $type]]]]
This will recreate the old look.
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Thanks much speechles! Everything works great. Also, thanks for updating the "Fully Automated Away Detection" script too. :D

Happy turkey day!

:D
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Had a chance to use the script for a few days and was wondering if this is doable.

Instead of having to do !wlogin for the bot to login, is it possible for the bot to auto login by itself and if it ever de-attaches from the server somehow make it relogin by itself? Kind of like all behind the scene kind of thing.

I have sent you the login info via the forum's message thing. :D

Thanks!

:D
Post Reply