PHP irc bot function library by me

Questions about programming languages and debugging
Post Reply
User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

PHP irc bot function library by me

Post by Gogeta70 »

I was bored so i made this for anybody that feels like making an IRC bot. It's a PHP file full of functions useful for IRC function such as banning, joining a channel, oping, kicking, etc.

Code: Select all

function send($con, $msg)
{
fputs($con, $msg . "\r\n");
}

function join($con, $channel)
{
send($con, "JOIN $channel");
}

function op($con, $channel, $user)
{
send($con, "MODE $channel +o $user");
}

function unop($con, $channel, $user)
{
send($con, "MODE $channel -o $user");
}

function ban($con, $channel $user);
{
send($con, "MODE $channel +b $user");
}

function unban($con, $channel, $user)
{
send($con, "MODE $channel -b $user");
}

function kick($con, $channel, $user)
{
send($con, "KICK $channel $user");
}

function kb($con, $channel, $user)
{
send($con, "MODE $channel +b $user");
send($con, "KICK $channel $user");
}

function part($con, $channel)
{
send($con, "PART $channel");
}

function oper($con, $user, $password)
{
send($con, "OPER $user $password");
}

function say($con, $channel, $sentence)
{
send($con, "PRIVMSG $channel :$sentence");
}

function encrypt($method, $string)
{
if($method == "sha1")
{
$hash = sha1($string);
}
if($method == "md5")
{
$hash = md5($string);
}
if($hash == "ripemd128")
{
$hash = hash("ripemd128", $string);
}
if($method == "snefru")
{
$hash = hash("snefru", $string);
}
if($method == "gost")
{
$hash = hash("gost", $string);
}
if($method == "adler32")
{
$hash = hash("adler32", $string);
}
return $hash;
}
Enjoy.

Note:

To add this into your bot, save it to a .php file and add the following line to the beginning of your bot:

Code: Select all

include("file.php");
¯\_(ツ)_/¯ It works on my machine...

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

well done! :)

because you're the botmaster I think you can answer my question:
How is it possible to cause outgoing traffic from a bot, sending a ping or loading an URL for example? can you supply me with a function?
because it would be good to block such traffic, a while ago (neo130 will remember) 2 bots opened a channel on the server, and I am sure they didn't do this because they wanted to create a chat channel....it was most likely done to abuse the server for scanning sites for RFI flaws, etc.
of course I kicked them off the server and banned the whole IP range, but in the long run it would be better to make this impossible in general.

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

Nice

Post by maboroshi »

Nice Gogeta :D

Keep the code coming

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Post by Gogeta70 »

Thanks mab.

B_b, to cause outgoing traffic, you first have to have a connection to a server.

Generally, something like this:

Code: Select all

<?PHP

$con = fsockopen("irc.suck-oold.com", 6667);
fputs($con, "blah blah blah");

?>
Or if you want to load a url:

Code: Select all

<?PHP

$con = fopen("http://google.com", 80);

$website = NULL;
while(!feof($con))
{
$website .= fgets($website, 4096);
}

echo $website;
?>
I hope this helps... :)
¯\_(ツ)_/¯ It works on my machine...

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

alrighty, thanks buddy.... :D will go through php.ini a little to see what can be done, fopen() is blocked already as far as I remember... :-k

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Post by Gogeta70 »

Alright, then you can use fsockopen(); however that will make you send raw commands, like "GET HTTP1.1 index.html" or whatever.
¯\_(ツ)_/¯ It works on my machine...

Post Reply