Skip to content

Commit

Permalink
第二个版本
Browse files Browse the repository at this point in the history
优化功能
  • Loading branch information
ResidualLaugh authored Sep 12, 2020
0 parents commit 3f2d999
Show file tree
Hide file tree
Showing 10 changed files with 9,528 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# FindSomething
FindSomething

被动式信息泄漏检测工具,使用chrome打包插件,即可直接使用。

123 changes: 123 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// @Date : 2020-09-12 16:26:48
// @Author : residuallaugh
var js = [];
var search_data = {};
var static_file = ['.jpg','.png','.gif','.css','.svg','.ico','.js'];
var key = ["ip","ip_port","domain","path","url","sfz","mobile","mail"];
function get_js(){
return js;
}
function add_js(js_name) {
js.push(js_name);
}
function unique(arr){
if(arr == 'null'){
return null;
}
var array=[];
for (var i = 0;i<arr.length;i++){
if (array.indexOf(arr[i])===-1){
array.push(arr[i])
}
}
return array
}
//查找search_data中是否已经存在了,如果已存在则不返回
function find(arr1,arr2) {
var arr3 = []
arr1.forEach(function (item,index,array) {
if(arr2.indexOf(item)==-1){
arr3.push(item)
}
})
return arr3
}
//去重合并两个数组 并集
function add(arr1,arr2) {
arr1.forEach(function (item,index,array) {
if(arr2.indexOf(item)==-1){
arr2.push(item)
}
})
return arr2
}

//交集
function jiaoji(arr1,arr2) {
var arr3 = [];
arr1.forEach(function (item,index,array) {
if(arr2.indexOf(item)>-1){
arr3.push(item)
}
})
return arr3
}


function collect_static(arr1,arr2) {
var arr3 = arr1.slice(0,arr1.length);
arr1.forEach(function (item,index,array) {
for (var i = 0; i < static_file.length; i++) {
if(item.indexOf(static_file[i])!=-1){
arr2.push(item)
arr3.splice(arr3.indexOf(item),1)
}
}
})
return {'arr1':arr3,'static':arr2}
}

chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.greeting == "get")//判断是否为要处理的消息
sendResponse({farewell: get_js()});
else if (request.greeting == "add"){
console.log("add "+sender.tab.url);
add_js(request.data);
sendResponse({farewell: get_js()});
}
else if (request.greeting == "result"){
var tmp_data = request.data;
//遍历所有数据类型
for (var i = 0; i < key.length; i++) {
//如果传入的数据没有这个类型,就看下一个
if (request.data[key[i]] == null){
continue;
}
//如果search_data有历史数据,进行检查
if (request.data['current'] in search_data){
for (var j = 0; j < key.length; j++) {
if (search_data[request.data['current']][key[j]]!=null){
tmp_data[key[i]] = jiaoji(unique(tmp_data[key[i]]),find(unique(request.data[key[i]]),search_data[request.data['current']][key[j]]))
}
}
}else{
search_data[request.data['current']] = {}
}
if (request.data['current'] in search_data && search_data[request.data['current']][key[i]]!=null ){
var search_data_value = unique(add(search_data[request.data['current']][key[i]],tmp_data[key[i]])).sort()
if ('static' in search_data[request.data['current']]){
var res = collect_static(search_data_value,search_data[request.data['current']]['static'])
}else{
var res = collect_static(search_data_value,[])
}
search_data[request.data['current']][key[i]] = res['arr1']
search_data[request.data['current']]['static'] = res['static']
}else{
var search_data_value = unique(tmp_data[key[i]]).sort()
if ('static' in search_data[request.data['current']]){
var res = collect_static(search_data_value,search_data[request.data['current']]['static'])
}else{
var res = collect_static(search_data_value,[])
}
search_data[request.data['current']]['static'] = res['static']
search_data[request.data['current']][key[i]] = res['arr1']
}
}
}
});


function result(host){
return search_data[host];
}
107 changes: 107 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// @Date : 2020-09-12 16:26:48
// @Author : residuallaugh
(function(){
var protocol = window.location.protocol;
var host = window.location.host;
var href = window.location.href;
var source = document.getElementsByTagName('html')[0].innerHTML;
var hostPath;
var urlPath;
var urlWhiteList = ['baidu.com','google.com'];
for(var i = 0;i < urlWhiteList.length;i++){
if(urlWhiteList[i].indexOf(host) != "-1"){
return false;
}
}

chrome.extension.sendMessage({greeting: "add",data:window.location.href}, function(response) { } );
findsomething(window.location.href);

var source_href = source.match(/href=\".*?\"/g);
var source_src = source.match(/src=\".*?\"/g);
// console.log(source_href,source_src)
chrome.extension.sendMessage({greeting: "get"},
function (response){
farewell=response.farewell;
for(var i=0;i<source_href.length;i++){
var u = deal_url(source_href[i].replace('href=\"','').replace('\"',''));
if(u){
// alert(u)
if(farewell.indexOf(u)=="-1"){
chrome.extension.sendMessage({greeting: "add",data:u}, function(response) { } );
console.log(u);
findsomething(u);
}
}
}
for(var i=0;i<source_src.length;i++){
var u = deal_url(source_src[i].replace('src=\"','').replace('\"',''));
if(u){
// alert(u)
if(farewell.indexOf(u)=="-1"){
chrome.extension.sendMessage({greeting: "add",data:u}, function(response) { } );
console.log(u);
findsomething(u);
}
}
}
});
function deal_url(u){
if(u.indexOf(".js")=='-1'){
return ;
}else if(u.substring(0,4)=="http"){
if(u.indexOf('?')!='-1'){
return u.substring(0,u.indexOf('?'));
}
else{
return u;
}
}
else if(u.substring(0,2)=="//"){
return protocol+u;
}
else if(u.substring(0,1)=='/'){
return protocol+'//'+host+u;
}
else if(u.substring(0,2)=='./'){
tmp_href = href.substring(0,href.indexOf('#'))
return tmp_href.substring(0,tmp_href.lastIndexOf('/')+1)+u;
}else{
console.log(u)
return ;
}
}


function findsomething(url){
$.ajax({
url: url,
type: 'get',
dataType: 'text',
async:false,
})
.done(function(data) {
var search_data = {'current':href}
search_data['sfz'] = data.match(/['"]\d{14}[0-9a-zA-Z]{4}['"]/g);
search_data['mobile'] = data.match(/['"]((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8])|(19[7]))\d{8}['"]/g);
search_data['mail'] = data.match(/['"][a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+['"]/g);
// var equal = data.match(/[\',\"].*?[\',\"]==[\',\"].*?[\',\"]/g);
search_data['ip'] = data.match(/['"]\d+\.\d+\.\d+\.\d+['"]/g);
search_data['ip_port'] = data.match(/['"]\d+\.\d+\.\d+\.\d+\:\d+['"]/g);
search_data['domain'] = data.match(/['"][a-zA-Z0-9\-\.]*?\.(xin|com|cn|net|com.cn|vip|top|cc|shop|club|wang|xyz|luxe|site|news|pub|fun|online|win|red|loan|ren|mom|net.cn|org|link|biz|bid|help|tech|date|mobi|so|me|tv|co|vc|pw|video|party|pics|website|store|ltd|ink|trade|live|wiki|space|gift|lol|work|band|info|click|photo|market|tel|social|press|game|kim|org.cn|games|pro|men|love|studio|rocks|asia|group|science|design|software|engineer|lawyer|fit|beer|我爱你|中国|公司|网络|在线|网址|网店|集团|中文网)['"]/g);
search_data['path'] = data.match(/['"]\/[^/][^>< \)\(\{\}]*?['"]/g);
search_data['url'] = data.match(/['"](([a-zA-Z0-9]+:)?\/\/)?[a-zA-Z0-9\-\.]*?\.(xin|com|cn|net|com.cn|vip|top|cc|shop|club|wang|xyz|luxe|site|news|pub|fun|online|win|red|loan|ren|mom|net.cn|org|link|biz|bid|help|tech|date|mobi|so|me|tv|co|vc|pw|video|party|pics|website|store|ltd|ink|trade|live|wiki|space|gift|lol|work|band|info|click|photo|market|tel|social|press|game|kim|org.cn|games|pro|men|love|studio|rocks|asia|group|science|design|software|engineer|lawyer|fit|beer|我爱你|中国|公司|网络|在线|网址|网店|集团|中文网)(\/.*?)?['"]/g);
chrome.extension.sendMessage({greeting: "result",data: search_data}, function(response) { } );
// console.log(search_data)
})
return ;
}
function show(url,something){
if(something){
console.log('----------------'+'find something in '+url+'!!!!!----------------');
console.log(something);
}else{
return;
}
}
})()
Binary file added icons/icon_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3f2d999

Please sign in to comment.