Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

LinuxAssetProbe

A lightweight Linux asset discovery probe for enterprise security operations.

面向企业安全运营的轻量级 Linux 服务器资产发现探针


项目简介 / Introduction

LinuxAssetProbe 是一个轻量级、零依赖的 Linux 服务器资产采集工具。
通过单个 Shell 脚本在服务器本地执行资产探测,自动采集系统基础信息、中间件、Java 组件、网络暴露面及运行状态,并生成适用于管理、运维和安全分析的多种格式报告。

LinuxAssetProbe is a lightweight, zero-dependency Linux asset discovery probe.
It runs locally using a single shell script and automatically collects system information, middleware versions, Java components, network exposure details and runtime status, generating multiple report formats for management, operations and security analysis.

设计目标 / Design Goals

  • 简单部署 / Easy deployment
  • 无需安装 Agent / No agent required
  • 无需数据库 / No database required
  • 无需额外服务 / No additional services required
  • 适用于企业级 Linux 服务器资产管理 / Suitable for enterprise Linux asset management

功能特点 / Features

1. 服务器资产采集 / System Asset Collection

信息项 (Item) 说明 (Description)
主机名 (Hostname) 服务器主机名
IP 地址 (IP Address) IPv4 地址
操作系统 (OS) Linux 发行版
内核版本 (Kernel) 内核版本
CPU 信息 (CPU) CPU 型号及核心数
内存信息 (Memory) 内存总量
扫描时间 (Scan Time) 扫描时间戳

The following items are automatically collected and included in the reports.


2. 中间件识别 / Middleware Discovery

自动识别并提取常见服务组件的版本信息。
Automatically discovers common service components and extracts their versions.

支持列表 / Supported Services
Nginx, Redis, MySQL, MariaDB, PHP, Python, Node.js, Docker

输出示例 / Output Example

Nginx
nginx version: nginx/1.28.0

Redis
Redis server v=8.0.6

Docker
Docker version 28.x

3. Java 组件识别 / Java Component Discovery

采用通用路径发现策略,通过进程、systemd、环境变量等多维度自动定位 JAR 文件,不依赖固定路径假设。
Uses a universal path discovery strategy that automatically locates JAR files through multiple dimensions (processes, systemd, environment variables), without relying on hardcoded path assumptions.

五层路径发现 / Five-Layer Path Discovery

层级 (Layer) 方法 (Method) 说明 (Description)
1 默认部署目录 (Default directories) 覆盖 50+ 常见部署根目录:/opt, /app, /data, /data1, /data2, /home, /srv, /usr/local, /usr/share, /var/lib, /workspace, /deploy, /middleware, /webapps, /u01, /u02 等 / Covers 50+ common deployment root directories
2 /proc 进程子系统 (Process /proc subsystem) 直接读取 /proc/[pid]/cmdlinecwdexefd/*maps,发现 Java 进程加载的所有 JAR(包括 symlink 和 mmap 加载的)/ Reads /proc/[pid]/ subsystems (cmdline, cwd, exe, fd/*, maps) to discover all JARs loaded by Java processes, including symlink and mmap loaded
3 systemd 单元文件 (systemd unit files) 解析 /etc/systemd/system 等目录中的 WorkingDirectoryExecStartEnvironment 配置,提取 JAR 路径和环境变量 / Parses WorkingDirectory, ExecStart, Environment from systemd unit files
4 进程环境变量 (Process environ) 读取 /proc/[pid]/environ,提取 JAVA_HOMECATALINA_HOMEJETTY_HOMEWILDFLY_HOME 等 11 个环境变量 / Reads /proc/[pid]/environ to extract 11 *HOME environment variables
5 目录名模式匹配 (Directory name patterns) 在根目录下按名字发现 tomcatjettywildflyjbosskafkaelasticsearchjenkins 等 14 种中间件目录 / Discovers 14 middleware directories by name pattern

与 V1.7 的关键区别:V1.7 使用 ps -ef 只能看命令行参数;V1.8 直接读 /procfd(文件描述符)和 maps(内存映射),能发现通过脚本间接加载、symlink 加载、systemd 管理的各种 JAR。

Key difference from V1.7: V1.7 uses ps -ef which only sees command-line arguments; V1.8 reads /proc fd (file descriptors) and maps (memory mappings), discovering JARs loaded via scripts, symlinks, or systemd management.

JDK/JRE 内部 JAR 排除 / JDK Internal JAR Exclusion
默认排除 JDK/JRE 自带的 JAR(如 rt.jartools.jar),减少噪音。可通过 LAP_INCLUDE_JDK=1 恢复扫描。
Excludes JDK/JRE internal JARs (e.g., rt.jar, tools.jar) by default to reduce noise. Use LAP_INCLUDE_JDK=1 to include them.

五层版本检测 / Five-Layer Version Detection

层级 (Layer) 方法 (Method) 可信度 (Confidence) 说明 (Description)
1 Maven pom.properties high 最准确,直接读取 Jar 内部 Maven 元数据 / Most accurate, reads Maven metadata inside JAR
2 MANIFEST.MF Implementation-Version / Specification-Version medium-high 标准 Java 版本声明,新增 Specification-Version fallback / Standard Java version declaration, added Specification-Version fallback
3 MANIFEST.MF Bundle-Version / Bundle-SymbolicName medium OSGi 组件,新增 Bundle-SymbolicName fallback / OSGi components, added Bundle-SymbolicName fallback
4 文件名解析 (Filename) low 增强正则,支持四段版本号和 RELEASE/beta 后缀 / Enhanced regex, supports 4-segment versions and RELEASE/beta suffixes
5 无版本兜底 (Unknown fallback) none JAR 已发现但无法提取版本,仍然记录 / JAR found but version undetectable, still recorded

Fat JAR 零提取扫描 / Fat JAR Zero-Extraction Scanning
通过 unzip -Z -1 仅列出内嵌 JAR 文件名(不落盘解压),从文件名提取版本信息。路径格式为 app.jar!/BOOT-INF/lib/spring-core-6.1.8.jar
Uses unzip -Z -1 to list nested JAR filenames without extracting to disk, extracting version from filenames. Path format: app.jar!/BOOT-INF/lib/spring-core-6.1.8.jar.

每个组件记录版本来源(source)和可信度(confidence),安全人员可区分版本是推断的还是 Jar 声明的。
Each component records its version source (source) and confidence (confidence), allowing security teams to distinguish inferred vs. declared versions.

SHA256 哈希 / SHA256 Hash
为每个 Jar 文件计算 SHA256 哈希,用于检测篡改和供应链异常。
Computes SHA256 hash for each JAR file to detect tampering and supply chain anomalies.

扫描排除与优化 / Scan Exclusion & Optimization

  • -prune 排除 /proc/sys/dev/run/boot/tmp/.git/node_modules/docker/overlay2 等系统目录
  • LAP_JAR_MAXDEPTH 控制 find 最大深度(默认 12)
  • LAP_FULL_SCAN=1 启用全盘增强模式(使用 -xdev 避免跨 NFS 文件系统)

Excludes system directories via -prune; LAP_JAR_MAXDEPTH controls find depth (default 12); LAP_FULL_SCAN=1 enables full-disk mode with -xdev to avoid NFS traversal.

示例 / Example

fastjson       1.2.83    (pom.properties, high)
log4j-core     2.22.1    (manifest, medium-high)
spring-core    5.3.21.RELEASE  (filename, low)
bm             unknown   (filename, none)
spring-core    6.1.8     (nested-filename, low, from fat-jar)

用途 / Use Cases

  • 软件供应链管理 / Software supply chain management
  • 组件版本统计 / Component version inventory
  • 安全风险排查 / Security vulnerability assessment
  • SBOM 数据采集基础 / Foundation for SBOM data collection

4. 网络暴露面分析 / Network Exposure Discovery

采集 TCP 监听端口、关联进程及网络状态。
Collects TCP listening ports, associated processes and network listening status.

输出文件 / Output Files

  • port.txt
  • process.txt

帮助快速了解哪些服务对外监听。
Helps administrators quickly identify externally listening services.


输出结果 / Output

执行完成后,会在当前目录生成以 IP 和日期命名的报告目录:
After execution, a report directory named with the IP address and date is created:

192.168.1.35_linux_asset_report_20260729/
├── report.html          # 可视化报告 / Visual report
├── asset_report.txt     # 文本报告 / Text report
├── asset.json           # 机器可读数据 / Machine-readable data
├── middleware.json       # 中间件信息 / Middleware information
├── component.json       # Java 组件信息 / Java component information
├── port.txt             # 监听端口 / Listening ports
└── process.txt          # 进程列表 / Process list

report.html – 适用于管理查看、安全检查和审计场景的 HTML 可视化报告。
Suitable for management review, security inspection and audit scenarios.

asset_report.txt – 适用于运维人员快速排查的文本格式报告。
Suitable for system administrators to quickly inspect details.

asset.json – 可供 CMDB、自动化平台和数据分析使用的结构化数据。
Structured data for CMDB systems, automation platforms and data analysis.

middleware.json 示例 / Example

[
    {
        "name": "Nginx",
        "version": "nginx version: nginx/1.28.0"
    }
]

component.json 示例 / Example

[
    {
        "name": "fastjson",
        "version": "1.2.83",
        "source": "pom.properties",
        "confidence": "high",
        "path": "/opt/app/demo.jar",
        "sha256": "a1b2c3d4e5f6...",
        "group_id": "com.alibaba"
    },
    {
        "name": "bm",
        "version": "unknown",
        "source": "filename",
        "confidence": "none",
        "path": "/data/server/bm/bm.jar",
        "sha256": "f7e8d9c0b1a2...",
        "group_id": ""
    },
    {
        "name": "spring-core",
        "version": "6.1.8",
        "source": "nested-filename",
        "confidence": "low",
        "path": "/data/server/bm/bm.jar!/BOOT-INF/lib/spring-core-6.1.8.jar",
        "sha256": "",
        "group_id": ""
    }
]

使用方法 / Usage

环境要求 / Requirements

  • Linux 操作系统 / Linux operating system
  • Bash Shell
  • 推荐以 root 权限执行(读取 /proc 进程信息需要)/ Running as root is recommended (required for /proc access)
  • unzip(可选,用于 Jar 内部元数据解析)/ unzip (optional, for JAR metadata parsing)
  • sha256sum(可选,用于 Jar 哈希采集)/ sha256sum (optional, for JAR hash collection)

环境变量 / Environment Variables

变量 (Variable) 默认值 (Default) 说明 (Description)
LAP_SCAN_PATH - 自定义扫描根路径(空格分隔),覆盖自动发现 / Custom scan root paths (space-separated), overrides auto-discovery
LAP_FULL_SCAN 0 设为 1 启用全盘增强模式(更全但更慢,使用 -xdev 避免跨 NFS)/ Set to 1 to enable full-disk mode (more thorough but slower, uses -xdev)
LAP_INCLUDE_JDK 0 设为 1 包含 JDK/JRE 自带 jar(默认排除以减少噪音)/ Set to 1 to include JDK/JRE internal JARs (excluded by default)
LAP_JAR_MAXDEPTH 12 find 命令最大搜索深度 / Maximum find search depth

自定义扫描路径 / Custom Scan Path

默认采用五层路径发现策略自动定位 JAR 文件。如需指定自定义路径,可通过环境变量覆盖:
By default, a five-layer path discovery strategy is used. To specify custom paths, use the environment variable:

# 自定义扫描路径
LAP_SCAN_PATH="/custom/path1 /custom/path2" ./linux_asset_probe_1.8.sh

# 全盘增强模式(更全更慢)
LAP_FULL_SCAN=1 ./linux_asset_probe_1.8.sh

# 包含 JDK 内部 jar
LAP_INCLUDE_JDK=1 ./linux_asset_probe_1.8.sh

# 控制搜索深度
LAP_JAR_MAXDEPTH=8 ./linux_asset_probe_1.8.sh

# 组合使用
sudo LAP_SCAN_PATH="/data/server/bm" LAP_FULL_SCAN=1 ./linux_asset_probe_1.8.sh

下载 / Download

git clone https://github.com/Liuzhiyong/LinuxAssetProbe.git

执行 / Run

chmod +x linux_asset_probe_1.8.sh
sudo ./linux_asset_probe_1.8.sh

执行成功后将显示报告目录路径。
After a successful run, the report directory path will be shown.


兼容性 / Compatibility

已测试环境 / Tested environments:

操作系统 状态
Ubuntu Linux ✅ 通过 / Passed
Debian Linux ✅ 通过 / Passed
CentOS Linux ✅ 通过 / Passed
openEuler ✅ 通过 / Passed
银河麒麟高级服务器操作系统 / Kylin Linux Advanced Server ✅ 通过 / Passed

安全说明 / Security Considerations

LinuxAssetProbe:

  • 本地运行,不上传数据 / Runs locally, does not upload data
  • 不修改系统配置 / Does not modify system configuration
  • 不安装后台服务 / Does not install persistent services

生成报告可能包含 IP 地址、软件版本、应用路径等敏感信息,请妥善保护。
Generated reports may contain sensitive information (IP addresses, software versions, application paths), please protect them properly.


使用场景 / Use Cases

  • 企业服务器资产盘点 / Enterprise server inventory
  • 网络安全检查 / Security assessment preparation
  • 攻防演练前资产梳理 / Asset inventory before cybersecurity exercises
  • 软件供应链识别 / Software supply chain visibility
  • 国产 Linux 环境资产采集 / Asset discovery on domestic Linux distributions
  • 安全运营基础数据采集 / Baseline data collection for security operations

路线图 / Roadmap

v1.7 - Java Component Intelligence Enhancement ✅

Java组件智能识别增强(已完成)

已实现:

  • Jar 内部元数据解析
  • 支持读取 MANIFEST.MF
  • 支持读取 Maven pom.properties
  • 提升无版本 Jar 文件识别能力
  • 增加组件版本来源标识(pom.properties / manifest / filename
  • 增加 Jar 文件 SHA256 哈希采集

Implemented:

  • Parse metadata inside Java archive files
  • Support MANIFEST.MF analysis
  • Support Maven pom.properties extraction
  • Improve version detection for versionless JAR files
  • Add component version source identification (pom.properties / manifest / filename)
  • Collect JAR SHA256 hashes

目标:

增强 Java 组件发现能力,为软件供应链管理和 SBOM 数据采集提供基础。

Goal:

Improve Java component discovery capabilities and provide a foundation for software supply chain management and SBOM data collection.


v1.7.2 - Fat JAR Support & Unknown Version Fallback ✅

Spring Boot Fat JAR 支持与兜底记录(已完成)

已实现:

  • Spring Boot Fat JAR 内嵌组件扫描(自动检测 BOOT-INF/lib/*.jar,逐个解压提取版本)
  • 无版本信息兜底:JAR 已发现但无法提取版本时仍然记录(confidence: unknown)
  • 五层版本检测体系(新增第五层 unknown 兜底)

Implemented:

  • Spring Boot Fat JAR nested component scanning (auto-detect BOOT-INF/lib/*.jar, extract and analyze each)
  • Unknown version fallback: JARs with undetectable versions are still recorded (confidence: unknown)
  • Five-layer version detection system (added fifth layer: unknown fallback)

目标:

解决 Spring Boot Fat JAR 组件无法识别、无版本 JAR 被静默丢弃的问题。

Goal:

Resolve issues with Spring Boot Fat JAR components being undetectable and versionless JARs being silently dropped.


v1.7.1 - Smart JAR Path Discovery ✅

Java 组件智能路径发现(已完成)

已实现:

  • 三层路径发现策略(默认目录 + Java 进程路径 + 标记文件发现)
  • 扩展默认扫描目录(新增 /home, /var/lib, /srv, /usr/share, /www, /workspace, /deploy
  • 从 Java 进程命令行提取 jar 路径和 classpath 目录
  • 通过 WEB-INFpom.xmlapplication.ymlapplication.properties 标记文件反推应用目录
  • 支持环境变量 LAP_SCAN_PATH 自定义扫描路径
  • 增加版本可信度字段(confidence: high / medium-high / medium / low)

Implemented:

  • Three-layer path discovery strategy (default directories + Java process paths + marker file discovery)
  • Expanded default scan directories
  • Extract JAR paths and classpath directories from Java process command lines
  • Discover application directories via WEB-INF, pom.xml, application.yml, application.properties marker files
  • Support custom scan paths via LAP_SCAN_PATH environment variable
  • Add version confidence field (confidence: high / medium-high / medium / low)

目标:

解决 JAR 包在自定义路径下无法被发现的问题,提升组件发现覆盖率。

Goal:

Resolve the issue of JAR files in custom paths being missed, improving component discovery coverage.


v1.8.0 - Universal JAR Path Discovery ✅

通用路径发现与 Fat JAR 零提取(已完成)

已实现:

  • 五层路径发现策略(默认目录 + /proc 子系统 + systemd 单元 + 进程环境变量 + 目录名模式)
  • 直接读取 /proc/[pid]/cmdlinecwdexefd/*maps,发现 symlink 和 mmap 加载的 JAR
  • systemd 单元文件解析(WorkingDirectoryExecStartEnvironment
  • 进程环境变量读取(JAVA_HOMECATALINA_HOME 等 11 个变量)
  • JDK/JRE 内部 jar 自动排除(LAP_INCLUDE_JDK=1 可开启)
  • Fat JAR 零磁盘提取(unzip -Z -1 仅列文件名,不再解压到磁盘)
  • MANIFEST 新增 Specification-Version / Bundle-SymbolicName fallback
  • 文件名正则增强:支持四段版本号和 RELEASE/beta 后缀
  • LAP_FULL_SCAN 全盘模式(-xdev 避免 NFS)
  • LAP_JAR_MAXDEPTH 环境变量控制搜索深度
  • -prune 排除系统目录(/proc/sys/dev/docker/overlay2 等)

Implemented:

  • Five-layer path discovery strategy (default directories + /proc subsystem + systemd units + process environ + directory name patterns)
  • Direct /proc/[pid]/ reads (cmdline, cwd, exe, fd/*, maps) to discover symlink and mmap loaded JARs
  • systemd unit file parsing (WorkingDirectory, ExecStart, Environment)
  • Process environment variable reading (JAVA_HOME, CATALINA_HOME, etc.)
  • JDK/JRE internal JAR auto-exclusion (LAP_INCLUDE_JDK=1 to enable)
  • Fat JAR zero-disk extraction (unzip -Z -1 lists filenames only)
  • MANIFEST Specification-Version / Bundle-SymbolicName fallback
  • Enhanced filename regex: 4-segment versions and RELEASE/beta suffixes
  • LAP_FULL_SCAN full-disk mode (-xdev to avoid NFS)
  • LAP_JAR_MAXDEPTH environment variable for depth control
  • -prune to exclude system directories

目标:

通过多维度路径发现彻底解决"JAR 在自定义路径下扫不到"的问题,提升组件发现覆盖率。

Goal:

Thoroughly resolve the issue of JAR files in custom paths being missed through multi-dimensional path discovery, improving component discovery coverage.


v1.8 - Enterprise Asset Management Enhancement

企业级资产管理增强

计划:

  • 多服务器批量采集
  • SSH 远程执行
  • 汇总资产报告生成
  • 资产统一视图
  • 资产变化检测
  • 历史版本对比

Planned:

  • Multi-server batch collection
  • Remote execution via SSH
  • Aggregated asset reports
  • Unified asset inventory view
  • Asset change detection
  • Historical version comparison

目标:

支持企业环境下的大规模 Linux 服务器资产管理。

Goal:

Support large-scale Linux server asset management in enterprise environments.


v1.9 - Container and Cloud Native Support

容器与云原生环境支持

计划:

  • Docker 资产识别
  • 容器镜像信息采集
  • Kubernetes 节点资产发现
  • Kubernetes 工作负载识别
  • 云原生环境组件采集

Planned:

  • Docker asset discovery
  • Container image information collection
  • Kubernetes node asset discovery
  • Kubernetes workload discovery
  • Cloud-native component inventory

目标:

扩展 LinuxAssetProbe 在云原生环境中的资产发现能力。

Goal:

Extend LinuxAssetProbe asset discovery capabilities into cloud-native environments.


许可证 / License

This project is licensed under the MIT License.
本项目采用 MIT License 开源协议。


作者 / Author

Liuzhiyong
GitHub: https://github.com/Liuzhiyong/LinuxAssetProbe

Version: 1.8.0


免责声明 / Disclaimer

本工具仅用于经过授权的资产管理、安全检查和系统运维场景。使用者应确保符合相关法律法规及组织管理要求。
This tool is intended for authorized asset management, security assessment and system administration only. Users are responsible for ensuring compliance with applicable laws, regulations and organizational policies.

About

A lightweight Linux asset discovery probe for collecting OS, middleware, Java components and runtime information.一个轻量级 Linux 服务器资产发现探针。

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages