Open MikePeters86 opened 6 months ago
@MikePeters86 Awesome request! I opened a PR that addresses this issue as well. Python provides a module for parsing command line arguments while also having a built-in help menu. Here is a little of what the code looks like:
[!NOTE] I am working on a few features to directly download the favicon image from the URL provided so disregard that portion for now
def favicon_locator():
parser = argparse.ArgumentParser(
description='Generate favicon hash for search.')
parser.add_argument('-f', '--file', help='The name of the favicon file')
parser.add_argument(
'-u', '--url', help='The url of the site to search for favicon (ex: https://www.kfc.com)')
args = parser.parse_args()
if args.url:
webpage_url = args.url
favicon_url = get_favicon_url(webpage_url)
file_name = download_favicon(favicon_url)
md5_hash = generate_md5_hash(file_name)
mmh3_hash = compute_mmh3_hash(file_name)
output(md5_hash, mmh3_hash)
elif args.file:
file_name = args.file
md5_hash = generate_md5_hash(file_name)
mmh3_hash = compute_mmh3_hash(file_name)
output(md5_hash, mmh3_hash)
else:
parser.print_help()
exit(1)
On the command line, it looks like:
$ python3 favicon_locator.py -f favicon.ico
@MikePeters86 For creating a PR on this repository, you can roughly follow these steps:
git clone git@github.com:RoseSecurity/FaviconLocator.git
git checkout -b accept-file-via-cli
git add <files>
git commit -m 'Allow files to be accepted via the CLI'
git push
# Note: this should show a URL where you can create the PR
I'm a GitHub novice not yet familiar with pull requests. That is why I enter my 'issue' here.
It would be nice to have the ability to provide the favicon filename directly on the command line instead of being asked for it. Something like the code below would work (or rather: does work. I have already changed it on my own machine). Needs an
import sys
.