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

Apply Ruff #50

Merged
merged 1 commit into from
Mar 5, 2024
Merged
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
7 changes: 4 additions & 3 deletions agent/asteroid_agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Asteroid Agent is designed to identify known exploitable vulnerabilities in a remote system. The agent expects a
message of type `v3.asset.ip.[v4,v6]` or `v3.asset.[domain_name,link]`, and emits back messages of type
`v3.report.vulnerability` with a technical report."""

import logging
from rich import logging as rich_logging
from concurrent import futures
Expand Down Expand Up @@ -46,9 +47,9 @@ def __init__(

super().__init__(agent_definition, agent_settings)
exploits.import_all()
self.exploits: list[
definitions.Exploit
] = exploits_registry.ExploitsRegistry.values()
self.exploits: list[definitions.Exploit] = (
exploits_registry.ExploitsRegistry.values()
)

def process(self, message: m.Message) -> None:
"""Process messages of type `v3.asset.ip.[v4,v6]` or `v3.asset.[domain_name,link]` and performs a network
Expand Down
1 change: 1 addition & 0 deletions agent/definitions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteriod definitions"""

import abc
import dataclasses

Expand Down
1 change: 1 addition & 0 deletions agent/exploits/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Importer module."""

from agent import importer

import_all = importer.importer_for(__file__, __name__)
1 change: 1 addition & 0 deletions agent/exploits/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common utilities for the exploits."""

import ipaddress


Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2014_7169.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2014-7169"""

import requests
from ostorlab.agent.kb import kb
from ostorlab.agent.mixins import agent_report_vulnerability_mixin
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2016_2386.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2016-2386"""

import re
from urllib import parse as urlparse

Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2018_13382.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2018-13382: Not tested on a live target."""

import requests
from urllib3 import exceptions
from urllib3 import disable_warnings
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2018_14558.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2018-14558"""

import requests
from ostorlab.agent.kb import kb
from ostorlab.agent.mixins import agent_report_vulnerability_mixin
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2018_14667.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2018-14667"""

import re

import requests
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2018_15133.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2018-15133"""

import re
from urllib import parse as urlparse

Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2018_7841.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2018-7841"""

import requests
from ostorlab.agent.kb import kb
from ostorlab.agent.mixins import agent_report_vulnerability_mixin
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2019_12989__cve_2019_12991.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2019-12989 and CVE-2019-12991 remarque:not tested on a live target"""

import random
import logging

Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2019_7193.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2019-7193"""

import re

import requests
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2021_32648.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2021-32648. Has the potential to generate false positives."""

import logging
import random
import string
Expand Down
11 changes: 6 additions & 5 deletions agent/exploits/cve_2022_26318.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2022_26318"""

import gzip

import requests
Expand Down Expand Up @@ -97,11 +98,11 @@ def _build_payload(self) -> bytes:
)

# shell code
payload += b"\x48\xC7\xC2\x30\x00\x00\x00" # mov rdx,0x30
payload += b"\x48\x89\xE6" # mov rsi,rsp
payload += b"\x48\x83\xC6\x2e" # add rsi,0x2e
payload += b"\x48\xC7\xC7\x09\x00\x00\x00" # mov rdi,0x9
payload += b"\x48\xC7\xC0\x01\x00\x00\x00" # mov rax,0x1
payload += b"\x48\xc7\xc2\x30\x00\x00\x00" # mov rdx,0x30
payload += b"\x48\x89\xe6" # mov rsi,rsp
payload += b"\x48\x83\xc6\x2e" # add rsi,0x2e
payload += b"\x48\xc7\xc7\x09\x00\x00\x00" # mov rdi,0x9
payload += b"\x48\xc7\xc0\x01\x00\x00\x00" # mov rax,0x1
payload += b"\x0f\x05" # syscall
payload += b"\x48\xc7\xc0\x3c\x00\x00\x00" # mov rax,0x3c
payload += b"\x48\xc7\xc7\x00\x00\x00\x00" # mov rdi,0x0
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2023_27997.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2021-22941"""

import hashlib
import re
import struct
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2023_36845.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2023–36845"""

import re

import requests
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2023_43770.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2023-43770"""

import re
from urllib import parse as urlparse

Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2023_49897.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2023-49897."""

import re

import requests
Expand Down
1 change: 1 addition & 0 deletions agent/exploits/cve_2024_21733.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation for CVE-2024-21733"""

import re
from urllib import parse as urlparse

Expand Down
1 change: 1 addition & 0 deletions agent/exploits/exposed_adb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Agent Asteroid implementation to detect unauthenticated exposed adb"""

import socket

from adb_shell import adb_device
Expand Down
1 change: 1 addition & 0 deletions agent/exploits_registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Register for exploits."""

from collections import defaultdict
from typing import Type, Any

Expand Down
1 change: 1 addition & 0 deletions agent/importer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dynamic importer to enable registry pattern."""

import logging
import sys
import traceback
Expand Down
1 change: 1 addition & 0 deletions agent/targets_preparer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Target Preparer Module for Asteroid Agent"""

from typing import Generator

from ostorlab.agent.message import message as m
Expand Down
1 change: 1 addition & 0 deletions tests/asteroid_agent_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for AsteroidAgent."""

from typing import Type, Iterator

from ostorlab.agent.message import message as m
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pytest fixtures for agent Asteroid"""

import pathlib
import random
from typing import Type, Generator
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2014_7169_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for CVE-2014-7169"""

import datetime
import random

Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2016_2386_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for CVE-2016-2386"""

import re

import requests_mock as req_mock
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2018_13382_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Agent Asteroid: CVE-2018-13382"""

import requests_mock as req_mock

from agent import definitions
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2018_14558_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for CVE-2018-14558"""

import datetime
import random

Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2018_15133_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Agent Asteroid: CVE-2018-15133"""

import re

import requests_mock as req_mock
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2018_7841_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for CVE-2018-7841"""

import datetime
import random

Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2019_7193_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for CVE-2019-7193"""

import requests_mock as req_mock
from agent.exploits import cve_2019_7193
from agent import definitions
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2021_22941_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Agent Asteriod exploits"""

import re

import requests_mock as req_mock
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2021_32648_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Agent Asteriod: CVE_2021_32648."""

import re

import requests_mock as req_mock
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2023_22518_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for CVE-2023-22518"""

import re

import requests_mock as req_mock
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2023_27997_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Agent Asteriod exploits"""

import datetime

import requests
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2023_36845_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for CVE-2023-36845"""

import requests_mock as req_mock
from agent.exploits import cve_2023_36845
from agent import definitions
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2023_43770_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Agent Asteroid: CVE-2023-43770"""

import re

import requests_mock as req_mock
Expand Down
1 change: 1 addition & 0 deletions tests/exploits/cve_2024_21733_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Agent Asteroid: CVE-2024-21733"""

import re

import requests_mock as req_mock
Expand Down
1 change: 1 addition & 0 deletions tests/exploits_registry_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for the exploits' registry."""

import collections

from agent import exploits_registry
Expand Down
1 change: 1 addition & 0 deletions tests/targets_preparer_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for target preparer"""

from ostorlab.agent.message import message
import pytest
from agent import targets_preparer
Expand Down
Loading