Skip to content

Commit 7efca56

Browse files
增加规律规则,减少误报
1 parent bca89b5 commit 7efca56

File tree

7 files changed

+255
-197
lines changed

7 files changed

+255
-197
lines changed

README-CN.md

Lines changed: 0 additions & 121 deletions
This file was deleted.

README-EN.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# SecureJS
2+
3+
SecureJS is a powerful tool designed to collect all related links from a target website, perform requests on these links (primarily JavaScript files), and scan for sensitive information such as tokens, keys, passwords, AKSKs, and more.
4+
5+
## Table of Contents
6+
7+
- [SecureJS](#securejs)
8+
- [Table of Contents](#table-of-contents)
9+
- [Features](#features)
10+
- [Usage](#usage)
11+
- [Example](#example)
12+
- [Configuration](#configuration)
13+
- [Sample `config.yaml`](#sample-configyaml)
14+
- [Loading Configuration](#loading-configuration)
15+
- [Project Structure](#project-structure)
16+
17+
## Features
18+
19+
- **Comprehensive Crawling**: Simulates browser visits to collect all links and JavaScript files from the target.
20+
- **Secondary Requests**: Performs additional requests on collected resources for deeper analysis.
21+
- **Customizable Matching Rules**: Supports custom rules defined in `config.yaml` to identify sensitive information.
22+
- **Flexible Output Formats**: Outputs results in CSV, JSON, or plain text formats.
23+
- **Easy Configuration**: Simplifies setup and customization through a configuration file.
24+
25+
## Usage
26+
27+
SecureJS can be executed via the command line with various options to customize its behavior.
28+
29+
### Example
30+
31+
```bash
32+
./SecureJS -u https://example.com -o results.csv
33+
```
34+
```bash
35+
./SecureJS -l targets.txt -o results.csv -t 30
36+
```
37+
## Configuration
38+
39+
SecureJS uses a `config.yaml` file to define custom matching rules and other project-level configurations.
40+
41+
### Sample `config.yaml`
42+
43+
```yaml
44+
rules:
45+
- name: Sensitive Field
46+
f_regex: (?i)\[?["']?[0-9A-Za-z_-]{0,15}(?:key|secret|token|config|auth|access|admin|ticket)[0-9A-Za-z_-]{0,15}["']?\]?\s*(?:=|:|\)\.val\()\s*\[?\{?["']([^"']{8,100})["']?(?::|,)?
47+
48+
- name: Password Field
49+
f_regex: ((|\\)(|'|")(|[\w]{1,10})([p](ass|wd|asswd|assword))(|[\w]{1,10})(|\\)(|'|")(:|=|\)\.val\()(|)(|\\)('|")([^'"]+?)(|\\)('|")(|,|\)))
50+
51+
- name: JSON Web Token
52+
f_regex: (eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9._-]{10,}|eyJ[A-Za-z0-9_\/+-]{10,}\.[A-Za-z0-9._\/+-]{10,})
53+
54+
- name: Cloud Key
55+
f_regex: (?i)(?:AWSAccessKeyId=[A-Z0-9]{16,32}|access[-_]?key[-_]?(?:id|secret)|LTAI[a-z0-9]{12,20})
56+
```
57+
58+
### Loading Configuration
59+
60+
The configuration is automatically loaded from the `config/config.yaml` file. Ensure that your custom rules are correctly defined to match the sensitive information you aim to identify.
61+
62+
## Project Structure
63+
64+
```
65+
SecureJS/
66+
├── cmd/
67+
│ └── root.go # Entry point for command-line arguments handling (-u, -l, -t, etc.)
68+
69+
├── internal/
70+
│ ├── crawler/
71+
│ │ ├── crawler.go # Crawler logic, simulates browser access, collects all links and JS files
72+
│ │ └── linkfind.go # Extracts all links and JS from the response body of the target page
73+
│ │
74+
│ ├── parser/
75+
│ │ └── parser.go # Performs secondary requests on all collected links and JS files
76+
│ │
77+
│ ├── matcher/
78+
│ │ └── matcher.go # Reads and parses custom rules from config.yaml and matches against response bodies
79+
│ │
80+
│ └── output/
81+
│ └── output.go # Outputs results to files in CSV, JSON, or text formats
82+
83+
├── config/
84+
│ ├── config.go # Handles loading and parsing of the configuration file (config.yaml)
85+
│ └── config.yaml # Custom rules and other project-level configurations
86+
87+
├── go.mod # Go Modules management file
88+
├── go.sum # Go Modules checksum file
89+
└── main.go # Main program entry point, initializes and starts the application
90+
```

README.md

Lines changed: 38 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,50 @@
11
# SecureJS
22

3-
SecureJS is a powerful tool designed to collect all related links from a target website, perform requests on these links (primarily JavaScript files), and scan for sensitive information such as tokens, keys, passwords, AKSKs, and more.
3+
SecureJS 是一个强大的工具,旨在从目标网站收集所有相关链接,对这些链接(主要是 JavaScript 文件)执行请求,并扫描敏感信息,如令牌、密钥、密码、AKSK 等。
44

5-
## Table of Contents
5+
## 目录
66

77
- [SecureJS](#securejs)
8-
- [Table of Contents](#table-of-contents)
9-
- [Features](#features)
10-
- [Installation](#installation)
11-
- [Prerequisites](#prerequisites)
12-
- [Steps](#steps)
13-
- [Usage](#usage)
14-
- [Example](#example)
15-
- [Configuration](#configuration)
16-
- [Sample `config.yaml`](#sample-configyaml)
17-
- [Loading Configuration](#loading-configuration)
18-
- [Project Structure](#project-structure)
8+
- [目录](#目录)
9+
- [功能](#功能)
10+
- [使用方法](#使用方法)
11+
- [示例](#示例)
12+
- [配置](#配置)
13+
- [示例 `config.yaml`](#示例-configyaml)
14+
- [加载配置](#加载配置)
15+
- [项目结构](#项目结构)
1916

20-
## Features
17+
## 功能
2118

22-
- **Comprehensive Crawling**: Simulates browser visits to collect all links and JavaScript files from the target.
23-
- **Secondary Requests**: Performs additional requests on collected resources for deeper analysis.
24-
- **Customizable Matching Rules**: Supports custom rules defined in `config.yaml` to identify sensitive information.
25-
- **Flexible Output Formats**: Outputs results in CSV, JSON, or plain text formats.
26-
- **Easy Configuration**: Simplifies setup and customization through a configuration file.
19+
- **全面爬取**:模拟浏览器访问,收集目标网站的所有链接和 JavaScript 文件。
20+
- **二次请求**:对收集的资源执行额外的请求以进行更深入的分析。
21+
- **可自定义的匹配规则**:支持在 `config.yaml` 中定义的自定义规则,以识别敏感信息。
22+
- **灵活的输出格式**:将结果输出为 CSVJSON 或纯文本格式。
23+
- **简易配置**:通过配置文件简化设置和自定义过程。
2724

28-
## Installation
25+
## 使用方法
2926

30-
### Prerequisites
27+
SecureJS 可以通过命令行执行,并提供各种选项以自定义其行为。
3128

32-
- [Go](https://golang.org/dl/) 1.16 or later
33-
34-
### Steps
35-
36-
1. **Clone the Repository**
37-
38-
```bash
39-
git clone
40-
cd SecureJS
41-
```
42-
43-
2. **Build the Application**
44-
45-
```bash
46-
go build
47-
```
48-
49-
3. **Verify Installation**
50-
51-
```bash
52-
./SecureJS -h
53-
```
54-
55-
## Usage
56-
57-
SecureJS can be executed via the command line with various options to customize its behavior.
58-
59-
### Example
29+
### 示例
6030

6131
```bash
6232
./SecureJS -u https://example.com -o results.csv
6333
```
6434
```bash
6535
./SecureJS -l targets.txt -o results.csv -t 30
6636
```
67-
## Configuration
6837

69-
SecureJS uses a `config.yaml` file to define custom matching rules and other project-level configurations.
38+
## 配置
39+
40+
SecureJS 使用 `config.yaml` 文件来定义自定义匹配规则和其他项目级配置。
7041

71-
### Sample `config.yaml`
42+
### 示例 `config.yaml`
7243

7344
```yaml
7445
rules:
7546
- name: Sensitive Field
76-
f_regex: (?i)\[?["']?[0-9A-Za-z_-]{0,15}(?:key|secret|token|config|auth|access|admin|ticket)[0-9A-Za-z_-]{0,15}["']?\]?\s*(?:=|:|\)\.val\()\s*\[?\{?["']([^"']{8,256})["']?(?::|,)?
47+
f_regex: (?i)\[?["']?[0-9A-Za-z_-]{0,15}(?:key|secret|token|config|auth|access|admin|ticket)[0-9A-Za-z_-]{0,15}["']?\]?\s*(?:=|:|\)\.val\()\s*\[?\{?["']([^"']{8,100})["']?(?::|,)?
7748

7849
- name: Password Field
7950
f_regex: ((|\\)(|'|")(|[\w]{1,10})([p](ass|wd|asswd|assword))(|[\w]{1,10})(|\\)(|'|")(:|=|\)\.val\()(|)(|\\)('|")([^'"]+?)(|\\)('|")(|,|\)))
@@ -85,36 +56,36 @@ rules:
8556
f_regex: (?i)(?:AWSAccessKeyId=[A-Z0-9]{16,32}|access[-_]?key[-_]?(?:id|secret)|LTAI[a-z0-9]{12,20})
8657
```
8758
88-
### Loading Configuration
59+
### 加载配置
8960
90-
The configuration is automatically loaded from the `config/config.yaml` file. Ensure that your custom rules are correctly defined to match the sensitive information you aim to identify.
61+
配置会自动从 `config/config.yaml` 文件中加载。请确保您的自定义规则已正确定义,以匹配您希望识别的敏感信息。
9162

92-
## Project Structure
63+
## 项目结构
9364

9465
```
9566
SecureJS/
9667
├── cmd/
97-
│ └── root.go # Entry point for command-line arguments handling (-u, -l, -t, etc.)
68+
│ └── root.go # 处理命令行参数(-u、-l、-t 等)的入口点
9869
9970
├── internal/
10071
│ ├── crawler/
101-
│ │ ├── crawler.go # Crawler logic, simulates browser access, collects all links and JS files
102-
│ │ └── linkfind.go # Extracts all links and JS from the response body of the target page
72+
│ │ ├── crawler.go # 爬虫逻辑,模拟浏览器访问,收集所有链接和 JS 文件
73+
│ │ └── linkfind.go # 从目标页面的响应体中提取所有链接和 JS
10374
│ │
10475
│ ├── parser/
105-
│ │ └── parser.go # Performs secondary requests on all collected links and JS files
76+
│ │ └── parser.go # 对所有收集的链接和 JS 文件执行二次请求
10677
│ │
10778
│ ├── matcher/
108-
│ │ └── matcher.go # Reads and parses custom rules from config.yaml and matches against response bodies
79+
│ │ └── matcher.go # config.yaml 中读取并解析自定义规则,并与响应体匹配
10980
│ │
11081
│ └── output/
111-
│ └── output.go # Outputs results to files in CSV, JSON, or text formats
82+
│ └── output.go # 将结果输出为 CSVJSON 或文本格式的文件
11283
11384
├── config/
114-
│ ├── config.go # Handles loading and parsing of the configuration file (config.yaml)
115-
│ └── config.yaml # Custom rules and other project-level configurations
85+
│ ├── config.go # 处理配置文件(config.yaml)的加载和解析
86+
│ └── config.yaml # 自定义规则和其他项目级配置
11687
117-
├── go.mod # Go Modules management file
118-
├── go.sum # Go Modules checksum file
119-
└── main.go # Main program entry point, initializes and starts the application
88+
├── go.mod # Go Modules 管理文件
89+
├── go.sum # Go Modules 校验文件
90+
└── main.go # 主程序入口点,初始化并启动应用程序
12091
```

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var rootCmd = &cobra.Command{
9595
// 6) 输出
9696
if outputFile == "" {
9797
// 未指定 -o,直接打印到控制台(这里包含“无信息”的提示)
98-
output.PrintResultsToConsole(matchResults)
98+
//output.PrintResultsToConsole(matchResults)
9999
} else {
100100
// 指定文件,就写文件(只写有敏感信息的条目)
101101
err := output.WriteResultsToFile(matchResults, outputFile)

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func LoadConfig(path string) (*Config, error) {
3939
defaultContent := `
4040
rules:
4141
- name: Sensitive Field
42-
f_regex: (?i)\[?["']?[0-9A-Za-z_-]{0,15}(?:key|secret|token|config|auth|access|admin|ticket)[0-9A-Za-z_-]{0,15}["']?\]?\s*(?:=|:|\)\.val\()\s*\[?\{?["']([^"']{8,256})["']?(?::|,)?
42+
f_regex: (?i)(\[?["']?[\w-]{0,10}(?:key|secret|token|config|auth|access|admin|ticket)[\w-]{0,10}["']?\]?)\s*(?:=|:|\)\.val\()\s*\[?\{?(?:'([^']{8,100})'|"([^"]{8,100})")(?:[:;,\}\]]?)?
4343
4444
- name: Password Field
4545
f_regex: ((|\\)(|'|")(|[\w]{1,10})([p](ass|wd|asswd|assword))(|[\w]{1,10})(|\\)(|'|")(:|=|\)\.val\()(|)(|\\)('|")([^'"]+?)(|\\)('|")(|,|\)))

config/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
rules:
22
- name: Sensitive Field
3-
f_regex: (?i)\[?["']?[0-9A-Za-z_-]{0,15}(?:key|secret|token|config|auth|access|admin|ticket)[0-9A-Za-z_-]{0,15}["']?\]?\s*(?:=|:|\)\.val\()\s*\[?\{?["']([^"']{8,256})["']?(?::|,)?
3+
f_regex: (?i)(\[?["']?[\w-]{0,10}(?:key|secret|token|config|auth|access|admin|ticket)[\w-]{0,10}["']?\]?)\s*(?:=|:|\)\.val\()\s*\[?\{?(?:'([^']{8,100})'|"([^"]{8,100})")(?:[:;,\}\]]?)?
44

55
- name: Password Field
66
f_regex: ((|\\)(|'|")(|[\w]{1,10})([p](ass|wd|asswd|assword))(|[\w]{1,10})(|\\)(|'|")(:|=|\)\.val\()(|)(|\\)('|")([^'"]+?)(|\\)('|")(|,|\)))

0 commit comments

Comments
 (0)