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.

IP scanning.

Help for those learning Tcl or writing their own scripts.
Post Reply
B
Bart

IP scanning.

Post by Bart »

Code: Select all

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
User avatar
CrazyCat
Revered One
Posts: 1303
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

The html answer is:

Code: Select all

<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.
B
Bart

Post by Bart »

So?

Code: Select all

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
User avatar
d3n
Voice
Posts: 15
Joined: Wed Jul 13, 2016 2:30 pm
Location: Italy
Contact:

Post by d3n »

Doesn't work for me...

[17:17:29] Tcl error [scan]: couldn't compile regular expression pattern: quantifier operand invalid
Post Reply