Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Simpler ID for scans, less verbose logging and ability to fetch logs differently.

Stevea7a25b78731f
diff --git a/sfdb.py b/sfdb.py
index aa8c608f..29f0a10e 100644
--- a/sfdb.py
+++ b/sfdb.py
@@ -468,12 +468,22 @@ class SpiderFootDb:
self.sf.error("SQL error encountered when fetching unique result events: " + e.args[0])
# Get scan logs
- def scanLogs(self, instanceId, limit=None):
+ def scanLogs(self, instanceId, limit=None, fromRowId=None, reverse=False):
qry = "SELECT generated AS generated, component, \
- type, message FROM tbl_scan_log WHERE scan_instance_id = ? \
- ORDER BY generated DESC"
+ type, message, rowid FROM tbl_scan_log WHERE scan_instance_id = ?"
+ if fromRowId:
+ qry += " and rowid > ?"
+
+ qry += " ORDER BY generated "
+ if reverse:
+ qry += "ASC"
+ else:
+ qry += "DESC"
qvars = [instanceId]
+ if fromRowId:
+ qvars.append(fromRowId)
+
if limit is not None:
qry += " LIMIT ?"
qvars.append(limit)
diff --git a/sflib.py b/sflib.py
index a11ef358..16f3b879 100644
--- a/sflib.py
+++ b/sflib.py
@@ -15,6 +15,7 @@ from stem import Signal
from stem.control import Controller
import inspect
import hashlib
+import binascii
import gzip
import gexf
import json
@@ -275,11 +276,13 @@ class SpiderFoot:
# Generate an globally unique ID for this scan
def genScanInstanceGUID(self, scanName):
- hashStr = hashlib.sha256(
- scanName +
- str(time.time() * 1000) +
- str(random.randint(100000, 999999))
- ).hexdigest()
+ # hashStr = hashlib.sha256(
+ # scanName +
+ # str(time.time() * 1000) +
+ # str(random.randint(100000, 999999))
+ # ).hexdigest()
+ rstr = scanName + str(time.time()) + str(random.randint(100000, 999999))
+ hashStr = "%08X" % int(binascii.crc32(rstr) & 0xffffffff)
return hashStr
def _dblog(self, level, message, component=None):
@@ -981,7 +984,7 @@ class SpiderFoot:
if sizeLimit or headOnly:
if not noLog:
self.info("Fetching (HEAD only): " + url + \
- " [user-agent: " + header['User-Agent'] + "] [timeout: " + \
+ " [timeout: " + \
str(timeout) + "]")
hdr = requests.head(url, headers=header, verify=False, timeout=timeout)
@@ -998,7 +1001,7 @@ class SpiderFoot:
if result['realurl'] != url:
if not noLog:
self.info("Fetching (HEAD only): " + url + \
- " [user-agent: " + header['User-Agent'] + "] [timeout: " + \
+ " [timeout: " + \
str(timeout) + "]")
hdr = requests.head(result['realurl'], headers=header, verify=False)
@@ -1014,12 +1017,11 @@ class SpiderFoot:
req.add_header('cookie', cookies)
if not noLog:
self.info("Fetching (incl. cookies): " + url + \
- " [user-agent: " + header['User-Agent'] + "] [timeout: " + \
+ " [timeout: " + \
str(timeout) + "]")
else:
if not noLog:
- self.info("Fetching: " + url + " [user-agent: " + \
- header['User-Agent'] + "] [timeout: " + str(timeout) + "]")
+ self.info("Fetching: " + url + " [timeout: " + str(timeout) + "]")
result['headers'] = dict()
opener = urllib2.build_opener(SmartRedirectHandler())