Beware of Dog: Secure Query — File Browser
BewareofDogSecureQueryv1.19 / BewareofDogSecureQueryv1.19 / secQuery.mrc
secQuery.mrc — 18.01 KB — Download this file
;****************************************
;Beware of Dog: Secure Query 1.19 by krazy :: Coded using mIRC 6.16
;Can be found @: /server irc.rizon.net -j #help
;
;Refer to the readme.txt for more information.
;Enjoy!
;****************************************
alias blockall { .ignore -p * }
alias bod.pm.load { if ($lines($bod.pm.configfile) > 0) { .hload -i bod.config $bod.pm.configfile } }
alias bod.pm.save { .hsave -i bod.config $bod.pm.configfile }
alias bod.pm.version { return v1.19 }
alias bod.pm.messageSend { $iif(%bod.send.waitMessage,return sent,return not sent) }
alias bod.status { if (%bod.pm.active) { return active } | else { return inactive } }
alias bodActivate { set %bod.pm.active $true }
alias bodDeActivate { set %bod.pm.active $false }
alias bod.getMessage { return [ [ %bod.message ] ] }
alias bod.pm.configfile { return $mircdir\bod-settings.ini }
alias inform { set %bod.temp.inform $$1 | dialog -om inform inform }
alias squery { dialog -m squery squery }
alias unblockall { .ignore -pr * }
on *:START:{
if (!$hget(bod.queries)) {
.hmake -m bod.queries 50
.hmake -m bod.config 50
.bod.pm.load
}
}
on 1:EXIT:{
bod.pm.save
}
alias bod.pm.config {
set %bod.settings $mircdir\bod-settings.ini
set %bod.pm.active $true
set %bod.flood.count 0
set %bod.flood.max 6
set %bod.flood.resetTime 11
set %bod.send.waitMessage $true
set %bod.message I'm using (BOD: secure queries $bod.pm.version $+ ). Please standby for confirmation.
}
on *:LOAD:{
bod.pm.config
}
on ^*:OPEN:?:*:{
var %t = bod.queries
.timer.bod.flood.count.reset 1 %bod.flood.resetTime set % $+ bod.flood.count 0
if ($nick != $hget(%t,current)) {
inc %bod.flood.count
}
if (%bod.pm.active == $true) {
if (!$window(@messages)) { clearMemory | window -k0nlg2 @messages }
;Check if user is in white list.
var %x = 1
while (%x <= $numtok($hget(bod.config,whitelist),59)) {
var %nick = $gettok($hget(bod.config,whitelist),%x,59)
if ($nick == %nick) { goto kAprooved }
inc %x
}
var %find.user $+(*,$nick,$chr(58),*)
var %buf = $hget(%t,$nick $+ .extra)
if (%buf == $null) { hadd -m %t $nick $+ .extra 1 | %buf = $hget(%t,$nick $+ .extra) }
var %addto = $gettok(%buf,$numtok(%buf,59),59)
if ($calc($len($hget(%t,$nick $+ %addto)) + $len($1-)) >= 922) {
%addto = $calc($gettok(%buf,$numtok(%buf,59),59) + 1)
hadd -m %t $nick $+ .extra $append(%buf,%addto,59)
}
hadd -m %t $nick $+ %addto $append($hget(%t,$nick $+ %addto),$1-,1)
hadd -m %t $nick $+ .server $cid
if ($calc($len($hget(%t,$nick $+ .time)) + $len($timestamp)) >= 922) {
halt
}
hadd -m %t $nick $+ .time $append($hget(%t,$nick $+ .time),$timestamp,1)
if ($nick == $hget(%t,current)) { halt }
else { hadd -m %t current $nick }
if (%bod.flood.count == %bod.flood.max) {
echo -s [SQUERY]: Attempt at flood detected; outgoing messages will be halted for the next ( $+ %bod.flood.resetTime $+ ) seconds.
halt
}
if ($numtok($hget(%t,$nick $+ 1),1) >= 1) {
if (%bod.send.waitMessage) {
.Msg $nick %bod.message
}
aline -ph @messages $timestamp $+([,$nick,]:) $1-
}
halt
:kAprooved
hdel %t current
}
}
on *:CLOSE:?:{
var %t = bod.queries
if (%bod.pm.active == $true) {
clearinfo $target
}
}
alias append {
var %string = $1
var %append = $2
var %sep = $chr($3)
if (%string == $null) { return %append }
else { return %string $+ %sep $+ %append }
}
alias clearMemory {
.hfree -sw bod.queries
.hmake -m bod.queries 50
}
alias showconvo {
var %t = bod.queries
var %window
var %x = 1
query $1
var %buf = $hget(%t,$1 $+ .extra)
if (%buf != $null) {
var %i = 1
while (%i <= $gettok(%buf,$numtok(%buf,59),59)) {
%x = 1
while ($gettok($hget(%t,$1 $+ %i),%x,1) != $null) {
echo $1 $gettok($hget(%t,$1 $+ .time),%x,1) < $+ $1 $+ > $gettok($hget(%t,$1 $+ %i),%x,1)
inc %x
}
inc %i
}
}
if (%bod.send.waitMessage) {
.msg $1 Your query has been accepted.
}
if ($hget(%t,current) == $1) {
hdel %t current
}
}
alias clearinfo {
var %t = bod.queries
var %buf = $hget(%t,$1 $+ .extra)
hdel %t $1
hdel %t $1 $+ .time
hdel %t $1 $+ .server
var %x = 1
while (%x <= $gettok(%buf,$numtok(%buf,59),59)) {
hdel %t $1 $+ %x
inc %x
}
hdel %t $1 $+ .extra
}
alias kAllow {
var %t = bod.queries
if ($1 == $hget(bod.queries,current)) {
hdel %t current
}
if (%bod.pm.active == $true) {
scid $hget(%t, $1 $+ .server)
showconvo $1
clearinfo $1
}
else { $inform(Error: $crlf BOD: Secure Queries is De-Activated. $crlf Type /bodactivate to activate.) }
}
alias kdecline {
var %t = bod.queries
if ($1 == $hget(bod.queries,current)) {
hdel %t current
}
if (%bod.pm.active == $true) {
scid $hget(%t,$1 $+ .server)
clearinfo $1
hdel %t current
if (%bod.send.waitMessage) {
.msg $1 Your query has been declined.
}
}
else { $inform(Error: $crlf BOD: Secure Queries is De-Activated. $crlf Type /bodactivate to activate.) }
}
alias kAlwaysAllow {
if (%bod.pm.messageline == $null) { set %bod.pm.messageline }
if (%bod.pm.added == $null) { set %bod.pm.added }
if (%bod.pm.addto == $null) { set %bod.pm.addto }
var %left = $2
if (%left == $null) { var %left = 1 }
var %x = 1
var %exists = $false
while (%x <= $numtok($hget(bod.config,whitelist),59)) {
var %nick = $gettok($hget(bod.config,whitelist),%x,59)
if ($1 == %nick) { %exists = $true }
inc %x
}
if (%exists) {
set %bod.pm.added $addtok(%bod.pm.added,$1,44)
}
else {
.hadd -m bod.config whitelist $addtok($hget(bod.config,whitelist),$1,59)
set %bod.pm.addto $addtok(%bod.pm.addto,$1,44)
}
if (%left == 1) {
if (%bod.pm.addto) { set %bod.pm.messageline $addtok(%bod.pm.messageline,Added %bod.pm.addto to your white list.,13) }
if (%bod.pm.added) { set %bod.pm.messageline $addtok(%bod.pm.messageline,%bod.pm.added is already on your white list.,13) }
if ($chr(44) isin %bod.pm.messageline) {
var %last.nick = $gettok(%bod.pm.messageline,$numtok(%bod.pm.messageline,44),44)
%last.nick = $gettok(%last.nick,1,32)
set %bod.pm.messageline $replace(%bod.pm.messageline,$chr(44), $chr(44) $+ $chr(32))
set %bod.pm.messageline $replace(%bod.pm.messageline,%last.nick, and %last.nick)
}
.timer 1 5 .unset %bod.pm.messageline
.timer 1 5 .unset %bod.pm.added
.timer 1 5 .unset %bod.pm.addto
$inform(%bod.pm.messageline)
}
}
alias kRemoveAllow {
if (%bod.pm.messageline.rm == $null) { set %bod.pm.messageline.rm }
if (%bod.pm.removed == $null) { set %bod.pm.removed }
if (%bod.pm.gone == $null) { set %bod.pm.gone }
var %left = $2
if ($2 == $null) { %left = 1 }
if (%bod.pm.active == $true) {
var %x = 1
var %exists = $false
while (%x <= $numtok($hget(bod.config,whitelist),59)) {
var %nick = $gettok($hget(bod.config,whitelist),%x,59)
if ($1 == %nick) {
%exists = $true
.hadd bod.config whitelist $deltok($hget(bod.config,whitelist),%x,59)
}
inc %x
}
if (%exists) {
set %bod.pm.removed $addtok(%bod.pm.removed,$1,44)
}
else {
set %bod.pm.gone $addtok(%bod.pm.gone,$1,44)
}
if (%left == 1) {
if (%bod.pm.removed) {
if ($numtok(%bod.pm.removed,44) == 2) { set %bod.pm.removed $replace(%bod.pm.removed,$chr(44), $chr(32) $+ and $+ $chr(32) ) }
set %bod.pm.messageline.rm $addtok(%bod.pm.messageline.rm, Removed %bod.pm.removed from your white list.,13)
}
if (%bod.pm.gone) {
if ($numtok(%bod.pm.gone,44) == 2) { set %bod.pm.gone $replace(%bod.pm.removed,$chr(44), $chr(32) $+ and $+ $chr(32) ) }
set %bod.pm.messageline.rm $addtok(%bod.pm.messageline.rm, %bod.pm.gone was not found.,13)
}
if ($chr(44) isin %bod.pm.messageline.rm) {
var %last.nick = $gettok(%bod.pm.messageline.rm,$numtok(%bod.pm.messageline.rm,44),44)
%last.nick = $gettok(%last.nick,1,32)
set %bod.pm.messageline.rm $replace(%bod.pm.messageline.rm,$chr(44), $chr(44) $+ $chr(32))
set %bod.pm.messageline.rm $replace(%bod.pm.messageline.rm,%last.nick, and %last.nick)
}
.timer 1 5 .unset %bod.pm.messageline.rm
.timer 1 5 .unset %bod.pm.removed
.timer 1 5 .unset %bod.pm.gone
$inform(%bod.pm.messageline.rm)
}
}
else { $inform(Error: $crlf BOD: Secure Queries is De-Activated. $crlf Type /bodactivate to activate.) }
}
alias MasskAlwaysAllow {
var %i = $snick($1,0),%x
while (%i) {
if ($snick($1,%i)) {
%x = $snick($1,%i)
kAlwaysAllow %x %i
%x = ""
}
dec %i
}
bod.pm.save
}
alias MasskRemoveAllow {
var %i = $snick($1,0),%x
while (%i) {
if ($snick($1,%i)) {
%x = $snick($1,%i)
kremoveallow %x %i
%x = ""
}
dec %i
}
bod.pm.save
}
alias bod.fill.whitelist {
var %t = bod.queries
var %table = $1
var %list = $2
var %x = 1
var %nicks = $numtok($hget(bod.config,whitelist),59)
while (%x <= %nicks) {
var %nick = $gettok($hget(bod.config,whitelist),%x,59)
did -a %table %list %nick
inc %x
}
}
alias bod.queries {
var %ret = monitored
if ($ignore(0) >= 1) {
var %x = 1
while (%x <= $ignore(0)) {
if (($ignore(%x).type == private) && ($ignore(%x) == *!*@*)) { %ret = blocked }
inc %x
}
}
return %ret
}
alias bod.window.remove {
var %window = $1
var %string = $+(*,$2,*)
var %total = $line(%window,0)
var %x = 1
while (%x <= %total) {
var %line = $line(%window,%x)
if (%string iswm %line) {
dline %window %x
}
inc %x
}
}
Dialog inform {
Title "Message"
Size -1 -1 300 100
Text %bod.temp.inform , 1, 0 10 300 80, center
Button "OK", 2, 111 70 90 25,ok
}
on *:dialog:inform:sclick:*:{
if ($did == 2) { unset %bod.temp.inform }
}
Dialog squery {
Title "Secure Queries"
Size -1 -1 200 250
Tab "General", 1, 0 10 200 240,
Tab "Settings", 18
Tab "White List", 2
Text "Active", 3, 20 40 89 19, tab 1
Button "&on", 4, 30 56 30 19, tab 1
Button "o&ff", 5, 60 56 34 19, tab 1
Text "Queries", 6, 20 80 89 19, tab 1
Button "&Block ALL Queries", 7, 30 96 139 19, tab 1
Button "&Unblock ALL Queries", 8, 30 116 139 19, tab 1
List 9, 20 45 89 200, tab 2
Button "&add user", 10, 130 100 60 23, tab 2
Button "&remove user", 11, 120 125 70 23, tab 2
Box "Status", 12, 10 158 180 85, tab 1
Text • $bod.status, 13, 25 170 50 15, tab 1
Text • queries are $bod.queries, 14, 25 183 130 15, tab 1
Text • max lines: %bod.flood.max, 15, 25 196 100 15, tab 1
Text • seconds before flood reset: %bod.flood.resetTime, 16, 25 209 160 15, tab 1
Button "remov&e all", 17, 120 150 70 23, tab 2
Button "&Clear Unanswered Queries", 19, 30 136 139 18, tab 1
Text "Max lines before flood protection", 20, 10 115 180 15, tab 18
Edit %bod.flood.max, 22, 10 130 30 20, tab 18
Text "Seconds before reset", 23, 10 160 180 15, tab 18
Edit %bod.flood.resetTime, 25, 10 175 30 20, tab 18
Button "?", 26, 40 130 20 19, tab 18
Button "?", 27, 40 175 20 19, tab 18
check "Send 'wait for response' message.", 28, 10 40 180 15, tab 18
Text "Message to send:", 29, 10 60 100 15, tab 18
Edit $bod.getMessage, 30, 10 80 160 20, tab 18 autohs
Button "ok", 31, 80 199 120 23, tab 18
Button "?", 32, 175 80 20 19, tab 18
Text "————————————————————————————————————", 33, 10 100 180 15, tab 18 disabled
Button "Reset to Defaults", 34, 80 222 120 23, tab 18
Text • Messages are $bod.pm.messageSend, 35, 25 222 160 15, tab 1
}
on *:dialog:squery:sclick:*:{
bod.pm.save
var %t = bod.queries
if ($did == 2) {
.did -r $dname 9
.bod.fill.whitelist $dname 9
}
if ($did == 4) {
.bodactivate
.did -i $dname 13 13 • $bod.status
}
if ($did == 5) {
.boddeactivate
.did -i $dname 13 13 • $bod.status
}
if ($did == 7) {
.blockall
.did -i $dname 14 14 • queries are $bod.queries
}
if ($did == 8) {
.unblockall
.did -i $dname 14 14 • queries are $bod.queries
}
if ($did == 10) {
var %nick = $?="nickname of user to add:"
if (!$findtok($hget(bod.config,whitelist),%nick,1,59)) {
.hadd -m bod.config whitelist $addtok($hget(bod.config,whitelist),%nick,59)
.did -r $dname 9
.bod.fill.whitelist $dname 9
}
else { $inform(Error: %nick already exists on the white list.) }
}
if ($did == 11) {
if (!$did($dname,9).sel) { $inform(No selection made!) | halt }
var %nick = $did($dname,9,$did($dname,9).sel).text
.hadd bod.config whitelist $remtok($hget(bod.config,whitelist),%nick,1,59)
.did -r $dname 9
.bod.fill.whitelist $dname 9
}
if ($did == 17) {
%bod.remAll = $?!="Are you sure you want to remove ALL the entries in the white list?"
if (%bod.remAll) {
hdel bod.config whitelist
.did -r $dname 9
}
}
if ($did == 18) {
if (%bod.send.waitMessage) { .did -c $dname 28 }
else { .did -u $dname 28 }
}
if ($did == 19) {
if ($?!="Are you sure you want to clear ALL the queries?") {
if ($window(@messages)) {
clear @messages
}
.hfree -sw bod.queries
.hmake -m bod.queries 50
}
}
if ($did == 26) {
$inform(This is the maximum amount of times that you will respond with the "wait for approval"(if sending messages is activated) message in a given amount of time. This is to decrease the chance of flooding off. Default is reccomended.)
}
if ($did == 27) {
$inform(This is the amount of seconds to wait after the "max lines" limit has been reached. After the given amout of seconds $+ $chr(44) the script will start sending the "wait for response" message again. Default is reccomended.)
}
if ($did == 28) {
if ($did($dname,28).state == 0) {
set %bod.send.waitMessage $false
.did -i $dname 35 35 • Wait messages are not sent
}
else {
set %bod.send.waitMessage $true
.did -i $dname 35 35 • Wait messages are sent
}
}
if ($did == 31) {
.set %bod.message $did($dname,30).text
.set %bod.flood.max $did($dname,22).text
.set %bod.flood.resetTime $did($dname,25).text
.did -i $dname 15 15 • max lines: %bod.flood.max
.did -i $dname 16 16 • seconds before flood reset: %bod.flood.resetTime
if ($?!="Close window?") { dialog -x $dname }
}
if ($did == 32) {
$inform(The message the user will receive informing him/her to wait)
}
if ($did == 34) {
if ($?!"Reset all settings to defaults?") {
bod.pm.config
.did -i $dname 13 13 • $bod.status
.did -i $dname 14 14 • queries are $bod.queries
.did -i $dname 15 15 • max lines: %bod.flood.max
.did -i $dname 16 16 • seconds before flood reset: %bod.flood.resetTime
.did -i $dname 35 35 • Wait messages are sent
.did -i $dname 22 22 %bod.flood.max
.did -i $dname 25 25 %bod.flood.resetTime
.did -i $dname 30 30 %bod.message
$iif(%bod.send.waitMessage,.did -c $dname 28,.did -u $dname 28)
}
}
}
menu nicklist {
-
$iif($1,Secure Query)
.$iif($hget(bod.queries,current) != $1,$style(2)) Accept Query From $1:kallow $1
.$iif($hget(bod.queries,current) != $1,$style(2)) Decline Query From $1:kdecline $1
.Add selected to 'white list':masskalwaysallow $$chan
.Remove selected from 'white list':masskremoveallow $$chan
-
}
menu query {
-
$iif($1,Secure Query)
.$iif($hget(bod.queries,current) != $1,$style(2)) Allow Current Query From $hget(bod.queries,current):kallow $hget(bod.queries,current)
.$iif($hget(bod.queries,current) != $1,$style(2)) Decline Current Query From $hget(bod.queries,current):kdecline $hget(bod.queries,current)
.Add $1 to 'white list':kalwaysallow $$1
.Remove $1 from 'white list':kremoveallow $$1
-
}
menu channel,status {
$iif($server == $null,$style(2)) Secure Query
.$iif($hget(bod.queries,current) == $null,$style(2)) Allow Current Query From $hget(bod.queries,current):kallow $hget(bod.queries,current)
.$iif($hget(bod.queries,current) == $null,$style(2)) Decline Current Query From $hget(bod.queries,current):kdecline $hget(bod.queries,current)
.Open dialog:squery
}
menu @messages {
$strip($remove($gettok($1-,2,32),$chr(58)))
.Accept query:{
if (%bod.pm.active) {
kallow $left($right($strip($remove($2,$chr(58))),$calc($len($strip($remove($2,$chr(58)))) - 1)),$calc($len($strip($remove($2,$chr(58)))) - 2))
bod.window.remove @messages $2
}
else { $inform(Error: $crlf BOD: Secure Queries is De-Activated. $crlf Type /bodactivate to activate.) }
}
.Decline query :{
if (%bod.pm.active) {
kdecline $left($right($strip($remove($2,$chr(58))),$calc($len($strip($remove($2,$chr(58)))) - 1)),$calc($len($strip($remove($2,$chr(58)))) - 2))
bod.window.remove @messages $left($right($strip($remove($2,$chr(58))),$calc($len($strip($remove($2,$chr(58)))) - 1)),$calc($len($strip($remove($2,$chr(58)))) - 2))
}
else { $inform(Error: $crlf BOD: Secure Queries is De-Activated. $crlf Type /bodactivate to activate.) }
}
-
Decline ALL queries:{
if (%bod.pm.active) {
if ($?!="Are you sure you want to decline all the queries?") {
var %x = 1
if ($line(@messages,0) >= 6) { goto bod.clearAll }
while (%x <= $line(@messages,0)) {
var %nick = $gettok($line(@messages,%x),2,32)
kdecline $left($right($strip($remove(%nick,$chr(58))),$calc($len($strip($remove(%nick,$chr(58)))) - 1)),$calc($len($strip($remove(%nick,$chr(58)))) - 2))
inc %x
}
:bod.clearAll
clearMemory
clear @messages
}
}
else { $inform(Error: $crlf BOD: Secure Queries is De-Activated. $crlf Type /bodactivate to activate.) }
}
}