Website Advisor for Eggdrop

By FordLawnmower on Jun 05, 2012

This is a tcl script for eggdrop. Not for mIRC!
This Script uses McAfee SiteAdvisor to check posted links for problems.
Links will Return:

  • Safe = No Problems found.
  • Warning = Security risks have been reported by trusted users.
  • Danger = Suspicious behavior has been reported by trusted users.
  • No Result = Site unresponsive or not yet indexed by McAfee.
    Loading:
  • Save this code to a file called advisor.tcl
  • Place the file in your eggdrop scripts directory
  • Add this line to eggdrop.conf -->> source scripts/advisor.tcl
  • Rehash or restart your eggdrop
  • (In the console) type .chanset #channelname +advisor "where #channelname is the channel you want the script on in"

See the setup at the top of the script.
All of the output can be changed, including turning off "safe" links.

Screen:
Image

##############################################################################################
##  ##     advisor.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help      ##  ##
##############################################################################################
## To use this script you must set channel flag +advisor (ie .chanset #chan +advisor)       ##
##############################################################################################
##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
namespace eval advisor {
## Edit safelogo to change the logo for sites that return a value of safe               ##  ##
  variable safelogo "\017\00300,03\002Safe\017"
## Edit safetext to change the text shown when a site returns a value of safe           ##  ##
  variable safetext "No problems found with\017"
## Edit warninglogo to change the logo for sites that return a warning                  ##  ##
  variable warninglogo "\017\00301,08\002Caution\017"
## Edit warningtext to change the text shown when a site returns a warning              ##  ##
  variable warningtext "Found potential suspicious behavior on\017"
## Edit dangerlogo to change the logo shown when a site returns danger                  ##  ##
  variable dangerlogo "\017\00300,04\002Danger\017"
## Edit dangertext to change the text shown when a site returns danger                  ##  ##
  variable dangertext "Found potential security risks with\017"
## showsafe, showwarning & showdanger can be turned on or off by changing the value.    ##  ##
## Use lowercase letters only for this setting.                                         ##  ##
  variable showsafe "on"
  variable showwarning "on"
  variable showdanger "on"
## Edit sitecolor to change the color that the sitename will be displayed in            ##  ##
  variable sitecolor "\017\002"
##############################################################################################
##  ##                           End Setup.                                              ## ##
##############################################################################################
  setudef flag advisor
  bind pubm -|- "*" advisor::main
}
proc advisor::main {nick host hand chan text} {
  if {[lsearch -exact [channel info $chan] +advisor] != -1} {
    set text [strip $text]
    if {[regexp {(www\.|http\x3A\x2F\x2F)([^\s]+)} $text]} {
      set counter 1
      set text [regexp -all -inline {(www\.|http\x3A\x2F\x2F)([^\s]+)} $text]
      foreach i $text {
        if {$counter == 3} {
          resolve $nick $host $hand $chan $i
          set counter 0
        }
        incr counter
      }
    }
  }
}
proc advisor::check {nick host hand chan site} {
  set advisorsite "www.siteadvisor.com"
  set advisorurl "/sites/${site}"
  if {[catch {set advisorsock [socket -async $advisorsite 80]} sockerr]} {
    putserv "PRIVMSG $chan :$advisorsite $advisorurl $sockerr error"
    return 0
  } else {
    puts $advisorsock "GET $advisorurl HTTP/1.0"
    puts $advisorsock "Host: $advisorsite"
    puts $advisorsock "User-Agent: Opera 9.6"
    puts $advisorsock ""
    flush $advisorsock
    while {![eof $advisorsock]} {
      set advisorvar " [gets $advisorsock] "
      if {[string match "*class=\"siteGreen\"*" $advisorvar] && $advisor::showsafe == "on"} {
        putserv "PRIVMSG $chan : $advisor::safelogo $advisor::safetext ${advisor::sitecolor}${site} $advisor::safelogo"
      } elseif {[string match "*class=\"siteYellow\"*" $advisorvar] && $advisor::showwarning == "on"} {
        putserv "PRIVMSG $chan : $advisor::warninglogo $advisor::warningtext ${advisor::sitecolor}${site} $advisor::warninglogo"
      } elseif {[string match "*class=\"siteRed\"*" $advisorvar] && $advisor::showdanger == "on"} {
        putserv "PRIVMSG $chan : $advisor::dangerlogo $advisor::dangertext ${advisor::sitecolor}${site} $advisor::dangerlogo"
      }
    }
  }
}
proc advisor::resolve {nick host hand chan site} {
  set resolveurl "/"
  regexp {([^\/]*)} [string map {\xf ""} $site] match resolvesite
  regexp {(\/.*)} [string map {\xf ""} $site] match resolveurl
  if {[catch {set resolvesock [socket -async $resolvesite 80]} sockerr]} {
    return 0
  } else {
    puts $resolvesock "GET $resolveurl HTTP/1.0"
    puts $resolvesock "Host: $resolvesite"
    puts $resolvesock "User-Agent: Opera 9.6"
    puts $resolvesock ""
    flush $resolvesock
    while {![eof $resolvesock]} {
      set resolvevar " [gets $resolvesock] "
      if {[regexp -nocase {http\/1\.[0-9]\s([0-9]{3})} $resolvevar match code]} {
        if {$code != "301"} {
          check $nick $host $hand $chan $resolvesite
          break
          return 0
        }
      } elseif {[regexp -nocase {Location:\s(.*)} $resolvevar match redirect]} {
        regexp {:\/\/([^\/]*)} $redirect match resolvesite
        check $nick $host $hand $chan $resolvesite
        break
        return 0
      } elseif {[regexp {<html} $resolvevar]} {
        check $nick $host $hand $chan $resolvesite
        break
        return 0
      }
    }
  }
}
proc advisor::strip {text} {
  regsub -all -- {\017|\015|\031|\002|\037|\026|\003(\d{1,2})?(,\d{1,2})?} $text "" text
    return $text
}
putlog "\002*Loaded* \002\00300,02Web Site Advisor\002\003 \002by Ford_Lawnmower irc.GeekShed.net #Script-Help"

Comments

Sign in to comment.
rinzes   -  Aug 26, 2014

Nice script Ford, Would like to add a filter to ignore a list of "nicks" any chance you can add? Thanks in advance

 Respond  
YG   -  May 09, 2014

I am not sure but but I think the script needs updating. . . . . It was working than it quit and [Question] could you make an advisor from other antivirus site advisor like Norton, Site Advisor, Avast Site Advisor etc. ?

 Respond  
Fuzion   -  Jul 01, 2012

nice work ford, very useful :)

 Respond  
FordLawnmower   -  Jun 07, 2012

@frederik That site has not been indexed.
http://www.siteadvisor.com/sites/www.chat1080.com
After the first request to siteadvisor.com, McAfee will add the site to it's list for testing. I'm really not sure how long it takes before they add the results but this site will be listed after testing.

From the websiteadvisor page:

AUTOMATED WEB SAFETY TESTING RESULTS FOR CHAT1080.COM

This site has been queued for testing. Please come back soon for automated results.

 Respond  
frederik   -  Jun 06, 2012

@FordLawnmower

does it work only for old website ?

i tryed www.chat1080.com
not working

Thanks

 Respond  
GrimReaper   -  Jun 05, 2012

I have the RSS going in a bot channel on GeekShed. So I see all post's and comment's straight away. :)

 Respond  
FordLawnmower   -  Jun 05, 2012

Wow quick response. Thanks @GrimReaper :)

 Respond  
GrimReaper   -  Jun 05, 2012

I saw you using the mIRC version of this before, Such an amazing script and I will definately be adding it to my eggdrop bot. :D

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.