#===========autotelnet.sh==============
#!/bin/bash tmptty=`tty` #鍙栧緱褰撳墠鐨?/span>tty鍊?br>tmptty=`basename $tmptty` #鍘繪帀tty鐨勭粷瀵硅礬寰?br>tmpname=`whoami` #鍙栧緱褰撳墠鎵ц紼嬪簭鐨勭敤鎴峰悕 ip="10.22.33.44" #鐩爣涓繪満鍦板潃 inp1="ABC^M" #涓繪満鐨勭敤鎴峰悕錛屾敞鎰?/span>^M蹇呴』鍦?/span>UNIX涓嬮噸瑁呯敤浠ヤ笅鏂規硶杈撳叆鎵嶈兘鐢紒錛?br>#鏂規硶涓烘寜浣?/span>ctrl閿寜v閿紝涓嶆斁ctrl閿紝鍐嶆寜shift閿拰m閿紝瀹屾垚鍚庡叏閮ㄦ斁寮 inp2="ABC^M" #涓繪満鐨勫瘑鐮侊紝娉ㄦ剰蹇呴』鏈?/span>^M inp3="ls^M" #鍏朵粬榪涘叆鍚庣殑鍛戒護錛屽彲鏃犳垨鐢?/span>ls涔嬬被鐨勫懡浠や唬鏇匡紝娉ㄦ剰蹇呴』鏈?/span>^M inp4="pwd^M" #鍛戒護4錛屽悓涓?br>#-------------------------- inputfile=in #瀵煎叆鏂囦歡綆¢亾鐢ㄧ殑錛屼笉瑕佹敼錛岃繖涓兼病鏈変換浣曞叧緋?br>outputfile=out.log #鏈緇堝鍑虹殑鏂囦歡 rm -fr $inputfile rm -fr $outputfile mknod $inputfile p touch $outputfile #file description 7 for out and 8 for in 浣跨敤7浣滀負杈撳叆綆¢亾錛?/span>8浣滀負杈撳叆 exec 7<>$outputfile exec 8<>$inputfile telnet $ip <&8 >&7 & sleep 2; echo $inp1 >> $inputfile #鐪嬪緱鎳傚惂 sleep 2; echo $inp2 >> $inputfile sleep 2; echo $inp3 >> $inputfile #濡傛灉娌℃湁鍏朵粬鍛戒護錛岃繖琛屽拰涓嬩竴琛屽彲浠ュ幓鎺?br>sleep 2; echo $inp4 >> $inputfile tail -f $outputfile & 寮哄埗鍦ㄥ睆騫曚笂鏄劇ず浠諱綍杈撳叆杈撳嚭 while true #姝e父鎯呭喌涓嬪凡緇忚繘鍏ョ洰鏍囦富鏈轟簡錛屽彲浠ヨ緭鍏ヤ換浣曞懡浠わ紝鎵鏈夌殑涓鍒囪緭鍏ヨ緭鍑洪兘浼氳璁板綍 do read str if [[ $str = "quit" || $str = "exit" ]] then echo $str >> $inputfile exit else echo $str >> $inputfile fi done #閫鍑烘椂鑷姩鏉鎺夌浉鍏寵繘紼?br>ps -ef | grep telnet | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", $2}' | sh ps -ef | grep tail | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", $2}' | sh |
#!/bin/bash
tmptty=`tty` #鍙栧緱褰撳墠鐨?/span>tty鍊?/span> tmptty=`basename $tmptty` #鍘繪帀tty鐨勭粷瀵硅礬寰?/span> tmpname=`whoami` #鍙栧緱褰撳墠鎵ц紼嬪簭鐨勭敤鎴峰悕 #浠ヤ笂淇℃伅鍦ㄦ渶鍚?/span>kill榪涚▼鏃朵綔涓虹瓫閫夋潯浠朵嬌鐢?/span> ip="10.22.33.44" #鐩爣涓繪満鍦板潃
inp1="ABC^M" #涓繪満鐨勭敤鎴峰悕銆傛敞鎰?/span>^M蹇呴』鍦?/span>UNIX涓嬮噸瑁呯敤浠ヤ笅鏂規硶杈撳叆鎵嶈兘鐢紒錛?/span> #鏂規硶涓烘寜浣?/span>ctrl閿寜v閿紝涓嶆斁ctrl閿紝鍐嶆寜shift閿拰m閿紝瀹屾垚鍚庡叏閮ㄦ斁寮 #緇忚繃瀹為檯浣跨敤錛屼笉姣旀寜shilf閿篃鍙互 inp2="ABC^M" #涓繪満鐨勫瘑鐮侊紝娉ㄦ剰蹇呴』鏈?/span>^M inp3="ls^M" #鍏朵粬榪涘叆鍚庣殑鍛戒護錛屽彲鏃犳垨鐢?/span>ls涔嬬被鐨勫懡浠や唬鏇匡紝娉ㄦ剰蹇呴』鏈?/span>^M inp4="pwd^M" #鍛戒護4錛屽悓涓?br>#-------------------------- inputfile=in #灝嗗懡浠ゅ鍏ュ悗鍙皌elnet榪涚▼鐢ㄧ殑綆¢亾鏂囦歡鍚嶇О outputfile=out.log #鍖呭惈telnet鍚庡彴榪涚▼杈撳叆鐨勬枃浠跺悕縐?/span> rm -fr $inputfile rm -fr $outputfile mknod $inputfile p #寤虹珛綆¢亾鏂囦歡 touch $outputfile #寤虹珛杈撳嚭鏂囦歡 exec 7<>$outputfile #灝嗘枃浠舵弿榪扮7鍒嗛厤緇?/span>outputfile exec 8<>$inputfile #灝嗘枃浠舵弿榪扮8鍒嗛厤緇?/span>inputfile telnet $ip <&8 >&7 & #鍚庡彴榪愯telent錛屽悓鏃墮噸瀹氬悜杈撳叆銆佽緭鍑?/span> sleep 2; echo $inp1 >> $inputfile #2縐掑悗杈撳叆鐢ㄦ埛鍚?/span> sleep 2; echo $inp2 >> $inputfile #2縐掑悗杈撳叆瀵嗙爜 sleep 2; echo $inp3 >> $inputfile #2縐掑悗杈撳叆鍛戒護inp3 sleep 2; echo $inp4 >> $inputfile #2縐掑悗杈撳叆鍛戒護inp3 錛冭繖閲岄潰inp3鍜?/span>inp4鍙槸涓涓鏄庯紝瀵硅嚜鍔ㄧ櫥褰曞疄闄呬笂娌℃湁浠涔堜綔鐢?/span> tail -f $outputfile & 錛?/span>寮哄埗鍦ㄥ睆騫曚笂鏄劇ず浠諱綍杈撳叆杈撳嚭
while true #姝e父鎯呭喌涓嬪凡緇忚繘鍏ョ洰鏍囦富鏈轟簡錛屽彲浠ヨ緭鍏ヤ換浣曞懡浠わ紝鎵鏈夌殑涓鍒囪緭鍏ヨ緭鍑洪兘浼氳璁板綍 do read str if [[ $str = "quit" || $str = "exit" ]] then echo $str >> $inputfile exit #榪欓噷鐨?/span>exit瀹為檯涓婃槸浠庡驚鐜腑閫鍑?/span> else echo $str >> $inputfile fi done #閫鍑烘椂鑷姩鏉鎺夌浉鍏寵繘紼?br>ps -ef | grep telnet | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", $2}' | sh ps -ef | grep tail | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", $2}' | sh |
#!/bin/bash
tmptty=`tty`
tmptty=`basename $tmptty`
tmpname=`whoami`
ip="136.39.75.102"
inp1="root^M"
inp2="Easy2get^M"
#####################################################################
#you may add as many commands as you want
#NOTE:every command should end with ^M, which is input under UNIX
# 鏂規硶涓烘寜浣廲trl閿寜v閿紝涓嶆斁ctrl閿紝鍐嶆寜shift閿拰m閿紝瀹屾垚鍚庡叏閮ㄦ斁寮
#####################################################################
inp3="ls^M"
inp4="echo 'hello,TeMIP users' >> hello.txt^M"
#--------------------------
inputfile=in
outputfile=out.log
rm -fr $inputfile
rm -fr $outputfile
mknod $inputfile p
touch $outputfile
exec 7<>$outputfile
exec 8<>$inputfile
telnet $ip <&8 >&7 &
sleep 2; echo $inp1 >> $inputfile
sleep 2; echo $inp2 >> $inputfile
echo "executing command $inp3"
sleep 2; echo $inp3 >> $inputfile
echo "executing $inp4"
sleep 2; echo $inp4 >> $inputfile
echo "exiting"
sleep 2; echo "exit^M" >> $inputfile
rm $inputfile
rm $outputfile
|
=> /var/log/messages : General log messages
=> /var/log/boot : System boot log
=> /var/log/debug : Debugging log messages
=> /var/log/auth.log : User login and authentication logs
=> /var/log/daemon.log : Running services such as squid, ntpd and others log message to this file
=> /var/log/dmesg : Linux kernel ring buffer log
=> /var/log/dpkg.log : All binary package log includes package installation and other information
=> /var/log/faillog : User failed login log file
=> /var/log/kern.log : Kernel log file
=> /var/log/lpr.log : Printer log file
=> /var/log/mail.* : All mail server message log files
=> /var/log/mysql.* : MySQL server log file
=> /var/log/user.log : All userlevel logs
=> /var/log/xorg.0.log : X.org log file
=> /var/log/apache2/* : Apache web server log files directory
=> /var/log/lighttpd/* : Lighttpd web server log files directory
=> /var/log/fsck/* : fsck command log
=> /var/log/apport.log : Application crash report / log file
Use tail, more, less and grep command.tail -f /var/log/apport.log
more /var/log/xorg.0.log
cat /var/log/mysql.err
less /var/log/messages
grep -i fail /var/log/boot
System Log Viewer is a graphical, menu-driven viewer that you can use to view and monitor your system logs. System Log Viewer comes with a few functions that can help you manage your logs, including a calendar, log monitor and log statistics display. System Log Viewer is useful if you are new to system administration because it provides an easier, more user-friendly display of your logs than a text display of the log file. It is also useful for more experienced administrators, as it contains a calendar to help you locate trends and track problems, as well as a monitor to enable you to continuously monitor crucial logs.
You can start System Log Viewer in the following ways:
Click on System menu > Choose Administration > System Log
(The GNOME System Log Viewer)
Note you can start the GNOME System Log Viewer from a shell prompt, by entering the following command:$ gnome-system-log &
[1]www.cyberciti.biz/faq/ubuntu-linux-gnome-system-log-viewer/