-
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
Changes from 5 commits
51de997
ee8f157
7d1cc75
aad3323
c966e6e
1668c7f
0fdbc7d
b5049f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM certpl/artemis:latest | ||
|
||
RUN apk add git | ||
RUN pip install requests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. requests is already in the artemis image There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
RUN pip3 install https://github.com/dlenski/what-vpn/archive/master.zip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pin versions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pinned latest hash on master branch |
||
|
||
WORKDIR /opt/ | ||
COPY karton_whatvpn/karton_whatvpn.py ./artemis/modules | ||
COPY extra_modules_config.py . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import subprocess | ||
|
||
from artemis import utils, load_risk_class | ||
from artemis.binds import TaskStatus, TaskType, Service | ||
from artemis.module_base import ArtemisBase | ||
from artemis.task_utils import get_target_url, get_target_host | ||
from karton.core import Task | ||
import string | ||
|
||
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): | ||
""" | ||
Runs what-vpn -> SSL VPN identifier | ||
""" | ||
|
||
identity = "what-vpn" | ||
filters = [ | ||
{"type": TaskType.IP.value} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm, if you want a service on a port, use TaskType.SERVICE There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll stay with IP task type as profit from scanning all discovered ports is debatable while increase number of sent requests is noticeable. |
||
] | ||
|
||
def _process(self, current_task: Task, host: str) -> None: | ||
output = subprocess.run( | ||
[ | ||
"what-vpn", | ||
"--keep-going-after-exception", | ||
"--timeout", | ||
ExtraModulesConfig.WHATVPN_TIMEOUT_S, | ||
host | ||
], | ||
capture_output=True | ||
) | ||
output = output.stdout.decode("utf-8") | ||
detected_vpn = [] | ||
|
||
error_messages = ["error", "timeout", "no match"] | ||
if any(msg in output for msg in error_messages): | ||
status = TaskStatus.OK | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. changed the logic to return separate OK and ERROR statuses |
||
status_reason = "Could not identify a VPN gateway" | ||
else: | ||
# Format of what-vpn output: | ||
# scanned_host: identified_VPN [VPN_version] | ||
detected_vpn.append(output.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() |
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.
nitpick: _S -> _SECOND
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 all occurrences