bind pub - !s scan
package require http
proc scan {nick host hand chan text} {
set scanconnect [::http::geturl "http://1whois.ru/scanhost/?host=$text&rem=scan" -timeout 10000]
set scandata [::http::data $scanconnect]
::http::cleanup $scanconnect
if {[string match -nocase "*Open port not found.*" $scandata]} { putquick "PRIVMSG $chan :Open port not found."; return}
regsub -all -- {\n} $scandata "" scandata
regsub -all {<a alt=.*?Открытые порты.*?<br><table><tr>} $scandata "" scandata
regsub -all {<a onclick=\".*?\" target=_blank href=\".*?\">} $scandata "" scandata
regsub -all {</a>|</table>} $scandata "" scandata
putlog $scandata
foreach line [split $scandata \n] {
regexp -- {<td width=\".*?\">(.*?): </td><td><b>(.*?)</b> \((.*?)\)</td></tr>} $line - port1 port2 port3
set result "$port1 - $port2 ($port3)"
putquick "PRIVMSG $chan :$result"
}
}
The script works, but it is wrong.
I get:
<User> !s 176.10.104.243
<Bot> 80 - HTTP (Title: This is a Tor Exit Router | Digital Society / Digitale Gesellschaft)
It should be:
<Bot> 80 - HTTP (Title: This is a Tor Exit Router | Digital Society / Digitale Gesellschaft)
<Bot> 443 - SSL
<Bot> 8080 - Proxy (Title: This is a Tor Exit Router | Digital Society / Digitale Gesellschaft)
<Bot> 53 - DNS
<a alt="rescan" href="" rel="nofollow" onclick="return rescan()"><img src="/img/rescan.jpg"></a> Открытые порты:<br>
<table><tr><td width="40">80: </td><td><b><a onclick="_i3 = new Image(); _i3.src = '/click.php?_HTTP-176.10.104.243';" target=_blank href="http://176.10.104.243">HTTP</a></b> (Title: This is a Tor Exit Router | Digital Society / Digitale Gesellschaft)</td></tr><tr><td width="40">443: </td><td><b><a onclick="_i3 = new Image(); _i3.src = '/click.php?_SSL-176.10.104.243';" target=_blank href="https://176.10.104.243">SSL</a></b></td></tr><tr><td width="40">8080: </td><td><b><a onclick="_i3 = new Image(); _i3.src = '/click.php?_Proxy-176.10.104.243';" target=_blank href="http://176.10.104.243:8080">Proxy</a></b> (Title: This is a Tor Exit Router | Digital Society / Digitale Gesellschaft)</td></tr><tr><td width="40">53: </td><td><b>DNS</b></td></tr></table>
So, no \n in it.
Try splitting on </tr> to get your lines, and remove </tr> from your regexp.
bind pub - !s scan
package require http
proc scan {nick host hand chan text} {
set scanconnect [::http::geturl "http://1whois.ru/scanhost/?host=$text&rem=scan" -timeout 10000]
set scandata [::http::data $scanconnect]
::http::cleanup $scanconnect
if {[string match -nocase "*Open port not found.*" $scandata]} { putquick "PRIVMSG $chan :Open port not found."; return}
regsub -all {<a alt=.*?Открытые порты.*?<br><table><tr>} $scandata "" scandata
regsub -all {<a onclick=\".*?\" target=_blank href=\".*?\">} $scandata "" scandata
regsub -all {</a>|</table>} $scandata "" scandata
putlog $scandata
foreach line [split $scandata </tr>] {
regexp -- {<td width=\".*?\">(.*?): </td><td><b>(.*?)</b> \((.*?)\)</td>} $line - port1 port2 port3
set result "$port1 - $port2 ($port3)"
putquick "PRIVMSG $chan :$result"
}
}
[16:21:28] <a alt="rescan" href="" rel="nofollow" onclick="return rescan()"><img src="/img/rescan.jpg"> Открытые порты:<br>
<table><tr><td width="40">80: </td><td><b>HTTP</b> (Title: This is a Tor Exit Router | Digital Society / Digitale Gesellschaft)</td></tr><tr><td width="40">443: </td><td><b>SSL</b></td></tr><tr><td width="40">8080: </td><td><b>Proxy</b> (Title: This is a Tor Exit Router | Digital Society / Digitale Gesellschaft)</td></tr><tr><td width="40">53: </
[16:21:28] Tcl error [scan]: can't read "port1": no such variable
[16:21:28] [egglib]: Catched BGError: can't read "port1": no such variable