Created
April 20, 2018 08:11
-
-
Save yevgenypats/f445025d66fd5d8f3c374f8862c76edf to your computer and use it in GitHub Desktop.
PhishTank + Phish.AI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import argparse | |
from datetime import datetime | |
def upload_urls(path, limit, api_key=None): | |
data = json.load(open(path, 'r')) | |
data = sorted(data, key=lambda x: datetime.strptime(x['submission_time'][:10], '%Y-%m-%d'), reverse=True) | |
headers = {'Authorization': api_key} if api_key else None | |
for i, phish in enumerate(data): | |
if i > limit: | |
break | |
print('submitting url={} with phish_id={} with i={}'.format(phish['url'], phish['phish_id'], i)) | |
res = requests.post('https://app.phish.ai/api/url/scan', | |
headers=headers, | |
data={'url': phish['url']}) | |
print(res) | |
def main(): | |
parser = argparse.ArgumentParser(description='Upload Phishtank JSON to Phish.AI') | |
parser.add_argument('json', type=str, help='PhishTanj JSON path') | |
parser.add_argument('limit', type=int, help='how many to upload') | |
parser.add_argument('--api_key', type=str, default=None, help='api key to use') | |
args = parser.parse_args() | |
upload_urls(args.json, args.limit, args.api_key) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment