Martineau
Part of the Furniture
Recently there was a query regarding the Web History tracking to which I replied, so I thought I would revisit my crude script I posted.
I believe the Web History is now more mature, and probably can provide useful info, but extracting the info into a printable report is sadly lacking.
So here is my shoddy WebHistory_Report.sh script to allow queries to be made on the Web History database
EDIT:22/11/2018 v1.08 Released see Release notes
EDIT:20/11/2018 v1.07 Fix 'time=HH:' matching etc. see post #6
So here is my shoddy TrafficAnalyzer_Report.sh script to allow queries to be made on the Traffic Analyzer database
So here is my shoddy AiProtectionMonitor_Report.sh" script to allow queries to be made on the AiProtection Monitor database
EDIT:13/12/2018 v1.09 Released see Release notes
EDIT:22/11/2018 v1.08 Released see Release notes
EDIT:20/11/2018 v1.07 Released:
Prerequisites:
1. Obviously Web History must be ENABLED
2. Entware must be installed (why isn't it? ) together with
e.g. Default filter in AND mode... i.e. both date= and url= must match
Find all URLs containing either of the strings 'facebook' or 'youtube' created 'today'
Complex query using OR mode
e.g. Find all URLs containing any of the strings ( 'amazon' or 'kindle' or 'game'), or any records timestamped between '10:00-10:59' or any records for LAN device 10.88.8.157 (which happens to be a kids phone )
I have similar scripts for Traffic Analyzer and AiProtection Monitor, but first I'd like the community to try out (aka debug ) the Web History script first to see if there is a need for such scripts.
As usual all/any feedback appreciated.
EDIT: If the Web History is large i.e. was enabled weeks ago?, then
will trundle slowly through ALL the database records on screen - starting with the first timestamped record and could take days
So, a quick tip to instantly dump/display ALL records in the database is to issue
and the 'raw' SQL records are returned within a few seconds.
i.e. the same database all 116458 records can be dumped/displayed on screen in <10 seconds! so if cosmetic formatting isn't required simple grep/sed/awk can be used to apply the filters.
I believe the Web History is now more mature, and probably can provide useful info, but extracting the info into a printable report is sadly lacking.
So here is my shoddy WebHistory_Report.sh script to allow queries to be made on the Web History database
EDIT:22/11/2018 v1.08 Released see Release notes
EDIT:20/11/2018 v1.07 Fix 'time=HH:' matching etc. see post #6
So here is my shoddy TrafficAnalyzer_Report.sh script to allow queries to be made on the Traffic Analyzer database
So here is my shoddy AiProtectionMonitor_Report.sh" script to allow queries to be made on the AiProtection Monitor database
EDIT:13/12/2018 v1.09 Released see Release notes
EDIT:22/11/2018 v1.08 Released see Release notes
EDIT:20/11/2018 v1.07 Released:
Prerequisites:
1. Obviously Web History must be ENABLED
2. Entware must be installed (why isn't it? ) together with
EDIT: 10/05/2019 Firmware v384.11 now includes 'sqlite3 v3.7.2' rather than Entware's
'sqlite3 v3.26.0' utility (opkg install sqlite3-cli) (if not already silently installed by Skynet)
'find' utility (opkg install findutils) Thanks @jtp10181
'sqlite3 v3.26.0' utility (opkg install sqlite3-cli) (if not already silently installed by Skynet)
'find' utility (opkg install findutils) Thanks @jtp10181
Code:
./WebHistory_Report.sh -h
#======================================================================================= © 2016-2018 Martineau v1.08
#
# Scan Web History database
#
# WebHistory_Report [help | -h] ['ip='{[ip_address[,...] | hostname[...]]} ['flush']] ['url='{url_string[,...]}] ['nofilter'] ['email'] ['mode=or'] ['noscript']
# ['date='[yyyy/mm/dd[,...]]] ['time='[hh:mm:ss[,...]]] ['sqldb='{database}] ['backup'] ['purgeallreset'] ['count'] ['sortby='column]
#
# WebHistory_Report
# Will list 'Todays' URL entries in the Web History database containing strings 'facebook' OR 'youtube'
# WebHistory_Report count
# Will count 'Todays' URL entries in the Web History database containing strings 'facebook' OR 'youtube'
# and will only display the result count. No records are displayed on screen.
# WebHistory_Report nofilter
# Will list ALL entries in the Web History database.
# WebHistory_Report nofilter sortby=url
# Will list ALL entries in the Web History database sorted by column URL
# WebHistory_Report nofilter email
# Will list ALL entries in the Web History database and will send an email with the results
# WebHistory_Report url=amazon,netflix
# Will list URL entries in the Web History database containing strings either 'amazon' OR 'netflix'
# WebHistory_Report ip=192.168.1.1 url=amazon,netflix time=18:,19: mode=or
# Will list URL entries in the Web History database for 192.168.1.1 or between 18:00-19:59 or URLs as above
# Without 'mode=or' then the databse records must match ALL three criteria
# WebHistory_Report date=2017/02/30
# Will list entries in the Web History database created on '30th Feb 2017'
# NOTE: The date specification can be an abbreviation e.g. '2017/02' for records created in 'Feb 2017'
# WebHistory_Report ip=10.88.8.123, 192.168.1.120-192.168.1.123, CAMERAS
# Will list database entries for five devices, plus all IPs for 'CAMERAS' entry in '/jffs/configs/IPGroups'
# NOTE: Only MAC addresses are stored in the database so if the devices are not 'reserved/static'
# then the report could be inaccurate.
# WebHistory_Report ip=10.88.8.123 flush url="www.veryexpensiveshoes.com"
# Will delete all URL 'www.veryexpensiveshoes.com' history for '10.88.8.123' Ha ha - wife mode eh? ;-)
# WebHistory_Report ip=10.88.8.123 flush
# Will delete all history for '10.88.8.123'
# WebHistory_Report time=09:
# Will list entries in the Web History database created between '09:00' to '09:59'
# NOTE: A full time specification can be used e.g. '12:05:30' but the report may never find a match!
# WebHistory_Report backup
# The current Web History database will be backed up to '/opt/var/WebHistory/'
# WebHistory_Report sqldb=/opt/var/WebHistory/WebHistory.db-Backup-20180401-060000
# The report/queries will be extracted from the archive/backup database '/opt/var/WebHistory/WebHistory.db-Backup-20180401-060000'
# WebHistory_Report purgeallreset
# The current Web History database is PURGED of ALL history!!!!! (NOTE: a backup is taken first ;-)
Find all URLs containing either of the strings 'facebook' or 'youtube' created 'today'
Code:
./WebHistory_Report.sh
Complex query using OR mode
e.g. Find all URLs containing any of the strings ( 'amazon' or 'kindle' or 'game'), or any records timestamped between '10:00-10:59' or any records for LAN device 10.88.8.157 (which happens to be a kids phone )
Code:
./WebHistory_Report.sh ip=10.88.8.157 url=amazon time=10 url=kindle,game mode=or
I have similar scripts for Traffic Analyzer and AiProtection Monitor, but first I'd like the community to try out (aka debug ) the Web History script first to see if there is a need for such scripts.
As usual all/any feedback appreciated.
EDIT: If the Web History is large i.e. was enabled weeks ago?, then
Code:
./WebHistory_Report.sh nofilter
e.g. Database contains 116458 records
Script takes approx. 9 seconds before the first record is displayed on screen, then takes a further 8 seconds to fill the screen with the first 32 records.
Script takes approx. 9 seconds before the first record is displayed on screen, then takes a further 8 seconds to fill the screen with the first 32 records.
So, a quick tip to instantly dump/display ALL records in the database is to issue
Code:
./WebHistory_Report.sh nofilter noscript
i.e. the same database all 116458 records can be dumped/displayed on screen in <10 seconds! so if cosmetic formatting isn't required simple grep/sed/awk can be used to apply the filters.
Last edited: