Please use the script to get an Email Report of Browsing History of all popular browsers
Note:
Run the procedure as a System User
If you want to use your own sender configuration then change the following lines of code.
msgbody='Hi,
Please find the attachment for the Browsing History in CSV file format.
Thank you.'
emailto=['youremail@domain.com']
emailfrom='testcomodomail1@gmail.com'
password='C0m0d0@123'
smtpserver='smtp.gmail.com'
port=587
or if you want to use the existing (ours) sender configuration then you have to change only the following line of code
emailto=['youremail@domain.com']
Limitation:
Collects data from following browsers only
- Internet Explorer (Version 4.00 and greater)
- Mozilla Firefox (Version 3.00 and greater)
- Microsoft Edge
- Google Chrome
- Safari
- Opera (Version 15 or later, which is based on Chrome Web browser)
msgbody='Hi,
Please find the attachment for the Browsing History in CSV file format.
Thank you.'
emailto=['yourmailid@domain.com']
emailfrom='testcomodomail1@gmail.com'
password='C0m0d0@123'
smtpserver='smtp.gmail.com'
port=587
def computername():
import os
return os.environ['COMPUTERNAME']
def ipaddress():
import socket
return socket.gethostbyname(socket.gethostname())
def emailreport(subject, emailto,emailfrom,fileToSend,password,smtpserver,port,msgbody):
import smtplib
import mimetypes
from email.mime.multipart import MIMEMultipart
from email import encoders
from email.message import Message
from email.mime.audio import MIMEAudio
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
import os
msg = MIMEMultipart()
msg["From"] = emailfrom
msg["To"] = ",".join(emailto)
msg["Subject"] = subject
msg.preamble = subject
body = MIMEText(msgbody)
msg.attach(body)
with open(fileToSend, 'rb') as fp:
record = MIMEBase('text', 'octet-stream')
record.set_payload(fp.read())
encoders.encode_base64(record)
record.add_header('Content-Disposition', 'attachment', filename=os.path.basename(fileToSend))
msg.attach(record)
try:
server = smtplib.SMTP(smtpserver,port)
server.ehlo()
server.starttls()
server.login(emailfrom, password)
server.sendmail(emailfrom, emailto, msg.as_string())
server.quit()
return "the email report has been sent to "+msg["To"]
except Exception as e:
return e
def ecmd(CMD, r=False):
import ctypes
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
from subprocess import PIPE, Popen
with disable_file_system_redirection():
OBJ = Popen(CMD, shell = True, stdout = PIPE, stderr = PIPE)
out, err = OBJ.communicate()
ret=OBJ.returncode
if r:
return ret
else:
if ret==0:
return out
else:
return ret
import os
import urllib2
import zipfile
import shutil
if 'PROGRAMW6432' in os.environ.keys():
url='http://www.nirsoft.net/utils/browsinghistoryview-x64.zip'
else:
url='http://www.nirsoft.net/utils/browsinghistoryview.zip'
o=urllib2.urlopen(url)
c=o.code
temp=os.environ['TEMP']
if c==200:
zf=os.path.join(temp, url.split('/')[-1])
with open(zf, 'wb') as w:
w.write(o.read())
## print zf, 'downloaded'
else:
print c, 'error with download url'
z=zipfile.ZipFile(zf, 'r')
ep=os.path.join(temp, url.split('/')[-1][:-4])
z.extractall(ep)
z.close()
os.remove(zf)
if os.path.exists(ep):
pf=os.path.join(ep, 'BrowsingHistoryView.exe')
if os.path.isfile(pf):
cf=os.path.join(temp, 'browsinghistory.csv')
ec=ecmd('"%s" /scomma "%s"'%(pf, cf), r=True)
if ec==0:
## print cf, 'report has been created'
subject=computername()+'::'+ipaddress()+' Browser History Report'
print emailreport(subject,emailto,emailfrom,cf,password,smtpserver,port,msgbody)
os.remove(cf)
else:
print ec, 'error on report creation'
shutil.rmtree(ep)
else:
print 'error on extraction ...'
Script to Import:
Sample Output:
Execution Log -
Email Notification -
Email Content -
CSV Report (After Downloading) -
20170512-Imported-Browser-History.json (5.43 KB)