zscams 2.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zscams-2.0.5/PKG-INFO +114 -0
- zscams-2.0.5/README.md +93 -0
- zscams-2.0.5/pyproject.toml +26 -0
- zscams-2.0.5/zscams/__init__.py +3 -0
- zscams-2.0.5/zscams/__main__.py +43 -0
- zscams-2.0.5/zscams/agent/__init__.py +93 -0
- zscams-2.0.5/zscams/agent/certificates/.gitkeep +0 -0
- zscams-2.0.5/zscams/agent/config.yaml +103 -0
- zscams-2.0.5/zscams/agent/configuration/config.j2 +103 -0
- zscams-2.0.5/zscams/agent/configuration/service.j2 +12 -0
- zscams-2.0.5/zscams/agent/keys/autoport.key +27 -0
- zscams-2.0.5/zscams/agent/src/__init__.py +0 -0
- zscams-2.0.5/zscams/agent/src/core/__init__.py +1 -0
- zscams-2.0.5/zscams/agent/src/core/backend/bootstrap.py +76 -0
- zscams-2.0.5/zscams/agent/src/core/backend/client.py +281 -0
- zscams-2.0.5/zscams/agent/src/core/backend/exceptions.py +10 -0
- zscams-2.0.5/zscams/agent/src/core/backend/update_machine_info.py +16 -0
- zscams-2.0.5/zscams/agent/src/core/prerequisites.py +36 -0
- zscams-2.0.5/zscams/agent/src/core/service_health_check.py +49 -0
- zscams-2.0.5/zscams/agent/src/core/services.py +86 -0
- zscams-2.0.5/zscams/agent/src/core/tunnel/__init__.py +144 -0
- zscams-2.0.5/zscams/agent/src/core/tunnel/tls.py +56 -0
- zscams-2.0.5/zscams/agent/src/core/tunnels.py +55 -0
- zscams-2.0.5/zscams/agent/src/services/__init__.py +0 -0
- zscams-2.0.5/zscams/agent/src/services/reverse_ssh.py +73 -0
- zscams-2.0.5/zscams/agent/src/services/ssh_forwarder.py +75 -0
- zscams-2.0.5/zscams/agent/src/services/system_monitor.py +264 -0
- zscams-2.0.5/zscams/agent/src/support/__init__.py +0 -0
- zscams-2.0.5/zscams/agent/src/support/cli.py +50 -0
- zscams-2.0.5/zscams/agent/src/support/configuration.py +86 -0
- zscams-2.0.5/zscams/agent/src/support/filesystem.py +63 -0
- zscams-2.0.5/zscams/agent/src/support/logger.py +88 -0
- zscams-2.0.5/zscams/agent/src/support/mac.py +18 -0
- zscams-2.0.5/zscams/agent/src/support/network.py +49 -0
- zscams-2.0.5/zscams/agent/src/support/openssl.py +114 -0
- zscams-2.0.5/zscams/agent/src/support/os.py +138 -0
- zscams-2.0.5/zscams/agent/src/support/ssh.py +24 -0
- zscams-2.0.5/zscams/agent/src/support/yaml.py +37 -0
- zscams-2.0.5/zscams/deps.py +86 -0
- zscams-2.0.5/zscams/lib/.gitkeep +0 -0
zscams-2.0.5/PKG-INFO
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: zscams
|
|
3
|
+
Version: 2.0.5
|
|
4
|
+
Summary: Async TLS tunnel client with SNI routing, auto-reconnect, and health checks
|
|
5
|
+
Author: OCD - Cairo Software Team
|
|
6
|
+
Maintainer: OCD - Cairo Software Team
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Requires-Dist: PyYAML ; sys_platform not in "freebsd"
|
|
15
|
+
Requires-Dist: cryptography ; sys_platform not in "freebsd"
|
|
16
|
+
Requires-Dist: getmac
|
|
17
|
+
Requires-Dist: psutil ; sys_platform not in "freebsd"
|
|
18
|
+
Requires-Dist: requests
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# Agent
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Getting started
|
|
26
|
+
|
|
27
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
28
|
+
|
|
29
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
30
|
+
|
|
31
|
+
## Add your files
|
|
32
|
+
|
|
33
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
34
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
cd existing_repo
|
|
38
|
+
git remote add origin https://gitlab.tech.orange/cairo-engineering-software-team/zscams/agent.git
|
|
39
|
+
git branch -M main
|
|
40
|
+
git push -uf origin main
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Integrate with your tools
|
|
44
|
+
|
|
45
|
+
- [ ] [Set up project integrations](https://gitlab.tech.orange/cairo-engineering-software-team/zscams/agent/-/settings/integrations)
|
|
46
|
+
|
|
47
|
+
## Collaborate with your team
|
|
48
|
+
|
|
49
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
50
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
51
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
52
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
53
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
54
|
+
|
|
55
|
+
## Test and Deploy
|
|
56
|
+
|
|
57
|
+
Use the built-in continuous integration in GitLab.
|
|
58
|
+
|
|
59
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
|
|
60
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
61
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
62
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
63
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
# Editing this README
|
|
68
|
+
|
|
69
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
70
|
+
|
|
71
|
+
## Suggestions for a good README
|
|
72
|
+
|
|
73
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
74
|
+
|
|
75
|
+
## Name
|
|
76
|
+
Choose a self-explaining name for your project.
|
|
77
|
+
|
|
78
|
+
## Description
|
|
79
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
80
|
+
|
|
81
|
+
## Badges
|
|
82
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
83
|
+
|
|
84
|
+
## Visuals
|
|
85
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
86
|
+
|
|
87
|
+
## Installation
|
|
88
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
92
|
+
|
|
93
|
+
## Support
|
|
94
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
95
|
+
|
|
96
|
+
## Roadmap
|
|
97
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
98
|
+
|
|
99
|
+
## Contributing
|
|
100
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
101
|
+
|
|
102
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
103
|
+
|
|
104
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
105
|
+
|
|
106
|
+
## Authors and acknowledgment
|
|
107
|
+
Show your appreciation to those who have contributed to the project.
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
For open source projects, say how it is licensed.
|
|
111
|
+
|
|
112
|
+
## Project status
|
|
113
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
114
|
+
|
zscams-2.0.5/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Agent
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.tech.orange/cairo-engineering-software-team/zscams/agent.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](https://gitlab.tech.orange/cairo-engineering-software-team/zscams/agent/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "zscams_agent"
|
|
3
|
+
|
|
4
|
+
[tool.poetry]
|
|
5
|
+
name = "zscams"
|
|
6
|
+
version = "2.0.5"
|
|
7
|
+
description = "Async TLS tunnel client with SNI routing, auto-reconnect, and health checks"
|
|
8
|
+
authors = ["OCD - Cairo Software Team"]
|
|
9
|
+
maintainers = ["OCD - Cairo Software Team"]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
packages = [ { include = "zscams"}]
|
|
12
|
+
|
|
13
|
+
[tool.poetry.dependencies]
|
|
14
|
+
python = ">=3.9"
|
|
15
|
+
requests = "*"
|
|
16
|
+
getmac = "*"
|
|
17
|
+
PyYAML = { version = "*", markers = "'freebsd' not in sys_platform" }
|
|
18
|
+
cryptography = { version = "*", markers = "'freebsd' not in sys_platform" }
|
|
19
|
+
psutil = { version = "*", markers = "'freebsd' not in sys_platform" }
|
|
20
|
+
|
|
21
|
+
[tool.poetry.scripts]
|
|
22
|
+
zscams = "zscams.__main__:main"
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["poetry-core>=1.0.0"]
|
|
26
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Main entry point for ZSCAMs Agent
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import sys
|
|
7
|
+
import os
|
|
8
|
+
from zscams.agent.src.core.backend.bootstrap import bootstrap
|
|
9
|
+
from zscams.agent.src.core.backend.update_machine_info import update_machine_info
|
|
10
|
+
from zscams.agent.src.support.logger import get_logger
|
|
11
|
+
from zscams.agent import init_parser, ensure_bootstrapped, run
|
|
12
|
+
|
|
13
|
+
logger = get_logger("ZSCAMs")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
"""Main function to run the asynchronous main."""
|
|
18
|
+
args = init_parser().parse_args()
|
|
19
|
+
|
|
20
|
+
if args.bootstrap:
|
|
21
|
+
try:
|
|
22
|
+
if os.geteuid() != 0:
|
|
23
|
+
logger.error("You are NOT running as root.")
|
|
24
|
+
sys.exit(1)
|
|
25
|
+
bootstrap()
|
|
26
|
+
sys.exit(0)
|
|
27
|
+
except Exception as exception:
|
|
28
|
+
logger.error(exception)
|
|
29
|
+
sys.exit(1)
|
|
30
|
+
|
|
31
|
+
if args.update_machine_info:
|
|
32
|
+
update_machine_info()
|
|
33
|
+
sys.exit(0)
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
ensure_bootstrapped()
|
|
37
|
+
asyncio.run(run())
|
|
38
|
+
except KeyboardInterrupt:
|
|
39
|
+
logger.info("Exiting TLS Tunnel Client")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
main()
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import asyncio
|
|
3
|
+
import sys
|
|
4
|
+
import argparse
|
|
5
|
+
from zscams.agent.src.support.configuration import get_config, CONFIG_PATH
|
|
6
|
+
from zscams.agent.src.support.filesystem import is_file_exists, resolve_path
|
|
7
|
+
from zscams.agent.src.core.tunnel.tls import create_ssl_context
|
|
8
|
+
from zscams.agent.src.core.tunnels import start_all_tunnels
|
|
9
|
+
from zscams.agent.src.core.services import start_all_services
|
|
10
|
+
from zscams.agent.src.core.service_health_check import monitor_services
|
|
11
|
+
from zscams.agent.src.core.backend.client import backend_client
|
|
12
|
+
from zscams.agent.src.support.logger import get_logger
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
logger = get_logger("tls_tunnel_main")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def init_parser():
|
|
19
|
+
parser = argparse.ArgumentParser(description="ZSCAMs Agent")
|
|
20
|
+
parser.add_argument(
|
|
21
|
+
"--bootstrap",
|
|
22
|
+
action="store_true",
|
|
23
|
+
help="Run bootstrap process and exit",
|
|
24
|
+
)
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"--update-machine-info",
|
|
27
|
+
action="store_true",
|
|
28
|
+
help="Run bootstrap process and exit",
|
|
29
|
+
)
|
|
30
|
+
return parser
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def ensure_bootstrapped():
|
|
34
|
+
"""Ensure the agent is bootstrapped with the backend."""
|
|
35
|
+
|
|
36
|
+
config = get_config()
|
|
37
|
+
remote_cfg = config["remote"]
|
|
38
|
+
config_dir = os.path.dirname(CONFIG_PATH)
|
|
39
|
+
|
|
40
|
+
files_to_ensure = [
|
|
41
|
+
resolve_path(remote_cfg.get("ca_cert"), config_dir),
|
|
42
|
+
resolve_path(remote_cfg.get("client_cert"), config_dir),
|
|
43
|
+
resolve_path(remote_cfg.get("client_key"), config_dir),
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
has_missing_file = False
|
|
47
|
+
|
|
48
|
+
for file in files_to_ensure:
|
|
49
|
+
if not is_file_exists(file, logger):
|
|
50
|
+
has_missing_file = True
|
|
51
|
+
break
|
|
52
|
+
|
|
53
|
+
bootstrapped = backend_client.is_bootstrapped()
|
|
54
|
+
|
|
55
|
+
logger.debug("Agent has entry on server: %s", bootstrapped)
|
|
56
|
+
|
|
57
|
+
if not bootstrapped or has_missing_file:
|
|
58
|
+
logger.error(
|
|
59
|
+
"Agent is not bootstrapped. Please run `zscams --bootstrap` to start the bootstrap process.",
|
|
60
|
+
)
|
|
61
|
+
sys.exit(1)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
async def run():
|
|
65
|
+
"""Asynchronous main function to start tunnels and services."""
|
|
66
|
+
|
|
67
|
+
config = get_config()
|
|
68
|
+
config_dir = os.path.dirname(CONFIG_PATH)
|
|
69
|
+
ssl_context = create_ssl_context(config["remote"], config_dir=config_dir)
|
|
70
|
+
remote_host = config["remote"]["host"]
|
|
71
|
+
remote_port = config["remote"]["port"]
|
|
72
|
+
|
|
73
|
+
# Start tunnels and wait for readiness
|
|
74
|
+
tunnel_tasks = await start_all_tunnels(
|
|
75
|
+
config.get("forwards", []), remote_host, remote_port, ssl_context
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Start services that depend on tunnels
|
|
79
|
+
service_tasks = asyncio.create_task(
|
|
80
|
+
start_all_services(config.get("services", []), config_dir=config_dir)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Start health checks
|
|
84
|
+
monitor_task = asyncio.create_task(
|
|
85
|
+
monitor_services(
|
|
86
|
+
config.get("services", []),
|
|
87
|
+
config_dir=config_dir,
|
|
88
|
+
interval=config.get("general", {}).get("health_check_interval", 300),
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
logger.info("[*] All tunnels and services started. Press Ctrl+C to stop.")
|
|
93
|
+
await asyncio.gather(*tunnel_tasks, service_tasks, monitor_task)
|
|
File without changes
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
backend:
|
|
3
|
+
base_url: http://22.0.122.40:5000/api
|
|
4
|
+
cache_dir: .cache
|
|
5
|
+
bootstrap_info:
|
|
6
|
+
blacklist_ports: []
|
|
7
|
+
cert_issuer: ZSCAMs
|
|
8
|
+
csr:
|
|
9
|
+
country: FR
|
|
10
|
+
default_common_name: zscams-agent.orangecyberdefense.com
|
|
11
|
+
locality: Paris
|
|
12
|
+
organization: zscams-agent.orangecyberdefense.com
|
|
13
|
+
state: Ile-de-France
|
|
14
|
+
forwards:
|
|
15
|
+
- description: Forward to SSH backend
|
|
16
|
+
local_port: 4422
|
|
17
|
+
sni_hostname: ssh-tunnel
|
|
18
|
+
- description: Forward to Seculogs
|
|
19
|
+
local_port: 4423
|
|
20
|
+
sni_hostname: monitor-tunnel
|
|
21
|
+
general:
|
|
22
|
+
health_check_interval: 30
|
|
23
|
+
logging:
|
|
24
|
+
level: 10
|
|
25
|
+
remote:
|
|
26
|
+
ca_cert: certificates/ca_chain.pem
|
|
27
|
+
ca_chain: certificates/ca_chain.pem
|
|
28
|
+
client_cert: certificates/client.crt
|
|
29
|
+
client_key: certificates/client.key
|
|
30
|
+
host: 81.255.240.214
|
|
31
|
+
port: 443
|
|
32
|
+
verify_cert: false
|
|
33
|
+
services:
|
|
34
|
+
- args: []
|
|
35
|
+
custom_port_name: reverse_port
|
|
36
|
+
health:
|
|
37
|
+
host: localhost
|
|
38
|
+
port: 22
|
|
39
|
+
name: Reverse SSH
|
|
40
|
+
params:
|
|
41
|
+
local_port: 4422
|
|
42
|
+
private_key: zscams/agent/keys/autoport.key
|
|
43
|
+
remote_host: localhost
|
|
44
|
+
reverse_port: 10000
|
|
45
|
+
server_ssh_user: ssh_user
|
|
46
|
+
ssh_options:
|
|
47
|
+
- -o LogLevel=error
|
|
48
|
+
- -o UserKnownHostsFile=/dev/null
|
|
49
|
+
- -o StrictHostKeyChecking=no
|
|
50
|
+
- -o ServerAliveInterval=30
|
|
51
|
+
- -o ServerAliveCountMax=2
|
|
52
|
+
port: 22
|
|
53
|
+
prerequisites:
|
|
54
|
+
files:
|
|
55
|
+
- zscams/agent/keys/autoport.key
|
|
56
|
+
ports:
|
|
57
|
+
- 22
|
|
58
|
+
services: []
|
|
59
|
+
script: src/services/reverse_ssh.py
|
|
60
|
+
- args: []
|
|
61
|
+
custom_port_name: forwarder_port
|
|
62
|
+
health:
|
|
63
|
+
host: localhost
|
|
64
|
+
port: 10001
|
|
65
|
+
name: Monitor Forwarder
|
|
66
|
+
params:
|
|
67
|
+
forwarder_port: 10001
|
|
68
|
+
local_port: 4423
|
|
69
|
+
private_key: zscams/agent/keys/autoport.key
|
|
70
|
+
remote_host: 194.51.14.159
|
|
71
|
+
remote_port: 530
|
|
72
|
+
server_ssh_user: ssh_user
|
|
73
|
+
ssh_options:
|
|
74
|
+
- -o LogLevel=error
|
|
75
|
+
- -o UserKnownHostsFile=/dev/null
|
|
76
|
+
- -o StrictHostKeyChecking=no
|
|
77
|
+
- -o ServerAliveInterval=30
|
|
78
|
+
- -o ServerAliveCountMax=2
|
|
79
|
+
port: 530
|
|
80
|
+
prerequisites:
|
|
81
|
+
files:
|
|
82
|
+
- zscams/agent/keys/autoport.key
|
|
83
|
+
ports: []
|
|
84
|
+
services: []
|
|
85
|
+
script: src/services/ssh_forwarder.py
|
|
86
|
+
- args: []
|
|
87
|
+
health:
|
|
88
|
+
host: localhost
|
|
89
|
+
port: 10001
|
|
90
|
+
name: Monitor Service
|
|
91
|
+
params:
|
|
92
|
+
equipment_name: zpa-orange-swec-dev-01
|
|
93
|
+
equipment_type: zpa
|
|
94
|
+
remote_host: localhost
|
|
95
|
+
remote_port: 10001
|
|
96
|
+
service_name: Zscaler-AppConnector
|
|
97
|
+
port: 10001
|
|
98
|
+
prerequisites:
|
|
99
|
+
files: []
|
|
100
|
+
ports:
|
|
101
|
+
- 10001
|
|
102
|
+
services: []
|
|
103
|
+
script: src/services/system_monitor.py
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
backend:
|
|
3
|
+
base_url: http://22.0.122.40:5000/api
|
|
4
|
+
cache_dir: .cache
|
|
5
|
+
bootstrap_info:
|
|
6
|
+
blacklist_ports: []
|
|
7
|
+
cert_issuer: ZSCAMs
|
|
8
|
+
csr:
|
|
9
|
+
country: FR
|
|
10
|
+
default_common_name: zscams-agent.orangecyberdefense.com
|
|
11
|
+
locality: Paris
|
|
12
|
+
organization: zscams-agent.orangecyberdefense.com
|
|
13
|
+
state: Ile-de-France
|
|
14
|
+
forwards:
|
|
15
|
+
- description: Forward to SSH backend
|
|
16
|
+
local_port: 4422
|
|
17
|
+
sni_hostname: ssh-tunnel
|
|
18
|
+
- description: Forward to Seculogs
|
|
19
|
+
local_port: 4423
|
|
20
|
+
sni_hostname: monitor-tunnel
|
|
21
|
+
general:
|
|
22
|
+
health_check_interval: 30
|
|
23
|
+
logging:
|
|
24
|
+
level: 10
|
|
25
|
+
remote:
|
|
26
|
+
ca_cert: certificates/ca_chain.pem
|
|
27
|
+
ca_chain: certificates/ca_chain.pem
|
|
28
|
+
client_cert: certificates/client.crt
|
|
29
|
+
client_key: certificates/client.key
|
|
30
|
+
host: 81.255.240.214
|
|
31
|
+
port: 443
|
|
32
|
+
verify_cert: false
|
|
33
|
+
services:
|
|
34
|
+
- args: []
|
|
35
|
+
health:
|
|
36
|
+
host: localhost
|
|
37
|
+
port: 22
|
|
38
|
+
name: Reverse SSH
|
|
39
|
+
custom_port_name: "reverse_port"
|
|
40
|
+
params:
|
|
41
|
+
local_port: 4422
|
|
42
|
+
private_key: zscams/agent/keys/autoport.key
|
|
43
|
+
remote_host: localhost
|
|
44
|
+
reverse_port: "{reverse_port}"
|
|
45
|
+
server_ssh_user: ssh_user
|
|
46
|
+
ssh_options:
|
|
47
|
+
- -o LogLevel=error
|
|
48
|
+
- -o UserKnownHostsFile=/dev/null
|
|
49
|
+
- -o StrictHostKeyChecking=no
|
|
50
|
+
- -o ServerAliveInterval=30
|
|
51
|
+
- -o ServerAliveCountMax=2
|
|
52
|
+
port: 22
|
|
53
|
+
prerequisites:
|
|
54
|
+
files:
|
|
55
|
+
- zscams/agent/keys/autoport.key
|
|
56
|
+
ports:
|
|
57
|
+
- 22
|
|
58
|
+
services: []
|
|
59
|
+
script: src/services/reverse_ssh.py
|
|
60
|
+
- args: []
|
|
61
|
+
health:
|
|
62
|
+
host: localhost
|
|
63
|
+
port: "{forwarder_port}"
|
|
64
|
+
name: Monitor Forwarder
|
|
65
|
+
custom_port_name: "forwarder_port"
|
|
66
|
+
params:
|
|
67
|
+
forwarder_port: "{forwarder_port}"
|
|
68
|
+
local_port: 4423
|
|
69
|
+
private_key: zscams/agent/keys/autoport.key
|
|
70
|
+
remote_host: 194.51.14.159
|
|
71
|
+
remote_port: 530
|
|
72
|
+
server_ssh_user: ssh_user
|
|
73
|
+
ssh_options:
|
|
74
|
+
- -o LogLevel=error
|
|
75
|
+
- -o UserKnownHostsFile=/dev/null
|
|
76
|
+
- -o StrictHostKeyChecking=no
|
|
77
|
+
- -o ServerAliveInterval=30
|
|
78
|
+
- -o ServerAliveCountMax=2
|
|
79
|
+
port: 530
|
|
80
|
+
prerequisites:
|
|
81
|
+
files:
|
|
82
|
+
- zscams/agent/keys/autoport.key
|
|
83
|
+
ports: []
|
|
84
|
+
services: []
|
|
85
|
+
script: src/services/ssh_forwarder.py
|
|
86
|
+
- args: []
|
|
87
|
+
health:
|
|
88
|
+
host: localhost
|
|
89
|
+
port: "{forwarder_port}"
|
|
90
|
+
name: Monitor Service
|
|
91
|
+
params:
|
|
92
|
+
equipment_name: "{equipment_name}"
|
|
93
|
+
equipment_type: "{equipment_type}"
|
|
94
|
+
remote_host: localhost
|
|
95
|
+
remote_port: "{forwarder_port}"
|
|
96
|
+
service_name: Zscaler-AppConnector
|
|
97
|
+
port: "{forwarder_port}"
|
|
98
|
+
prerequisites:
|
|
99
|
+
files: []
|
|
100
|
+
ports:
|
|
101
|
+
- "{forwarder_port}"
|
|
102
|
+
services: []
|
|
103
|
+
script: src/services/system_monitor.py
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-----BEGIN RSA PRIVATE KEY-----
|
|
2
|
+
MIIEpQIBAAKCAQEA4kpci9i3k9OhuYpC1+0OSQCpXVRThIjtmwl9Nl4oRSsse9zj
|
|
3
|
+
vkzPShMvlZwvEzzZ/Y3hVDHLD5W3hhy63pyi75uxC9RDzb/7ckc1SdunTzj0mtAt
|
|
4
|
+
FhV+cXFZfv79NfaluN/WZwrbpMO+7+uATuEFIGe/t05PgYX9CzhaagCsC355jFHt
|
|
5
|
+
t2z/9Ul40mJkpMZwr+pk6BOSo/DeW7LNikFljqU8BjoZmGuwGuIHzF6ivhDA8hRz
|
|
6
|
+
aKVfw3e+BuxSyOH3xWxzpHSYiZGU5x9hHk8VEbkP7lISxqYdncCw1Is0O6awfXs0
|
|
7
|
+
azx7yzfUumjDdNSmrwpb5/ard30x/aE96upnRwIDAQABAoIBAQC2ghUcMWD2WDTS
|
|
8
|
+
iSGaNzZTSLZQcKefeDRy23didxRxnP2WtLP2EssIymqRdtM859JFPr4igrpsymqn
|
|
9
|
+
Ptq0mo6LQ/3KNZuuAQ4SwD3JYOAS9DPL/OSwMAu4ARyWYZ/lexV0AwxQNSCrRbjk
|
|
10
|
+
lgL5G2FgHm0wsXdMVr2c5Al//yTDauzgOJtQfi/LzuHusnz05iHzEp0ByBfiRL8z
|
|
11
|
+
xKQ9LFW7pIYUsgn4kXry5tQokH6NwDZ7vGPcjAQLD0lLDfAHF9HOiwpkQYXw8q91
|
|
12
|
+
lNvhaFHxa9jyfvuG9e66Q72YCevsCGBEl8Hvmbpz5/9oBZ6Pt82BZKjSouYh7Cya
|
|
13
|
+
a+JVxQcxAoGBAPSKdJdMXH6hCi5DBYhWnGSpDKvRwvxb2PgntCwajkaEZmuITj4y
|
|
14
|
+
dk9IH89ryl0yAmF6q2pKLyWHOir0fVX1HsnC9m2SErhMuSrhSVpcOLiI09wFwcAM
|
|
15
|
+
PRbS/6g1h/Q+MoaVuD0h9ElO8GkONBIBrmiVYqOifotXuPXjMMGT8oNpAoGBAOzk
|
|
16
|
+
+OSilwjwtwv/MkLOXqGFymSnG7l5zmt/KGxMCThjxY9b1DzyvXcUvojCRjFl4L0W
|
|
17
|
+
OyDbKRiEJZHSH6jV1gj2N8/53b3C1ziCRvHWvix7MJ7DeDfZLp0QEYZBm6Xm7mG+
|
|
18
|
+
TZ27kya0Hprev/t960UfOpwhb8+MNd1dxdgspC8vAoGBALcGpcrTyWqxZ2hGm252
|
|
19
|
+
vKkOacBzyAePSu448T4NRi17TRjwtPcSV8BxD/X0DEsCcgu5f3CXQ4BIHP4nbWOX
|
|
20
|
+
icqi1EQgD0jHi9OPOJKb8YwURNUpreDqiBJ8LAMexbnFj5Vxm6qNrkPsBD3s9oX/
|
|
21
|
+
oiT+ogwtQ59RMcs/lq9b5yf5AoGAbPmYFXVGDXLOgdJPiLPujFdDl7HX6ybBcmn4
|
|
22
|
+
ank/9JTRGPWhWLhBuDnuvHLCX48CJ3nGkYLAEOsZbU9ACSb1YwIBAsdq3hR3dSNZ
|
|
23
|
+
B39F1KiG4UICV46tBsuRhDVCKLtnBcfJZLoZI0DQo2W84zA1voJzL8eh69QQI1kz
|
|
24
|
+
3hILJTkCgYEAwT+XKnxX8jExNvpe71O2pm3mit6UyOHXB1KyT4Y3UuKjDxwZZ4w1
|
|
25
|
+
vPp6eQ3VcI+4+mpf0qs1cgDz8w35EInt60nKy0+0hwQaM7N0EmsguASHRprESZR9
|
|
26
|
+
dAPDJQ1UJlAMSJxZxFzTvMzDQHY+86GGh5mdoNwJDb0142etE7rSFUI=
|
|
27
|
+
-----END RSA PRIVATE KEY-----
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
running_services = set()
|