Commit 3bcdbe1f authored by hackhard's avatar hackhard
Browse files

Removed logical error

parent 5ad1ac3c
......@@ -108,6 +108,12 @@ class Analyzer:
# Loads JSON
HAR_json_tor = json.loads(tor.http_requests)
HAR_json_non_tor = json.loads(non_tor.http_requests)
self.captcha_checker_value = None
self.dom_analyze_value = None
self.status_check_value = None
self.consensus_lite_dom_value = None
self.consensus_lite_captcha_value = None
self.status_check(
tor.html_data,
......@@ -335,7 +341,6 @@ class Analyzer:
proxy_node_detail.append(node_proxy)
proxy_node_count.append(len(node_proxy))
print(proxy_node_count)
self.captcha_proxy_val = captcha_val_proxy
self.__logger.info(
"Nodes by tor: %f, non-tor: %f and proxies: %s",
......@@ -377,7 +382,7 @@ class Analyzer:
if _ in self.soup_t and _ not in self.soup_n:
res = 1
if res == 0:
self.__logger.info("Same!!")
self.__logger.info("Survived Checklist but still doubt (Further modules might help)")
self.dom_analyze_value = 2
else:
self.__logger.info("Tor Blocked : checklist!! ")
......@@ -414,57 +419,58 @@ class Analyzer:
"""
tor_H = {}
tor_N = {}
try:
for i in range(0, len(tor_http_requests["log"]["entries"])):
tor_H[
tor_http_requests["log"]["entries"][i]["request"]["url"]
] = tor_http_requests["log"]["entries"][i]["response"]["status"]
# pylint: disable=C0206
for i in tor_H:
if tor_H[i] != 0 or tor_H != "" or tor_H is not None:
self.tor_store[i] = tor_H[i] # type: ignore
for i in range(0, len(tor_http_requests["log"]["entries"])):
tor_H[
tor_http_requests["log"]["entries"][i]["request"]["url"]
] = tor_http_requests["log"]["entries"][i]["response"]["status"]
for i in range(len(non_tor_http_requests["log"]["entries"])):
tor_N[
non_tor_http_requests["log"]["entries"][i]["request"]["url"]
] = non_tor_http_requests["log"]["entries"][i]["response"]["status"]
# pylint: disable=C0206
for i in tor_H:
if tor_H[i] != 0 or tor_H != "" or tor_H is not None:
self.tor_store[i] = tor_H[i] # type: ignore
# pylint: disable=C0206
for i in tor_N:
if tor_N[i] != 0 or tor_N != "" or tor_N is not None:
self.non_store[i] = tor_N[i] # type: ignore
for i in range(len(non_tor_http_requests["log"]["entries"])):
tor_N[
non_tor_http_requests["log"]["entries"][i]["request"]["url"]
] = non_tor_http_requests["log"]["entries"][i]["response"]["status"]
first_url_t = list(self.tor_store.keys())[0]
first_status_t = self.tor_store[str(first_url_t)]
# pylint: disable=C0206
for i in tor_N:
if tor_N[i] != 0 or tor_N != "" or tor_N is not None:
self.non_store[i] = tor_N[i] # type: ignore
first_url_t = list(self.tor_store.keys())[0]
first_status_t = self.tor_store[str(first_url_t)]
# non tor use HARExportTrigger
first_url_nt = list(self.non_store.keys())[0]
first_status_nt = self.non_store[str(first_url_nt)]
if int(first_status_t) > 399 and int(first_status_nt) < 400:
# Error for tag and no error for non tor
self.__logger.info("Tor Blocked")
self.status_check_value = 0
elif int(first_status_t) > 399 and int(first_status_nt) > 399:
# Both blocked on tor and non-tor
self.__logger.info("Site is blocked on tor and non-tor browsers")
self.status_check_value = 1
elif int(first_status_t) < 300 and int(first_status_nt) > 399:
# When tor isn't blocked and non-tor is blocked
self.__logger.info("Tor is not blocked, rather non-tor browser is blocked")
self.status_check_value = 2
else:
if int(first_status_t) > 299 and int(first_status_t) < 400:
# Chek if tor returns error pages or warning or captchas due to reload
self.dom_analyze(
tor_html_data, non_tor_html_data, proxy_countries_html_code
)
# non tor use HARExportTrigger
first_url_nt = list(self.non_store.keys())[0]
first_status_nt = self.non_store[str(first_url_nt)]
elif int(first_status_t) < 300 and int(first_status_nt) < 300:
# When both tor and non tor returns no errors
self.dom_analyze(
tor_html_data, non_tor_html_data, proxy_countries_html_code
)
if int(first_status_t) > 399 and int(first_status_nt) < 400:
# Error for tag and no error for non tor
self.__logger.info("Tor Blocked")
self.status_check_value = 0
elif int(first_status_t) > 399 and int(first_status_nt) > 399:
# Both blocked on tor and non-tor
self.__logger.info("Site is blocked on tor and non-tor browsers")
self.status_check_value = 1
elif int(first_status_t) < 300 and int(first_status_nt) > 399:
# When tor isn't blocked and non-tor is blocked
self.__logger.info("Tor is not blocked, rather non-tor browser is blocked")
self.status_check_value = 2
else:
if int(first_status_t) > 299 and int(first_status_t) < 400:
# Chek if tor returns error pages or warning or captchas due to reload
self.dom_analyze(
tor_html_data, non_tor_html_data, proxy_countries_html_code
)
elif int(first_status_t) < 300 and int(first_status_nt) < 300:
# When both tor and non tor returns no errors
self.dom_analyze(
tor_html_data, non_tor_html_data, proxy_countries_html_code
)
except TypeError as e:
self.__logger.debug("Check for the HARExport. Might have actually returned nothing")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment