Skip to content
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

Domain Scanner #1146

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ba4d38e
dns_resolver
kshitijk4poor Jul 12, 2024
1b370bb
Merge branch 'CERT-Polska:main' into main
kshitijk4poor Jul 12, 2024
a578fb4
linting
kshitijk4poor Jul 13, 2024
52098dc
lookup for NS and A records
kshitijk4poor Jul 17, 2024
4852348
fixed lint
kshitijk4poor Jul 17, 2024
bd5f25a
Merge branch 'CERT-Polska:main' into main
kshitijk4poor Jul 18, 2024
1c7aa6d
yeahhh
kshitijk4poor Jul 22, 2024
5876115
added task
kshitijk4poor Jul 22, 2024
cd7d4c0
Merge branch 'CERT-Polska:main' into main
kshitijk4poor Jul 27, 2024
9bac8ef
passing pre-commit
kshitijk4poor Jul 29, 2024
1101e33
updated logic
kshitijk4poor Jul 29, 2024
15d32cd
fixed whitespace-trail
kshitijk4poor Jul 29, 2024
d70c894
should fix lint
kshitijk4poor Jul 29, 2024
57d4a4e
added test
kshitijk4poor Jul 29, 2024
e255f09
implemented the module as a function
kshitijk4poor Aug 2, 2024
23bd878
cleanup
kshitijk4poor Aug 2, 2024
c9fd4d6
lint
kshitijk4poor Aug 2, 2024
7ce1ecd
fixed
kshitijk4poor Aug 2, 2024
78ee50c
using the payload
kshitijk4poor Aug 2, 2024
481a9d7
fixed param
kshitijk4poor Aug 2, 2024
e5dcdfe
fixed context
kshitijk4poor Aug 2, 2024
9c7b86b
update
kshitijk4poor Aug 2, 2024
480d432
fixed
kshitijk4poor Aug 3, 2024
a6cfe1a
lint pass
kshitijk4poor Aug 3, 2024
c887da8
finally working
kshitijk4poor Aug 3, 2024
e4678e2
fixed with better error handling
kshitijk4poor Aug 3, 2024
7b08d3c
better logging and documentation
kshitijk4poor Aug 3, 2024
01dbe78
.
kshitijk4poor Aug 3, 2024
0e969ef
fixed triling-whitespaces and end-of-file for docker-compose.yaml
kshitijk4poor Aug 3, 2024
bdf4c06
fixed test
kshitijk4poor Aug 5, 2024
2feb681
lint
kshitijk4poor Aug 5, 2024
dc01949
Merge branch 'CERT-Polska:main' into main
kshitijk4poor Aug 5, 2024
dc356d4
fixed return
kshitijk4poor Aug 9, 2024
594aecd
lint
kshitijk4poor Aug 9, 2024
da27aa4
fix
kshitijk4poor Aug 9, 2024
a0330a5
lint
kshitijk4poor Aug 9, 2024
1977c41
Merge branch 'CERT-Polska:main' into main
kshitijk4poor Aug 9, 2024
a81a1db
fixed
kshitijk4poor Aug 13, 2024
9003dc2
lint
kshitijk4poor Aug 13, 2024
26e65f3
lint
kshitijk4poor Aug 14, 2024
5fb5944
Merge branch 'CERT-Polska:main' into main
kshitijk4poor Aug 21, 2024
4fbec0a
fix
kazet Sep 12, 2024
13bb41f
.
kazet Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions artemis/modules/domain_scanner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
from karton.core import Task
from artemis.resolvers import lookup, ResolutionException

from artemis.binds import TaskStatus, TaskType
from artemis.module_base import ArtemisBase

class DomainScanner(ArtemisBase):
"""
DNS checker to verify if domains exist in the DNS system.
"""

identity = "domain_scanner"
filters = [
{"type": TaskType.DOMAIN.value},
]

def run(self, current_task: Task) -> None:
domain = current_task.get_payload(TaskType.DOMAIN)
domain_exists = self.check_domain_exists(domain)

if domain_exists:
self.db.save_task_result(
task=current_task,
status=TaskStatus.OK,
data={
"domain": domain,
"exists": True
}
)
# Create a new task for the next module
new_task = Task(
{"type": TaskType.DOMAIN},
kshitijk4poor marked this conversation as resolved.
Show resolved Hide resolved
payload={TaskType.DOMAIN: domain},
payload_persistent={"domain_exists": True}
)
self.add_task(current_task, new_task)
else:
self.db.save_task_result(
task=current_task,
status=TaskStatus.ERROR,
status_reason=f"Domain does not exist: {domain}",
data={"domain": domain, "exists": False}
)

def check_domain_exists(self, domain: str) -> bool:
try:
# Check for NS records
ns_records = lookup(domain, "NS")
if ns_records:
return True

# If no NS records, check for A records
a_records = lookup(domain, "A")
return len(a_records) > 0
except ResolutionException:
return False

if __name__ == "__main__":
DomainScanner().loop()
11 changes: 9 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ services:
env_file: .env
restart: always
volumes: ["./docker/karton.ini:/etc/karton/karton.ini", "${DOCKER_COMPOSE_ADDITIONAL_SHARED_DIRECTORY:-./shared}:/shared/"]


karton-domain_scanner:
<<: *artemis-build-or-image
command: "python3 -m artemis.modules.domain_scanner"
depends_on: [karton-system, karton-logger]
env_file: .env
restart: always
volumes: ["./docker/karton.ini:/etc/karton/karton.ini", "${DOCKER_COMPOSE_ADDITIONAL_SHARED_DIRECTORY:-./shared}:/shared/"]

karton-drupal_scanner:
<<: *artemis-build-or-image
command: "python3 -m artemis.modules.drupal_scanner"
Expand All @@ -176,7 +184,6 @@ services:
restart: always
volumes: ["./docker/karton.ini:/etc/karton/karton.ini", "${DOCKER_COMPOSE_ADDITIONAL_SHARED_DIRECTORY:-./shared}:/shared/"]


karton-http_service_to_url:
<<: *artemis-build-or-image
command: "python3 -m artemis.modules.http_service_to_url"
Expand Down
Loading