From 2949d4a8c2f3e3cdde3abca888ceec3fbc7f6d32 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Tue, 3 Oct 2017 18:20:20 +0300 Subject: [PATCH] Remove DNET library. --- chaos_monkey/exploit/tools.py | 42 +++++++++++++++-------------------- chaos_monkey/readme.txt | 6 +---- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/chaos_monkey/exploit/tools.py b/chaos_monkey/exploit/tools.py index bdb97d975..0903d85c8 100644 --- a/chaos_monkey/exploit/tools.py +++ b/chaos_monkey/exploit/tools.py @@ -1,25 +1,27 @@ +import logging +import ntpath import os -import sys +import os.path +import pprint import socket import struct -import ntpath -import pprint -import logging -import os.path +import sys import urllib -import monkeyfs from difflib import get_close_matches -from network import local_ips -from transport import HTTPServer -from network.info import get_free_tcp_port, get_routes -from network.firewall import app as firewall + from impacket.dcerpc.v5 import transport, srvs -from impacket.dcerpc.v5.dcom.wmi import DCERPCSessionError -from impacket.smbconnection import SMBConnection, SMB_DIALECT -from impacket.smb3structs import SMB2_DIALECT_002, SMB2_DIALECT_21 -from impacket.dcerpc.v5.dcomrt import DCOMConnection from impacket.dcerpc.v5.dcom import wmi +from impacket.dcerpc.v5.dcom.wmi import DCERPCSessionError +from impacket.dcerpc.v5.dcomrt import DCOMConnection from impacket.dcerpc.v5.dtypes import NULL +from impacket.smb3structs import SMB2_DIALECT_002, SMB2_DIALECT_21 +from impacket.smbconnection import SMBConnection, SMB_DIALECT + +import monkeyfs +from network import local_ips +from network.firewall import app as firewall +from network.info import get_free_tcp_port, get_routes +from transport import HTTPServer class DceRpcException(Exception): @@ -387,14 +389,7 @@ class HTTPTools(object): def get_interface_to_target(dst): if sys.platform == "win32": - try: - import dnet - intf = dnet.intf() - inte = intf.get_dst(dnet.addr(dst)) - return str(inte['addr']).split("/")[0] - except ImportError: - # dnet lib is not installed - return get_close_matches(dst, local_ips())[0] + return get_close_matches(dst, local_ips())[0] else: # based on scapy implementation @@ -476,7 +471,7 @@ def build_monkey_commandline(target_host, depth, location=None): def report_failed_login(exploiter, machine, user, password='', lm_hash='', ntlm_hash=''): from control import ControlClient - telemetry_dict =\ + telemetry_dict = \ {'result': False, 'machine': machine.__dict__, 'exploiter': exploiter.__class__.__name__, 'user': user, 'password': password} if lm_hash: @@ -492,4 +487,3 @@ def get_binaries_dir_path(): return sys._MEIPASS else: return os.path.dirname(os.path.abspath(__file__)) - diff --git a/chaos_monkey/readme.txt b/chaos_monkey/readme.txt index 726f434df..4f84ecce1 100644 --- a/chaos_monkey/readme.txt +++ b/chaos_monkey/readme.txt @@ -18,11 +18,7 @@ Windows: Install the python packages listed in requirements.txt. Using pip install -r requirements.txt 7. Download and extract UPX binary to [source-path]\monkey\chaos_monkey\bin\upx.exe: http://upx.sourceforge.net/download/upx391w.zip -8. (Optional) For some exploits to work better, install 'dnet' python library. You'll need to compile it for your OS - or use a precompiled setup that can be found at: - 32bit: https://github.com/Kondziowy/scapy_win64/raw/master/win32/dnet-1.12.win32-py2.7.exe - 64bit: https://github.com/Kondziowy/scapy_win64/raw/master/win64/dnet-1.12.win-amd64-py2.7.exe -9. Run [source-path]\monkey\chaos_monkey\build_windows.bat to build, output is in dist\monkey.exe +8. Run [source-path]\monkey\chaos_monkey\build_windows.bat to build, output is in dist\monkey.exe Linux (Tested on Ubuntu 12.04): 1. Run: