text stringlengths 1 93.6k |
|---|
elif 31.0 <= percentage < 67.0:
|
return 0
|
else:
|
return -1
|
# Links in <Script> and <Link> tags
|
def links_in_tags(wiki, soup, domain):
|
i = 0
|
success = 0
|
for link in soup.find_all('link', href=True):
|
dots = [x.start() for x in re.finditer(r'\.', link['href'])]
|
if wiki in link['href'] or domain in link['href'] or len(dots) == 1:
|
success = success + 1
|
i = i + 1
|
for script in soup.find_all('script', src=True):
|
dots = [x.start() for x in re.finditer(r'\.', script['src'])]
|
if wiki in script['src'] or domain in script['src'] or len(dots) == 1:
|
success = success + 1
|
i = i + 1
|
try:
|
percentage = success / float(i) * 100
|
except:
|
return 1
|
if percentage < 17.0:
|
return 1
|
elif 17.0 <= percentage < 81.0:
|
return 0
|
else:
|
return -1
|
# Server Form Handler (SFH)
|
# Have written conditions directly from word file..as there are no sites to test ######
|
def sfh(wiki, soup, domain):
|
for form in soup.find_all('form', action=True):
|
if form['action'] == "" or form['action'] == "about:blank":
|
return -1
|
elif wiki not in form['action'] and domain not in form['action']:
|
return 0
|
else:
|
return 1
|
return 1
|
# Mail Function
|
# PHP mail() function is difficult to retrieve, hence the following function is based on mailto
|
def submitting_to_email(soup):
|
for form in soup.find_all('form', action=True):
|
return -1 if "mailto:" in form['action'] else 1
|
# In case there is no form in the soup, then it is safe to return 1.
|
return 1
|
def abnormal_url(domain, url):
|
hostname = domain.name
|
match = re.search(hostname, url)
|
return 1 if match else -1
|
# IFrame Redirection
|
def i_frame(soup):
|
for i_frame in soup.find_all('i_frame', width=True, height=True, frameBorder=True):
|
# Even if one iFrame satisfies the below conditions, it is safe to return -1 for this method.
|
if i_frame['width'] == "0" and i_frame['height'] == "0" and i_frame['frameBorder'] == "0":
|
return -1
|
if i_frame['width'] == "0" or i_frame['height'] == "0" or i_frame['frameBorder'] == "0":
|
return 0
|
# If none of the iframes have a width or height of zero or a frameBorder of size 0, then it is safe to return 1.
|
return 1
|
def age_of_domain(domain):
|
creation_date = domain.creation_date
|
expiration_date = domain.expiration_date
|
ageofdomain = 0
|
if expiration_date:
|
ageofdomain = abs((expiration_date - creation_date).days)
|
return -1 if ageofdomain / 30 < 6 else 1
|
def web_traffic(url):
|
try:
|
rank = \
|
bs4.BeautifulSoup(urllib.urlopen("http://data.alexa.com/data?cli=10&dat=s&url=" + url).read(), "xml").find(
|
"REACH")['RANK']
|
except TypeError:
|
return -1
|
rank = int(rank)
|
return 1 if rank < 100000 else 0
|
def google_index(url):
|
site = search(url, 5)
|
return 1 if site else -1
|
def statistical_report(url, hostname):
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.