Skip to content

Commit

Permalink
style: Automatic code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 2, 2025
1 parent a322aa6 commit 5b46031
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
18 changes: 10 additions & 8 deletions modules/signatures/all/network_cnc_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.


import os
import logging
import ipaddress
import csv
import ipaddress
import logging
import os

from lib.cuckoo.common.constants import CUCKOO_ROOT
from lib.cuckoo.common.abstracts import Signature
from lib.cuckoo.common.constants import CUCKOO_ROOT

log = logging.getLogger()

ip_ranges = []
HAVE_MSFT_PUB_IPS = False
msf_public_ips_list = os.path.join(CUCKOO_ROOT, "extra", "msft-public-ips.csv")
if os.path.exists(msf_public_ips_list):
with open(msf_public_ips_list, 'r') as file:
with open(msf_public_ips_list, "r") as file:
reader = csv.DictReader(file)
for row in reader:
ip_ranges.append(row['Prefix'])
ip_ranges.append(row["Prefix"])
HAVE_MSFT_PUB_IPS = True
else:
log.debug("Missed file extra/msft-public-ips.csv. Get a fresh copy from https://www.microsoft.com/en-us/download/details.aspx?id=53602")
log.debug(
"Missed file extra/msft-public-ips.csv. Get a fresh copy from https://www.microsoft.com/en-us/download/details.aspx?id=53602"
)


def check_ip_in_ranges(ip_address):
Expand Down Expand Up @@ -81,7 +83,7 @@ class NetworkMultipleDirectIPConnections(Signature):
severity = 2
confidence = 30
categories = ["network", "c2"]
authors = ["Kevin Ross","Wassime BATTA"]
authors = ["Kevin Ross", "Wassime BATTA"]
minimum = "1.3"
enabled = False

Expand Down
23 changes: 14 additions & 9 deletions modules/signatures/all/pdf_annot_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
from urllib.parse import urlparse, parse_qs
from urllib.parse import parse_qs, urlparse

from lib.cuckoo.common.abstracts import Signature
from lib.cuckoo.common.constants import CUCKOO_ROOT
Expand Down Expand Up @@ -46,7 +46,7 @@ class PDF_Annot_URLs_Checker(Signature):
minimum = "0.5"
enaled = False

filter_analysistypes = set(["file","static"])
filter_analysistypes = set(["file", "static"])

malicious_tlds_files = (
"custom/data/malicioustlds.txt",
Expand Down Expand Up @@ -87,8 +87,9 @@ def run(self):
for entry in self.results.get("target").get("file", {}).get("pdf", {}).get("Annot_URLs", []):
entry_lower = entry.lower()
self.data.append({"url": entry})
if entry_lower.endswith((".exe", ".zip", ".rar", ".bat", ".cmd", ".js", ".jse", ".vbs", ".vbe", ".ps1", ".psm1", ".sh")) \
and not entry_lower.startswith("mailto:"):
if entry_lower.endswith(
(".exe", ".zip", ".rar", ".bat", ".cmd", ".js", ".jse", ".vbs", ".vbe", ".ps1", ".psm1", ".sh")
) and not entry_lower.startswith("mailto:"):
found_malicious_extension = True
if entry_lower.startswith(("http://", "https://")):
domain_start = entry_lower.find("//") + 2
Expand All @@ -108,12 +109,16 @@ def run(self):
blacklisted_server, server = self.check_dnsbbl(target)
if blacklisted_server:
found_blacklist_ip = True
self.data.append({"blacklisted": f"The domain or IP address {target} is blacklisted on the following server: {server} "})
#break # Stop checking once blacklisted IP is found
#print ( blacklisted_server)
#else:
self.data.append(
{
"blacklisted": f"The domain or IP address {target} is blacklisted on the following server: {server} "
}
)
# break # Stop checking once blacklisted IP is found
# print ( blacklisted_server)
# else:
# print(f"The domain or IP address {target} is not blacklisted.")
if found_malicious_domain or found_malicious_extension or found_blacklist_ip :
if found_malicious_domain or found_malicious_extension or found_blacklist_ip:
self.severity = 6
self.description = "The PDF contains a Malicious Link Annotation"
suspect = True
Expand Down

0 comments on commit 5b46031

Please sign in to comment.