Skip to content

Commit

Permalink
Allow the malicioustlds.txt file to exist under 'custom/data/'.
Browse files Browse the repository at this point in the history
This is a quick fix to allow it to exist outside of a directory
under control of the CAPEv2 git repo.
  • Loading branch information
Tommy Beadle committed Jan 15, 2025
1 parent 176d018 commit c03f5e9
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit c03f5e9

Please sign in to comment.