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

Draft: Added EyeWitness #75

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ services:
restart: always
command: "python3 -m artemis.modules.karton_ssl_checks"

karton-eyewitness:
build:
context: Artemis-modules-extra
dockerfile: karton_eyewitness/Dockerfile
volumes: ["./docker/karton.ini:/etc/karton/karton.ini", "${DOCKER_COMPOSE_ADDITIONAL_SHARED_DIRECTORY:-./shared}:/shared/"]
depends_on: [karton-system]
env_file: .env
restart: always
command: "python3 -m artemis.modules.karton_eyewitness"

autoreporter:
volumes:
- ./Artemis-modules-extra/extra_modules_config.py:/opt/extra_modules_config.py
Expand Down
14 changes: 14 additions & 0 deletions karton_eyewitness/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM certpl/artemis:latest

RUN apk add git

RUN git clone https://github.com/RedSiege/EyeWitness.git /eyewitness

COPY karton_eyewitness/requirements.txt /requirements_eyewitness.txt
RUN pip install -r /requirements_eyewitness.txt

RUN /eyewitness/Python/setup/setup.sh

WORKDIR /opt/

COPY karton_eyewitness/karton_eyewitness.py /opt/artemis/modules/
118 changes: 118 additions & 0 deletions karton_eyewitness/karton_eyewitness.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/env python3
import dataclasses
import json
import os
import shutil
import subprocess
from typing import Any, Dict, List
from bs4 import BeautifulSoup

from karton.core import Task

from artemis.binds import Service, TaskStatus, TaskType
from artemis.config import Config
from artemis.module_base import ArtemisBase
from artemis.task_utils import get_target_url


@dataclasses.dataclass
class Message:
category: str
problems: List[str]

@property
def message(self) -> str:
return f"{self.category}: {', '.join(self.problems)}"


def parse_http(html_content: str) -> List[str]:
soup = BeautifulSoup(html_content, 'html.parser')

table = soup.find('table')
extracted_content = []
if table:
rows = table.find_all('tr')
for row in rows:
cells = row.find_all(['th', 'td'])
if cells:
first_column_content = cells[0].text.strip()
# Extracting content separated by <br> tags
extracted_content = [content.strip().rstrip('\n') for content in first_column_content.split('<br>')]

return extracted_content
return []

class EyeWitness(ArtemisBase):
"""
Runs EyeWitness -> EyeWitness is designed to take screenshots of websites provide some server header info,
and identify default credentials if known.
"""

identity = "eyewitness"
filters = [
{"type": TaskType.SERVICE.value, "service": Service.HTTP.value},
]

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)

def run(self, current_task: Task) -> None:

base_url = get_target_url(current_task)
result_location = "/eyewitness/results/"

data = subprocess.check_output(
[
"python3",
"Python/EyeWitness.py",
"--web",
"--single",
base_url,
"--no-prompt",
"--delay",
str(1.0 / Config.Limits.REQUESTS_PER_SECOND) if Config.Limits.REQUESTS_PER_SECOND else "0",
# ("--user-agent" + str(Config.Miscellaneous.CUSTOM_USER_AGENT)) if Config.Miscellaneous.CUSTOM_USER_AGENT else " ",
"-d",
result_location
],
cwd="/eyewitness",
stderr=subprocess.DEVNULL,
)

data = open(result_location + "report.html", "r").read()

# Check if the input string is empty
if data.strip():
result = data
else:
result = []

messages = parse_http(data)

# cleanup files
try:
shutil.rmtree(result_location)
except OSError as e:
print("Error: %s - %s." % (e.filename, e.strerror))

if messages:
status = TaskStatus.INTERESTING
status_reason = ", ".join([message for message in messages])
else:
status = TaskStatus.OK
status_reason = None

self.db.save_task_result(
task=current_task,
status=status,
status_reason=status_reason,
data={
"original_result": result,
"message_data": messages,
"messages": messages,
},
)


if __name__ == "__main__":
EyeWitness().loop()
1 change: 1 addition & 0 deletions karton_eyewitness/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
beautifulsoup4==4.12.3
Loading