-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New module using what-vpn #117
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
51de997
Introduce a working module draft
lukigruszka ee8f157
Return OK/INTERESTING statuses
7d1cc75
Add -K and -t arguments passed to what-vpn
lukigruszka aad3323
Add risk/load and limit accepted service types
lukigruszka c966e6e
Consume all error messages
lukigruszka 1668c7f
Pin version of what-vpn and fix linter errors
lukigruszka 0fdbc7d
Fix incompatible types linter error
lukigruszka b5049f7
Changed returned data type from array to string
lukigruszka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM certpl/artemis:latest | ||
|
||
RUN apk add git | ||
RUN pip3 install https://github.com/dlenski/what-vpn/archive/607c351037acb1fae06ba98760f462a3aa61b359.zip | ||
# Last release v0.7 is from 2022, but current master branch contains significant improvements | ||
|
||
WORKDIR /opt/ | ||
COPY karton_whatvpn/karton_whatvpn.py ./artemis/modules | ||
COPY extra_modules_config.py . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import subprocess | ||
|
||
from artemis import load_risk_class, utils | ||
from artemis.binds import TaskStatus, TaskType | ||
from artemis.module_base import ArtemisBase | ||
from artemis.task_utils import get_target_host | ||
from karton.core import Task | ||
|
||
from extra_modules_config import ExtraModulesConfig | ||
|
||
logger = utils.build_logger(__name__) | ||
|
||
|
||
@load_risk_class.load_risk_class(load_risk_class.LoadRiskClass.LOW) | ||
class WhatVPN(ArtemisBase): # type: ignore | ||
""" | ||
Runs what-vpn -> SSL VPN identifier | ||
""" | ||
|
||
identity = "what-vpn" | ||
filters = [{"type": TaskType.IP.value}] | ||
|
||
def _process(self, current_task: Task, host: str) -> None: | ||
output = subprocess.run( | ||
["what-vpn", "--keep-going-after-exception", "--timeout", ExtraModulesConfig.WHATVPN_TIMEOUT_SECONDS, host], | ||
capture_output=True, | ||
) | ||
output_str = output.stdout.decode("utf-8") | ||
detected_vpn = None | ||
|
||
error_messages = ["error", "timeout"] | ||
if any(msg in output_str for msg in error_messages): | ||
status = TaskStatus.ERROR | ||
status_reason = "Error or timeout occurred" | ||
elif "no match" in output_str: | ||
status = TaskStatus.OK | ||
status_reason = "Could not identify a VPN gateway" | ||
else: | ||
# Format of what-vpn output: | ||
# scanned_host: identified_VPN [VPN_version] | ||
detected_vpn = output_str.split(" ", 1)[1] | ||
status = TaskStatus.INTERESTING | ||
status_reason = f"Detected {detected_vpn}" | ||
|
||
# Save the task result to the database | ||
self.db.save_task_result( | ||
task=current_task, | ||
status=status, | ||
status_reason=status_reason, | ||
data=detected_vpn, | ||
) | ||
|
||
def run(self, current_task: Task) -> None: | ||
target_host = get_target_host(current_task) | ||
|
||
self.log.info("Requested to check if %s is a VPN gateway", target_host) | ||
|
||
self._process(current_task, target_host) | ||
|
||
|
||
if __name__ == "__main__": | ||
WhatVPN().loop() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TaskStatus.ERROR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed the logic to return separate OK and ERROR statuses