diff --git a/README.md b/README.md index 326e4db..3b752ec 100644 --- a/README.md +++ b/README.md @@ -74,4 +74,7 @@ - 完善了身份证号和手机号码的正则匹配 - 修改了信息搜集页面样式,内容更加紧凑 - 增加了白名单功能 -- 修改了页面样式(信息搜集,配置页面) \ No newline at end of file +- 修改了页面样式(信息搜集,配置页面) +- 新增指纹嗅探页面(静态) +- 新增完善静态文件匹配 +- 完善手机号的正则匹配 \ No newline at end of file diff --git a/background/background.js b/background/background.js index dea5245..b2a2498 100644 --- a/background/background.js +++ b/background/background.js @@ -22,6 +22,40 @@ const DOMAIN_RULES = { ] }; +// 更新扩展图标的badge +function updateBadge(results) { + // 计算有内容的类别数量 + const categories = [ + results.domains, + results.apis, + results.staticFiles, + results.ips, + results.phones, + results.emails, + results.idcards, + results.urls, + results.jwts, + results.awsKeys, + results.hashes?.md5, + results.hashes?.sha1, + results.hashes?.sha256 + ]; + + const nonEmptyCategories = categories.filter(category => + Array.isArray(category) && category.length > 0 + ).length; + + // 更新badge + chrome.action.setBadgeText({ + text: nonEmptyCategories > 0 ? nonEmptyCategories.toString() : '' + }); + + // 根据是否有内容设置不同的颜色 + chrome.action.setBadgeBackgroundColor({ + color: nonEmptyCategories > 0 ? '#4dabf7' : '#666666' + }); +} + // 处理跨域请求 chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { if (request.type === 'FETCH_JS') { @@ -70,5 +104,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { }); return true; // 保持消息通道打开 + } else if (request.type === 'UPDATE_BADGE') { + // 处理badge更新请求 + updateBadge(request.results); } }); \ No newline at end of file diff --git a/content/config/scanner.config.js b/content/config/scanner.config.js index 26c0608..df0e394 100644 --- a/content/config/scanner.config.js +++ b/content/config/scanner.config.js @@ -20,9 +20,9 @@ const SCANNER_CONFIG = { // API 相关配置 API: { - PATTERN: /['"](?:\/|\.\.\/|\.\/)[^\/\>\< \)\(\{\}\,\'\"\\]([^\>\< \)\(\{\}\,\'\"\\])*?[\'"]/g, - // 静态文件后缀 - STATIC_FILE_PATTERN: /\.(js|css|ico|png|webp|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|map|json)$/i + PATTERN: /['"](?:\/|\.\.\/|\.\/)[^\/\&\>\< \)\(\{\}\,\'\"\\]([^\>\< \)\(\{\}\,\'\"\\])*?[\'"]/g, + // 静态文件后缀 - 增强匹配规则 + STATIC_FILE_PATTERN: /\.(js|css|ico|png|webp|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|map|json|jsonp)(?:\?[^'"]*)?$/i }, // 域名相关配置 @@ -181,7 +181,7 @@ const SCANNER_CONFIG = { }, // 其他敏感信息匹配 - PHONE: /(?:13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9]|198|199)\d{8}(?!\d)/g, + PHONE: /(? { if (tabs[0]) { chrome.tabs.sendMessage(tabs[0].id, {type: 'REFRESH_SCAN'}, response => { if (chrome.runtime.lastError) { - container.innerHTML = '
无法连接到页面,刷新试试
'; + container.innerHTML = '
无法连接到页面,尝试刷新页面后再试吧
'; } else if (response === 'WHITELISTED') { container.innerHTML = '
当前域名在白名单中,已跳过扫描
'; } else if (response) { @@ -307,7 +307,7 @@ document.addEventListener('DOMContentLoaded', () => { if (tabs[0]) { chrome.tabs.sendMessage(tabs[0].id, {type: 'GET_RESULTS'}, response => { if (chrome.runtime.lastError) { - container.innerHTML = '
无法连接到页面,刷新试试
'; + container.innerHTML = '
无法连接到页面,尝试刷新页面后再试吧
'; } else if (response === 'WHITELISTED') { container.innerHTML = '
当前域名在白名单中,已跳过扫描
'; } else if (response) {