Skip to content
This repository has been archived by the owner on Jul 1, 2019. It is now read-only.

Commit

Permalink
close #22: Auto update ressources as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
SageHack committed Mar 30, 2018
1 parent 2634ff9 commit 4a0a6f7
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 44 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
lists/x*
lists/ipout-hosts
lists/ipout-protected
tmp/

*.pyc
*.txt
*.log
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ A security tool that aim at doing the following
* openssl

# Usage instructions
* Install (see below)
* Download latest CloudFlare IPs and CrimeFlare DB
* `python3 lists/update.py`
* Run the fast/simple scan
* `python3 bust mydomain.com`
* Run the slow/comprehensive scan
Expand Down
6 changes: 6 additions & 0 deletions bust/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from updater import Updater
from buster import CloudBuster
from cli import args, parser
from options import Options
Expand All @@ -12,9 +13,14 @@


def main(args):

print(logo, flush=True)

if not args.target:
parser.print_help()
return

Updater.run()
if os.path.isfile(args.target):
scan_list(args)
else:
Expand Down
43 changes: 43 additions & 0 deletions bust/updater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import urllib.request
import zipfile
import os
import sys
import time

class Updater:
def run():
if Updater.uptodate():
return

downloads = [
['https://www.cloudflare.com/ips-v4', 'lists/cloudflare_ipv4'],
['https://www.cloudflare.com/ips-v6', 'lists/cloudflare_ipv6'],
]

for d in downloads:
Updater.download(d[0], d[1])

Updater.last_updated(Updater.today())
print('')


def uptodate():
last_updated = open('lists/last_updated', 'r').read()
if last_updated == Updater.today():
return True
return False

def last_updated(date):
file = open('lists/last_updated', 'w')
file.write(date)
file.close

def today():
return time.strftime("%Y-%m-%d")

def download(url, file):
print('[download] %s' % url)
try:
urllib.request.urlretrieve(url, file)
except (OSError, HTTPError, http.client.BadStatusLine):
pass
2 changes: 2 additions & 0 deletions lists/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
last_updated
cloudflare_ip*
1 change: 1 addition & 0 deletions lists/last_updated
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2018-03-29
37 changes: 0 additions & 37 deletions lists/update.py

This file was deleted.

0 comments on commit 4a0a6f7

Please sign in to comment.