# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['emews',
 'emews.api',
 'emews.api.env',
 'emews.api.env_key',
 'emews.api.random',
 'emews.api.service',
 'emews.base',
 'emews.core_emu',
 'emews.core_emu.core8_config_services',
 'emews.core_emu.core8_config_services.node',
 'emews.core_emu.core8_legacy_services',
 'emews.core_emu.core_services',
 'emews.core_emu.core_services.node',
 'emews.core_emu.core_services.servers',
 'emews.core_emu.generate_service',
 'emews.environments',
 'emews.environments.example',
 'emews.environments.web',
 'emews.services',
 'emews.services.autossh',
 'emews.services.floodingbot',
 'emews.services.helloworld',
 'emews.services.sitecrawler',
 'emews.services.synflooder',
 'emews.services.throughput']

package_data = \
{'': ['*'],
 'emews.core_emu': ['example_conf/*', 'networks/*'],
 'emews.core_emu.core8_config_services.node': ['templates/*'],
 'emews.core_emu.core_services.node': ['templates/*'],
 'emews.core_emu.core_services.servers': ['templates/*',
                                          'templates/etc/apache2/*']}

install_requires = \
['bs4>=0.0.1',
 'linuxfd>=1.4.4',
 'pexpect>=4.6',
 'psutil>=5.8',
 'ruamel.yaml>=0.17',
 'scapy>=2.5',
 'scipy>=1.5.4',
 'urllib3>=1.25.8']

setup_kwargs = {
    'name': 'emews',
    'version': '0.9.2',
    'description': 'Network traffic automation and prototyping.',
    'long_description': '# eMews - Network Traffic Automation and Prototyping\n\neMews is a framework which automates client-side computer network traffic generation, while providing centralized monitoring of a network while traffic is being generated.  eMews provides an API to write network applications which abstract away basic functionality such as peer-to-peer communication.  These applications, called _services_, provide client-side traffic generation, but can also be used to prototype complex network protocols, or even agent-environment interaction, in which the environment is the network itself [2].  eMews is designed for emulated networks such as those built with CORE, enabling quick deployment over potentially large-scale networks which reside on a single physical host [1].\n\nBundled with eMews are services which can generate SSH and HTTPS client-side network traffic in a connection-orientated paradigm.  This is different from a playback approach, in that the traffic generated factors in response traffic from the server, and can be captured as PCAP data representing valid TCP sessions.  By writing your own eMews services, you can generate any client-side traffic for any network protocol you desire.\n\nWith eMews you can quickly deploy large-scale botnets for flooding-type network traffic captures.  eMews comes with a botnet service which can generate distributed UDP or TCP traffic, and supports multiple concurrent botnets.\n\n- eMews version used in IRI-18 [1] paper: v0.32.\n- eMews version used in IRI-19 [2] paper: v0.4.\n\n## Quick Start\nWe will assume that eMews is going to be run with the CORE 9 network emulator on an Ubuntu 24.04 system.  To install CORE, see [here](https://coreemu.github.io/core/).  While CORE has an Ubuntu package, it may be more straightforward to build CORE from source.  eMews is tested to work with CORE 8 and 9, through CORE 9.2.1, the most recent version as of this writing.  While this guide is written for CORE 9, if a step is different to perform in CORE 8, the difference will be mentioned so CORE 8 users can also work with eMews.\n\nCreate a Python virtual environment (venv) that you will install eMews in.  If you plan to write services for eMews, then a straightforward way to create a venv is to use an IDE such as [PyCharm](https://www.jetbrains.com/pycharm/) and create a new project for eMews development.  By default, PyCharm will create a venv for the project, and then you can enter it by simply opening a terminal session in PyCharm.\n\nAssuming you have created and entered your virtual environment, download / install eMews using `pip`:\n\n```shell\npip install emews\n```\n\nYou need to know where eMews was installed so you can modify CORE\'s configuration accordingly.  Type the following to get the eMews package path:\n\n```shell\npip show emews\n```\n\nThe path is located under `Location` in the output, for example:\n\n```\nLocation: /home/username/venv-emews/venv/lib/python3.12/site-packages\n```\n\nCopy the path given at Location, which we will call `<emews_pkg_path>`, and open `core.conf`.  In Ubuntu 24.04, `core.conf` is usually located at `/opt/core/etc`. Modify the following line in `core.conf`:\n\n```\ncustom_services_dir = <emews_pkg_path>/emews/core_emu/core_services\n```\n\nIf using CORE 8, you\'ll need to modify the following lines in `core.conf` instead:\n\n```\ncustom_services_dir = <emews_pkg_path>/emews/core_emu/core8_legacy_services\ncustom_config_services_dir = <emews_pkg_path>/emews/core_emu/core8_config_services\n```\n\neMews provides a sample `core.conf` file under `<emews_pkg_path>/emews/core_emu/example_conf`.  eMews interfaces with CORE through CORE services which map to eMews nodes and services.  These CORE services are generated by eMews and will be discussed in a bit.  Note that CORE services are different from eMews services.  Starting from CORE 8, CORE service structure changed and these services were called \'config services\'.  Legacy CORE services were still supported and called \'services\'.  With CORE 9, support for legacy services was dropped and \'config services\' were renamed to \'services\', including API changes which required updating eMews CORE service generation. \n\n- The venv containing eMews does not need to be active when running a CORE network as CORE will know where eMews is located via the `custom_services_dir` entry in `core.conf`.\n\n### Building CORE Networks\nCORE networks can be built using `core_gui`.  When building a CORE network to run eMews, one CORE node in the network should be designated to run the eMews hub.  This node should be the first one created in the network (\'n1\') and should be a host type like a PC.  In `core_gui`, right-click on this node, and select \'Services\'.  If running CORE 8, you\'ll select \'Config Services\' instead.  Under \'Groups\', select \'eMews\' and then select \'HubNode\' as the service.  Note that multiple eMews services can run on a single CORE node.\n\n- If you do not see \'eMews\' as a group option, then most likely your `custom_services_dir` (or `custom_config_services_dir` if using CORE 8) was not set correctly in `core.conf`.\n\nBy default, the IP address assigned to the first node created in a CORE network is 10.0.0.20.  This IP address is also where eMews expects the HubNode service to reside.  If the IP address of the CORE node running the eMews hub is not 10.0.0.20, then this IP address will need to be set in the eMews system configuration file located at `<emews_pkg_path>/emews/system.yml`.  Under the `hub` section of `system.yml` change this field:\n\n```\naddress: 10.0.0.20\n```\n\nfrom 10.0.0.20 to the IP address of the CORE node running the eMews HubNode service.\n\n- To skip having to change the hub node IP address in `system.yml`, simply assign the eMews \'HubNode\' service to the first CORE node created.\n- eMews was not originally designed with PyPi packaging in mind, and thus the global system configuration (along with services) are contained within the package.\n\nAll remaining CORE nodes that will run eMews services need to additionally run an eMews host.  In `core_gui`, right-click on a CORE node which should be an eMews host, and select \'Services\' (or \'Config Services\' if using CORE 8).  Select \'eMews\' as the group, and select \'HostNode\' as the service.  Then select additional eMews services that you\'d like to run on the selected node.\n\n- The eMews hub can itself run eMews services without requiring the \'HostNode\' service.\n\nWhen running a CORE network with eMews-enabled nodes, you can both control eMews and monitor what it is doing by connecting to the hub node.  In `core_gui`, you need to first enable a control network for your CORE network so you can connect to the eMews hub node externally.  With your CORE network open in `core_gui`, click on the \'Session\' menu, select \'Options\', and type an IP address range for \'Control Network\', for example 172.16.0.0/24.\n\n- The IP address range for the control network should be private and not conflict with existing networks your physical host interfaces with, for example your school or home network.  See [here](https://www.arin.net/reference/research/statistics/address_filters/) for a list of private IPv4 address ranges.\n\nExample CORE networks running eMews nodes are located under `<emews_pkg_path>/emews/core_emu/networks`.\n\n### Controlling and Monitoring eMews\nWhen running your CORE network, which is called a _CORE session_, you may want to run an eMews console and monitor to interact with eMews and view log output, respectively.  To start a session of your network, click the \'Start Session\' button, and wait for your network to finish start-up (for large networks this can take some time).  Once your network is running, double-click on the hub node in `core_gui`.  This opens a root shell, and in this shell type:\n\n```shell\nifconfig\n```\n\nThe NIC for the control network will be called `ctrl0`.  Copy the IP address assigned to this NIC, which we will call `<hub_ctrl_ip>`.  Then, open a local console, activate the eMews venv (or if using an IDE like PyCharm open the eMews project and then open a terminal session within the IDE) and type:\n\n```shell\npython3 -m emews -n monitor1 monitor --hub_address <hub_ctrl_ip>\n```\n\nThis will create a local standalone eMews node called \'monitor1\', which will connect to the hub node and output log messages.  Now open another local console, activate the eMews venv as before (of if using an IDE open another terminal session) and type:\n\n```shell\npython3 -m emews -n console1 console --hub_address <hub_ctrl_ip>\n```\n\nThis will create a local standalone eMews node called \'console1\', which will connect to the hub node and provide a console in which you can type commands to eMews.\n\n### Console Node Commands\nWhen a CORE session starts, eMews services will be suspended.  To manually start all eMews services, type in the console node:\n\n```\nexp start\n```\n\nHere, \'exp\' is short for \'experiment\', which is what we refer to as eMews\' goal, for example network traffic generation.\n\n- eMews can start an experiment automatically by setting the `system.yml` field `scenario_autostart` to `True` under the `hub` section\n\nTo check if there are any issues with a running experiment, type:\n\n```\nexp status\n```\n\nIf the status is green, then all eMews services are running normally.  To get a detailed list of all services and their execution state, type:\n\n```\nlist services\n```\n\nTo stop all eMews services, type:\n\n```\nexp stop\n```\n\nThe eMews console supports many commands to interact with eMews.  You can check resource usage, start and stop individual services, and even create service instances on a node.  Type `help` to get a list of commands.  Type `help <command>` to get help on a specific command.\n\n## eMews Services\neMews comes with client-side services to interact with servers such as SSH and HTTPS, along with bots for generating various DDoS traffic.  All services which eMews comes with are located here:\n\n```\n<emews_pkg_path>/emews/services\n```\n\nEach service is in a sub-folder named accordingly.  Services are configured using `.yml` files within the service folder.  There is at least one configuration per service called `default.yml`, but there may be others.  When adding an eMews service to a CORE node in `core_gui`, the configuration loaded is `default.yml`.  To load another configuration instead, right-click the CORE node and click \'Services\'.  Then under \'Selected\', click the eMews services you would like to configure and click \'Configure\'.  All the available configurations are given in a drop-down list.\n\n## Helpful Hints\nCORE network nodes are run as containers under root, and are built under `/tmp/pycore.###` (the \'###\' is a number).  In this directory are directories for each CORE node, named `<node_name>.conf`, where `<node_name>` is the name of the node as assigned in `core_gui` (such as \'n1\').  For example, the path to a CORE node called \'n1\' would be:\n\n```\n/tmp/pycore.###/n1.conf\n```\n\nAll CORE nodes running eMews contain log files which start with `emews` and end with `.log`.  These files log console output (including exceptions) from each eMews daemon and service launcher, and may contain useful messages related to local issues.  For example, a CORE node running an eMews host has two log files:  `emews_node_host.log` and `emews_servspawn.log`.  The first provides local (to the CORE node) log output of the eMews host, whereas the second provides local log output for eMews service spawning.  To obtain eMews service log output among all nodes in the network, launch a monitor node.\n \nIf you want eMews services to start automatically when your CORE network is started, under `<emews_pkg_path>/emews/system.yml`, set `hub.scenario_autostart` to `True`.  When your CORE network starts, eMews services will start automatically after an amount of seconds given by `hub.scenario_autostart_delay`.  This enables you to launch a CORE network and start eMews services without having to connect a console session to the hub node.\n\nReferences:\n\n[1] B. Ricks, P. Tague and B. Thuraisingham, "Large-Scale Realistic Network Data Generation on a Budget," IEEE Intl Conference on Information Reuse and Integration for Data Science (IRI), Jul 2018\n- URL: https://mews.sv.cmu.edu/papers/iri-18.pdf\n\n[2] B. Ricks, B. Thuraisingham, and P. Tague, "Mimicking Human Behavior in Shared-Resource Computer Networks", IEEE Intl Conference on Information Reuse and Integration for Data Science (IRI), Jul 2019\n- URL: https://mews.sv.cmu.edu/papers/iri-19.pdf\n',
    'author': 'Brian Ricks',
    'author_email': 'absolutefunk@utdallas.edu',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://mews.sv.cmu.edu/research/emews/',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8',
}


setup(**setup_kwargs)
