egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IP scanning.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Bart
Guest





PostPosted: Thu Jan 12, 2017 8:16 am    Post subject: IP scanning. Reply with quote

Code:
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:
Quote:
<User> !s 176.10.104.243
<Bot> 80 - HTTP (Title: This is a Tor Exit Router | Digital Society / Digitale Gesellschaft)


It should be:
Quote:
<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
Back to top
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Fri Jan 13, 2017 8:50 am    Post subject: Reply with quote

The html answer is:
Code:
<a alt="rescan" href="" rel="nofollow" onclick="return rescan()"><img src="/img/rescan.jpg"></a>&nbsp;&nbsp;Открытые порты:<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.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
Bart
Guest





PostPosted: Fri Jan 13, 2017 9:21 am    Post subject: Reply with quote

So?
Code:
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"
}
}


Quote:
[16:21:28] <a alt="rescan" href="" rel="nofollow" onclick="return rescan()"><img src="/img/rescan.jpg">&nbsp;&nbsp;Открытые порты:<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
Back to top
d3n
Voice


Joined: 13 Jul 2016
Posts: 15
Location: Italy

PostPosted: Wed Jan 18, 2017 6:19 pm    Post subject: Reply with quote

Doesn't work for me...

[17:17:29] Tcl error [scan]: couldn't compile regular expression pattern: quantifier operand invalid
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber