forked from valendono/TCL-Eggdrop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhois.tcl
344 lines (293 loc) · 12.4 KB
/
whois.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
####################################################
#### Who is Versi 1.1 by dono
### +Update host +Whois Automation With IP Info
##################################################
bind pub - !whois msg_whois
proc msg_whois {nick uhost hand chan text} {
global botnick
if {$text == ""} { putquick "PRIVMSG $chan :You have to use true command for look up whois information. Command: <!whois domain>"; return }
package require tls
::http::register https 443 ::tls::socket
if {[string match "*.id" $text]} {
set connect [::http::geturl https://tools.whois.com.au/whois/$text]
set files [::http::data $connect]
::http::cleanup $files
set l [regexp -all -inline -- {Creation Date:(.*?)T.*?Expiration Date:(.*?)T.*?Sponsoring Registrar:(.*?)Status:.*?Registrant ID:(.*?)Admin Contact.*?Name Server:(.*?)Access to WHOIS} $files]
foreach {black a b c d e} $l {
set a [string trim $a " \n"]
set b [string trim $b " \n"]
set c [string trim $c " \n"]
set d [string trim $d " \n"]
set e [string trim $e " \n"]
regsub -all {<.+?>} $a {} a
regsub -all {<.+?>} $b {} b
regsub -all {<.+?>} $c {} c
regsub -all {<.+?>} $d {} d
regsub -all {<.+?>} $e {} e
if {[info exists a]} { putserv "PRIVMSG $chan :\[\002$text\002\] Created: $a - Exp: $b - Registrar: $c - Registrant: $d - DNS: $e"
set connect2 [::http::geturl https://tools.whois.com.au/dig/$text]
set files2 [::http::data $connect2]
::http::cleanup $files2
set l2 [regexp -all -inline -- {<td headers="th-ip-1">(.*?)</td>} $files2]
foreach {blue z } $l2 {
set a [string trim $z " \n"]
regsub -all {<.+?>} $z {} z
if {[info exists z]} {
set connect3 [::http::geturl http://whatismyipaddress.com/ip/$z]
set files3 [::http::data $connect3]
::http::cleanup $files3
regexp -- {ISP:</th><td>(.*?)</td></tr><tr><th>Organization} $files3 - isp
regexp -- {Country:</th><td>(.*?) <img src=} $files3 - country
regexp -- {Hostname:</th><td>(.*?)</td></tr>} $files3 - hostname
regexp -- {State/Region:</th><td>(.*?)</td></tr>} $files3 - state
regexp -- {City:</th><td>(.*?)</td></tr>} $files3 - city
if {[info exists country]} { puthelp "privmsg $chan :\[\002$text\002\] IP: $z - ISP: $isp - Hostname: $hostname - Country: $country" }
if {[info exists state]} { puthelp "privmsg $chan :\[\002$text\002\] State: $state - City: $city"}
}
}
# tutup info exists f
}
# tutup foreach
}
# tutup string match "*.id"
} elseif {[string match "*.org" $text]} {
set connect [::http::geturl https://tools.whois.com.au/whois/$text]
set files [::http::data $connect]
::http::cleanup $files
set l [regexp -all -inline -- {Created On:(.*?)UTC.*?Last Updated On:(.*?)UTC.*?Expiration Date:(.*?)Sponsoring Registrar:(.*?)Status:.*?Registrant Street1:(.*?)Registrant Street2:.*?Registrant City:(.*?)Registrant State/Province:(.*?)Registrant Postal Code:(.*?)Registrant Country:(.*?)Registrant Phone:.*?Registrant Email:(.*?)Admin ID} $files]
foreach {black a b c d e f g h i j} $l {
set a [string trim $a " \n"]
set b [string trim $b " \n"]
set c [string trim $c " \n"]
set d [string trim $d " \n"]
set e [string trim $e " \n"]
set f [string trim $f " \n"]
set g [string trim $g " \n"]
set h [string trim $h " \n"]
set i [string trim $i " \n"]
set j [string trim $j " \n"]
regsub -all {<.+?>} $a {} a
regsub -all {<.+?>} $b {} b
regsub -all {<.+?>} $c {} c
regsub -all {<.+?>} $d {} d
regsub -all {<.+?>} $e {} e
regsub -all {<.+?>} $f {} f
regsub -all {<.+?>} $g {} g
regsub -all {<.+?>} $h {} h
regsub -all {<.+?>} $i {} i
regsub -all {<.+?>} $j {} j
if {[info exists a]} { putserv "PRIVMSG $chan :\[\002$text\002\] Created: $a - Update: $b - Exp: $c - Registrar: $d - Email: $j"
set connect2 [::http::geturl https://tools.whois.com.au/dig/$text]
set files2 [::http::data $connect2]
::http::cleanup $files2
set l2 [regexp -all -inline -- {<td headers="th-ip-1">(.*?)</td>} $files2]
foreach {blue z } $l2 {
set a [string trim $z " \n"]
regsub -all {<.+?>} $z {} z
if {[info exists z]} {
set connect3 [::http::geturl http://whatismyipaddress.com/ip/$z]
set files3 [::http::data $connect3]
::http::cleanup $files3
regexp -- {ISP:</th><td>(.*?)</td></tr><tr><th>Organization} $files3 - isp
regexp -- {Country:</th><td>(.*?) <img src=} $files3 - country
regexp -- {Hostname:</th><td>(.*?)</td></tr>} $files3 - hostname
regexp -- {State/Region:</th><td>(.*?)</td></tr>} $files3 - state
regexp -- {City:</th><td>(.*?)</td></tr>} $files3 - city
if {[info exists country]} { puthelp "privmsg $chan :\[\002$text\002\] IP: $z - ISP: $isp - Hostname: $hostname - Country: $country" }
if {[info exists state]} { puthelp "privmsg $chan :\[\002$text\002\] State: $state - City: $city"}
}
}
# tutup info exists f
}
# tutup foreach
# }
# tutup string match "*.org"
} else {
set connect [::http::geturl https://tools.whois.com.au/whois/$text]
set files [::http::data $connect]
::http::cleanup $files
set l [regexp -all -inline -- {Domain Name:(.*?)Registrar:(.*?)Whois Server:.*?Updated Date:(.*?)Creation Date:(.*?)Expiration Date:(.*?)>>>} $files]
foreach {red a b c d e } $l {
set a [string trim $a " \n"]
set b [string trim $b " \n"]
set c [string trim $c " \n"]
set d [string trim $d " \n"]
set e [string trim $e " \n"]
regsub -all {<.+?>} $a {} a
regsub -all {<.+?>} $b {} b
regsub -all {<.+?>} $c {} c
regsub -all {<.+?>} $d {} d
regsub -all {<.+?>} $e {} e
if {[info exists b]} { putserv "PRIVMSG $chan : \[\002$text\002\] Registrar: $b - Updated Date: $c - Creation Date: $d - Expiration Date: $e" }
set connect2 [::http::geturl https://tools.whois.com.au/dig/$text]
set files2 [::http::data $connect2]
::http::cleanup $files2
set l2 [regexp -all -inline -- {<td headers="th-ip-1">(.*?)</td>} $files2]
foreach {blue z } $l2 {
set a [string trim $z " \n"]
regsub -all {<.+?>} $z {} z
if {[info exists z]} {
set connect3 [::http::geturl http://whatismyipaddress.com/ip/$z]
set files3 [::http::data $connect3]
::http::cleanup $files3
regexp -- {ISP:</th><td>(.*?)</td></tr><tr><th>Organization} $files3 - isp
regexp -- {Country:</th><td>(.*?) <img src=} $files3 - country
regexp -- {Hostname:</th><td>(.*?)</td></tr>} $files3 - hostname
regexp -- {State/Region:</th><td>(.*?)</td></tr>} $files3 - state
regexp -- {City:</th><td>(.*?)</td></tr>} $files3 - city
if {[info exists country]} { puthelp "privmsg $chan : \[\002$text\002\] IP: $z - ISP: $isp - Hostname: $hostname - Country: $country" }
if {[info exists state]} { puthelp "privmsg $chan : \[\002$text\002\] State: $state - City: $city" }
}
}
}
}
}
#bind pub - !ip msg_ipwhois
#proc msg_ipwhois {nick uhost hand chan text} {
# global botnick
# if {$text == "" } {putquick "PRIVMSG $chan :You have to use true command for look up whois information. Command: !ip ipnumber";return}
# if {[string match "*" $text]} {
# set connect [::http::geturl http://whatismyipaddress.com/ip/$text]
# set files [::http::data $connect]
# ::http::cleanup $files
# regexp -- {ISP:</th><td>(.*?)</td></tr><tr><th>Organization} $files - isp
# regexp -- {Country:</th><td>(.*?) <img src=} $files - country
# regexp -- {Hostname:</th><td>(.*?)</td></tr>} $files - hostname
# regexp -- {State/Region:</th><td>(.*?)</td></tr>} $files - state
# regexp -- {City:</th><td>(.*?)</td></tr>} $files - city
#if {[info exists country]} {
# puthelp "privmsg $chan :IP: $text - ISP: $isp - Hostname: $hostname - Country: $country"
#if {[info exists state]} {
# puthelp "privmsg $chan :State: $state - City: $city"
#}
#} else { puthelp "privmsg $chan :Invalid address or IP not found" }
# }
#}
set whoisinfo(port) 43
set whoisinfo(ripe) "whois.ripe.net"
set whoisinfo(arin) "whois.arin.net"
set whoisinfo(apnic) "whois.apnic.net"
set whoisinfo(lacnic) "whois.lacnic.net"
set whoisinfo(afrinic) "whois.afrinic.net"
bind pub - !ip pub_whoisinfo
bind pub - .ip pub_whoisinfo
proc whoisinfo_setarray {} {
global query
set query(netname) "(none)"
set query(country) "(none)"
set query(orgname) "(none)"
set query(orgid) "(none)"
set query(range) "(none)"
}
proc whoisinfo_display { chan } {
global query
putlog "Firstline: $query(firstline)"
putquick "PRIVMSG $chan :Range : $query(range) - NetName : $query(netname) - Organization : $query(orgname) - Country : $query(country)"
}
proc pub_whoisinfo {nick uhost handle chan search} {
global whoisinfo
global query
whoisinfo_setarray
if {[whoisinfo_whois $whoisinfo(arin) $search]==1} {
if {[string compare [string toupper $query(orgid)] "RIPE"]==0} {
if {[whoisinfo_whois $whoisinfo(ripe) $search]==1} {
whoisinfo_display $chan
}
} elseif {[string compare [string toupper $query(orgid)] "APNIC"]==0} {
if {[whoisinfo_whois $whoisinfo(apnic) $search]==1} {
whoisinfo_display $chan
}
} elseif {[string compare [string toupper $query(orgid)] "LACNIC"]==0} {
if {[whoisinfo_whois $whoisinfo(lacnic) $search]==1} {
whoisinfo_display $chan
}
} elseif {[string compare [string toupper $query(orgid)] "AFRINIC"]==0} {
if {[whoisinfo_whois $whoisinfo(afrinic) $search]==1} {
whoisinfo_display $chan
}
} else {
whoisinfo_display $chan
}
} else {
if { [info exist query(firstline)] } {
puthelp "PRIVMSG $chan :$query(firstline)"
} else {
puthelp "PRIVMSG $chan :Error!"
}
}
}
proc whoisinfo_whois {server search} {
global whoisinfo
global query
set desccount 0
set firstline 0
set reply 0
putlog "Whois: $server:$whoisinfo(port) -> $search"
if {[catch {set sock [socket -async $server $whoisinfo(port)]} sockerr]} {
puthelp "PRIVMSG $chan :Error: $sockerr. Try again later."
close $sock
return 0
}
puts $sock $search
flush $sock
while {[gets $sock whoisline]>=0} {
putlog "Whois: $whoisline"
if {[string index $whoisline 0]!="#" && [string index $whoisline 0]!="%" && $firstline==0} {
if {[string trim $whoisline]!=""} {
set query(firstline) [string trim $whoisline]
set firstline 1
}
}
if {[regexp -nocase {netname:(.*)} $whoisline all item]} {
set query(netname) [string trim $item]
set reply 1
} elseif {[regexp -nocase {owner-c:(.*)} $whoisline all item]} {
set query(netname) [string trim $item]
set reply 1
} elseif {[regexp -nocase {country:(.*)} $whoisline all item]} {
set query(country) [string trim $item]
set reply 1
} elseif {[regexp -nocase {descr:(.*)} $whoisline all item] && $desccount==0} {
set query(orgname) [string trim $item]
set desccount 1
set reply 1
} elseif {[regexp -nocase {orgname:(.*)} $whoisline all item]} {
set query(orgname) [string trim $item]
set reply 1
} elseif {[regexp -nocase {owner:(.*)} $whoisline all item]} {
set query(orgname) [string trim $item]
set reply 1
} elseif {[regexp -nocase {orgid:(.*)} $whoisline all item]} {
set query(orgid) [string trim $item]
set reply 1
} elseif {[regexp -nocase {inetnum:(.*)} $whoisline all item]} {
set query(range) [string trim $item]
set reply 1
} elseif {[regexp -nocase {netrange:(.*)} $whoisline all item]} {
set query(range) [string trim $item]
set reply 1
}
}
close $sock
return $reply
}
bind pub - !check msg_domain
proc msg_domain {nick uhost hand chan text} {
global botnick
if {$text == "" } {putquick "PRIVMSG $chan :You have to use true command for look up whois information. Command: !check domain";return}
if {[string match "*" $text]} {
set connect [::http::geturl http://www.isup.me/$text]
set isup [::http::data $connect]
::http::cleanup $isup
regexp -- {class="domain">.*?</a></span> (.*?)
<p><a href.*?</a></p>} $isup - hasil
if {[info exists hasil]} { puthelp "privmsg $chan :$nick, web server na $text $hasil" } else { puthelp "privmsg $chan :Kayaknya down br0 ?" }
}
}
bind pub - !help msg_help
proc msg_help {nick uhost hand chan text} {
global botnick
if {$text == "" } {putquick "PRIVMSG $nick :!help twitter";return}
puthelp "privmsg $nick : Silahkan baca full commandnya di http://www.kaskus.xxx/twit.txt"
}
putlog "whois.tcl v1.1 by dono Loaded..."