Exemple #1
0
def create_container() -> Union[bool, str]:
    """Create a container with a honeypot docker image

    :return: get container id or false
    """
    global CURRENT_CONTAINER

    container, created = docker_run(image=HONEYPOT_DOCKER_IMAGE,
                                    image_cmd=HONEYPOT_DOCKER_IMAGE_CMD,
                                    options=HONEYPOT_DOCKER_OPTIONS)
    CURRENT_CONTAINER = container
    return container if created else created
Exemple #2
0
def dns_start(image_id="mgropp/dns"):
	container_hosts_dir = '/etc/dnsmasq.hosts.d'
	
	hosts_dir = tempfile.mkdtemp(prefix="dns-")
	atexit.register(lambda: shutil.rmtree(hosts_dir))
	
	container = docker_run(
		image_id,
		'-v', '%s:%s:ro' % (hosts_dir, container_hosts_dir)
	)
	
	container["hosts_dir"] = hosts_dir
	
	return container
	print("Starting proxy...")
	proxy = proxy_recorder_start_container(real_dns["ip_address"])
	running_containers.append(proxy["id"])
	print("Proxy: %s (%s)" % (proxy["ip_address"], proxy["output_file"]))
	print()
	
	# Services
	for service in services:
		hostname = service[0]
		image_id = service[1]
		arguments = service[2:]
		
		print('Starting %s with arguments %s...' % (image_id, arguments))
		container = docker_run(
			image_id,
			'--dns=%s' % fake_dns["ip_address"],
			*arguments
		)
		
		print('%s %s (%s)' % (container["ip_address"], image_id, container["id"]))
		
		running_containers.append(container["id"])
		dns_add(real_dns["hosts_dir"], hostname, container["ip_address"])
		dns_add(fake_dns["hosts_dir"], hostname, proxy["ip_address"])
	
	# Wait for end
	print()
	input('Press return to terminate...')
	
	for container_id in reversed(running_containers):
		docker_kill(container_id)