├── screenshot.png ├── test-favicon.png ├── requirements.txt ├── README.md ├── test_favicorn.py ├── LICENSE └── favicorn.py /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharsil/favicorn/HEAD/screenshot.png -------------------------------------------------------------------------------- /test-favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharsil/favicorn/HEAD/test-favicon.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | about-time==4.2.1 2 | alive-progress==3.1.5 3 | appdirs==1.4.4 4 | beautifulsoup4==4.12.3 5 | bs4==0.0.2 6 | certifi==2024.8.30 7 | charset-normalizer==3.3.2 8 | click==8.1.7 9 | click-plugins==1.1.1 10 | colorama==0.4.6 11 | dnspython==2.6.1 12 | favicon==0.7.0 13 | filelock==3.16.1 14 | grapheme==0.6.0 15 | idna==3.10 16 | markdown-it-py==3.0.0 17 | mdurl==0.1.2 18 | mmh3==5.0.1 19 | netlas==0.5.1 20 | Pygments==2.18.0 21 | PyYAML==6.0.2 22 | requests==2.32.3 23 | requests-file==2.1.0 24 | rich==13.8.1 25 | shodan==1.31.0 26 | soupsieve==2.6 27 | tldextract==5.1.2 28 | tqdm==4.66.5 29 | urllib3==2.2.3 30 | XlsxWriter==3.2.0 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FAVICORN 💖🦄 2 | 3 | **All-sources tool to search websites by favicons.** 4 | 5 | ## The mechanism 6 | 7 | Favicorn takes a favicon and provides search result links across 10 platforms, and not only. 8 | 9 | Drop a ⭐ on the repo, and we’ll add automated scraping for all sources! 10 | 11 | ![](screenshot.png) 12 | 13 | ## Usage 14 | 15 | There are 3 search modes: 16 | * search by direct favicon URL; 17 | * search by file; 18 | * and search by domain (guessing possible favicons). 19 | 20 | Search by a specific favicon URL (`--uri`, `-u`): 21 | ```sh 22 | ./favicorn.py -u https://emojipedia.org/images/favicon-32x32.png 23 | ``` 24 | 25 | Search by a favicon file (`--file`, `-f`): 26 | ```sh 27 | ./favicorn.py -f test-favicon.png 28 | ``` 29 | 30 | Search by a domain, resolving to IPs and checking their favicons (`--domain`, `-d`): 31 | ```sh 32 | ./favicorn.py -d google.com 33 | ``` 34 | 35 | ### Additional options 36 | 37 | Show favicon hashes for a search (`--verbose`): `./favicorn.py -d google.com -v` 38 | 39 | Get additional favicon versions using search engines (`--add-from-search-engines`, `-e`): `./favicorn.py -d google.com -e` 40 | 41 | Save all links to the specific file (`-s`, `--save-links-filename`): `./favicorn.py -d google.com -s links.txt` 42 | 43 | Give tinyurl links instead of full links for platforms: `--tinyurl` 44 | 45 | Show only links to platforms, don't extract preview of results: `--no-fetch` 46 | 47 | Disable unicorn animation (dangerous option, use with caution!): `--no-logo` 48 | 49 | ## Preview of results 50 | 51 | By default, Favicorn generates links to search for websites by their favicon 52 | across all known platforms, and then retrieves the first pages of results from some of them. 53 | 54 | Currently, ZoomEye, Shodan (key required), and Netlas (key required) are supported. 55 | 56 | Export API keys in the following way: 57 | ``` 58 | export SHODAN_KEY=... 59 | export NETLAS_KEY=... 60 | ``` 61 | 62 | ## Supported platforms 63 | 64 | | Name | Login required | 65 | |-------------|----------------| 66 | | ZoomEye | yes | 67 | | Shodan | yes | 68 | | Fofa | no | 69 | | VirusTotal | yes | 70 | | BinaryEdge | yes | 71 | | Netlas | no | 72 | | Censys | no | 73 | | ODIN | no | 74 | | CriminalIP | yes | 75 | | HunterHow | yes | 76 | 77 | ## Use cases 78 | 79 | - Search for phishing domains & brand protection 80 | - [Andrea Fortuna: Favicon Forensics: hunting phishing sites with Shodan](https://andreafortuna.org/2024/09/18/unmasking-digital-deception-leveraging-shodan-and-favicon-hashes-to-detect-phishing-sites) 81 | - Extend your scope for pentesting 82 | - [Devansh batham: Weaponizing favicon.ico for BugBounties , OSINT and what not](https://medium.com/@Asm0d3us/weaponizing-favicon-ico-for-bugbounties-osint-and-what-not-ace3c214e139) 83 | - Search for C2 (command and control) servers of hackers 84 | - Research purposes, you have to think bigger 85 | 86 | ## Other relevant tools 87 | 88 | - [Favicon-Search](https://github.com/truda8/Favicon-Search) 89 | - [favihunter](https://github.com/eremit4/favihunter) 90 | - [favfound](https://github.com/elihypoo414/favfound) 91 | - [favicon](https://github.com/scottwernervt/favicon) 92 | - [pyfav](https://github.com/phillipsm/pyfav) 93 | - [besticon (favicon-service)](https://github.com/mat/besticon/) 94 | - [favicongrabber.com](https://github.com/antongunov/favicongrabber.com) 95 | - [favicheck](https://github.com/szTheory/favicheck) 96 | - [favicon-hash](https://favicon-hash.kmsec.uk/) 97 | 98 | ## Testing 99 | 100 | ```sh 101 | python3 -m unittest test_favicorn.py 102 | ``` 103 | 104 | ## Thanks :purple_heart: 105 | 106 | Thanks for [@soxoj](https://github.com/soxoj), who was an inspirer, muse, auditor of my pure code and for his huge peace of development. Also i'm grateful for one of the most vibrant OSINT communities for testing this project. Do not hesitate to provide something interesting or fix our bugs! But don't forget, it's not a just another boring swiss-knife. 107 | 108 | -------------------------------------------------------------------------------- /test_favicorn.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from unittest.mock import patch, mock_open 3 | from favicorn import Favicon # Import your Favicon class 4 | import requests 5 | import dns 6 | 7 | class TestFavicon(unittest.TestCase): 8 | 9 | def setUp(self): 10 | """Common setup for tests""" 11 | with open('test-favicon.png', 'rb') as file: 12 | self.sample_favicon_content = file.read() 13 | 14 | self.expected_murmur_hash = 553299689 15 | self.expected_md5 = 'e8a7fa0c08b4e1670b633f7246fd57ec' 16 | self.expected_base64 = 'aWNvbl9oYXNoPSI1NTMyOTk2ODki' 17 | self.expected_sha256 = '95c171ef60f0cdf6f11543b0ce0a4361ad014de84bae370dc2b2a61cd5482c84' 18 | self.expected_hex_hash = '20faaee9' 19 | 20 | @patch('requests.get') 21 | def test_from_url(self, mock_get): 22 | """Test Favicon creation from URL""" 23 | mock_get.return_value.status_code = 200 24 | mock_get.return_value.content = self.sample_favicon_content 25 | mock_get.return_value.headers = {'Content-Type': 'image/x-icon'} 26 | 27 | favicon = Favicon.from_url('http://example.com/favicon.ico') 28 | 29 | # Check that the content and hashes were generated correctly 30 | 31 | self.assertEqual(favicon.md5_hash, self.expected_md5, "MD5 hash does not match expected value.") 32 | self.assertEqual(favicon.sha256_hash, self.expected_sha256, "SHA256 hash does not match expected value.") 33 | self.assertEqual(favicon.murmur_hash, self.expected_murmur_hash, "MurmurHash does not match expected value.") 34 | self.assertEqual(favicon.hex_hash, self.expected_hex_hash, "Hex hash does not match expected value.") 35 | self.assertEqual(favicon.base64_hash, self.expected_base64, "Base64 hash does not match expected value.") 36 | 37 | # Validate the links_text output (partially, for brevity) 38 | links_output = favicon.links_text() 39 | self.assertIn('ZoomEye', links_output) 40 | self.assertIn('Shodan', links_output) 41 | 42 | @patch('builtins.open', new_callable=mock_open) 43 | @patch('os.path.exists', return_value=True) 44 | def test_from_file(self, mock_exists, mock_file): 45 | """Test Favicon creation from file""" 46 | # Set the read_data dynamically using self.sample_favicon_content 47 | mock_file.return_value.read.return_value = self.sample_favicon_content 48 | 49 | # Create Favicon object from file 50 | favicon = Favicon.from_file('/path/to/fake/favicon.ico') 51 | 52 | # Check that the content and hashes were generated correctly 53 | self.assertEqual(favicon.md5_hash, self.expected_md5) 54 | self.assertEqual(favicon.sha256_hash, self.expected_sha256) 55 | self.assertEqual(favicon.hex_hash, self.expected_hex_hash) 56 | 57 | # Validate the links_text output 58 | links_output = favicon.links_text() 59 | self.assertIn('ZoomEye', links_output) 60 | self.assertIn('Fofa', links_output) 61 | 62 | def test_links_text_output(self): 63 | """Test if links_text generates proper links""" 64 | favicon = Favicon(self.sample_favicon_content, source="http://example.com", type="direct link") 65 | 66 | links_output = favicon.links_text() 67 | platforms = favicon.get_platform_names() 68 | 69 | for platform in platforms: 70 | self.assertIn(platform, links_output) 71 | 72 | # @patch('dns.resolver.Resolver.resolve') 73 | # @patch('requests.get') 74 | # def test_resolve_domain(self, mock_get, mock_resolve): 75 | # """Test resolving a domain and fetching favicon from the IP""" 76 | # mock_resolve.return_value = [dns.rdtypes.ANY.A.A(None, None, '93.184.216.34')] 77 | # mock_get.return_value.status_code = 200 78 | # mock_get.return_value.content = self.sample_favicon_content 79 | 80 | # favicon = Favicon.from_url('http://93.184.216.34/favicon.ico') 81 | 82 | # # Check hashes for resolved IP 83 | # self.assertEqual(favicon.md5_hash, self.expected_md5) 84 | # self.assertEqual(favicon.sha256_hash, self.expected_sha256) 85 | # self.assertEqual(favicon.hex_hash, self.expected_hex_hash) 86 | 87 | if __name__ == '__main__': 88 | unittest.main() -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /favicorn.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import codecs 5 | import concurrent.futures 6 | import hashlib 7 | import io 8 | import json 9 | import mimetypes 10 | import os 11 | import random 12 | import re 13 | import sys 14 | import time 15 | from contextlib import closing 16 | # tinyurl 17 | from urllib.parse import urlencode 18 | from urllib.request import urlopen 19 | 20 | import favicon 21 | import netlas 22 | import requests 23 | # fetchers 24 | import shodan 25 | from alive_progress import alive_bar 26 | from colorama import Fore, Style, init 27 | 28 | requests.packages.urllib3.disable_warnings() 29 | init(autoreset=True) 30 | 31 | 32 | OUTPUT_DIR = "api_responses" 33 | 34 | try: 35 | import dns.resolver, mmh3 36 | except ImportError as e: 37 | print("[-] {}. Please, install all required dependencies!".format(e)) 38 | sys.exit(1) 39 | 40 | 41 | def make_url_tiny(url): 42 | request_url = f"http://tinyurl.com/api-create.php?{urlencode({'url':url})}" 43 | with closing(urlopen(request_url)) as response: 44 | return response.read().decode("utf-8") 45 | 46 | def clear_terminal(): 47 | os.system('cls' if os.name == 'nt' else 'clear') 48 | 49 | def print_ascii_art(): 50 | clear_terminal() 51 | ascii_art = [['\033[33m+\033[0m' if char == '+' else '\033[1;35m' + char + '\033[0m' for char in line.ljust(45)] 52 | for line in r""" + + 53 | + 54 | + / + 55 | / + 56 | + + 57 | + , + 58 | /| 59 | \ / -> \ 60 | + \,_ / -> + \ 61 | /0(`` \ -> \ 62 | (, /"(``-\_/_--_ + 63 | \ )___( )\\. 64 | |/ \/ \\\ 65 | \\ /\ 66 | o o o o 67 | """.split("\n")] 68 | dim_x, dim_y = len(ascii_art[0]), len(ascii_art) 69 | mask = [['O' for _ in range(dim_x)] for _ in range(dim_y)] 70 | available_positions = [(y, x) for y in range(dim_y) for x in range(dim_x)] 71 | while available_positions: 72 | for _ in ascii_art: 73 | print("\033[F", end='') 74 | y, x = random.choice(available_positions) 75 | available_positions.remove((y, x)) 76 | mask[y][x] = 0 77 | for dy, line in enumerate(ascii_art): 78 | print(''.join(mask[dy][dx] or line[dx] for dx in range(dim_x)), flush=os.name != 'nt') 79 | time.sleep(0.001) 80 | 81 | class Favicon: 82 | def __init__(self, content, source=None, type=None, tinyurl=False): 83 | """Initialize Favicon object""" 84 | self.content = content 85 | self.source = source 86 | self.type = type 87 | self.tinyurl = tinyurl 88 | 89 | base64_favicon = codecs.encode(content, 'base64') 90 | 91 | self.murmur_hash = mmh3.hash(base64_favicon) 92 | self.md5_hash = hashlib.md5(content).hexdigest() 93 | self.sha256_hash = hashlib.sha256(content).hexdigest() 94 | self.base64_hash = codecs.encode('icon_hash="{}"'.format(self.murmur_hash).encode('utf-8'), 'base64').decode('utf-8').strip() 95 | self.hex_hash = hex(self.murmur_hash).replace('0x', '', 1) 96 | self.average_hash = Favicon.get_perceptual_hash(source, content) 97 | 98 | def __eq__(self, other): 99 | if isinstance(other, Favicon): 100 | return self.murmur_hash == other.murmur_hash 101 | return False 102 | 103 | def __hash__(self): 104 | return hash(self.murmur_hash) 105 | 106 | def name(self): 107 | return f'favicon from {self.type}: {self.source}' 108 | 109 | @classmethod 110 | def get_perceptual_hash(cls, source, content): 111 | request_url = "https://app.netlas.io/api/get_hash_by_link/?link=" 112 | request_data = "https://app.netlas.io/api/get_perceptual_hash/" 113 | try: 114 | if source.startswith('http'): 115 | response = requests.get(request_url+source) 116 | return response.json().get("average_hash") 117 | else: 118 | files = {'file': ('favicon.png', io.BytesIO(content), 'image/png')} 119 | response = requests.post(request_data, files=files) 120 | return response.json().get("average_hash") 121 | except Exception as e: 122 | print(f'[-] Error getting perceptual average hash from Netlas: {e}') 123 | 124 | return "" 125 | 126 | @classmethod 127 | def from_url(cls, url, custom_type="direct link"): 128 | """Create Favicon object from a URL""" 129 | response = requests.get(url, verify=False) 130 | if response.status_code == 200: 131 | favi_words = ['image', 'icon'] 132 | content_type = response.headers['Content-Type'] 133 | 134 | if not any(re.findall('|'.join(favi_words) , content_type)): 135 | raise Exception(f"Invalid content-type {str(content_type)} for URL: {url}") 136 | 137 | content = response.content 138 | return cls(content, source=url, type=custom_type) 139 | else: 140 | raise Exception(f"Failed to fetch favicon from URL: {url}") 141 | 142 | @classmethod 143 | def from_file(cls, filepath): 144 | """Create Favicon object from a file""" 145 | if not os.path.exists(filepath): 146 | raise FileNotFoundError(f"File not found: {filepath}") 147 | mime_type, _ = mimetypes.guess_type(filepath) 148 | if mime_type and mime_type.startswith('image'): 149 | with open(filepath, 'rb') as file: 150 | content = file.read() 151 | return cls(content, source=os.path.abspath(filepath), type="file") 152 | else: 153 | raise ValueError(f"'{filepath}' is not a valid image file") 154 | 155 | def generate_links_dict(self): 156 | links_dict = { 157 | 'ZoomEye': f'https://www.zoomeye.org/searchResult?q=iconhash%3A%22{self.murmur_hash}%22', 158 | 'Shodan': f'https://www.shodan.io/search?query=http.favicon.hash:{self.murmur_hash}', 159 | 'Fofa': f'https://en.fofa.info/result?qbase64={self.base64_hash}', 160 | 'VirusTotal': f'https://www.virustotal.com/gui/search/entity:url%20main_icon_md5:{self.md5_hash}', 161 | 'BinaryEdge': f'https://app.binaryedge.io/services/query?query=web.favicon.md5:{self.md5_hash}&page=1', 162 | 'Netlas': f'https://app.netlas.io/responses/?q=http.favicon.hash_sha256:{self.sha256_hash}&page=1', 163 | 'Netlas Perceptual': f'https://app.netlas.io/responses/?q=http.favicon.perceptual_hash:{self.average_hash}~2&page=1', 164 | 'Censys': f'https://search.censys.io/search?resource=hosts&sort=RELEVANCE&per_page=25&virtual_hosts=EXCLUDE&q=services.http.response.favicons.md5_hash:{self.md5_hash}', 165 | 'ODIN': f'https://search.odin.io/hosts?query=services.modules.http.favicon.murmur_hash%3A%22{self.murmur_hash}%22', 166 | 'CriminalIP': f'https://www.criminalip.io/asset/search?query=favicon:+{self.hex_hash}', 167 | 'HunterHow': f'https://hunter.how/list?searchValue=favicon_hash%3D%22{self.md5_hash}%22' 168 | } 169 | 170 | if self.tinyurl: 171 | for p, l in links_dict.items(): 172 | links_dict[p] = make_url_tiny(l) 173 | 174 | return links_dict 175 | 176 | def get_platform_names(self): 177 | """Return a list of all platform names""" 178 | links_dict = self.generate_links_dict() 179 | return list(links_dict.keys()) 180 | 181 | def hashes_text(self): 182 | return '\n'.join([ 183 | f'{Fore.CYAN}{Style.BRIGHT}MurMurHash(Base64): {Style.NORMAL}{self.murmur_hash}', 184 | f'{Fore.CYAN}{Style.BRIGHT}MD5(Favicon): {Style.NORMAL}{self.md5_hash}', 185 | f'{Fore.CYAN}{Style.BRIGHT}SHA256(Favicon): {Style.NORMAL}{self.sha256_hash}', 186 | f'{Fore.CYAN}{Style.BRIGHT}Base64(MurMurHash): {Style.NORMAL}{self.base64_hash}', 187 | f'{Fore.CYAN}{Style.BRIGHT}Hex(MurMurHash): {Style.NORMAL}{self.hex_hash}', 188 | f'{Fore.CYAN}{Style.BRIGHT}NetlasAverageHash: {Style.NORMAL}{self.average_hash}', 189 | ]) 190 | 191 | def links_only_text(self): 192 | links_dict = self.generate_links_dict() 193 | links_bundle = '\n'.join([link for _, link in links_dict.items()]) 194 | return links_bundle + '\n' 195 | 196 | def links_categorized_text(self): 197 | links_dict = self.generate_links_dict() 198 | 199 | text = f'''{Style.BRIGHT}{Fore.GREEN}Trial/free results, no login:{Style.NORMAL} 200 | {Fore.CYAN}Netlas: {Fore.GREEN}{links_dict.get("Netlas")} 201 | {Fore.CYAN}Netlas fuzzy: {Fore.GREEN}{links_dict.get("Netlas Perceptual")} 202 | {Fore.CYAN}Censys: {Fore.GREEN}{links_dict.get("Censys")} 203 | {Fore.CYAN}ZoomEye: {Fore.GREEN}{links_dict.get("ZoomEye")} 204 | {Fore.CYAN}Fofa: {Fore.GREEN}{links_dict.get("Fofa")} 205 | {Fore.CYAN}ODIN: {Fore.GREEN}{links_dict.get("ODIN")} 206 | 207 | {Style.BRIGHT}{Fore.YELLOW}Login required:{Style.NORMAL} 208 | {Fore.CYAN}Shodan: {Fore.GREEN}{links_dict.get("Shodan")} 209 | {Fore.CYAN}BinaryEdge: {Fore.GREEN}{links_dict.get("BinaryEdge")} 210 | {Fore.CYAN}HunterHow: {Fore.GREEN}{links_dict.get("HunterHow")} 211 | {Fore.CYAN}CriminalIP: {Fore.GREEN}{links_dict.get("CriminalIP")} 212 | 213 | {Style.BRIGHT}{Fore.RED}Subscription needed:{Style.NORMAL} 214 | {Fore.CYAN}VirusTotal: {Fore.GREEN}{links_dict.get("VirusTotal")} 215 | ''' 216 | 217 | return text 218 | 219 | def links_text(self): 220 | """Generate the same text output as the original function with aligned columns""" 221 | links_dict = self.generate_links_dict() 222 | 223 | # Find the longest platform name to adjust alignment 224 | max_platform_length = max(len(platform) for platform in links_dict.keys()) 225 | 226 | # Format links with colored platform names and links 227 | links_bundle = '\n'.join([ 228 | f'{Style.BRIGHT}{Fore.CYAN}{(platform+":").ljust(max_platform_length + 5)}' 229 | f'{Fore.GREEN}{link}' 230 | for platform, link in links_dict.items() 231 | ]) 232 | return links_bundle + '\n' 233 | 234 | 235 | class Fetcher: 236 | """Base fetcher class""" 237 | @classmethod 238 | def _load_response_from_file(cls, murmur_hash): 239 | filename = f"{murmur_hash}_{cls.get_platform()}.json" 240 | 241 | file_path = os.path.join(OUTPUT_DIR, filename) 242 | if os.path.exists(file_path): 243 | with open(file_path, 'r', encoding='utf-8') as file: 244 | return json.load(file) 245 | return None 246 | 247 | @classmethod 248 | def _save_response_to_file(cls, data, murmur_hash): 249 | """Save the API response data to a JSON file with a formatted filename.""" 250 | filename = f"{murmur_hash}_{cls.get_platform()}.json" 251 | os.makedirs(OUTPUT_DIR, exist_ok=True) 252 | file_path = os.path.join(OUTPUT_DIR, filename) 253 | with open(file_path, 'w', encoding='utf-8') as file: 254 | json.dump(data, file, ensure_ascii=False, indent=4) 255 | 256 | @classmethod 257 | def get_platform(cls): 258 | """Method to return the platform name. This should be overridden in subclasses.""" 259 | raise NotImplementedError("Subclasses should implement this method to return the platform name.") 260 | 261 | @classmethod 262 | def _format_output(cls, total_results_count, domains, ip_addresses_by_waf, murmur_hash, favicon_name): 263 | """Format the output to display the total results count, domains, and IP addresses.""" 264 | if not total_results_count: 265 | return f"\n{Style.BRIGHT}{Fore.BLUE}No results found in {cls.get_platform()} for {favicon_name}" 266 | 267 | def make_header(header): 268 | return f'{Fore.CYAN}{Style.BRIGHT}{header}{Style.NORMAL}' 269 | 270 | result = f"\n{Style.BRIGHT}{Fore.BLUE}{cls.get_platform()} Results Preview{Style.NORMAL}\n" 271 | result += f"{make_header('Total results:')} {Fore.GREEN}{total_results_count}\n" 272 | result += f"{make_header('Domains:')} {Fore.YELLOW}{', '.join(domains)}\n" 273 | for waf, ips in ip_addresses_by_waf.items(): 274 | result += f"{make_header(f'IP Addresses [{waf}]:')} {Fore.MAGENTA}{', '.join(ips)}\n" 275 | 276 | path = os.path.join(OUTPUT_DIR, f"{murmur_hash}_{cls.get_platform()}.json") 277 | result += f"\n{Fore.GREEN}{cls.get_platform()} JSON response saved to {path}" 278 | return result 279 | 280 | 281 | class ShodanPreviewAPIKeyFetcher(Fetcher): 282 | """Stateless fetcher for getting results from Shodan based on favicon hash.""" 283 | def __init__(self, api_key, use_cache=True): 284 | self.api_key = api_key 285 | self.use_cache = use_cache 286 | 287 | @classmethod 288 | def get_platform(self): 289 | return 'Shodan' 290 | 291 | def get_info(self, favicon): 292 | """Fetch information from Shodan based on the favicon object using its API key.""" 293 | api = shodan.Shodan(self.api_key) 294 | murmur_hash = favicon.murmur_hash 295 | try: 296 | result = None 297 | if self.use_cache: 298 | result = ShodanPreviewAPIKeyFetcher._load_response_from_file(favicon.murmur_hash) # cached 299 | 300 | if not result: 301 | result = api.search(f'http.favicon.hash:{murmur_hash}') 302 | ShodanPreviewAPIKeyFetcher._save_response_to_file(result, favicon.murmur_hash) 303 | 304 | total_results_count, domains, ip_addresses_by_waf = ShodanPreviewAPIKeyFetcher._parse_response(result) 305 | output = ShodanPreviewAPIKeyFetcher._format_output(total_results_count, domains, ip_addresses_by_waf, murmur_hash, favicon.name()) 306 | return domains, ip_addresses_by_waf, output 307 | 308 | except shodan.APIError as e: 309 | return f"Shodan API request failed: {str(e)}" 310 | 311 | @staticmethod 312 | def _parse_response(data): 313 | """Extracts the total results count, domains, and IP addresses from the Shodan response.""" 314 | total_results_count = data.get('total', 0) 315 | domains = [] 316 | ip_addresses_by_waf = {} 317 | 318 | matches = data.get('matches', []) 319 | for match in matches: 320 | # Extract domain (if available) 321 | hostnames = match.get('hostnames', []) 322 | if hostnames: 323 | domains.append(f"{hostnames[0]}:{match.get('port')}") 324 | 325 | # Extract IP addresses 326 | ip = match.get('ip_str', '') 327 | if ip: 328 | ips = [ip] # Wrap in list to unify with other methods 329 | else: 330 | ips = [] 331 | 332 | waf_name = match.get('http', {}).get('waf', 'No CDN/WAF') 333 | 334 | if waf_name not in ip_addresses_by_waf: 335 | ip_addresses_by_waf[waf_name] = [] 336 | ip_addresses_by_waf[waf_name].extend(ips) 337 | 338 | return total_results_count, domains, ip_addresses_by_waf 339 | 340 | 341 | class ZoomEyePreviewFetcher(Fetcher): 342 | """Stateless fetcher for getting results preview from ZoomEye based on favicon hash.""" 343 | def __init__(self, use_cache): 344 | self.use_cache = use_cache 345 | 346 | @classmethod 347 | def get_platform(self): 348 | return 'ZoomEye' 349 | 350 | def get_info(self, favicon): 351 | """Fetch information from ZoomEye based on the favicon object.""" 352 | base_url = 'https://www.zoomeye.hk/api/search' 353 | headers = { 354 | 'Accept': 'application/json, text/plain, */*', 355 | 'Accept-Language': 'en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7,pt;q=0.6', 356 | 'Connection': 'keep-alive', 357 | 'Cookie': '__jsluid_s=b7c2017087e12824248295feed7dfdb1', 358 | 'Cube-Authorization': 'undefined', 359 | 'Sec-Fetch-Dest': 'empty', 360 | 'Sec-Fetch-Mode': 'cors', 361 | 'Sec-Fetch-Site': 'same-origin', 362 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36', 363 | 'sec-ch-ua': '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"', 364 | 'sec-ch-ua-mobile': '?0', 365 | 'sec-ch-ua-platform': '"macOS"', 366 | } 367 | 368 | url = f'{base_url}?q=iconhash%3A%22{favicon.murmur_hash}%22&page=1&t=v4%2Bv6%2Bweb' 369 | referer = f'https://www.zoomeye.hk/searchResult?q=iconhash%3A%22{favicon.murmur_hash}%22' 370 | headers['Referer'] = referer 371 | 372 | response = None 373 | data = {} 374 | 375 | if self.use_cache: 376 | data = ZoomEyePreviewFetcher._load_response_from_file(favicon.murmur_hash) # cached 377 | response = data 378 | 379 | if not response: 380 | response = requests.get(url, headers=headers) 381 | data = response.json() 382 | if response.status_code != 200: 383 | return f"ZoomEye Web API request failed: {response.status_code}" 384 | ZoomEyePreviewFetcher._save_response_to_file(data, favicon.murmur_hash) 385 | 386 | if data.get('status') == 429: 387 | return f"ZoomEye Web API request failed: Ratelimit" 388 | 389 | total_results_count, domains, ip_addresses_by_waf = ZoomEyePreviewFetcher._parse_response(data) 390 | output = ZoomEyePreviewFetcher._format_output(total_results_count, domains, ip_addresses_by_waf, favicon.murmur_hash, favicon.name()) 391 | return domains, ip_addresses_by_waf, output 392 | 393 | @staticmethod 394 | def _parse_response(data): 395 | """Extracts the total results count, domains, and IP addresses from the response.""" 396 | total_results_count = data.get('total', 0) 397 | domains = [] 398 | ip_addresses_by_waf = {} 399 | 400 | matches = data.get('matches', []) 401 | for match in matches: 402 | site = match.get('site', '') 403 | port = match.get('portinfo', {}).get('port', '') 404 | if site and port: 405 | domains.append(f"{site}:{port}") 406 | 407 | ips = match.get('ip', []) 408 | if isinstance(ips, str): 409 | ips = [ips] 410 | 411 | waf_list = match.get('waf', []) 412 | if waf_list: 413 | waf_name = waf_list[0].get('name', {}).get('en', 'Unknown WAF') 414 | else: 415 | waf_name = 'No WAF' 416 | 417 | if waf_name not in ip_addresses_by_waf: 418 | ip_addresses_by_waf[waf_name] = [] 419 | ip_addresses_by_waf[waf_name].extend(ips) 420 | 421 | return total_results_count, domains, ip_addresses_by_waf 422 | 423 | 424 | class NetlasPreviewAPIKeyFetcher(Fetcher): 425 | """Stateless fetcher for getting results from Netlas based on favicon hash.""" 426 | 427 | def __init__(self, api_key, use_cache=True): 428 | self.api_key = api_key 429 | self.use_cache = use_cache 430 | 431 | @classmethod 432 | def get_platform(cls): 433 | return 'Netlas' 434 | 435 | def get_info(self, favicon): 436 | """Fetch information from Netlas based on the favicon object using its API key.""" 437 | netlas_connection = netlas.Netlas(api_key=self.api_key) 438 | murmur_hash = favicon.murmur_hash 439 | 440 | try: 441 | result = None 442 | if self.use_cache: 443 | result = NetlasPreviewAPIKeyFetcher._load_response_from_file(murmur_hash) # cached response 444 | 445 | if not result: 446 | query_string = f'http.favicon.hash_sha256:{favicon.sha256_hash}' 447 | result = netlas_connection.query(query=query_string) 448 | NetlasPreviewAPIKeyFetcher._save_response_to_file(result, murmur_hash) 449 | 450 | total_results_count, domains, ip_addresses_by_waf = NetlasPreviewAPIKeyFetcher._parse_response(result) 451 | output = NetlasPreviewAPIKeyFetcher._format_output(total_results_count, domains, ip_addresses_by_waf, murmur_hash, favicon.name()) 452 | return domains, ip_addresses_by_waf, output 453 | 454 | except Exception as e: 455 | return [], {}, f"Netlas API request failed: {str(e)}" 456 | 457 | @staticmethod 458 | def _parse_response(data): 459 | """Extracts the total results count, domains, and IP addresses from the response.""" 460 | domains = [] 461 | ip_addresses_by_waf = {'No WAF': []} 462 | 463 | matches = data.get('items', []) 464 | total_results_count = len(matches) 465 | 466 | for match in matches: 467 | match_data = match.get('data', {}) 468 | site = match_data.get('host', '') 469 | port = match_data.get('port', '') 470 | if site: 471 | domains.append(f"{site}:{port}") 472 | 473 | ip = match_data.get('ip') 474 | if ip and not ip in ip_addresses_by_waf['No WAF']: 475 | ip_addresses_by_waf['No WAF'].append(ip) 476 | 477 | domains = list(set(domains)) 478 | 479 | return total_results_count, domains, ip_addresses_by_waf 480 | 481 | 482 | def run_fetchers(favicons, fetchers): 483 | """Run fetchers in parallel with a spinning progress bar and print results sequentially.""" 484 | results = [] 485 | 486 | # Prepare a list of tasks (fetchers for each favicon) 487 | tasks = [(fetcher, favicon) for favicon in favicons for fetcher in fetchers] 488 | 489 | with alive_bar(len(tasks), title="Fetching some results...") as bar: 490 | with concurrent.futures.ThreadPoolExecutor() as executor: 491 | futures = [executor.submit(fetcher.get_info, favicon) for fetcher, favicon in tasks] 492 | 493 | for future in concurrent.futures.as_completed(futures): 494 | try: 495 | results.append(future.result()) 496 | except Exception as e: 497 | results.append(([], {}, f"Error occurred: {e}")) 498 | bar() # Update the progress bar 499 | 500 | return results 501 | 502 | 503 | def make_se_links(domain): 504 | links_bundle = [ 505 | ('Google 16x16', f'https://www.google.com/s2/favicons?domain={domain}&size=16'), 506 | ('Google 32x32', f'https://www.google.com/s2/favicons?domain={domain}&size=32'), 507 | ('DuckDuckGo', f'https://icons.duckduckgo.com/ip3/{domain}.ico'), 508 | ('Icon Horse', f'https://icon.horse/icon/{domain}'), 509 | # Useless 510 | # ('Unavatar', f'https://unavatar.io/{domain}'), 511 | # ('Yandex', f'https://favicon.yandex.net/favicon/{domain}'), 512 | ] 513 | return links_bundle 514 | 515 | 516 | def resolve_domain(domain): 517 | try: 518 | resolver = dns.resolver.Resolver() 519 | resolver.nameservers = ['8.8.8.8', '8.8.4.4', 520 | '1.1.1.1', '1.0.0.1'] 521 | dns_answer = resolver.resolve(domain, 'A') 522 | ip_list = [ ip.to_text() for ip in dns_answer ] 523 | return ip_list 524 | 525 | except Exception as e: 526 | print(f'[-] {e}') 527 | return [] 528 | 529 | 530 | if __name__ == "__main__": 531 | parser = argparse.ArgumentParser( 532 | description="Get favicon hashes from multiple sources" 533 | ) 534 | 535 | search_modes = parser.add_mutually_exclusive_group(required=True) 536 | search_modes.add_argument("-u", "--uri", help="Get favicon hash from WEB") 537 | search_modes.add_argument("-f", "--file", help="Get favicon hash from a specific file") 538 | search_modes.add_argument("-d", "--domain", help="Get favicon hash from resolved domain") 539 | 540 | parser.add_argument("-e", "--add-from-search-engines", action="store_true", 541 | help="Get additional favicon versions using search engines") 542 | parser.add_argument("--tinyurl", action="store_true", 543 | help="Get short links for results with TinyURL") 544 | parser.add_argument("--no-fetch", action="store_true", default=False, 545 | help="Don't fetch results from engines") 546 | parser.add_argument("-v", "--verbose", action="store_true", default=False, 547 | help="Verbose (show hashes)") 548 | parser.add_argument("--no-logo", action="store_true", default=False, 549 | help="Disable unicorn animation (dangerous option, use with caution!)") 550 | parser.add_argument("-s", "--save-links-filename", type=str, help="Save links to a text file") 551 | args = parser.parse_args() 552 | 553 | if not args.no_logo: 554 | print_ascii_art() 555 | 556 | selist = [] 557 | favicons = [] 558 | 559 | fetchers = [ 560 | ZoomEyePreviewFetcher(use_cache=True), 561 | ] 562 | 563 | SHODAN_KEY = os.getenv('SHODAN_KEY') 564 | NETLAS_KEY = os.getenv('NETLAS_KEY') 565 | if SHODAN_KEY: 566 | fetchers.append(ShodanPreviewAPIKeyFetcher(SHODAN_KEY)) 567 | fetchers.append(NetlasPreviewAPIKeyFetcher(NETLAS_KEY)) 568 | 569 | if args.uri: 570 | if args.uri.count('/') >= 3 and not args.uri.endswith('/'): 571 | print(f"Searching by favicon from direct link {args.uri}...") 572 | try: 573 | favicon = Favicon.from_url(args.uri) 574 | favicons.append(favicon) 575 | except Exception as e: 576 | print(f"[-] Failed to fetch favicon: {e}") 577 | else: 578 | print(f"[-] Is it correct or full URI: '{args.uri}'?") 579 | 580 | elif args.file: 581 | print(f"Searching by favicon from file {os.path.abspath(args.file)}...") 582 | try: 583 | favicon = Favicon.from_file(args.file) 584 | favicons.append(favicon) 585 | except Exception as e: 586 | print(f"[-] Failed to load favicon from file: {e}") 587 | 588 | elif args.domain: 589 | # Try to find favicons on domain 590 | print(f"Searching by possible favicons from domain {args.domain}...") 591 | icons = [] 592 | try: 593 | icons = favicon.get(f"http://{args.domain}") 594 | except Exception as e: 595 | print(f'[!] Unable to guess favicons for {args.domain}: {e}') 596 | if icons: 597 | icon_urls = ', '.join([icon.url for icon in icons]) 598 | print(f'[-] Found {len(icons)} favicons for {args.domain}: {icon_urls}') 599 | unique_favicons = set(favicons) 600 | for icon in icons: 601 | if icon.width not in (32, 0): 602 | continue 603 | try: 604 | new_favicon = Favicon.from_url(icon.url, custom_type=f'guessed favicons of {args.domain}') 605 | if new_favicon not in unique_favicons: 606 | favicons.append(new_favicon) 607 | unique_favicons.add(new_favicon) 608 | except Exception as e: 609 | print(f"Error processing found favicon from URL {icon.url} for {args.domain}: {e}") 610 | 611 | # Try to get favicons from all related IPs 612 | ips = resolve_domain(args.domain) 613 | for ip in ips: 614 | try: 615 | favicon = Favicon.from_url(f"http://{ip}/favicon.ico", custom_type=f"resolved domain '{args.domain}'") 616 | unique_favicons = set(favicons) 617 | if favicon and not favicon in unique_favicons: 618 | favicons.append(favicon) 619 | except Exception as e: 620 | print(f'[-] Error {e} for {ip}') 621 | 622 | if args.add_from_search_engines and args.domain: 623 | unique_favicons = set(favicons) 624 | urls = make_se_links(args.domain) 625 | for url in urls: 626 | try: 627 | new_favicon = Favicon.from_url(url[1], custom_type=f'search engine {url[0]}') 628 | if new_favicon not in unique_favicons: 629 | favicons.append(new_favicon) 630 | unique_favicons.add(new_favicon) 631 | except Exception as e: 632 | print(f"Error processing favicon from URL {url} from search engine {url[0]}: {e}") 633 | 634 | preview_results = [] 635 | preview_file = '_preview_results.txt' 636 | were_links_saved = False 637 | no_results = False 638 | 639 | if favicons: 640 | for favicon in favicons: 641 | favicon.tinyurl = args.tinyurl 642 | print(f"Results for favicon from {favicon.type}: {favicon.source}\n") 643 | if args.verbose: 644 | print(favicon.hashes_text()+'\n') 645 | print(favicon.links_categorized_text()) 646 | if args.save_links_filename: 647 | with open(args.save_links_filename, "a") as f: 648 | were_links_saved = True 649 | f.write(favicon.links_only_text()) 650 | 651 | if args.no_fetch: 652 | print("Fetching of results is disabled, exiting.") 653 | else: 654 | all_domains = set() 655 | all_ips = set() 656 | results = run_fetchers(favicons, fetchers) 657 | for r in results: 658 | domains, ips_dict, output = r 659 | all_domains |= set(domains) 660 | for name, ips in ips_dict.items(): 661 | if 'cloudflare' in name.lower(): 662 | continue 663 | all_ips |= set(ips) 664 | 665 | print(output) 666 | 667 | preview_results = sorted(list(all_domains)) + sorted(list(all_ips)) 668 | if preview_results: 669 | filename = f'{favicon.murmur_hash}{preview_file}'.replace('-', '_') 670 | path = os.path.join(OUTPUT_DIR, filename) 671 | with open(filename, 'w') as file: 672 | file.write('\n'.join(preview_results)) 673 | print(f'{Fore.GREEN}Preview results for favicon with MurmurHash {favicon.murmur_hash} saved to {path}') 674 | else: 675 | no_results = True 676 | else: 677 | print("No results.") 678 | no_results = True 679 | 680 | if no_results: 681 | if args.file: 682 | print(f'{Fore.YELLOW}Try to specify as an input a domain with -d or an url of favicon with -u!') 683 | elif args.uri: 684 | print(f'{Fore.YELLOW}Try to specify as an input a domain with -d or a PNG/ICO file of favicon with -f!') 685 | elif args.domain: 686 | print(f'{Fore.YELLOW}Try to specify as an input an url of favicon with -u or a PNG/ICO file of favicon with -f!') 687 | 688 | if were_links_saved: 689 | print(f'{Fore.GREEN}All links saved to {os.path.abspath(args.save_links_filename)}') 690 | 691 | --------------------------------------------------------------------------------