Skip to content

Commit 12b8b43

Browse files
authored
Merge pull request #22 from KnightBlood/master
针对#16优化
2 parents b9989b7 + 107fb96 commit 12b8b43

10 files changed

Lines changed: 431 additions & 53 deletions

File tree

README.md

Lines changed: 177 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,184 @@
11
# lmap
22

3-
lmap (LinuxHub's Nmap) is the nmap next generation pro plus max, made by 浪神 (from THE GREAT [LinuxHub](https://github.com/LinuxHub-Group)).
3+
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
44

5-
# LICENSE
5+
<h3 align="center">LinuxHub's Nmap - 下一代网络扫描工具</h3>
66

7-
Copyright (C) <2021> <LinuxHub-Group>
7+
<p align="center">
8+
比 nmap 更强大、更灵活的网络探测与扫描能力
9+
<br/>
10+
<a href="#使用方法"><strong>探索 lmap 的功能 »</strong></a>
11+
<br/>
12+
<br/>
13+
<a href="https://github.com/LinuxHub-Group/lmap/issues">报告 Bug</a>
14+
·
15+
<a href="https://github.com/LinuxHub-Group/lmap/issues">请求新功能</a>
16+
·
17+
<a href="#贡献">贡献</a>
18+
</p>
819

9-
This program is free software: you can redistribute it and/or modify
10-
it under the terms of the GNU General Public License as published by
11-
the Free Software Foundation, either version 3 of the License, or
12-
(at your option) any later version.
20+
## 目录
1321

14-
This program is distributed in the hope that it will be useful,
15-
but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17-
GNU General Public License for more details.
22+
- [关于项目](#关于项目)
23+
- [功能特性](#功能特性)
24+
- [快速开始](#快速开始)
25+
- [安装](#安装)
26+
- [使用方法](#使用方法)
27+
- [构建选项](#构建选项)
28+
- [贡献](#贡献)
29+
- [许可证](#许可证)
1830

19-
You should have received a copy of the GNU General Public License
20-
along with this program. If not, see <https://www.gnu.org/licenses/>.
31+
## 关于项目
32+
33+
lmap (LinuxHub's Nmap) 是 LinuxHub 团队开发的下一代网络扫描工具,被称为 nmap 的 Pro Plus Max 版本。它是一个现代化的网络扫描工具,旨在提供比传统 nmap 更强大、更灵活的网络探测与扫描能力。
34+
35+
该工具专为网络安全工程师、系统管理员和渗透测试人员设计,帮助他们快速识别网络中的活动主机、开放端口和服务。
36+
37+
### 为什么选择 lmap?
38+
39+
- **快速扫描** - 利用 Go 语言的并发特性,实现高速网络扫描
40+
- **跨平台支持** - 支持 Windows、Linux、macOS 等多种操作系统
41+
- **易于使用** - 简洁的命令行界面,直观的参数设置
42+
- **高度可定制** - 支持灵活的排除规则和扫描配置
43+
- **开源免费** - 基于 GPL-3.0 许可证,完全开源
44+
45+
## 功能特性
46+
47+
- [x] 🚀 **网络扫描** - 快速扫描指定网络段中的活动主机
48+
- [x]**IP检查** - 验证IP地址有效性并检查主机是否在线
49+
- [x] 🔍 **子网解析** - 解析CIDR格式的子网并生成IP地址列表
50+
- [x] 📡 **ICMP监听** - 监听网络中的ICMP数据包
51+
- [x] 🏓 **Ping探测** - 使用ICMP协议探测主机是否在线
52+
- [x]**并发处理** - 支持高并发扫描,提高扫描效率
53+
- [x] 🚫 **排除规则** - 支持排除特定IP或子网,避免扫描不必要目标
54+
- [x] 📋 **详细输出** - 提供详细的扫描过程信息
55+
56+
## 快速开始
57+
58+
### 安装
59+
60+
#### 预编译二进制文件
61+
62+
[Releases](https://github.com/LinuxHub-Group/lmap/releases) 页面下载适用于您系统的预编译二进制文件。
63+
64+
#### 从源码构建
65+
66+
**要求**:
67+
- Go 1.16 或更高版本
68+
69+
```bash
70+
# 克隆项目
71+
git clone https://github.com/LinuxHub-Group/lmap.git
72+
cd lmap
73+
74+
# 构建
75+
make
76+
77+
# 或者直接使用Go构建
78+
go build ./cmd/lmap
79+
```
80+
81+
构建完成后,您将在项目根目录下获得 [lmap](file:///D:/works/lmap/lmap/lmap.exe) 可执行文件。
82+
83+
### 使用方法
84+
85+
#### 基本扫描
86+
87+
```bash
88+
# 扫描单个子网
89+
./lmap -subnet 192.168.1.0/24
90+
91+
# 扫描多个子网
92+
./lmap -subnet 192.168.1.0/24 -subnet 10.0.0.0/16
93+
94+
# 详细输出模式
95+
./lmap -subnet 192.168.1.0/24 -v
96+
```
97+
98+
#### 排除特定IP或子网
99+
100+
```bash
101+
# 排除单个IP
102+
./lmap -subnet 192.168.1.0/24 -exclude 192.168.1.1
103+
104+
# 排除多个IP或子网
105+
./lmap -subnet 192.168.1.0/24 -exclude 192.168.1.1 -exclude 192.168.1.10/32
106+
```
107+
108+
#### 命令行选项
109+
110+
| 选项 | 描述 | 示例 |
111+
|------|------|------|
112+
| `-subnet` | 要扫描的网络段,CIDR格式 (可多次指定) | `-subnet 192.168.1.0/24` |
113+
| `-exclude` | 要排除的IP或子网 (可多次指定) | `-exclude 192.168.1.1` |
114+
| `-v` | 详细输出模式 | `-v` |
115+
116+
## 构建选项
117+
118+
```bash
119+
# 默认构建当前平台版本
120+
make
121+
122+
# 构建所有平台版本
123+
make all
124+
125+
# 格式化代码
126+
make fmt
127+
128+
# 运行测试
129+
make test
130+
131+
# 清理构建产物
132+
make clean
133+
```
134+
135+
## 贡献
136+
137+
欢迎任何形式的贡献!如果您想为 lmap 做出贡献,请遵循以下步骤:
138+
139+
1. Fork 项目
140+
2. 创建您的特性分支 (`git checkout -b feature/AmazingFeature`)
141+
3. 提交您的更改 (`git commit -m 'Add some AmazingFeature'`)
142+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
143+
5. 开启一个 Pull Request
144+
145+
### 开发环境设置
146+
147+
```bash
148+
# 1. 克隆项目
149+
git clone https://github.com/LinuxHub-Group/lmap.git
150+
151+
# 2. 进入项目目录
152+
cd lmap
153+
154+
# 3. 安装依赖
155+
make install
156+
157+
# 4. 运行测试
158+
make test
159+
```
160+
161+
## 社区和支持
162+
163+
- [报告 Bug](https://github.com/LinuxHub-Group/lmap/issues)
164+
- [请求新功能](https://github.com/LinuxHub-Group/lmap/issues)
165+
- [查看已知问题](https://github.com/LinuxHub-Group/lmap/issues)
166+
167+
## 许可证
168+
169+
```
170+
Copyright (C) <2021> <LinuxHub-Group>
171+
172+
This program is free software: you can redistribute it and/or modify
173+
it under the terms of the GNU General Public License as published by
174+
the Free Software Foundation, either version 3 of the License, or
175+
(at your option) any later version.
176+
177+
This program is distributed in the hope that it will be useful,
178+
but WITHOUT ANY WARRANTY; without even the implied warranty of
179+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
180+
GNU General Public License for more details.
181+
182+
You should have received a copy of the GNU General Public License
183+
along with this program. If not, see <https://www.gnu.org/licenses/>.
184+
```

cmd/lmap/main.go

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,51 @@ import (
2828

2929
func main() {
3030
isVerbose := false
31-
flag.BoolVar(&isVerbose, "v", false, "be verbose")
31+
flag.BoolVar(&isVerbose, "v", false, "详细输出")
32+
33+
subnets := multiArg{}
34+
flag.Var(&subnets, "subnet", "要扫描的网络段,CIDR格式 (可多次指定)")
35+
36+
excludes := multiArg{}
37+
flag.Var(&excludes, "exclude", "要排除的IP或子网 (可多次指定)")
38+
3239
flag.Parse()
33-
args := flag.Args()
34-
if len(args) < 1 {
35-
_, _ = fmt.Fprintf(os.Stderr, "使用方法:%s [-v] <网络号>/<CIDR>\n", os.Args[0])
36-
os.Exit(-1)
40+
41+
if len(subnets) < 1 {
42+
printUsage()
43+
os.Exit(1)
44+
}
45+
46+
lmap.CheckIP(subnets, excludes, isVerbose)
47+
}
48+
49+
// printUsage prints the usage information for the program
50+
func printUsage() {
51+
progName := os.Args[0]
52+
if progName == "" {
53+
progName = "lmap"
3754
}
38-
lmap.CheckIP(args[0], isVerbose)
55+
56+
fmt.Fprintf(os.Stderr, "使用方法: %s [选项] -subnet <网络号>/<CIDR> [-subnet ...]\n", progName)
57+
fmt.Fprintln(os.Stderr, "")
58+
fmt.Fprintln(os.Stderr, "选项:")
59+
flag.PrintDefaults()
60+
fmt.Fprintln(os.Stderr, "")
61+
fmt.Fprintln(os.Stderr, "示例:")
62+
fmt.Fprintf(os.Stderr, " %s -subnet 192.168.1.0/24\n", progName)
63+
fmt.Fprintf(os.Stderr, " %s -subnet 192.168.1.0/24 -subnet 10.0.0.0/16\n", progName)
64+
fmt.Fprintf(os.Stderr, " %s -subnet 192.168.1.0/24 -exclude 192.168.1.1\n", progName)
65+
fmt.Fprintf(os.Stderr, " %s -subnet 192.168.1.0/24 -exclude 192.168.1.10/32 -v\n", progName)
66+
}
67+
68+
// multiArg implements the flag.Value interface for collecting multiple string values
69+
type multiArg []string
70+
71+
func (m *multiArg) String() string {
72+
return fmt.Sprintf("%v", *m)
73+
}
74+
75+
func (m *multiArg) Set(value string) error {
76+
*m = append(*m, value)
77+
return nil
3978
}

go.mod

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
module github.com/LinuxHub-Group/lmap
22

3-
go 1.16
3+
go 1.23.0
44

55
require (
6-
github.com/ysmood/got v0.30.0
7-
golang.org/x/net v0.0.0-20220607020251-c690dde0001d
6+
github.com/ysmood/got v0.41.0
7+
golang.org/x/net v0.43.0
8+
)
9+
10+
require (
11+
github.com/google/go-cmp v0.6.0 // indirect
12+
github.com/ysmood/gop v0.2.0 // indirect
13+
github.com/yuin/goldmark v1.4.13 // indirect
14+
golang.org/x/crypto v0.41.0 // indirect
15+
golang.org/x/mod v0.26.0 // indirect
16+
golang.org/x/sync v0.16.0 // indirect
17+
golang.org/x/sys v0.35.0 // indirect
18+
golang.org/x/telemetry v0.0.0-20250710130107-8d8967aff50b // indirect
19+
golang.org/x/term v0.34.0 // indirect
20+
golang.org/x/text v0.28.0 // indirect
21+
golang.org/x/tools v0.35.0 // indirect
22+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 // indirect
823
)

go.sum

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
2+
github.com/ysmood/gop v0.2.0 h1:+tFrG0TWPxT6p9ZaZs+VY+opCvHU8/3Fk6BaNv6kqKg=
3+
github.com/ysmood/gop v0.2.0/go.mod h1:rr5z2z27oGEbyB787hpEcx4ab8cCiPnKxn0SUHt6xzk=
14
github.com/ysmood/got v0.30.0 h1:n6KVknQ2gjU2FsEVvMrpEw20uoqkhRDvAoNK69bOV/U=
25
github.com/ysmood/got v0.30.0/go.mod h1:pE1l4LOwOBhQg6A/8IAatkGp7uZjnalzrZolnlhhMgY=
6+
github.com/ysmood/got v0.41.0 h1:XiFH311ltTSGyxjeKcNvy7dzbJjjTzn6DBgK313JHBs=
7+
github.com/ysmood/got v0.41.0/go.mod h1:W7DdpuX6skL3NszLmAsC5hT7JAhuLZhByVzHTq874Qg=
8+
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
9+
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
10+
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
311
golang.org/x/net v0.0.0-20220607020251-c690dde0001d h1:4SFsTMi4UahlKoloni7L4eYzhFRifURQLw+yv0QDCx8=
412
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
13+
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
14+
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
15+
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
516
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
617
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
718
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
19+
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
20+
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
21+
golang.org/x/telemetry v0.0.0-20250710130107-8d8967aff50b/go.mod h1:4ZwOYna0/zsOKwuR5X/m0QFOJpSZvAxFfkQT+Erd9D4=
822
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
23+
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
924
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
25+
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
1026
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
27+
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
28+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

0 commit comments

Comments
 (0)