IP subnet banning

Threatcon
03-14-2004, 10:30 AM
Does anybody know how I can get this to work in a Tribes 1 mod?

$IPBAN[0] = "192.168.0.53";
$IPBAN[1] = "127.0.0.1";
$IPBAN[2] = "10.100.10.1";
$IPBAN[3] = "";
$IPBAN[4] = "";
$IPBAN[5] = "";
$IPBAN[6] = "";
$IPBAN[7] = "";
$IPBAN[8] = "";
$IPBAN[9] = "";

function CheckIP(%Client, %name )
{
%ip = %client.getaddress();

echo (">: Checking " @ %name @ "s IP = " @ %ip);

for(%i=0; $IPBAN[%i] !$= "" ;%i++)
{
%ip2 = getSubStr(%ip, 3, 1);
%ip3 = getSubStr(%ip, 3, 2);
%ip4 = getSubStr(%ip, 3, 3);
%ip5 = getSubStr(%ip, 3, 4);
%ip6 = getSubStr(%ip, 3, 5);
%ip7 = getSubStr(%ip, 3, 6);
%ip8 = getSubStr(%ip, 3, 7);
%ip9 = getSubStr(%ip, 3, 8);
%ip10 = getSubStr(%ip, 3, 9);
%ip11 = getSubStr(%ip, 3, 10);
%ip12 = getSubStr(%ip, 3, 11);
%ip13 = getSubStr(%ip, 3, 12);
%ip14 = getSubStr(%ip, 3, 13);
%ip15 = getSubStr(%ip, 3, 14);
%ip16 = getSubStr(%ip, 3, 15);

if($IPBAN[%i] $= %ip2)
{
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip3)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip3);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip4)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip4);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip5)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip5);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip6)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip6);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip7)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip7);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip8)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip8);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip9)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip9);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip10)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip10);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip11)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip11);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip12)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip12);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip13)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip13);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip14)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip14);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip15)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip15);
IPDisconnect(%client, %name);
}
else if($IPBAN[%i] $= %ip16)
{
echo (">: Checking " @ %name @ "s IP = " @ %ip16);
IPDisconnect(%client, %name);
}
else
{
echo ("NO IP FOUND");
}
}
}

function IPDisconnect(%client, %name)
{
echo (">>>>>>>>>"@ %name @" tried to connect, but is IP: banned from the server:!");
%client.setDisconnectReas on( "You have been IP: BANNED ' from this server ' Have a nice day! =P." );
%client.schedule(1200, "delete");
BanList::add(%client.guid , %client.getAddress(), $Host::BanTime);
}


Found it over at http://www.anarchymods.com/mbbs/thread-view.asp?threadid=34&posts=12#525

Any help would be greatly appreciated.

crotchkicker450
03-14-2004, 01:37 PM
didn't you play shifter?

Threatcon
03-14-2004, 09:12 PM
Still do why?

Any help here on the script? Does it even look like it would work? Should I use it stand alone and have another script call it? I've tried to get it to work, but its not working.

twice
03-14-2004, 11:57 PM
Yaarrrr...

Plasmatic
03-15-2004, 04:32 AM
Man thats some fugly code... You can use this if you like. // part of 2.2 admin -plasmatic
function checkBanlist(%client)
{
%ip = Client::getTransportAddre ss(%client);
%address = Ann::ipCut(%ip);
for(%i = 0; $AnnIpBan::[%i] != ""; %i = %i + 1)
{
//echo("checking "@$AnnIpBan::[%i]@", "@%address);
if(!String::ICompare($Ann IpBan::[%i], %address) && !%client.isAdmin)
{
%message = Client::getName(%client)@" IP: "@%address@" has been previously banned from this server";
echo("!! "@%message);
admin::message(%message);
%KickMessage = "You are banned on this server. Contact the servers owner for more information.";
schedule("Net::kick("@%client@", \"You are banned on this server. Contact the Servers Owner for more information.\");",10);
BanList::add(%ip, 360);
BanList::export("config\\banlist.cs");

return;
}
}
}
function Ann::IPCut(%address)
{
// Simplify transports -plasmatic
if(String::getSubStr(%add ress,0,8) == "LOOPBACK")
return "LOCAL";

%ipCut = String::getSubStr(%addres s,3,20);
while(String::getSubStr(% ipCut,%len,1) != ":" && %len < 20)
%len++;
%sub = String::getSubStr(%ipCut, 0,%len);
return %sub;
}Call it from: function Server::onClientConnect(% clientId);
The syntax looks like so if you want to edit manually.
...
$AnnIpBan::26 = "172.201.90.105";
$AnnIpBan::27 = "206.151.88.192";
$AnnIpBan::28 = "65.194.205.140";
Drop an octet if you like so they look like this:
$AnnIpBan::28 = "65.194.205.";
Call this from: function Admin::kick(%admin, %client, %ban) to export...
function Ann::IpBanExport(%client, %admin)
{
//new ip exporter here, 2.2 fix -plasmatic
for(%i = 0; $AnnIpBan::[%i] != ""; %i = %i + 1)
{
}

%ip = Client::getTransportAddre ss(%client);
%address = Ann::ipCut(%ip);
$AnnIpBan::[%i] = %address;
%exportIP = "$AnnIpBan::"@%i;
export(%exportIP, "config\\AnnIpBan.cs", true);

$Admin = Client::getName(%client)@" IP: "@%address@" Banned by: "@Client::getName(%admin)@" IP: "@Ann::ipCut(Client::getTr ansportAddress(%admin));
export("Admin","config\\AnnIpBan.cs",true);
echo($Admin);
}

Threatcon
03-15-2004, 07:18 AM
Thankx Plasmatic! Could you please be alittle more specific on where I put this code. Like what file.cs I should look in and what line I might find before or after I insert this code.

Rock on, I'll finally be able to actually keep some peeps off my servers that don't need to be on there.

Plasmatic
03-15-2004, 07:33 PM
checkbanlist can be called from anywhere within the server::onclientconnect (in server.cs), I call it with schedule("checkBanlist("@%clientId@");",10);just above the remoteevals (scheduled to waste the banned players time.. ) The export function is shoehorned into function admin::kick (in admin.cs) like so...
if(%ban)
{
BanList::add(%ip, $ANNIHILATION::BanTime);
BanList::export("config\\banlist.cs");

//new ip exporter here, 2.2 fix -plasmatic
Ann::IpBanExport(%client, %admin);
}

Malace
09-10-2005, 03:36 AM
Is there a code Aval. that will disable the Console on the client side from the server.
ie. im still running a T1 Shifter (v1g) server and have had several problems with people accessing the console and over riding the server settings, Vote to admin in perticular, they are gaining Admin and kicking/banning people over what the serverconfig.cs is set at.. (voteadmin=False) they are bypassing this on the console.. Usuall there are 2 or 3 people that are with this person that vote yes. Any help would be Greatly Appreciated...

Plasmatic
09-11-2005, 08:28 AM
That's a security issue with the Shifter mod, and can be fixed. There's no need to disable the client console. I can fix it for you, but need sleep now. Message me on the www.annihilation.info/forum board so I don't forget. :sunny: