|
@ -17,7 +17,7 @@ except: |
|
|
print "\nError importing: sqlite3 lib. \n\nOn Debian based systems, please try like root:\n\n $ apt-get install sqlite3\n" |
|
|
print "\nError importing: sqlite3 lib. \n\nOn Debian based systems, please try like root:\n\n $ apt-get install sqlite3\n" |
|
|
sys.exit(2) |
|
|
sys.exit(2) |
|
|
|
|
|
|
|
|
import subprocess, socket |
|
|
import subprocess, socket, thread |
|
|
from options import BCOptions |
|
|
from options import BCOptions |
|
|
from webserver import BorderCheckWebserver |
|
|
from webserver import BorderCheckWebserver |
|
|
|
|
|
|
|
@ -185,12 +185,12 @@ class bc(object): |
|
|
# Set database (GeoLiteCity) |
|
|
# Set database (GeoLiteCity) |
|
|
self.geoip= pygeoip.GeoIP('GeoLiteCity.dat') |
|
|
self.geoip= pygeoip.GeoIP('GeoLiteCity.dat') |
|
|
|
|
|
|
|
|
print "Fetching URL:", self.url[0], "\n" |
|
|
print '='*45 + "\n", "Current target:\n" + '='*45 + "\n" |
|
|
|
|
|
print "URL:", self.url[0], "\n" |
|
|
#url = urlparse(self.url[0]).netloc |
|
|
#url = urlparse(self.url[0]).netloc |
|
|
url = urlparse(self.getURL()).netloc #changed this for prototyping |
|
|
url = urlparse(self.getURL()).netloc #changed this for prototyping |
|
|
url = url.replace('www.','') #--> doing a tracert to example.com and www.example.com yields different results. |
|
|
url = url.replace('www.','') #--> doing a tracert to example.com and www.example.com yields different results. |
|
|
url_ip = socket.gethostbyname(url) |
|
|
url_ip = socket.gethostbyname(url) |
|
|
print '='*45 + "\n", "Current target:\n" + '='*45 + "\n" |
|
|
|
|
|
print "Host:", url, "\n" |
|
|
print "Host:", url, "\n" |
|
|
if url != self.old_url: |
|
|
if url != self.old_url: |
|
|
count = 1 |
|
|
count = 1 |
|
@ -250,6 +250,7 @@ class bc(object): |
|
|
""" |
|
|
""" |
|
|
Get Geolocation database (http://dev.maxmind.com/geoip/legacy/geolite/) |
|
|
Get Geolocation database (http://dev.maxmind.com/geoip/legacy/geolite/) |
|
|
""" |
|
|
""" |
|
|
|
|
|
print "="*45 + "\n", "GeoIP Options:\n" + '='*45 + "\n" |
|
|
# Download, extract and set geoipdatabase |
|
|
# Download, extract and set geoipdatabase |
|
|
if not os.path.exists('GeoLiteCity.dat'): |
|
|
if not os.path.exists('GeoLiteCity.dat'): |
|
|
import urllib, gzip |
|
|
import urllib, gzip |
|
@ -271,6 +272,7 @@ class bc(object): |
|
|
f_in.close() |
|
|
f_in.close() |
|
|
|
|
|
|
|
|
os.remove('GeoLiteCity.gz') |
|
|
os.remove('GeoLiteCity.gz') |
|
|
|
|
|
print "Database: GeoLiteCity\n" |
|
|
|
|
|
|
|
|
def run(self, opts=None): |
|
|
def run(self, opts=None): |
|
|
""" |
|
|
""" |
|
@ -294,8 +296,12 @@ class bc(object): |
|
|
url = self.try_running(self.getURL, "\nInternal error getting urls from browser's database.") |
|
|
url = self.try_running(self.getURL, "\nInternal error getting urls from browser's database.") |
|
|
# set geoip database |
|
|
# set geoip database |
|
|
geo = self.try_running(self.getGEO, "\nInternal error setting geoIP database.") |
|
|
geo = self.try_running(self.getGEO, "\nInternal error setting geoIP database.") |
|
|
# start web mode |
|
|
# start web mode (on a different thread) |
|
|
BorderCheckWebserver(self) #child process or another thread |
|
|
try: |
|
|
|
|
|
thread.start_new_thread(BorderCheckWebserver(self)) |
|
|
|
|
|
except: |
|
|
|
|
|
print "Error: unable to start thread" |
|
|
|
|
|
pass |
|
|
# run traceroutes |
|
|
# run traceroutes |
|
|
traces = self.try_running(self.traces, "\nInternal error tracerouting.") |
|
|
traces = self.try_running(self.traces, "\nInternal error tracerouting.") |
|
|
|
|
|
|
|
|