亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? irc bot in perl.html

?? 1000 HOWTOs for various needs [WINDOWS]
?? HTML
字號:
<html>

<head>
<title>Bare Bones IRC Bot In Perl - by b0iler</title>
</head>

<body bgcolor="black">
<font color="white">

<h1>Bare Bones IRC Bot In Perl.</h1>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; by b0iler : <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b0iler@hotmail.com : last update July 26th 2002<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Written for :<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://b0iler.eyeonsecurity.net">http://b0iler.eyeonsecurity.net</a> - my site full of other cool tutorials<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://blacksun.box.sk">http://blacksun.box.sk</a> - a legendary site full of original tutorials

<br><br><br>

This is a short guide to creating your own perl bot which will work on irc.  I will not 
cover all the different modules and ways to connect to irc and issue commands.  This 
will only cover connecting with IO::Socket and using raw irc commands.  I feel you learn 
the most this way and have alot of control over what is happening.

<br><br>

IRC experience is helpful, but I'll take things slow enough so that an absolute beginner 
can understand what is taking place.  This will also help those with alittle knowledge 
fully understand the irc protocol.  Although I am no irc expert, after creating this 
bot I did learn a few tricks.

<br><br>

We start off by getting a connection underway:

<br><pre>

#!/usr/bin/perl
use IO::Socket;

$sock = IO::Socket::INET->new(
	PeerAddr => 'irc.undernet.org', 
	PeerPort => 6667, 
	Proto => 'tcp' ) or die "could not make the connection";
</pre><br>

You can use any irc server and any port (commonly used ports are 6667-7000), so long 
as they are valid.  If you have problems try to find a different server on that 
network.  To make things easier you can make the PeerAddr a variable which is 
specified by an argument from the command line.  Or purhaps map out all the servers 
on the network and make an arry from them, connecting to random ones and using the 
best connection.  There are many possibilities, each work best for certain 
situations.  We'll stick to the simple hard coded address and port.

<br><br>

Now we have a connection to the server.  We still need to get connected/logged in to 
the ircd.  Anything we send to or recieve from the server will go through $sock.  So 
lets see what the server is sending us after we make a connection.

<br><pre>

while($line = &lt;$sock>){
	print "$line\n";
}
</pre><br>

We will see that the server prints out some lines.  Each line will have a number 
representation to it.  This will really help to tell the bot when to start and end 
routines.  The key here is the line with 'NOTICE AUTH' in it.  This is when we need 
to login to the irc server.  To do this we send 

<br><br>

NICK bots_nick<br>
USER bots_ident 0 0 :bots name

<br><br>

With a line break after the bots_nick and a line break at the end.  So in the while loop 
we will add something like this:

<br><pre>

while($line = &lt;$sock>){
	print $line;
	if($line =~ /(NOTICE AUTH).*(checking ident)/i){
		print $sock "NICK b0ilersbot\nUSER bot 0 0 :just a bot\n";
		last;
	}
}
</pre><br>

Now we are done with the login process.  If you are having any problems try to read up 
on the irc protocol and how to login to it with telnet.  Raven from www.securitywriters.org 
has wrote a decent tutorial on the subject, look for it.

<br><br>

Some servers will ask for a ping to make sure the client is active.  This is only done 
on some servers and is a common pitfall to many bots which don't support this kind of 
login proceedure.  To handle this we will check if the server wants us to ping it.  
The server will ask for a ping before it asks about nickserv registration/identification, 
so we will stop this loop after it mentions nickserv.  This is what those numbers in 
the last if statment are for, the 376|422.  The way to identify to nickserv is like this

<br><br>

NICKSERV :identify nick_password

<br><br>

this is just a simple irc command.  The command is 'NICKSERV' and the arguments are 
'identify nick_password' where nick_password is the actual password for this nick.  The 
line ends in a line break and all irc commands are in upper case.  When there is a : 
before something it means it is a multiple word argument (has spaces in it).  This is 
how we will handle the possible ping and the nickserv identification.

<br><pre>

while($line = &lt;$sock>){
	print $line;    
	#use next line if the server asks for a ping
	if($line =~ /^PING/){
		print $sock "PONG :" . (split(/ :/, $line))[1];
	}
	if($line =~ /(376|422)/i){
		print $sock "NICKSERV :identify nick_password\n";
		last;
	}
}
</pre><br>

If you want to have a registration code you can find this out on your own.. or do what I 
do and register the nick with a normal irc client.  This way we only need the bot to 
identify.

<br><br>

When you create your bot you can customize it however you want.  Most of my bots have 
alittle bit more AI then this tutorial shows.  This bot will be pretty strait forword 
and doesn't make many decisions.  It just connects and does something.

<br><br>

I like to make the bot sleep for a few seconds just to get the connection cought up.  
I am on a 56k and things can go slow sometimes.  A few times without the sleep the bot 
has joined channels before the nickserv identification is complete, this can be a pain 
in the neck if the bot needs a usermode or other circumstances which require the nick 
to be identified (such as other bots, +R channel mode, or trust issues with users).

<br><br>

After it sleeps it will join the channel.  You will see that the server prints out alot 
of information about the channel when you join.  You can save this information in 
variables to allow the bot to make many decisions.  Again, this is a simple bot and 
won't be aware of it's environment or be dynamic in anyway.  But you could for example 
turn on/off colors by what channel modes are set or who is in the channel (some people 
really hate colors).  This is the last bit of the login proccess, after this the bot 
can actually do something.

<br><pre>

sleep 3;
print $sock "JOIN #channel\n";
</pre><br>

Notice there is no : before #channel.  This is because it does not have any spaces in it.  
And the JOIN command is in all caps.  For a full list of commands try reading a tutorial 
on the IRC protocol.  I don't even cover the basics here, there are tons of useful to know 
commands.

<br><br>

Now we are joining the channel.  There is nothing else to do besides read the messages 
users send to the channel and respond to them.  But inorder to read the messages we need 
to parse them so they make sense.  The format of a priv_msg is as follows:

<br><br>

:nick!ident@hostname.com PRIVMSG #channel :the line of text

<br><br>

I like to seperate them into the following variables to make things easier to keep track of.  

<br><br>

:$nick!$hostname $type $channel :$text

<br><br>

in this example here is the values of the variables:

<br><br>

$nick = nick<br>
$hostname = ident<br>
$type = priv_msg<br>
$channel = #channel<br>
$text = the line of text

<br><br>

So we are going to need to parse what is send from the server into useable data.  This is 
how we'll do it.  There is only one twist here, and that is incase the server sends a 
ping.  They do this quite often to check and see if you are still connected.  If we don't 
reply the the pings then we will get disconnected.  When the server sends a ping you 
must reply with a PONG and the same characters the ping had.  So this is how we will send it

<br><pre>

while ($line = &lt;$sock>) {
	($command, $text) = split(/ :/, $line);   #$text is the stuff from the ping or the text from the server
	
	if ($command eq 'PING'){
		#while there is a line break - many different ways to do this
		while ( (index($text,"\r") >= 0) || (index($text,"\n") >= 0) ){ chop($text); }
		print $sock "PONG $text\n";
		next;
	}
	#done with ping handling
	
	($nick,$type,$channel) = split(/ /, $line); #split by spaces
	
	($nick,$hostname) = split(/!/, $nick); #split by ! to get nick and hostname seperate
	
	$nick =~ s/://; #remove :'s
	$text =~ s/://;
	
	#get rid of all line breaks.  Again, many different way of doing this.
	$/ = "\r\n";
	while($text =~ m#$/$#){ chomp($text); }
        
	#end of parsing, now for actions
}
</pre><br>

ok.  That was a rather large chunk of code and some parts were rather confusing.  Most of 
it is just getting rid of what we don't want and seperating what we do want into variables.
The next bit is just for looks.  We print out what is said as if this is a normal irc client.  

<br><pre>

if($channel eq '#channel'){
	print "&lt;$nick> $text";
}
</pre><br>

The $channel check is needed incase people priv_msg or notice you things.  This can be a 
problem when dealing with bots which need to be secure or can cause large headaches when 
things go wrong.  I'll leave dealing with multiple channels to you.  But to send Notices 
you simply do:  print $sock "NOTICE nick :the line of text here\n";  and to send a 
priv_msg you do:  print $sock "PRIVMSG nick :the line of text here\n"; 

<br><br>

Now the bot structure is done.  Everything required is done, the only thing left to do 
is custimize your bot to have it do what you want it to do.  This can be almost any sort 
of task imaginable.  Simply parse the $text $nick and other variables we created to 
have the bot make decisions on what to do.

<br><br>

Here is the final bot in whole.  I added one bit just to prove that the bot works:

<br><pre>
#!/usr/bin/perl
use IO::Socket;

$sock = IO::Socket::INET->new(
	PeerAddr => 'irc.undernet.org', 
	PeerPort => 6667, 
	Proto => 'tcp' ) or die "could not make the connection";
	
while($line = &lt;$sock>){
	print $line;
	if($line =~ /(NOTICE AUTH).*(checking ident)/i){
		print $sock "NICK b0ilersbot\nUSER bot 0 0 :just a bot\n";
		last;
	}
}

while($line = &lt;$sock>){
	print $line;    
	#use next line if the server asks for a ping
	if($line =~ /^PING/){
		print $sock "PONG :" . (split(/ :/, $line))[1];
	}
	if($line =~ /(376|422)/i){
		print $sock "NICKSERV :identify nick_password\n";
		last;
	}
}

sleep 3;
print $sock "JOIN #channel\n";

while ($line = &lt;$sock>) {
	($command, $text) = split(/ :/, $line);   #$text is the stuff from the ping or the text from the server
	
	if ($command eq 'PING'){
		#while there is a line break - many different ways to do this
		while ( (index($text,"\r") >= 0) || (index($text,"\n") >= 0) ){ chop($text); }
		print $sock "PONG $text\n";
		next;
	}
	#done with ping handling
	
	($nick,$type,$channel) = split(/ /, $line); #split by spaces
	
	($nick,$hostname) = split(/!/, $nick); #split by ! to get nick and hostname seperate
	
	$nick =~ s/://; #remove :'s
	$text =~ s/://;
	
	#get rid of all line breaks.  Again, many different way of doing this.
	$/ = "\r\n";
	while($text =~ m#$/$#){ chomp($text); }
	
	if($channel eq '#channel'){
		print "&lt;$nick> $text";
		
		if($text =~ /hi b0ilerbot/gi){
			print $sock "PRIVMSG #channel :hi $nick\n";
		}
	}
}
</pre><br>

Not very complicated once you look at each part of it.  But finding out things for yourself 
is the real fun of creating a bot.  Much trial and error is involved in perfecting the bot, 
adding security and function can be alot of fun.  I would like to stress the security of irc bots.  
They are in the most hostile environment known to the net and one security mistake and your 
bot could be used to execute commands on your box.  I have found 4 irc perl bots vulnerable 
to remote command execution, don't let me find yours vulnerable aswell!  Read all of the perl 
security related tutorials at <a href="http://b0iler.eyeonsecurity.net/tutorials/">http://b0iler.eyeonsecurity.net/tutorials/</a> 
Don't let this discurage you from coding your own bot, it's a great learning experience and as long as you 
are careful you should be fairly safe.  I would love to hear what kind of bots you come up with.  The bots
I have created include:

<br><br>

<b>quote bot</b>&nbsp; -&nbsp; a bot which has many features that deal with irc quotes.  it reads off funny/witty things 
people have said while chatting in my channels.  It also has some more advanced features such as listing 
off all the users in the channel who have a quote and an admin feature which allows me to add quotes while 
the bot is running.

<br><br>

<b>quiz bot</b>&nbsp; -&nbsp; A bot which quizes the channel users.  I used this while studying for networking.  This bot is 
great when the channel is dead or to start up a conversation with others.  I learned alot from this bot.

<br><br>

<b>poker bot</b>&nbsp; -&nbsp; A bot which plays poker.  I started to make a ucker (sp?) bot, but I lost motivation when the 
other people who wantted to play quit going on irc.

<br><br>

<b>channel bot</b>&nbsp; -&nbsp; A bot which enforces the channel rules.  it warns, kicks, and kick bans users for breaking the 
rules.  it voices,half ops, and ops identified users and keeps stats of channel activity.  Good for preventing 
channel takeovers.

<br><br>

The reason for creating this text was because I remember the stress I had finding info on this subject when 
I first created the bot.  I have since read a few crappy papers on irc bots, but nothing which would be very 
helpful.

<br><br>

<b>[-----]</b><br><br>

<a href="http://b0iler.eyeonsecurity.net">http://b0iler.eyeonsecurity.net</a>&nbsp; - is my homepage.&nbsp;  - Come and check out the message board some friends and I have started, many great disscussions to be had there.&nbsp; <a href="http://rawt.daemon.sh/wwwboard/">http://rawt.daemon.sh/wwwboard/</a>

<br><br>

I got tons of tutorials, mini-tutorials, advisories, and code written by me there.&nbsp; Come check out what I'm up to and possibly 
learn a bit.

<br><br>

<b>[-----]</b>

<br><br><br><br>
</body>
</html>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久88久久88久久久| 午夜av区久久| 亚洲国产综合91精品麻豆 | 欧美性一区二区| 欧美三电影在线| 日本一区二区三区国色天香| 综合精品久久久| 国产精品一二三四区| 欧美色手机在线观看| 久久久精品人体av艺术| 午夜精品免费在线| 色综合久久天天综合网| 久久久久久久久久久久久久久99 | 国产剧情在线观看一区二区| 在线影视一区二区三区| 国产婷婷色一区二区三区| 亚洲国产精品一区二区久久恐怖片 | 韩国成人精品a∨在线观看| 91久久免费观看| 中文字幕一区二区三区精华液| 另类小说欧美激情| 欧美男女性生活在线直播观看 | 精品91自产拍在线观看一区| 亚洲综合激情网| 99久久免费视频.com| 国产亚洲精品久| 精品一区二区三区免费观看| 91精品国产综合久久久久久久久久 | 在线播放亚洲一区| 一区二区三区国产精华| 99这里只有精品| 国产精品污污网站在线观看| 国产精品69久久久久水密桃| 精品久久国产97色综合| 日本系列欧美系列| 欧美精品18+| 日韩精品视频网| 91精品国产色综合久久ai换脸| 亚洲成人av电影在线| 欧美亚洲国产一区二区三区va | 亚洲天堂av一区| 成人av在线一区二区| 亚洲一级不卡视频| 色哟哟亚洲精品| 亚洲精品国产一区二区精华液| av一区二区不卡| 亚洲欧美欧美一区二区三区| 91网站在线播放| 亚洲综合色在线| 欧美精品三级在线观看| 日韩av高清在线观看| 日韩美女视频在线| 国产精品正在播放| 国产精品污污网站在线观看| 91麻豆国产精品久久| 亚洲永久免费视频| 91麻豆精品国产91久久久久| 久久精品国产亚洲a| 国产欧美日韩三区| 一本久久a久久免费精品不卡| 亚洲一区二区视频在线| 欧美一级欧美三级在线观看| 国产精品一区专区| 日韩毛片高清在线播放| 欧美日韩精品欧美日韩精品| 九一九一国产精品| 国产精品国产自产拍在线| 在线免费视频一区二区| 日本美女视频一区二区| 欧美国产亚洲另类动漫| 欧美丝袜丝交足nylons| 国产一区二区不卡在线| 亚洲欧洲中文日韩久久av乱码| 88在线观看91蜜桃国自产| 国产呦萝稀缺另类资源| 亚洲精品欧美激情| 精品国产一区二区亚洲人成毛片 | 国产日韩欧美电影| 欧洲在线/亚洲| 久久精品72免费观看| 国产精品久久久久影院| 在线成人小视频| 9人人澡人人爽人人精品| 亚洲18影院在线观看| 国产人成一区二区三区影院| 欧美日韩一卡二卡| 风间由美中文字幕在线看视频国产欧美| 悠悠色在线精品| 久久久久国产一区二区三区四区| 欧美性感一类影片在线播放| 国产91丝袜在线观看| 日韩国产一区二| 亚洲欧美另类久久久精品2019| 精品久久久久久久一区二区蜜臀| 色综合久久六月婷婷中文字幕| 精品午夜久久福利影院| 亚洲高清视频中文字幕| 中文字幕一区二区三区色视频| 精品国产污污免费网站入口| 欧美日韩国产另类一区| 99精品在线免费| 国产99久久久国产精品免费看 | 8x8x8国产精品| 色综合久久99| 99天天综合性| 国产成人亚洲综合a∨婷婷图片| 日本v片在线高清不卡在线观看| 亚洲欧洲国产日韩| 欧美国产一区在线| 久久久久综合网| 精品国免费一区二区三区| 欧美日韩一本到| 日本久久一区二区三区| av一区二区三区黑人| 成人免费视频app| 国产99精品国产| 国产成人在线视频网址| 国产麻豆一精品一av一免费 | 欧美日韩三级一区| 色一区在线观看| 91看片淫黄大片一级在线观看| 成人aaaa免费全部观看| 国产91精品露脸国语对白| 国产精品18久久久久| 国产精品123| 成人小视频在线| 成人手机电影网| av福利精品导航| 在线免费观看一区| 欧美亚洲综合网| 欧美精品在线观看播放| 这里只有精品99re| 精品免费视频一区二区| 国产三级欧美三级日产三级99 | 日韩西西人体444www| 日韩一区二区精品| 精品国产伦一区二区三区观看方式 | 国产精品影视在线| 高清在线不卡av| 91丨国产丨九色丨pron| 欧美性大战久久久久久久蜜臀| 欧美一区二区三区电影| 久久日韩精品一区二区五区| 国产精品私人影院| 亚洲久草在线视频| 日韩国产精品91| 国v精品久久久网| 91福利区一区二区三区| 欧美一区二区三区免费观看视频| 久久久精品黄色| 一区二区三区免费看视频| 日韩精品一二三| 国产成人免费视频| 欧亚洲嫩模精品一区三区| 欧美电影免费提供在线观看| 中国av一区二区三区| 亚洲已满18点击进入久久| 美女视频一区二区三区| 成人免费高清在线| 91精品国产综合久久精品性色 | 国产精品 日产精品 欧美精品| 99精品欧美一区二区三区小说| 欧美高清精品3d| 欧美激情综合在线| 午夜精品一区二区三区电影天堂| 国产精品一区二区x88av| 欧美在线免费观看视频| 久久日韩精品一区二区五区| 一个色妞综合视频在线观看| 激情另类小说区图片区视频区| 日本高清不卡一区| 久久色在线视频| 日韩中文字幕1| 91玉足脚交白嫩脚丫在线播放| 欧美xxxxx牲另类人与| 亚洲男女毛片无遮挡| 韩国一区二区三区| 欧美久久久久久蜜桃| 亚洲日本丝袜连裤袜办公室| 国内精品视频666| 欧美日韩高清一区二区不卡| 中文字幕一区视频| 国产精品一卡二| 欧美成人一级视频| 午夜国产不卡在线观看视频| 色综合天天性综合| 国产精品你懂的| 国产激情一区二区三区| 日韩视频永久免费| 五月天中文字幕一区二区| 色综合亚洲欧洲| 综合av第一页| 99视频一区二区三区| 久久久99精品免费观看| 毛片一区二区三区| 日韩一区二区影院| 日韩国产在线观看一区| 欧美日韩一卡二卡三卡| 洋洋av久久久久久久一区| 一本久久精品一区二区 |