ãã®è¨äºã¯ KMC Advent Calendar 2015 - Adventar19æ¥ç®ã®è¨äºã§ãã18æ¥ç®ã¯ãmurataããã®KMCとPiet,そして最強のPietの為にdllを動的にC#で読みこむ話 - <(/^^)/⌒●~* $> :(){ :|:& };:ã§ããã
ã¯ããã«
KMC 4åçkazakami https://twitter.com/Kazakami_9ã§ãã *
ä»æ¥ã¯shellãã£ã³ãã«ã®è©±ãã§ãã
shellãã£ã³ãã«èªä½ã¯10æ¥ç®ã®ã¢ããã³ãã«ã¬ã³ãã¼ã§ããmesos+marathon+docker と slack の shell チャンネルの話 - KMC活動ブログã§ãã§ã¦ãã¦ãã¾ãã
shellããã«ã¤ãã¦
$ããå§ã¾ãæååãslackã§çºè¨ãããã¨ãããã³ãã³ãã¨ãã¦è§£éãã¦å®è¡ããæ¨æºåºåãslackã§çºè¨ããã¨ããèå¼±æ§ã®å¡ã®ãããªbotã§ãã(botã®ã½ã¼ã¹ã³ã¼ãã¯å è¿°ã®è¨äºã«ã¦å ¬éããã¦ãã¾ãããããããæ¸ãã人ããã¹ã¯ãªãããããã£ã¦ããªã©ã¨ä¾è¿°ãã¦ãã¾ãããç§ã¯ãããããã¨ããå ¬éãã¦ãããã¨ãè¨ã£ã¦ãã¾ããã(å ¨ã®ã¬ã·ãã·ã))
åä½ä¾ã¨ãã¦ããã¨ãã° $ls ã¨çºè¨ããã¨ãããªæãã«ãªãã¾ãã
ãããã«ãããªãã®ç´ã«åãããã¨ã¯ã§ããªãã®ã§ãä»®æ³ãã·ã³ã®ä¸ã§åããã¦ãã¾ãããç°å¢æ§ç¯ãéãããããã«ubuntuã®ä»®æ³ãã·ã³ç¨ã®ã¤ã¡ã¼ã¸ãã£ã¹ã¯ãç¨ãã¾ããã
ä»åã¯æªè³ªãªäººéã«ãã£ã¦ã©ã®ãããªæªè³ªãªã³ãã³ããæãããããããã®ä¸é¨ã«ã¤ãã¦ç´¹ä»ãã¦ããããã¨æãã¾ãã
ãªããã®ãã£ã³ãã«ã®ãã°ã¯ããã¹ããã¡ã¤ã«ã§ããã«ãé¢ããããã¡ã¤ã«ãµã¤ãºã20MBãããã¾ãã(åã®ã¬)
大éã®ã¡ãã»ã¼ã¸ã表示ããããã®
$yes
ã²ããã y ãåºåããã³ãã³ãã§ããä»åä½ã£ãbotã§ã¯å¦çãçµäºãã¦ããã¡ã¢ãªã«æºãã¦ãããæ¨æºåºåã®ãã¼ã¿ãéä¿¡ããããã«ãã¦ããã®ã§ãè¿äºããªããªã£ããã¡ã¢ãªã使ãåã£ãããã¦è½ã¡ããã¨ãæ®ãã©ã§ããã
$seq 100000
ãã¡ãã¯1ãã100000ã¾ã§ã®æ°åã表示ããã³ãã³ãã§ããyesã¨ç°ãªããã¡ãã¯çµäºããã®ã§100000åæ°åã表示ããã¾ããæªè³ªã
$ls -R /
ã«ã¼ã以ä¸å ¨ã¦ã®ãã¡ã¤ã«ã表示ãã¾ããåç´ã«å®è¡ãã¦ã表示ã«æéãããã代ç©ãªã®ã§å®éæªè³ªã
éä¸ããé·ãããæååã¯è¡¨ç¤ºããªãããã«ä¿®æ£ãããããããããã®ã¯çµçãè¿ãã¾ããã
å¦çã飽åããããã®
ç¡éã«ã¼ã
shell scriptãrubyã®ã¯ã³ã©ã¤ãã¼ãªã©æ§ã ãªææ³ã§æ§ã ãªç¡éã«ã¼ããåãã¦ããã¾ãããããã°ã©ã ã®1ã¤2ã¤ãç¡éã«ã¼ããã¦ãã¦ããããªã«è² è·ã¯å¢ãã¾ããããã«ã¼ãã®ä¸ã§ããã°ã©ã ã®èµ·åããã¦ãããã®ã ã¨ããªãæªè³ªã«ãªãã¾ããã
$while true; do gnome-terminal; done
å è¿°ã®éãbotã®åä½ç°å¢ã¨ãã¦ä»®æ³ãã·ã³ä¸ã®ubuntuã使ç¨ãã¦ããã®ã§ãããGUIã§ä½¿ç¨ãã¦ãããããã®ãããªã³ãã³ããæããããã¨ãç»é¢ä¸ã«å¤§éã®terminalãä¸æã«è±éãæ»ãã§ãã¾ãã¾ããæªè³ªã
$:(){ :|:& };: ã $perl -e 'fork while fork' ãªã©
ãããããã©ã¼ã¯çå¼¾ã§ããããããããã¨ãsshçµç±ã§ãã°ã¤ã³ãã¦botãåèµ·åãããªã©ã®ä½æ¥ãã§ããªããªãã®ã§é常ã«å°ãã¾ãããä¸ææbotãåããã¦ãããµã¼ãã®Load Averageã¯5000è¿ãã«ãªã£ã¦ã¾ããã
ã¾ããã¨ããé¨å¡ããµã¼ã¯ã«ã®å ±ç¨ãã·ã³ã§ãããå®è¡ãã¦æ¥½ãããã¨ã«ããªãã¾ãããä¸ä½èª°ããããªæªè³ªãªãã¨ããããã§ãããã
çµããªãã³ã³ãã¤ã«
次ã®ãããªCè¨èªã®ã½ã¼ã¹ã®ã³ã³ãã¤ã«ã¯çµäºãã¾ããã
#include ".//.//.//.//hoge.cpp"
#include "hoge.cpp"
echoã³ãã³ããç¨ãã¦ãã®ãããªãã¡ã¤ã«ãçæããã³ã³ãã¤ã«ããã¨CPUãã¡ã¢ãªã大éã«æ¶è²»ãã¦ããã¾ãã
$ruby hoge.rb
hoge.rbã¯ãã®botã®ã½ã¼ã¹ã³ã¼ãã§ãããã®ã³ãã³ãã«ãã£ã¦botããã1ã¤èµ·åããã¦ãã¾ãã¾ãããã®ã³ãã³ãã®å®è¡åæ°ã®ææ°ã§botãå¤éèµ·åããã¦ããã¾ãã
$echo $PATH | tr ':' '\n' | xargs -n1 ls | while read line; do ($line &); done;
ãã¹ãéããã¦ããå ¨ã¦ã®ããã°ã©ã ãå®è¡ãã¾ããGUIã使ã£ã¦ããã¨libre officeããã©ã¦ã¶,ã¹ã¯ãªã¼ã³ããã¯ãªã©æ§ã ãªãã®ãèµ·åãããã£ã¦ããã¾ãã
ä½æ¥ã®éªéããããã®
$killall tmux
å®ã«åç´ã§ãããªããå®ã«æªè³ªã
$killall ruby
ããã¦ãã ãããbotãæ»ãã§ãã¾ãã¾ãã
$yes | write kazakami
ç§ã®ç«¯æ«ã«å¤§éã®yãéã£ã¦ãã¾ãã
$gnome-terminal -e sl
çªç¶ç«¯æ«ãéããSLãèµ°ãã ãã¾ãã
ç°å¢ç ´å£
$rm -rf / --no-preserve-root
å®çªãå ¨ã¦ã®æ¶ãããã¡ã¤ã«ãæ¶ãã¾ãããã¡ããroot権éã§botãèµ·åãã¦ããããã§ã¯ãªãã®ã§è´å½çãªãã¨ã¯èµ·ãã¾ããã§ããã
$rm hoge.rb
hoge.rbã¯ãã®botã®ã½ã¼ã¹ã§ãããããæ¶ãããã¨ã¤ãã¿ã§ãã
$echo 'exit' > ~/.bashrc
ãã°ã¤ã³ããã¨ãã°ã¢ã¦ãããããã«ãªãã¾ããæªè³ªã
/bin 以ä¸ã®æ¸ãæã
lsãå ¨ãé¢ä¿ãªãã³ãã³ãã«ããããkillãæ¸ãæã㦠echo 'æ»ãã§ãã¾ãã' ã®ããã«ãããã¨æ··æ²ã極ãã¦ãã¾ããã
ãã®ä»
$echo 'password' | sudo -S é©å½ãªã³ãã³ã
sudoã«ã¯ -S ãªãã·ã§ã³ã¨ãããã®ããã£ã¦ãæ¨æºå ¥åãããã¹ã¯ã¼ããååãããã«ã§ããããã§ããããããå®éã«ä½¿ããã¨ã¯ãªãããã
ã¡ãªã¿ã«ãã¹ã¯ã¼ãã¯ç°¡åãªãã®ãè¨å®ãã¦ãã¾ãããã誰ãçªç ´ãã¦ããã¾ããã§ããã
.ssh以ä¸ã«éµãéãè¾¼ãã§ãéµèªè¨¼ã«ãããã°ã¤ã³
ããããã«ãªã£ã¦ããã®ãããã«.sshã®æ¸ãè¾¼ã¿æ¨©éã奪ãã¾ããã
botãä½ã
echoã«ããããã°ã©ã ãæ¸ãè¾¼ãã§å®è¡ãããã¨ã¯ããã¾ããããbotãå©ç¨ãã¦botãä½ã£ã¦ãã人ããã¾ããã
ã¡ãªã¿ã«ãã®botãbotã®çºè¨ã«ãåå¿ããããã«ãªã£ã¦ããã®ã§èªåèªèº«ã®çºè¨ã«ãåå¿ãã¦ãã¾ã大å¤ãªãã¨ã«ãªã£ã¦ãã¾ããã
$find / -perm -u=w -type f 2>/dev/null | ruby -e 'STDIN.each{|line| echo ":fuck:" > #{line}
}'
å ¨ã¦ã®æ¸ãè¾¼ã¿å¯è½ãªãã¡ã¤ã«ã®å 容ã:fuck:ã«æ¸ãæãããã¾ããbotãåããããã«ãã«ãããã°ããã®rubyã®ææ°çã:fuck:ã«æ¸ãæãããã¾ãã
Reverse Shell
ãããªãã¨ã§ãããã ãªã£ã¦æãã«ãªãã¾ããã
ã¾ã¨ã
æªä¹ãã§ã¤ãã£ãbotã§ããããçããæãæãã®æ¹æ³ã§æªè³ªãªãã¨ããã¦ãããã®ã§å¤ãã®shellã®ã³ãã³ããæ©è½ãç¥ããã¨ãã§ãã¾ããã(大é¨åã¯ä½¿ããã¨ããªãã§ãããã)
ãã®ãããªãã®ã§ãçããçµæ§æ¥½ããã§ããã¦ãããããªã®ã§ãé©å½ãªãã®ã§ãåãæ¢ããä½ã£ã¦ä½¿ããç¶æ ã«ããã®ã¯å¤§åã ã¨æãã¾ããã
ç©æ¥µçã«ã¯ã½botä½ã£ã¦ããã¾ãããï¼ï¼ï¼ï¼
次åäºå
ææ¥ã20æ¥ç®ã® KMC Advent Calendar 2015 - Adventarã®è¨äºã¯MSZ_006_A_E_U_Gåã«ãã天ä¸ä¸åãã§ã¢2015ã§ã