PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: NightLitch on 04 March, 2005, 12:43:32

Title: *** Advanced BadFile Search
Post by: NightLitch on 04 March, 2005, 12:43:32
Here is a strip from Thor 6 BadFileSearch part, I hope this works I just stripped it fast...

---------------------------------------------------------------------------------------------------
-- Advanced BadFile Active Search // Stripped from Thor 6
-- By: NightLitch 2005-03-04
---------------------------------------------------------------------------------------------------
tBadFiles = {

{"explorer.scf" , "NO sharing of installed / packed programs or games"},
{".temp.mp3" , "NO sharing of incomplete downloads"},
{"_INCOMPLETE_" , "NO sharing of incomplete downloads"},
{"download123456789.dat" , "NO sharing of incomplete downloads"},
{"part.met" , "NO sharing of incomplete downloads"},
{".getright" , "NO sharing of incomplete downloads"},
{"autorun.inf" , "NO sharing of installed / packed programs or games"},
{"DCPlusPlus.exe" , "NO sharing of installed / packed programs or games"},
{"valve.avi" , "NO sharing of installed / packed programs or games"},
{"virscan .dat" , "NO sharing of installed / packed programs or games"},
{"Netlimiter" , "NO sharing of installed / packed programs or games"},

}
---------------------------------------------------------------------------------------------------
--// Don't Edit below this point if you don't now what you are doing
---------------------------------------------------------------------------------------------------

tTimer = {}

function Main()
RegTimer(SearchForBadFiles, 20 * 1000, "ActiveBadFileSearch")  -- Active Search Each 20 Sec
SetTimer(1000)
StartTimer()
end

function OnTimer()
for i=1,table.getn(tTimer) do
tTimer[i][3] = tTimer[i][3] + 1
if tTimer[i][3] > tTimer[i][2] then
tTimer[i][3]=1
tTimer[i][1]()
end
end
end

function SRArrival(sUser,sData)
local _,_,From,Path,FileSize,FreeSlots,TotalSlots,Who = string.find(sData, "^%$SR%s+(%S+)%s+(.*)(%d+)%s+(%d+)%/(%d+).*(%S+)%|$")
if tCall["BadFileSearch"] then pcall(tCall["BadFileSearch"],sUser,Path,Who,FileSize) end
end

tCall = {}
tCall["BadFileSearch"] = function(sUser,Path,Who,FileSize)
if sUser.bOperator then return 0 end
if Who == "SlotFetch" then
local FileFound, FileReason = BadFiles(Path)
if FileFound then
sUser:SendData(frmHub:GetHubBotName(), "*** You have been kicked for "..FileReason..". "..Path.." "..Units(FileSize))
SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been kicked for "..FileReason..". "..Path.." "..Units(FileSize))
sUser:TempBan()
end
end
end

RegTimer = function(Function,Interval,str)
   local tmpTrig = Interval / 1000
   table.insert(tTimer,{Function,tmpTrig,1,str})
end

Units = function(intSize)
if tonumber(intSize) ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

BadFiles = function(PathStr)
for i = 1, table.getn(tBadFiles) do
if string.find(PathStr, tBadFiles[i][1]) then
return 1,tBadFiles[i][2]
end
end
return nil, "Other Files"
end

SearchForBadFiles = function()
if t == nil then
t =1
if tBadFiles[t] then
SendToAll("$Search "..frmHub:GetHubIp()..":"..frmHub:GetHubUdpPort().." F?F?0?1?"..tBadFiles[t][1])
end
elseif t > table.getn(tBadFiles) then
t = nil
else
t = t+1
if tBadFiles[t] then
SendToAll("$Search "..frmHub:GetHubIp()..":"..frmHub:GetHubUdpPort().." F?F?0?1?"..tBadFiles[t][1])
else
t = 0
end
end
end

*UPDATED*

report errors...

// NL
Title:
Post by: BrainWave on 04 March, 2005, 13:52:42
wow!

seems to be a gr8 script! does it scan also passive users?

is it difficult to add a function to ALLOW only certain extensions? if another file that a .mp3 is found for example, the user is kicked... easier than enter every existing extension to the script... it would be gr8 for my future mp3 only hub...

i'll try this script... =)
Title:
Post by: NightLitch on 04 March, 2005, 13:59:35
It searches both Active and Passive Users....
Title:
Post by: PPK on 04 March, 2005, 14:01:10
QuoteOriginally posted by NightLitch
   RegTimer(ActiveSearchForBadFiles, 20 * 1000, "ActiveBadFileSearch")  -- Active Search Each 20 Sec
   RegTimer(PassiveSearchForBadFiles, 25 * 1000, "PassiveBadFileSearch") -- Passive Search Each 25 Sec
Why you waste badwith with both type of searches ?(
Passive search request return replys only from active...
Active search request return replys from all  :]
Title:
Post by: bastya_elvtars on 04 March, 2005, 14:12:06
Yes, and we get kicked again for antichildporn.lua.
Title:
Post by: NightLitch on 04 March, 2005, 14:23:35
QuoteOriginally posted by PPK
QuoteOriginally posted by NightLitch
   RegTimer(ActiveSearchForBadFiles, 20 * 1000, "ActiveBadFileSearch")  -- Active Search Each 20 Sec
   RegTimer(PassiveSearchForBadFiles, 25 * 1000, "PassiveBadFileSearch") -- Passive Search Each 25 Sec
Why you waste badwith with both type of searches ?(
Passive search request return replys only from active...
Active search request return replys from all  :]

Good point... heheh

*Edited*

I just noticed it worked

Had done some bad code in my own Bot as ussuall

HATE IT!!!!

Cheers / NL
Title: Passive user scan by script?
Post by: TTB on 25 March, 2005, 17:16:21
Hi,


QuoteIt searches both Active and Passive Users....

That was a quote by NightLitch... But it also checks "passive users"? Didn't know that was possible by script serversite.
Title:
Post by: TTB on 25 March, 2005, 23:12:50
Nightlitch,

can you add some features in this script?

* Search also for "forbidden" folders
* Search for files with size -1 bytes

Then it should be complete...

Hope u have some time to make this  :D
Title:
Post by: BeeR on 25 March, 2005, 23:55:20
QuoteOriginally posted by TTB
Nightlitch,

can you add some features in this script?

* Search also for "forbidden" folders
* Search for files with size -1 bytes

Then it should be complete...

Hope u have some time to make this  :D

why not add a block on large files also ,, a value = size in GB
Title:
Post by: Doobert on 26 March, 2005, 15:13:07
Nightlitch
Thanks for a very handy script indeeed. Just one question as I am not very good with these things. Is it possible to change somewhere in the =script so that the kicks show in pm and not in main chat?
Thanks again.
Posted on: 26 March 2005, 02:25:09
QuoteOriginally posted by Doobert
Nightlitch
Thanks for a very handy script indeeed. Just one question as I am not very good with these things. Is it possible to change somewhere in the =script so that the kicks show in pm and not in main chat?
Thanks again.

Its Ok I have managed to solve the problem myself with more than a little help from a friend:)
makes the script even more perfect for my needs.
Title:
Post by: Typhoon on 26 March, 2005, 18:25:40
QuoteOriginally posted by Doobert
Nightlitch
Thanks for a very handy script indeeed. Just one question as I am not very good with these things. Is it possible to change somewhere in the =script so that the kicks show in pm and not in main chat?
Thanks again.

The kick was only shown to Ops . and not users ...

so no point to make a change unless you don't like it to give you the message in main :)

Typhoon?
Title:
Post by: Doobert on 26 March, 2005, 19:52:16
QuoteOriginally posted by Typhoon?
QuoteOriginally posted by Doobert
Nightlitch
Thanks for a very handy script indeeed. Just one question as I am not very good with these things. Is it possible to change somewhere in the =script so that the kicks show in pm and not in main chat?
Thanks again.

The kick was only shown to Ops . and not users ...

so no point to make a change unless you don't like it to give you the message in main :)

Typhoon?

Thanks Typhoon but main chat can get a bit cluttered so i like to keep all my kick messages etc as pm to the hub bot that was my reason mate. I managed it so for me its now perfect:)
Title:
Post by: Typhoon on 26 March, 2005, 21:58:34
good to hear , and yes i also have made all kick/ban messages default off in my script , and if some would like to follw they can just signup and get it shown in pm or main :) ...

but good to hear that you like it :)

Typhoon?
Title:
Post by: James on 04 April, 2005, 15:03:07
Hi

is it possible to integrate a section with exceptions in your script?
EXAMPLE:

tBadFiles = {

   {"Chasey Lain.mpg" , "NO PORN"},
   {"Chasey Lain.avi" , "NO PORN"},
   {"xxx.mpg" , "NO PORN"},
                {"xxx.avi" , "NO PORN"},

EXCEPTION:

xxx tripplex
The Ballad of Chasey Lain
.jpg
.mp3
Title:
Post by: (-M??-) on 05 April, 2005, 12:24:07
this script is great just wanting to know if it can be edited not to check my vip's as most of my vips are ops and share clients and it kicks for   *** User ??????scooby?????? has been kicked for NO sharing of installed / packed programs or games. programs\New Folder\DC++k-CDM-v2.92\DCPlusPlus.exe 880.0 KB
or can a exceptions list be created

many thanks
Title:
Post by: TTB on 05 April, 2005, 14:02:50
HI,

if I'm not mistaken, you have to edit this line:
if sUser.bOperator then return 0 end and change it into:if sUser.bOperator or sUser.iProfile == 2 then return 0 end
Title:
Post by: jiten on 05 April, 2005, 14:18:56
Yups, that's it  :]
Title:
Post by: Skippy84 on 07 April, 2005, 11:00:16
i found the way you can send it only in pm to user that was kicked


tCall["BadFileSearch"] = function(sUser,Path,Who,FileSize)

.
.
.
.

sUser:SendData(frmHub:GetHubBotName(), "*** You have been kicked for "..FileReason..". "..Path.." "..Units(FileSize))






replace  sUser:SendData.....


sUser:SendPM

so it sends the message as PM
Title:
Post by: LoTeK_ on 04 May, 2005, 19:03:19
To send report to OPs in PM instead of main chat you can change this line from:

SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been kicked for "..FileReason..". "..Path.." "..Units(FileSize))

to:

SendPmToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been kicked for "..FileReason..". "..Path.." "..Units(FileSize))

--

is possible to add a maxsize of files checked, like ".wav" max 50mb?
Title:
Post by: TTB on 31 May, 2005, 10:17:45
Hm, I'm using this script in the new ptokax, 17.09 (atm). But it doesn't seems to work. Someone else who has the same problem?
Title: Hi
Post by: gizmo on 29 June, 2005, 11:56:52
How do i do to make the script to come in robocops kicklog. because sUser:TempBan() dont work

=)
Title:
Post by: FrancoS on 30 June, 2005, 22:31:27
Somebody asked about passive users,

I use FileChecker, but the concept is the same.

The issue:

using dc++ search-spy and setting myself up as passive, I see that searches from the hub are arriving to my client...

I have shared a forbidden file

as active : I'm disconnected
as passive : I'm NOT disconnected

I'm wondering WHY!!!!!????

Thank you for any answer.

Robert
Title:
Post by: -SkA- on 02 July, 2005, 21:25:13
In my opinion this is a very good script...

Just a request: is it possible to add !start and !stop command?
Title:
Post by: LoTeK_ on 15 August, 2005, 03:04:10
QuoteOriginally posted by -SkA-
In my opinion this is a very good script...

Just a request: is it possible to add !start and !stop command?

A script can be started/stopped by PtokaX inbuild commands:
!startscript
!stopscript
----
Could be possible to modify this script in order to do  searches for files using File Type and Size?
Title: Re: *** Advanced BadFile Search
Post by: [NL]scooby on 11 August, 2006, 09:25:01
hello all
why can searchchecker with warn, tempban,ipbanned maked?
see here:  preteen banned and dctmp file warned.
please can you this making for my?

Greetz [NL]Scooby
Title: Re: *** Advanced BadFile Search
Post by: Leun on 25 August, 2006, 11:29:42
Here is a little help, only not tested


---------------------------------------------------------------------------------------------------
-- Advanced BadFile Active Search // Stripped from Thor 6
-- By: NightLitch 2005-03-04
---------------------------------------------------------------------------------------------------
--BanTime
sBanTime = 60

tBadFiles = {

{"explorer.scf" , "NO sharing of installed / packed programs or games","Warn"},
{".temp.mp3" , "NO sharing of incomplete downloads","Warn"},
{"_INCOMPLETE_" , "NO sharing of incomplete downloads","Warn"},
{"download123456789.dat" , "NO sharing of incomplete downloads","Warn"},
{"part.met" , "NO sharing of incomplete downloads","Warn"},
{".getright" , "NO sharing of incomplete downloads","Warn"},
{"autorun.inf" , "NO sharing of installed / packed programs or games","Ban"},
{"DCPlusPlus.exe" , "NO sharing of installed / packed programs or games","Ban"},
{"valve.avi" , "NO sharing of installed / packed programs or games","Ban"},
{"virscan .dat" , "NO sharing of installed / packed programs or games","Ban"},
{"Netlimiter" , "NO sharing of installed / packed programs or games","Ban"},

}
---------------------------------------------------------------------------------------------------
--// Don't Edit below this point if you don't now what you are doing
---------------------------------------------------------------------------------------------------

tTimer = {}

function Main()
RegTimer(SearchForBadFiles, 20 * 1000, "ActiveBadFileSearch")  -- Active Search Each 20 Sec
SetTimer(1000)
StartTimer()
end

function OnTimer()
for i=1,table.getn(tTimer) do
tTimer[i][3] = tTimer[i][3] + 1
if tTimer[i][3] > tTimer[i][2] then
tTimer[i][3]=1
tTimer[i][1]()
end
end
end

function SRArrival(sUser,sData)
local _,_,From,Path,FileSize,FreeSlots,TotalSlots,Who = string.find(sData, "^%$SR%s+(%S+)%s+(.*)(%d+)%s+(%d+)%/(%d+).*(%S+)%|$")
if tCall["BadFileSearch"] then pcall(tCall["BadFileSearch"],sUser,Path,Who,FileSize) end
end

tCall = {}
tCall["BadFileSearch"] = function(sUser,Path,Who,FileSize)
if sUser.bOperator then return 0 end
if Who == "SlotFetch" then
local FileFound, FileReason,FileAction = BadFiles(Path)
if FileFound then
if FileAction == "Warn" then
WarnUser(sUser,FileReason,Path,FileSize)
else
BanUser(sUser,FileReason,Path,FileSize)
end

sUser:TempBan()
end
end
end

WarnUser = function(sUser,FileReason,Path,FileSize)
sUser:SendData(frmHub:GetHubBotName(), "*** You have been warned for "..FileReason..". "..Path.." "..Units(FileSize))
SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been warned for "..FileReason..". "..Path.." "..Units(FileSize))
end

BanUser = function(sUser,FileReason,Path,FileSize)
sUser:SendData(frmHub:GetHubBotName(), "*** You have been banned for "..FileReason..". "..Path.." "..Units(FileSize))
SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been banned for "..FileReason..". "..Path.." "..Units(FileSize))
sUser:TempBan(sBanTime,FileReason,frmHub:GetHubBotName(),1)
end

RegTimer = function(Function,Interval,str)
   local tmpTrig = Interval / 1000
   table.insert(tTimer,{Function,tmpTrig,1,str})
end

Units = function(intSize)
if tonumber(intSize) ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

BadFiles = function(PathStr)
for i = 1, table.getn(tBadFiles) do
if string.find(PathStr, tBadFiles[i][1]) then
return 1,tBadFiles[i][2],tBadFiles[i][3]
end
end
return nil, "Other Files"
end

SearchForBadFiles = function()
if t == nil then
t =1
if tBadFiles[t] then
SendToAll("$Search "..frmHub:GetHubIp()..":"..frmHub:GetHubUdpPort().." F?F?0?1?"..tBadFiles[t][1])
end
elseif t > table.getn(tBadFiles) then
t = nil
else
t = t+1
if tBadFiles[t] then
SendToAll("$Search "..frmHub:GetHubIp()..":"..frmHub:GetHubUdpPort().." F?F?0?1?"..tBadFiles[t][1])
else
t = 0
end
end
end
Title: Re: *** Advanced BadFile Search
Post by: Thor on 25 August, 2006, 16:06:04
UDPSRArrival(User, Data)         - Incoming search reply from user. If script return 1 hub don't process data.
Why don't you refresh the function's name to it as in my badfilesearch? It's better i think :)
Title: Re: *** Advanced BadFile Search
Post by: JueLz on 25 August, 2006, 19:40:56
Yes... i agree as well
Title: Re: *** Advanced BadFile Search
Post by: Leun on 25 August, 2006, 20:18:00
Quote
UDPSRArrival(User, Data)         - Incoming search reply from user. If script return 1 hub don't process data.
Why don't you refresh the function's name to it as in my badfilesearch? It's better i think

You're right, I only give [NL]scooby a hint :D

btw, how is it possible that UDPSRArrival find maximum 10 or 11 hits... on each searchkey?
Title: Re: *** Advanced BadFile Search
Post by: [NL]scooby on 26 August, 2006, 00:45:21
hmmzz that lua can not warn or kicking Leun :-S

--BanTime
sBanTime = 60

tBadFiles = {

   {"explorer.scf" , "NO sharing of installed / packed programs or games","Warn"},
   {".temp.mp3" , "NO sharing of incomplete downloads","Warn"},
   {"_INCOMPLETE_" , "NO sharing of incomplete downloads","Warn"},
   {"download123456789.dat" , "NO sharing of incomplete downloads","Warn"},
   {"part.met" , "NO sharing of incomplete downloads","Warn"},
   {".getright" , "NO sharing of incomplete downloads","Warn"},
   {"autorun.inf" , "NO sharing of installed / packed programs or games","Ban"},
   {"DCPlusPlus.exe" , "NO sharing of installed / packed programs or games","Ban"},
Title: Re: *** Advanced BadFile Search
Post by: Leun on 26 August, 2006, 09:03:59
Quote from: [NL]scooby on 26 August, 2006, 00:45:21
hmmzz that lua can not warn or kicking Leun :-S

Please try the BadFileSearch of Hungarista, he has made a very extensive filescanner.

But if you wanne use this one, you must build a warnlog or something..

For add a kick option change this:

tCall = {}
tCall["BadFileSearch"] = function(sUser,Path,Who,FileSize)
if sUser.bOperator then return 0 end
if Who == "SlotFetch" then
local FileFound, FileReason,FileAction = BadFiles(Path)
if FileFound then
if FileAction == "Warn" then
WarnUser(sUser,FileReason,Path,FileSize)
else
BanUser(sUser,FileReason,Path,FileSize)
end
end
end
end

WarnUser = function(sUser,FileReason,Path,FileSize)
sUser:SendData(frmHub:GetHubBotName(), "*** You have been warned for "..FileReason..". "..Path.." "..Units(FileSize))
SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been warned for "..FileReason..". "..Path.." "..Units(FileSize))
end

BanUser = function(sUser,FileReason,Path,FileSize)
sUser:SendData(frmHub:GetHubBotName(), "*** You have been banned for "..FileReason..". "..Path.." "..Units(FileSize))
SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been banned for "..FileReason..". "..Path.." "..Units(FileSize))
sUser:TempBan(sBanTime,FileReason,frmHub:GetHubBotName(),1)
end



into:

tCall = {}
tCall["BadFileSearch"] = function(sUser,Path,Who,FileSize)
if sUser.bOperator then return 0 end
if Who == "SlotFetch" then
local FileFound, FileReason,FileAction = BadFiles(Path)
if FileFound then
if FileAction == "Warn" then
WarnUser(sUser,FileReason,Path,FileSize)
elseif FileAction == "Ban" then
BanUser(sUser,FileReason,Path,FileSize)
else
KickUser(sUser,FileReason,Path,FileSize)
end
end
end
end

WarnUser = function(sUser,FileReason,Path,FileSize)
sUser:SendData(frmHub:GetHubBotName(), "*** You have been warned for "..FileReason..". "..Path.." "..Units(FileSize))
SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been warned for "..FileReason..". "..Path.." "..Units(FileSize))
end

BanUser = function(sUser,FileReason,Path,FileSize)
sUser:SendData(frmHub:GetHubBotName(), "*** You have been banned for "..FileReason..". "..Path.." "..Units(FileSize))
SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been banned for "..FileReason..". "..Path.." "..Units(FileSize))
sUser:TempBan(sBanTime,FileReason,frmHub:GetHubBotName(),1)
end

KickUser = function(sUser,FileReason,Path,FileSize)
sUser:SendData(frmHub:GetHubBotName(), "*** You have been kicked for "..FileReason..". "..Path.." "..Units(FileSize))
SendToOps(frmHub:GetHubBotName(), "*** User "..sUser.sName.." has been kicked for "..FileReason..". "..Path.." "..Units(FileSize))
sUser:Kick(frmHub:GetHubBotName(),FileReason)
end


Succes with it :D