From 8a56144a09d026976991ce59907a393055fe1c59 Mon Sep 17 00:00:00 2001
From: Itay Mizeretz <itay.mizeretz@guardicore.com>
Date: Wed, 23 May 2018 20:29:32 +0300
Subject: [PATCH] Various required fixes

---
 monkey/infection_monkey/main.py                |  2 +-
 monkey/monkey_island/cc/app.py                 | 11 ++++++++---
 monkey/monkey_island/cc/resources/local_run.py |  4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/monkey/infection_monkey/main.py b/monkey/infection_monkey/main.py
index 51fd6b9f7..4ff4917b9 100644
--- a/monkey/infection_monkey/main.py
+++ b/monkey/infection_monkey/main.py
@@ -11,7 +11,7 @@ import traceback
 from config import WormConfiguration, EXTERNAL_CONFIG_FILE
 from dropper import MonkeyDrops
 from model import MONKEY_ARG, DROPPER_ARG
-from monkey import InfectionMonkey
+from infection_monkey.monkey import InfectionMonkey
 import utils
 
 if __name__ == "__main__":
diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py
index 34d14ae86..fdd18345d 100644
--- a/monkey/monkey_island/cc/app.py
+++ b/monkey/monkey_island/cc/app.py
@@ -4,7 +4,7 @@ from datetime import datetime
 import bson
 import flask_restful
 from bson.json_util import dumps
-from flask import Flask, send_from_directory, make_response
+from flask import Flask, send_from_directory, make_response, Response
 from werkzeug.exceptions import NotFound
 
 from cc.auth import init_jwt
@@ -28,18 +28,23 @@ from cc.services.config import ConfigService
 __author__ = 'Barak'
 
 
+HOME_FILE = 'index.html'
+
+
 def serve_static_file(static_path):
     if static_path.startswith('api/'):
         raise NotFound()
     try:
-        return send_from_directory('ui/dist', static_path)
+        return send_from_directory(os.path.join(os.getcwd(), 'monkey_island/cc/ui/dist'), static_path)
     except NotFound:
         # Because react uses various urls for same index page, this is probably the user's intention.
+        if static_path == HOME_FILE:
+            flask_restful.abort(Response("Server cwd isn't right, should be monkey\\monkey.", 500))
         return serve_home()
 
 
 def serve_home():
-    return serve_static_file('index.html')
+    return serve_static_file(HOME_FILE)
 
 
 def normalize_obj(obj):
diff --git a/monkey/monkey_island/cc/resources/local_run.py b/monkey/monkey_island/cc/resources/local_run.py
index c588eaf80..918e3fe28 100644
--- a/monkey/monkey_island/cc/resources/local_run.py
+++ b/monkey/monkey_island/cc/resources/local_run.py
@@ -24,8 +24,8 @@ def run_local_monkey():
     if not result:
         return False, "OS Type not found"
 
-    monkey_path = os.path.join('binaries', result['filename'])
-    target_path = os.path.join(os.getcwd(), result['filename'])
+    monkey_path = os.path.join(os.getcwd(), 'monkey_island', 'cc', 'binaries', result['filename'])
+    target_path = os.path.join(os.getcwd(), 'monkey_island', result['filename'])
 
     # copy the executable to temp path (don't run the monkey from its current location as it may delete itself)
     try: