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

Allow the malicioustlds.txt file to exist under 'custom/data/'. #476

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
15 changes: 13 additions & 2 deletions modules/signatures/all/pdf_annot_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os.path

from lib.cuckoo.common.abstracts import Signature


Expand All @@ -26,15 +28,24 @@ class PDF_Annot_URLs_Checker(Signature):

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

malicious_tlds_file = "/opt/CAPEv2/data/malicioustlds.txt"
malicious_tlds_files = (
"/opt/CAPEv2/custom/data/malicioustlds.txt",
"/opt/CAPEv2/data/malicioustlds.txt",
)

def __init__(self, *args, **kwargs):
super(PDF_Annot_URLs_Checker, self).__init__(*args, **kwargs)
self.malicious_tlds = self.load_malicious_tlds()

def load_malicious_tlds(self):
malicious_tlds = set()
with open(self.malicious_tlds_file, "r") as f:
for malicious_tlds_file in self.malicious_tlds_files:
if os.path.exists(malicious_tlds_file):
break
else:
raise FileNotFoundError(malicious_tlds_file)

with open(malicious_tlds_file, "r") as f:
for line in f:
line = line.strip()
if line.startswith("."):
Expand Down
Loading