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

Update phishing_catcher.py #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 8 additions & 2 deletions bin/phishing_catcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
app_home = "{}/etc/apps/OSweep".format(os.environ['SPLUNK_HOME'])
tp_modules = "{}/bin/_tp_modules".format(app_home)
sys.path.insert(0, tp_modules)
import entropy
import math
import pylev
import tld
import yaml
Expand All @@ -60,6 +60,12 @@ def get_modules():
return
return suspicious, confusables

def entropy(string):
"""Calculates the Shannon entropy of a string"""
prob = [ float(string.count(c)) / len(string) for c in dict.fromkeys(list(string)) ]
entropy = - sum([ p * math.log(p) / math.log(2.0) for p in prob ])
return entropy

def request_module(session, filename):
"""Return a list of tags."""
base_url = "https://raw.githubusercontent.com/x0rz/phishing_catcher/master{}"
Expand Down Expand Up @@ -125,7 +131,7 @@ def score_domain(provided_ioc):
except Exception:
domain = provided_ioc

score += int(round(entropy.shannon_entropy(domain)*50))
score += int(round(entropy(domain)*10))
domain = confusables.unconfuse(domain)
words_in_domain = re.split("\W+", domain)

Expand Down
1 change: 0 additions & 1 deletion bin/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
bs4
entropy
HTMLParser
pylev
PySocks
Expand Down