URL data analyzer and extractor. Detect malicious signs and other useful data associated with URLs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1002 lines
123 KiB

  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# URL domain registrar variation analysis\n",
  8. "\n",
  9. "Author: Pekka Helenius, 2021\n",
  10. "\n",
  11. "- Analyzes given URLs and stores results into a new JSON data file\n",
  12. "- Outputs associated domain registrars for each input URL as a plot\n",
  13. " - \"Phishing campaigns register domains of websites from the same registrar (than the legitimate URL)\""
  14. ]
  15. },
  16. {
  17. "cell_type": "code",
  18. "execution_count": 3,
  19. "metadata": {},
  20. "outputs": [
  21. {
  22. "name": "stdout",
  23. "output_type": "stream",
  24. "text": [
  25. "URL data: https://hoxhunt.com/\n",
  26. "URL data: https://hs.fi\n",
  27. "URL data: https://ts.fi\n",
  28. "URL data: https://facebook.com\n",
  29. "Generate statistics: https://hoxhunt.com/\n"
  30. ]
  31. },
  32. {
  33. "data": {
  34. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAF+CAYAAABUEbfJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOzdd7gcZfn/8fcnIRBKACkSSkJUilQVQheNiDThh4pSBCkqCIoIiiCoGCsIgoiIGAQFLIANkW8AEekIUqRIR6SEEjqEIhC4f3/cz5LJ5pQ9SSa7e/J5Xde5zu7M7O4zuzNzz9MVEZiZmdVpSLsTYGZmg5+DjZmZ1c7BxszMaudgY2ZmtXOwMTOz2jnYmJlZ7RxsbAaSVpd0laTLJf1CktqdJrNu4/Noeg421pM7I2LDiNi4PB/b1tSYdSefRxUONjaDiHi18vRl4MF2pcWsW/k8mp6DjfVI0v+T9G/gzcCT7U6PWTf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DZv1vKj30W8F1JI8rF+4tkscXMGEHehfxP0rrAx2cyre+TtIayT85zZADo6cBckPzRHy+v24PM2TTe52OSlitPny7bviZpnZILG0YecP8js539fR8/Bw6UtLbSCmWbnr6H54Dny93ePk3rJwNvrTw/Cdi7pEmSFlQ2thgB/IO8Q99P0jySPgKs289XeCkZgBsVxpc0PW/2OPB6U5ra6UyyGOqs3jZQNiKp/vV0IT4T2F/S28v3OpYsoj2jj88+AjhIUrURxrCmz+opd3AW+RstJ+lNZJ1Ew7xk/dvjwFRlJfVmlfWTgcUlLVJZ1t8x9IaIeBX4G1n
  35. "text/plain": [
  36. "<Figure size 432x288 with 1 Axes>"
  37. ]
  38. },
  39. "metadata": {
  40. "needs_background": "light"
  41. },
  42. "output_type": "display_data"
  43. },
  44. {
  45. "name": "stdout",
  46. "output_type": "stream",
  47. "text": [
  48. "Generate statistics: https://hs.fi\n"
  49. ]
  50. },
  51. {
  52. "data": {
  53. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAiYAAAJICAYAAABVMC9sAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOzdedzlc/3/8cfLzDD2JcPYiShalEnFlyRraVOSKJWoJCVKaZtWQlIpRZSlsrRY+klFaZGEElkryT5GtrGE4fX74/0+5szVdc1c5rrOdT7nOo/77Ta3uc7nLJ/357rOOZ/n571GZiJJktQEC3W7AJIkSS0GE0mS1BgGE0mS1BgGE0mS1BgGE0mS1BgGE0mS1BgGEzVKRKweEQ9ExIRul6UTIuKqiNhijPb13Yj43Ahf46CI+PY87n9bRPx+JPvoZxGxZkRkREwcw31eGBHPrz9Pj4iTx2rfIzFa77WIWDQizo6I+yLi9IjYNSJ+Ue9bJCKujYgVRl5iLSiDiYiIGyPi4YiYFRH3RsQfIuLdETHm74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+MvN04PN12yxKX4TlBin/AZRQNqvu59QB908HTqjNNm/MMhpkT0rz0j2Upoy31X0+CuxYb99Dqdb+8aC/tTl+Qzmx/XaI23OpVeefBy6sZerqqIXMfDgzz6t9jwazCqUJsf3fYDVZxwLfAc4G7qPUwHwsM8+dx+7/H+X3vGfbtnMG7Gv6EPv6OeVq/M+0/Y1qrdW+lM/DPZT3xllt919L6Y91Q/39r8z830MDfYu5+4bNz8HAx+v+Dpj
  54. "text/plain": [
  55. "<Figure size 648x576 with 1 Axes>"
  56. ]
  57. },
  58. "metadata": {
  59. "needs_background": "light"
  60. },
  61. "output_type": "display_data"
  62. },
  63. {
  64. "name": "stdout",
  65. "output_type": "stream",
  66. "text": [
  67. "Generate statistics: https://ts.fi\n"
  68. ]
  69. },
  70. {
  71. "data": {
  72. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAJICAYAAADB1oaeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOzdd5QlZbm28esmjkgSQZAwYMKcRxAFRURFRT0eI4iCAdSjYMD8GTAHED2KAQQRMaEes4hZMKKgoAJiIEiQASSLIuH5/nhrD3vanpmmmV27u+f6rdVresd6umaHu95UqSokSZL6stK4C5AkSSsWw4ckSeqV4UOSJPXK8CFJknpl+JAkSb0yfEiSpF4ZPnqSZKckP+p+/pbkv8Zd07glmZ/kqiQrj7uWUUhySpLte9rWJ5K87WY+x+uSHLqU2/dI8pObs40VWZItklSSVXrc5k+T3Lf7fb8kn+pr2+OS5vAklyb5ZZLtkpw+dPsvk9x9nDXK8NGbqjqmqravqu2BvwLfG0cdSc5K8s8kVya5LMnPkrwgSe+vhar6a1WtWVXX973tPlTV3avqR1O5b/eldMcRl7RUVfWOqnpeV8/N/qLsXms7TrhuUYDpgufg54budT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Zue29k+kcrGwFfpH3onEb70vyPQFRVp9LGZPyc9gF2T+CnQ3d5AHB8kqtoLTIvqaozaYP+PkYLJGfTBo0e0D1mifujqr4AvL277kraEdl6k9T/ClrwurLbzlETbt8POKLrYnlqtVkWe9K6gi6ldTvs0W3z37RZU3t0tz0N+NKke+1Gx9K+vI5bwuXFdF0qbwd+2tX0wGU
  73. "text/plain": [
  74. "<Figure size 648x576 with 1 Axes>"
  75. ]
  76. },
  77. "metadata": {
  78. "needs_background": "light"
  79. },
  80. "output_type": "display_data"
  81. },
  82. {
  83. "name": "stdout",
  84. "output_type": "stream",
  85. "text": [
  86. "Generate statistics: https://facebook.com\n"
  87. ]
  88. },
  89. {
  90. "data": {
  91. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAikAAAJICAYAAACkO3ThAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO3deZxkZX3v8c9XGAEBQWUiAjNgFKOCxmXcYkyIUYOIck1co3GLTsQFNRrjkhg0LhiX5HqJEtzBxCWJUVREjYq4XEAkLAoSuW4sgsg2IAQZ+N0/ztNQNNU9BUx1Pz39eb9e9eo65zx1zu9UV5361nOWSlUhSZLUm1stdgGSJEnjGFIkSVKXDCmSJKlLhhRJktQlQ4okSeqSIUWSJHXJkCKpW0n2TPKtJF9P8sEkWeyaJC0cQ4qknp1RVb9VVQ9rw2sWtRpJC8qQIqlbVXX1yOBVwFmLVYukhWdIkdS1JI9L8l3g14ALF7seSQvHkCKpa1V1RFXtCZwD7LvY9UhaOIYUSd1KssXI4DrgysWqRdLC23yxC5Ckeeyd5M/b/R8AX1zMYiQtrPgryJIkqUfu7pEkSV0ypEiSpC4ZUiRJUpcMKZIkqUuGFEmS1CVDiiRJ6pIhRZIkdcmQIkmSumRIkSRJXTKkSJ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Du0D8bvziyzqs6rqudV1U4MPSLvTjurpqreVVX3Z+gqvxvwF2z4+TiLoct+Q97D0PW/e1XdlqGbeL7n4SzgTaMf8FV1m6r6KPAzYOdZ+7dXzzWjqjqT4QPpAOCYqrqM4cNqLUMPwrXjHjbBOi2kwxjO9jjsFs7npwzfQkfdmTEhr6quqap3MHSj3+RwxfB/WjUyfN3/KMkWDN90387QC7k9wwGjM//Tcc//TXkN/WB
  92. "text/plain": [
  93. "<Figure size 648x576 with 1 Axes>"
  94. ]
  95. },
  96. "metadata": {
  97. "needs_background": "light"
  98. },
  99. "output_type": "display_data"
  100. }
  101. ],
  102. "source": [
  103. "#!/bin/env python\n",
  104. "\n",
  105. "\"\"\"\n",
  106. "URL data extractor\n",
  107. "\n",
  108. "Pekka Helenius <pekka [dot] helenius [at] fjordtek [dot] com>\n",
  109. "\n",
  110. "Requirements:\n",
  111. "\n",
  112. "Python 3\n",
  113. "Python 3 BeautifulSoup4 (python-beautifulsoup4)\n",
  114. "Python 3 whois (python-whois; PyPI)\n",
  115. "Python 3 JSON Schema (python-jsonschema)\n",
  116. "Python 3 Numpy (python-numpy)\n",
  117. "Python 3 matplotlib (python-matplotlib)\n",
  118. "\n",
  119. "TODO: URL domain part length comparison analysis\n",
  120. "TODO: URL non-TLD part length comparison analysis\n",
  121. " - in phishing webpages, URL tends to be much longer than legitimate webpages\n",
  122. " however, domains themselves tend to be much shorter (without TLD)\n",
  123. " - phishing URLs often contain more number of dots and subdomains than legitimate URLs\n",
  124. " - legitimate: robots.txt redirects bots to a legitimate domain rather than to the original phishing domain\n",
  125. "\n",
  126. "TODO: Website visual similarity analysis\n",
  127. "TODO: consistency of RDN usage in HTML data\n",
  128. "\"\"\"\n",
  129. "\n",
  130. "######################################\n",
  131. "\n",
  132. "%matplotlib inline\n",
  133. "import matplotlib.pyplot as plt\n",
  134. "\n",
  135. "from bs4 import BeautifulSoup as bs\n",
  136. "from collections import Counter\n",
  137. "from datetime import date, datetime\n",
  138. "import json\n",
  139. "import os\n",
  140. "import re\n",
  141. "import requests\n",
  142. "from time import sleep\n",
  143. "import urllib\n",
  144. "from whois import whois\n",
  145. "\n",
  146. "# Target URLs\n",
  147. "urls = [\n",
  148. " \"https://hoxhunt.com/\",\n",
  149. " \"https://hs.fi\",\n",
  150. " \"https://ts.fi\",\n",
  151. " \"https://facebook.com\"\n",
  152. "]\n",
  153. "\n",
  154. "# Some web servers may block our request unless we set a widely used, well-known user agent string\n",
  155. "request_headers = {\n",
  156. " 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36'\n",
  157. "}\n",
  158. "\n",
  159. "# Date format for domain timestamps\n",
  160. "dateformat = \"%Y/%m/%d\"\n",
  161. "\n",
  162. "# All webpages may not like fetching data too fast\n",
  163. "# Sleep time in seconds\n",
  164. "sleep_interval_between_requests = 0.5\n",
  165. "\n",
  166. "# Write JSON results to a file?\n",
  167. "use_file = True\n",
  168. "# Full file path + name\n",
  169. "filename = os.getcwd() + \"/\" + \"url_info.json\"\n",
  170. "\n",
  171. "# Generate plot from existing JSON data?\n",
  172. "plot_only = False\n",
  173. "\n",
  174. "# Save generated plot images?\n",
  175. "save_plot_images = True\n",
  176. "\n",
  177. "# DPI of plot images\n",
  178. "plot_images_dpi = 150\n",
  179. "\n",
  180. "# Common link attribute references in various HTML elements\n",
  181. "link_refs = {\n",
  182. " 'a': 'href',\n",
  183. " 'img': 'src',\n",
  184. " 'script': 'src'\n",
  185. "}\n",
  186. "\n",
  187. "############################################################################\n",
  188. "############################################################################\n",
  189. "\n",
  190. "class json_url_data(object):\n",
  191. "\n",
  192. "# def __init__(self):\n",
  193. "\n",
  194. "######################################\n",
  195. " \"\"\"\n",
  196. " Set a new HTTP session and get response.\n",
  197. "\n",
  198. " Returns a requests.models.Response object.\n",
  199. " \"\"\"\n",
  200. " def set_session(self, url, method='get', redirects=True):\n",
  201. " \n",
  202. " # HTTP response status codes 1XX, 2XX and 3XX are OK\n",
  203. " # Treat other codes as errors\n",
  204. " sc = re.compile(r\"^[123]{1}[0-9]{2}\")\n",
  205. " \n",
  206. " sleep(sleep_interval_between_requests)\n",
  207. " \n",
  208. " try:\n",
  209. " session = requests.Session()\n",
  210. " response = session.request(method, url, headers=request_headers, allow_redirects=redirects)\n",
  211. " \n",
  212. " if not sc.match(str(response.status_code)):\n",
  213. " raise Exception(\"Error: got invalid response status from the web server\")\n",
  214. " return response\n",
  215. " \n",
  216. " except:\n",
  217. " raise Exception(\"Error: HTTP session could not be established. URL: '\" + url + \"' (method: \" + method + \")\") from None\n",
  218. "\n",
  219. "######################################\n",
  220. " \"\"\"\n",
  221. " Fetch HTML data.\n",
  222. "\n",
  223. " Returns a bs4.BeautifulSoup object.\n",
  224. " \"\"\"\n",
  225. " def get_html_data(self, url):\n",
  226. " \n",
  227. " try:\n",
  228. " data = bs(self.set_session(url).content, 'html.parser')\n",
  229. " return data\n",
  230. " except:\n",
  231. " raise Exception(\"Error: HTML data could not be retrieved\")\n",
  232. "\n",
  233. "######################################\n",
  234. " \"\"\"\n",
  235. " Get URL redirects and related HTTP status codes.\n",
  236. "\n",
  237. " Returns a list object.\n",
  238. " \"\"\"\n",
  239. " def get_url_redirects(self, url):\n",
  240. " \n",
  241. " response = self.set_session(url)\n",
  242. " list_data = []\n",
  243. " \n",
  244. " if response.history:\n",
  245. " \n",
  246. " for r in response.history:\n",
  247. " list_data.append({'redirect_url': r.url, 'status': r.status_code})\n",
  248. " \n",
  249. " return list_data\n",
  250. "\n",
  251. "######################################\n",
  252. " \"\"\"\n",
  253. " Extract title HTML element contents from given HTML data.\n",
  254. "\n",
  255. " Returns a string object.\n",
  256. " \"\"\"\n",
  257. " def get_webpage_title(self, url):\n",
  258. " \n",
  259. " html_data = self.get_html_data(url)\n",
  260. " \n",
  261. " title = html_data.title.string\n",
  262. " return title\n",
  263. "\n",
  264. "######################################\n",
  265. " \"\"\"\n",
  266. " Get WHOIS domain data.\n",
  267. "\n",
  268. " Returns a dict object.\n",
  269. " \"\"\"\n",
  270. " def get_whois_data(self, url):\n",
  271. " dict_data = whois(url)\n",
  272. " return dict_data\n",
  273. "\n",
  274. "######################################\n",
  275. " \"\"\"\n",
  276. " Get domain name based on WHOIS domain data.\n",
  277. " \"\"\"\n",
  278. " def get_domain_name(self, url):\n",
  279. " domain_name = self.get_whois_data(url).domain_name\n",
  280. " \n",
  281. " if type(domain_name) is list:\n",
  282. " return domain_name[0].lower()\n",
  283. " else:\n",
  284. " return domain_name.lower()\n",
  285. "\n",
  286. "######################################\n",
  287. " \"\"\"\n",
  288. " Get initial and final URLs\n",
  289. " \n",
  290. " Compare whether the final (destination) URL\n",
  291. " matches with the initial URL in a request.\n",
  292. " \n",
  293. " Returns a dict object.\n",
  294. " \"\"\"\n",
  295. " def get_startfinal_urls(self, url):\n",
  296. " \n",
  297. " response = self.set_session(url)\n",
  298. " end_url = response.url\n",
  299. " \n",
  300. " start_match = False\n",
  301. " final_match = False\n",
  302. " \n",
  303. " # dr = re.compile(r\"^([a-z]+://)?([^/]+)\")\n",
  304. " # dr_group_lastindex = dr.match(url).lastindex\n",
  305. " # domain_name = dr.match(url).group(dr_group_lastindex)\n",
  306. " \n",
  307. " domain_name = self.get_domain_name(url)\n",
  308. " \n",
  309. " if re.search(domain_name, end_url):\n",
  310. " final_match = True\n",
  311. " \n",
  312. " dict_data = {\n",
  313. " 'startfinal_urls': {\n",
  314. " 'start_url': {\n",
  315. " 'url': url\n",
  316. " },\n",
  317. " 'final_url': {\n",
  318. " 'url': end_url, 'domain_match': final_match\n",
  319. " }\n",
  320. " }\n",
  321. " }\n",
  322. " \n",
  323. " return dict_data\n",
  324. "\n",
  325. "######################################\n",
  326. " \"\"\"\n",
  327. " Get domain registrar\n",
  328. " \n",
  329. " Returns a dict object.\n",
  330. " \"\"\"\n",
  331. " def get_domain_registrar(self, url):\n",
  332. " dict_data = {'domain_registrar': self.get_whois_data(url).registrar }\n",
  333. " return dict_data\n",
  334. "\n",
  335. "######################################\n",
  336. " \"\"\"\n",
  337. " Do comparison between the domain name, extracted\n",
  338. " from WHOIS domain data and contents of a title HTML\n",
  339. " element, extracted from HTML data based on a given URL.\n",
  340. " \n",
  341. " Returns a dict object.\n",
  342. " \"\"\"\n",
  343. " def get_domain_title_match(self, url):\n",
  344. " \n",
  345. " domain_name = self.get_domain_name(url)\n",
  346. " title = self.get_webpage_title(url)\n",
  347. " \n",
  348. " # If is string:\n",
  349. " if type(domain_name) is str:\n",
  350. " if re.search(domain_name, title, re.IGNORECASE):\n",
  351. " match = True\n",
  352. " else:\n",
  353. " match = False\n",
  354. " \n",
  355. " # If is list:\n",
  356. " elif type(domain_name) is list:\n",
  357. " for d in domain_name:\n",
  358. " if re.search(d, title, re.IGNORECASE):\n",
  359. " match = True\n",
  360. " break\n",
  361. " else:\n",
  362. " match = False\n",
  363. " else:\n",
  364. " match = False\n",
  365. " \n",
  366. " dict_data = {\n",
  367. " 'webpage_title': title,\n",
  368. " 'domain_in_webpage_title': match\n",
  369. " }\n",
  370. " \n",
  371. " return dict_data\n",
  372. "\n",
  373. "######################################\n",
  374. " \"\"\"\n",
  375. " Get a single timestamp from given data\n",
  376. " \n",
  377. " Two scenarios are considered: dates argument is either\n",
  378. " a list or a string. If it is a list, then we need\n",
  379. " to decide which date value to extract.\n",
  380. " \n",
  381. " Returns a date object.\n",
  382. " \"\"\"\n",
  383. " def get_single_date(self, dates, newest=False):\n",
  384. " \n",
  385. " dates_epoch = []\n",
  386. " \n",
  387. " if type(dates) is list:\n",
  388. " for d in dates:\n",
  389. " dates_epoch.append(d.timestamp())\n",
  390. " else:\n",
  391. " dates_epoch.append(dates.timestamp())\n",
  392. " \n",
  393. " return datetime.fromtimestamp(sorted(dates_epoch, reverse=newest)[0])\n",
  394. "\n",
  395. "######################################\n",
  396. " \"\"\"\n",
  397. " Get domain time information based on WHOIS domain data.\n",
  398. " \n",
  399. " Returns a dict object.\n",
  400. " \"\"\"\n",
  401. " def get_domain_timeinfo(self, url):\n",
  402. " \n",
  403. " whois_data = self.get_whois_data(url)\n",
  404. " domain_creation_date = self.get_single_date(whois_data.creation_date, newest = False)\n",
  405. " domain_updated_date = self.get_single_date(whois_data.updated_date, newest = False)\n",
  406. " domain_expiration_date = self.get_single_date(whois_data.expiration_date, newest = False)\n",
  407. " \n",
  408. " dict_data = {\n",
  409. " 'domain_timestamps':\n",
  410. " {\n",
  411. " 'created': domain_creation_date.strftime(dateformat),\n",
  412. " 'updated': domain_updated_date.strftime(dateformat),\n",
  413. " 'expires': domain_expiration_date.strftime(dateformat)\n",
  414. " }\n",
  415. " }\n",
  416. " \n",
  417. " return dict_data\n",
  418. "\n",
  419. "######################################\n",
  420. " \"\"\"\n",
  421. " Get domain time information based on WHOIS domain data,\n",
  422. " relative to the current date (UTC time).\n",
  423. " \n",
  424. " Returns a dict object.\n",
  425. " \"\"\"\n",
  426. " def get_domain_timeinfo_relative(self, url):\n",
  427. " \n",
  428. " date_now = datetime.utcnow()\n",
  429. " \n",
  430. " whois_data = self.get_whois_data(url)\n",
  431. " domain_creation_date = self.get_single_date(whois_data.creation_date, newest = False)\n",
  432. " domain_updated_date = self.get_single_date(whois_data.updated_date, newest = False)\n",
  433. " domain_expiration_date = self.get_single_date(whois_data.expiration_date, newest = False)\n",
  434. " \n",
  435. " dict_data = {\n",
  436. " 'domain_timestamps_relative':\n",
  437. " {\n",
  438. " 'current_date': (date_now.strftime(dateformat)),\n",
  439. " 'created_days_ago': (date_now - domain_creation_date).days,\n",
  440. " 'updated_days_ago': (date_now - domain_updated_date).days,\n",
  441. " 'expires_days_left': (domain_expiration_date - date_now).days\n",
  442. " }\n",
  443. " }\n",
  444. " \n",
  445. " return dict_data\n",
  446. "\n",
  447. "######################################\n",
  448. " \"\"\"\n",
  449. " Determine whether URL matches syntaxes such as\n",
  450. " '../foo/bar/'\n",
  451. " '/foo/../../bar/,\n",
  452. " 'https://foo.bar/foo/../'\n",
  453. " \n",
  454. " etc.\n",
  455. " \n",
  456. " Returns a boolean object.\n",
  457. " \"\"\"\n",
  458. " def is_multidot_url(self, url):\n",
  459. " \n",
  460. " multidot = re.compile(r\".*[.]{2}/.*\")\n",
  461. " \n",
  462. " if multidot.match(url):\n",
  463. " return True\n",
  464. " return False\n",
  465. "\n",
  466. "######################################\n",
  467. " \"\"\"\n",
  468. " Get HTML element data from HTML data contents.\n",
  469. " \n",
  470. " Two fetching methods are supported:\n",
  471. " - A) use only HTML element/tag name and extract raw contents of\n",
  472. " these tags\n",
  473. " - B) use both HTML element/tag name and more fine-grained\n",
  474. " inner attribute name to determine which HTML elements are extracted\n",
  475. " \n",
  476. " Special case - URL link references:\n",
  477. " - attributes 'href' or 'src' are considered as link referrals and \n",
  478. " they are handled in a special way\n",
  479. " - A) link referrals to directly to domain are placed in 'self_refs' list\n",
  480. " (patterns: '/', '#', '../' and '/<anything>')\n",
  481. " - B) link referrals to external domains are placed in 'ext_refs' list\n",
  482. " (patterns such as 'https://foo.bar.dot/fancysite' etc.)\n",
  483. " \n",
  484. " - Both A) and B) link categories have 'normal' and 'multidot' subcategories\n",
  485. " - normal links do not contain pattern '../'\n",
  486. " - multidot links contain '../' pattern\n",
  487. " \n",
  488. " Returns a dict object.\n",
  489. " \"\"\"\n",
  490. " \n",
  491. " def get_tag_data(self, url, tag, attribute=None):\n",
  492. " \n",
  493. " html_data = self.get_html_data(url)\n",
  494. " domain_name = self.get_domain_name(url)\n",
  495. " data = []\n",
  496. " \n",
  497. " if attribute != None:\n",
  498. " \n",
  499. " for d in html_data.find_all(tag):\n",
  500. " \n",
  501. " # Ignore the HTML tag if it does not contain our attribute\n",
  502. " if d.get(attribute) != None:\n",
  503. " data.append(d.get(attribute))\n",
  504. " \n",
  505. " if attribute == 'href' or attribute == 'src':\n",
  506. " \n",
  507. " self_refs = { 'normal': [], 'multidot': []}\n",
  508. " ext_refs = { 'normal': [], 'multidot': []}\n",
  509. " \n",
  510. " # Syntax: '#<anything>', '/<anything>', '../<anything>'\n",
  511. " rs = re.compile(r\"^[/#]|^[.]{2}/.*\")\n",
  512. " \n",
  513. " # Syntax: '<text>:<text>/'\n",
  514. " rd = re.compile(r\"^[a-z]+:[a-z]+/\")\n",
  515. " \n",
  516. " # Syntax examples:\n",
  517. " # 'http://foo.bar/', 'https://foo.bar/, 'foo.bar/', 'https://virus.foo.bar/'\n",
  518. " rl = re.compile(r\"^([a-z]+://)?([^/]*\" + domain_name + \"/)\")\n",
  519. " \n",
  520. " for s in data:\n",
  521. " \n",
  522. " # Ignore mailto links\n",
  523. " if re.match(\"^mailto:\", s): continue\n",
  524. " \n",
  525. " if rs.match(s) or rl.match(s) or rd.match(s):\n",
  526. " if self.is_multidot_url(s):\n",
  527. " self_refs['multidot'].append(s)\n",
  528. " else:\n",
  529. " self_refs['normal'].append(s)\n",
  530. " else:\n",
  531. " \n",
  532. " if self.is_multidot_url(s):\n",
  533. " try:\n",
  534. " ext_refs['multidot'].append({'url': s, 'registrar': self.get_whois_data(s).registrar })\n",
  535. " except:\n",
  536. " # Fallback if WHOIS query fails\n",
  537. " ext_refs['normal'].append({'url': s, 'registrar': None })\n",
  538. " pass\n",
  539. " else:\n",
  540. " try:\n",
  541. " ext_refs['normal'].append({'url': s, 'registrar': self.get_whois_data(s).registrar })\n",
  542. " except:\n",
  543. " ext_refs['normal'].append({'url': s, 'registrar': None })\n",
  544. " pass\n",
  545. " \n",
  546. " data = None\n",
  547. " \n",
  548. " dict_data = {\n",
  549. " tag: {\n",
  550. " attribute + '_ext': (ext_refs),\n",
  551. " attribute + '_self': (self_refs)\n",
  552. " }\n",
  553. " }\n",
  554. " \n",
  555. " else:\n",
  556. " dict_data = {\n",
  557. " tag: {\n",
  558. " attribute: (data)\n",
  559. " }\n",
  560. " }\n",
  561. " \n",
  562. " else:\n",
  563. " for d in html_data.find_all(tag):\n",
  564. " data.append(d.prettify())\n",
  565. " \n",
  566. " dict_data = {\n",
  567. " tag: (data)\n",
  568. " }\n",
  569. " \n",
  570. " return dict_data\n",
  571. "\n",
  572. "######################################\n",
  573. " \"\"\"\n",
  574. " How many external URL links have same registrar than\n",
  575. " the webpage itself?\n",
  576. " \"\"\"\n",
  577. " def get_registrar_count(self, registrar, urls):\n",
  578. " \n",
  579. " i = 0\n",
  580. " \n",
  581. " for u in urls:\n",
  582. " for k,v in u.items():\n",
  583. " if k == 'registrar' and v == registrar:\n",
  584. " i += 1\n",
  585. " \n",
  586. " o = len(urls) - i\n",
  587. " \n",
  588. " dict_data = {\n",
  589. " 'same_registrar_count': i,\n",
  590. " 'other_registrar_count': o\n",
  591. " }\n",
  592. " \n",
  593. " return dict_data\n",
  594. "\n",
  595. "######################################\n",
  596. "\n",
  597. " \"\"\"\n",
  598. " Get values existing in a dict object,\n",
  599. " based on a known key string.\n",
  600. " \n",
  601. " Returns a list object.\n",
  602. " \n",
  603. " TODO: Major re-work for the fetch function\n",
  604. "\n",
  605. " TODO: Support for more sophisticated JSON key string filtering\n",
  606. " (possibility to use multiple keys for filtering)\n",
  607. " \"\"\"\n",
  608. " class json_fetcher(object):\n",
  609. "\n",
  610. " def __init__(self, dict_data, json_key):\n",
  611. " self.json_dict = json.loads(json.dumps(dict_data))\n",
  612. " self.json_key = json_key\n",
  613. "\n",
  614. " ##########\n",
  615. " # Ref: https://www.codespeedy.com/how-to-loop-through-json-with-subkeys-in-python/\n",
  616. " def fetch(self, jdata):\n",
  617. "\n",
  618. " if isinstance(jdata, dict):\n",
  619. "\n",
  620. " for k,v in jdata.items():\n",
  621. " if k == self.json_key:\n",
  622. " yield v\n",
  623. " elif isinstance(v, dict):\n",
  624. " for val in self.fetch(v):\n",
  625. " yield val\n",
  626. " elif isinstance(v, list):\n",
  627. " for l in v:\n",
  628. " if isinstance(l, dict):\n",
  629. " for ka,va in l.items():\n",
  630. " if ka == self.json_key:\n",
  631. " yield va\n",
  632. "\n",
  633. " elif isinstance(jdata, list):\n",
  634. " for l in jdata:\n",
  635. " if isinstance(l, dict):\n",
  636. " for k,v in l.items():\n",
  637. " if k == self.json_key:\n",
  638. " yield v\n",
  639. " elif isinstance(l, list):\n",
  640. " for lb in v:\n",
  641. " for ka,va in lb.items():\n",
  642. " if ka == self.json_key:\n",
  643. " yield va\n",
  644. "\n",
  645. " ##########\n",
  646. " def get_data(self, flatten=True):\n",
  647. "\n",
  648. " data_extract = []\n",
  649. " flat_data = []\n",
  650. "\n",
  651. " for i in self.fetch(self.json_dict):\n",
  652. " data_extract.append(i)\n",
  653. "\n",
  654. " # Flatten possible nested lists\n",
  655. " # (i.e. JSON data contains multiple keys in\n",
  656. " # different nested sections)\n",
  657. " def get_data_extract(ld):\n",
  658. " for l in ld:\n",
  659. " if isinstance(l, list):\n",
  660. " for la in get_data_extract(l):\n",
  661. " yield la\n",
  662. " else:\n",
  663. " yield l\n",
  664. "\n",
  665. " if flatten == True:\n",
  666. " for u in get_data_extract(data_extract):\n",
  667. " flat_data.append(u)\n",
  668. " \n",
  669. " return flat_data\n",
  670. " else:\n",
  671. " return data_extract\n",
  672. "\n",
  673. "######################################\n",
  674. " \"\"\"\n",
  675. " Compile URL related data.\n",
  676. " \"\"\"\n",
  677. " def get_url_data(self, url):\n",
  678. " \n",
  679. " # Dict object for simple, non-nested data\n",
  680. " data_simple = {}\n",
  681. "\n",
  682. " # Pre-defined dict object for specific data sets\n",
  683. " webpage_data = {}\n",
  684. " \n",
  685. " startfinal_url = self.get_startfinal_urls(url)\n",
  686. " redirect_url = self.get_url_redirects(url)\n",
  687. " domain_registrar = self.get_domain_registrar(url)\n",
  688. " domaintitle_match = self.get_domain_title_match(url)\n",
  689. " \n",
  690. " domain_time_relative = self.get_domain_timeinfo_relative(url)\n",
  691. " domain_time = self.get_domain_timeinfo(url)\n",
  692. " \n",
  693. " html_element_iframe = self.get_tag_data(url, 'iframe')\n",
  694. " html_element_a_href = self.get_tag_data(url, 'a', link_refs['a'])\n",
  695. " html_element_img_src = self.get_tag_data(url, 'img', link_refs['img'])\n",
  696. " html_element_script_src = self.get_tag_data(url, 'script', link_refs['script'])\n",
  697. "\n",
  698. " iframes_count = {\n",
  699. " 'iframes_count':\n",
  700. " len(self.json_fetcher(html_element_iframe, 'iframe').get_data())\n",
  701. " }\n",
  702. " \n",
  703. " multidot_urls_count = {\n",
  704. " 'multidot_url_count':\n",
  705. " len(self.json_fetcher(html_element_a_href, 'multidot').get_data()) + len(self.json_fetcher(html_element_img_src, 'multidot').get_data()) + len(self.json_fetcher(html_element_script_src, 'multidot').get_data())\n",
  706. " }\n",
  707. " \n",
  708. " ###################\n",
  709. " def get_total_registrars():\n",
  710. "\n",
  711. " same_registrar_counts = 0\n",
  712. " other_registrar_counts = 0\n",
  713. " for k,v in link_refs.items():\n",
  714. " \n",
  715. " html_element = self.get_tag_data(url, k, v)\n",
  716. " \n",
  717. " same_registrar_counts += self.get_registrar_count(\n",
  718. " domain_registrar['domain_registrar'],\n",
  719. " html_element[k][v + '_ext']['normal']\n",
  720. " )['same_registrar_count']\n",
  721. " \n",
  722. " other_registrar_counts += self.get_registrar_count(\n",
  723. " domain_registrar['domain_registrar'],\n",
  724. " html_element[k][v + '_ext']['normal']\n",
  725. " )['other_registrar_count']\n",
  726. " \n",
  727. " registrar_counts = {\n",
  728. " 'same_registrar_count': same_registrar_counts,\n",
  729. " 'other_registrar_count': other_registrar_counts\n",
  730. " }\n",
  731. " return registrar_counts\n",
  732. " \n",
  733. " # Avoid unnecessary nesting of the following data\n",
  734. " data_simple.update(domain_registrar)\n",
  735. " data_simple.update(domaintitle_match)\n",
  736. " data_simple.update(iframes_count)\n",
  737. " data_simple.update(multidot_urls_count)\n",
  738. " data_simple.update(get_total_registrars())\n",
  739. " \n",
  740. " url_data = dict({\n",
  741. " url: [\n",
  742. " data_simple,\n",
  743. " startfinal_url,\n",
  744. " {'redirects': redirect_url},\n",
  745. " \n",
  746. " domain_time_relative,\n",
  747. " domain_time,\n",
  748. " \n",
  749. " {'webpage_data': [\n",
  750. " html_element_iframe,\n",
  751. " html_element_a_href,\n",
  752. " html_element_img_src,\n",
  753. " html_element_script_src\n",
  754. " ]\n",
  755. " }\n",
  756. " ]\n",
  757. " })\n",
  758. " \n",
  759. " return url_data\n",
  760. "\n",
  761. "\n",
  762. "\n",
  763. "class write_operations(object):\n",
  764. "\n",
  765. " def __init__(self):\n",
  766. " self.filename = filename\n",
  767. "\n",
  768. "######################################\n",
  769. " \"\"\"\n",
  770. " Set JSON file name, append number suffix\n",
  771. " # if file exists already.\n",
  772. " \n",
  773. " Returns file name path.\n",
  774. " \"\"\"\n",
  775. " def set_filename(self):\n",
  776. " \n",
  777. " c = 0\n",
  778. " while True:\n",
  779. " if os.path.exists(self.filename):\n",
  780. " if c == 0:\n",
  781. " self.filename = self.filename + \".\" + str(c)\n",
  782. " else:\n",
  783. " self.filename = re.sub(\"[0-9]+$\", str(c), self.filename)\n",
  784. " else:\n",
  785. " break\n",
  786. " c += 1\n",
  787. " return self.filename\n",
  788. "\n",
  789. "######################################\n",
  790. " \"\"\"\n",
  791. " Append to a JSON file.\n",
  792. " \"\"\"\n",
  793. " def write_to_file(self, data):\n",
  794. " \n",
  795. " try:\n",
  796. " json_file = open(self.filename, \"a\")\n",
  797. " json_file.write(data)\n",
  798. " json_file.close()\n",
  799. " return 0\n",
  800. " except:\n",
  801. " return 1\n",
  802. "\n",
  803. "######################################\n",
  804. " \"\"\"\n",
  805. " Fetch all pre-defined URLs.\n",
  806. " \"\"\"\n",
  807. " def fetch_and_store_url_data(self, urls, use_file):\n",
  808. "\n",
  809. " data_parts = {}\n",
  810. " fetch_json_data = json_url_data()\n",
  811. "\n",
  812. " for u in urls:\n",
  813. " print(\"URL data: %s\" % u)\n",
  814. " try:\n",
  815. " data_parts.update(fetch_json_data.get_url_data(u))\n",
  816. " except:\n",
  817. " print(\"Failed: %s\" % u)\n",
  818. " pass\n",
  819. "\n",
  820. " json_data = json.dumps(data_parts)\n",
  821. "\n",
  822. " if use_file == True:\n",
  823. " self.write_to_file(json_data)\n",
  824. "\n",
  825. " return json_data\n",
  826. "\n",
  827. "######################################\n",
  828. "\"\"\"\n",
  829. "Visualize & summarize data.\n",
  830. "\"\"\"\n",
  831. "\n",
  832. "class data_visualization(object):\n",
  833. "\n",
  834. " def __init__(self, url, json_data):\n",
  835. " self.url = url\n",
  836. " self.json_data = json_data\n",
  837. "\n",
  838. " self.data = json.loads(json.dumps(self.json_data)).get(self.url)\n",
  839. " self.json_url_obj = json_url_data()\n",
  840. " self.domain_registrar = self.json_url_obj.get_domain_registrar(self.url)['domain_registrar']\n",
  841. " self.webpage_data = self.json_url_obj.json_fetcher(self.data, 'webpage_data').get_data()\n",
  842. "\n",
  843. " def get_urls_count_summary(self):\n",
  844. "\n",
  845. " unique_refs = []\n",
  846. "\n",
  847. " for k,v in link_refs.items():\n",
  848. " if v in unique_refs: continue\n",
  849. " unique_refs.append(v)\n",
  850. "\n",
  851. " def link_count(refs, suffix):\n",
  852. "\n",
  853. " urls_cnt = 0\n",
  854. "\n",
  855. " for u in self.webpage_data:\n",
  856. " for l in refs:\n",
  857. " urls = self.json_url_obj.json_fetcher(u, l + suffix).get_data()\n",
  858. " for n in urls:\n",
  859. " urls_cnt += len(n['normal'])\n",
  860. " urls_cnt += len(n['multidot'])\n",
  861. " return urls_cnt\n",
  862. "\n",
  863. " data = {\n",
  864. " 'local_urls': link_count(unique_refs, '_self'),\n",
  865. " 'external_urls': link_count(unique_refs, '_ext')\n",
  866. " }\n",
  867. " \n",
  868. " return data\n",
  869. "\n",
  870. " def get_registrars(self):\n",
  871. "\n",
  872. " registrars = []\n",
  873. " #registrars.append(self.domain_registrar)\n",
  874. "\n",
  875. " for w in self.webpage_data:\n",
  876. " webpage_registrars = self.json_url_obj.json_fetcher(w, 'registrar').get_data()\n",
  877. " for wa in webpage_registrars:\n",
  878. " if wa != None:\n",
  879. " registrars.append(wa)\n",
  880. " return registrars\n",
  881. "\n",
  882. " def get_registrar_count_summary(self):\n",
  883. " \n",
  884. " domain_counter = dict(Counter(self.get_registrars()))\n",
  885. " data = {'fetched_domains': domain_counter, 'url_domain_registrar': self.domain_registrar }\n",
  886. " return data\n",
  887. "\n",
  888. "######################################\n",
  889. "\"\"\"\n",
  890. "Execute the main program code.\n",
  891. "\n",
  892. "TODO: this code must figure out the correct JSON file\n",
  893. "if multiple generated files are present.\n",
  894. "\"\"\"\n",
  895. "if __name__ == '__main__':\n",
  896. "\n",
  897. " if plot_only == False:\n",
  898. " write_obj = write_operations()\n",
  899. " write_obj.set_filename()\n",
  900. " data = write_obj.fetch_and_store_url_data(urls, use_file)\n",
  901. "\n",
  902. " url_str_pattern = re.compile(r\"(^[a-z]+://)?([^/]*)\")\n",
  903. "\n",
  904. " if os.path.exists(filename):\n",
  905. " with open(filename, \"r\") as json_file:\n",
  906. " json_data = json.load(json_file)\n",
  907. " else:\n",
  908. " json_data = data\n",
  909. "\n",
  910. " # Get URLs from an available JSON data\n",
  911. " for key_url in json_data.keys():\n",
  912. " \n",
  913. " print(\"Generate statistics: %s\" % key_url)\n",
  914. "\n",
  915. " fig = plt.figure()\n",
  916. " fig_params = {\n",
  917. " 'xtick.labelsize': 8,\n",
  918. " 'figure.figsize': [9,8]\n",
  919. " # 'figure.constrained_layout.use': True\n",
  920. " }\n",
  921. " plt.rcParams.update(fig_params)\n",
  922. " \n",
  923. " domain_string = url_str_pattern.split(key_url)[2].replace('.','')\n",
  924. " summary = data_visualization(key_url, json_data)\n",
  925. " \n",
  926. " summary_registrars = summary.get_registrar_count_summary()['fetched_domains']\n",
  927. "\n",
  928. " x_r = list(summary_registrars.keys())\n",
  929. " y_r = list(summary_registrars.values())\n",
  930. " \n",
  931. " # Show bar values\n",
  932. " for index,data in enumerate(y_r):\n",
  933. " plt.text(x=index, y=data+0.5, s=data, fontdict=dict(fontsize=8))\n",
  934. " \n",
  935. " title_r = \"Domains associated with HTML URL data (\" + key_url + \")\"\n",
  936. " xlabel_r = \"Fetched domains\"\n",
  937. " ylabel_r = \"Domain count\"\n",
  938. "\n",
  939. " plt.bar(x_r, y_r, color=\"green\", edgecolor=\"black\")\n",
  940. " plt.title(title_r)\n",
  941. " plt.xlabel(xlabel_r)\n",
  942. " plt.ylabel(ylabel_r)\n",
  943. " plt.xticks(rotation=45, horizontalalignment=\"right\")\n",
  944. "\n",
  945. " if save_plot_images == True:\n",
  946. " plt.savefig(os.getcwd() + \"/\" + \"domain_figure_\" + domain_string + \".png\", dpi=plot_images_dpi)\n",
  947. " plt.show()\n",
  948. "\n",
  949. " #fig_u = plt.figure()\n",
  950. " \n",
  951. " #summary_urls = summary.get_urls_count_summary()\n",
  952. " \n",
  953. " #x_u = list(summary_urls.keys())\n",
  954. " #y_u = list(summary_urls.values())\n",
  955. " #title_u = \"Local and external URL references (\" + key_url + \")\"\n",
  956. " #xlabel_u = \"Fetched URLs\"\n",
  957. " #ylabel_u = \"URL count\"\n",
  958. " \n",
  959. " #plt.bar(x_u, y_u, color=\"blue\", edgecolor='black')\n",
  960. " #plt.title(title_u)\n",
  961. " #plt.xlabel(xlabel_u)\n",
  962. " #plt.ylabel(ylabel_u)\n",
  963. " #plt.show()\n"
  964. ]
  965. },
  966. {
  967. "cell_type": "markdown",
  968. "metadata": {},
  969. "source": [
  970. "## Analysis\n",
  971. "\n",
  972. "| Website | Analysis | Top registrars |\n",
  973. "|--------------|--------------------------------------------------------------------------------|----------------------------------------|\n",
  974. "| HoxHunt | Great variation of different registrars | `MarkMonitor Inc.`, `CloudFlare Inc.` |\n",
  975. "| HS.fi | Average variation of different registrars, relies mostly on its own registrar | `Sanoma` |\n",
  976. "| TS.fi | Great variation of different registrars, uses mostly its own regisrtrar | `TS-Yhtymä Oy` |\n",
  977. "| Facebook | Very low variation of different registrars, relies on a single regisrtrar | `RegistrarSafe LLC` |"
  978. ]
  979. }
  980. ],
  981. "metadata": {
  982. "kernelspec": {
  983. "display_name": "Python 3",
  984. "language": "python",
  985. "name": "python3"
  986. },
  987. "language_info": {
  988. "codemirror_mode": {
  989. "name": "ipython",
  990. "version": 3
  991. },
  992. "file_extension": ".py",
  993. "mimetype": "text/x-python",
  994. "name": "python",
  995. "nbconvert_exporter": "python",
  996. "pygments_lexer": "ipython3",
  997. "version": "3.8.5"
  998. }
  999. },
  1000. "nbformat": 4,
  1001. "nbformat_minor": 4
  1002. }