-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from karton.core import Task | ||
|
||
from artemis import http_requests | ||
from artemis.binds import Device, Service, TaskStatus, TaskType | ||
from artemis.module_base import ArtemisBase | ||
from artemis.task_utils import get_target_host, get_target_url | ||
|
||
|
||
class DeviceIdentifier(ArtemisBase): | ||
""" | ||
Tries to identify the device (FortiOS, ...) and produces a DEVICE task with proper type (e.g. Device.FORTIOS) | ||
""" | ||
|
||
identity = "device_identifier" | ||
|
||
filters = [ | ||
{"type": TaskType.SERVICE.value, "service": Service.HTTP.value}, | ||
] | ||
|
||
@staticmethod | ||
def _identify(url: str) -> Device: | ||
response = http_requests.get(url, allow_redirects=True) | ||
if "xxxxxxxx-xxxxx" in response.headers.get("Server", "") and "/remote/login" in response.url: | ||
return Device.FORTIOS | ||
|
||
return Device.UNKNOWN | ||
|
||
def _process(self, current_task: Task, url: str, host: str, port: int) -> None: | ||
device = self._identify(url) | ||
|
||
new_task = Task( | ||
{ | ||
"type": TaskType.DEVICE, | ||
"device": device, | ||
}, | ||
payload={"host": host, "port": int(port), "ssl": current_task.get_payload("ssl")}, | ||
) | ||
self.add_task(current_task, new_task) | ||
|
||
self.db.save_task_result(task=current_task, status=TaskStatus.OK, data=device) | ||
|
||
def run(self, current_task: Task) -> None: | ||
url = get_target_url(current_task) | ||
host = get_target_host(current_task) | ||
port = current_task.get_payload("port") | ||
|
||
self.log.info(f"device identifier scanning {url}") | ||
|
||
self._process(current_task, url, host, port) | ||
|
||
|
||
if __name__ == "__main__": | ||
DeviceIdentifier().loop() |
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