{"id":29732418,"url":"https://github.com/philipp2604/s7scanner","last_synced_at":"2025-07-25T08:14:35.317Z","repository":{"id":303398330,"uuid":"1015236567","full_name":"philipp2604/S7Scanner","owner":"philipp2604","description":".NET library for discovering Siemens S7 devices (PLCs and HMIs) across a network.","archived":false,"fork":false,"pushed_at":"2025-07-16T23:41:01.000Z","size":60,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-22T06:20:30.130Z","etag":null,"topics":["blueteam","ics-security","industrial-automation","ot-security","reconnaissance","redteam","s7comm","siemens-plc","siemens-s7","siemens-s7-plcs","siemens-wincc"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philipp2604.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-07T07:52:00.000Z","updated_at":"2025-07-11T06:11:15.000Z","dependencies_parsed_at":"2025-07-07T12:37:28.277Z","dependency_job_id":"1c7c07da-0f08-4132-8738-fe5a8532d799","html_url":"https://github.com/philipp2604/S7Scanner","commit_stats":null,"previous_names":["philipp2604/s7scanner"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/philipp2604/S7Scanner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipp2604%2FS7Scanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipp2604%2FS7Scanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipp2604%2FS7Scanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipp2604%2FS7Scanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philipp2604","download_url":"https://codeload.github.com/philipp2604/S7Scanner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipp2604%2FS7Scanner/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266978296,"owners_count":24015492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blueteam","ics-security","industrial-automation","ot-security","reconnaissance","redteam","s7comm","siemens-plc","siemens-s7","siemens-s7-plcs","siemens-wincc"],"created_at":"2025-07-25T08:14:31.347Z","updated_at":"2025-07-25T08:14:35.304Z","avatar_url":"https://github.com/philipp2604.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# S7Scanner 📡\nA modern, high-performance .NET library for discovering Siemens S7 devices (PLCs and HMIs) across a network. It provides a simple, asynchronous API to scan IP ranges, identify potential Siemens devices, and classify them, and retrieve detailed hardware information from compatible PLCs. The project also includes a ready-to-use command-line tool.\n\n[![.NET 8 (LTS) Build \u0026 Test](https://github.com/philipp2604/S7Scanner/actions/workflows/dotnet-8-build-and-test.yml/badge.svg)](https://github.com/philipp2604/S7Scanner/actions/workflows/dotnet-8-build-and-test.yml)\n[![.NET 9 (Latest) Build \u0026 Test](https://github.com/philipp2604/S7Scanner/actions/workflows/dotnet-9-build-and-test.yml/badge.svg)](https://github.com/philipp2604/S7Scanner/actions/workflows/dotnet-9-build-and-test.yml)\n[![Language](https://img.shields.io/badge/language-C%23-blue.svg)](https://docs.microsoft.com/en-us/dotnet/csharp/)\n[![NuGet Version](https://img.shields.io/nuget/v/philipp2604.S7Scanner.Lib.svg?style=flat-square\u0026logo=nuget)](https://www.nuget.org/packages/philipp2604.S7Scanner.Lib/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![GitHub issues](https://img.shields.io/github/issues/philipp2604/S7Scanner)](https://github.com/philipp2604/S7Scanner/issues)\n\n## ✨ Key Features\n\n- **⚡️ High-Speed Parallel Scanning**: Utilizes modern `async`/`await` and `Parallel.ForEachAsync` to scan hundreds of IP addresses concurrently, delivering results quickly.\n- **🔬 Detailed Device Identification**: Intelligently distinguishes between Siemens PLCs and HMIs. For PLCs, it actively queries for detailed hardware information.\n    - **Full Details for S7-300/400**: Retrieves module info, serial number, system name, and version from S7-300 PLCs using the S7-COMM protocol.\n    - **Identifies S7-1200/1500**: Detects modern PLCs that normally restrict detailed queries, marking them as \"Potential S7-1200/-1500\".\n- **〰️ Flexible IP Range Parsing**: Easily parse various input formats, including single IP addresses (`192.168.0.1`) and complex ranges (`192.168.0.1-192.168.1.254`).\n- **🖥️ Ready-to-Use CLI**: Includes a powerful and easy-to-use command-line interface for immediate scanning without writing any code.\n- **🏗️ Modern \u0026 Asynchronous API**: A fully `async` and thread-safe library built with modern C# features, including records for immutable data transfer objects.\n- **✅ Well-Tested**: Comes with a comprehensive suite of unit and integration tests to ensure reliability and correctness.\n- **💾 JSON Output**: The CLI can export scan results to a structured JSON file for easy integration with other tools and scripts.\n\n## 🚀 Getting Started\n\n### Installation\n\nS7Scanner.Lib is available on NuGet. You can install it using the .NET CLI:\n\n```bash\ndotnet add package philipp2604.S7Scanner.Lib\n```\nOr via the NuGet Package Manager in Visual Studio.\n\n### Quick Start (Library Usage)\n\nHere's a simple example of how to use the `S7Scanner.Lib` in your own application.\n\n```csharp\nusing S7Scanner.Lib.Helpers;\nusing S7Scanner.Lib.IpScannerService;\nusing System.Net;\n\n// 1. Define the scan parameters\nconst string ipRange = \"192.168.0.1-192.168.0.254\";\nconst int timeoutMs = 500;\nconst int parallelism = 100;\n\nConsole.WriteLine($\"Scanning IP range: {ipRange}...\");\n\ntry\n{\n    // 2. Parse the IP range string into a collection of IP addresses\n    IEnumerable\u003cIPAddress\u003e ipsToScan = IpRangeParser.Parse(ipRange);\n\n    // 3. Run the discovery process asynchronously\n    var discoveredDevices = await IpScannerService.DiscoverDevicesAsync(\n        ipsToScan,\n        timeoutMs,\n        parallelism,\n        CancellationToken.None\n    );\n\n    // 4. Process the results\n    if (!discoveredDevices.Any())\n    {\n        Console.WriteLine(\"No devices found.\");\n    }\n    else\n    {\n        Console.WriteLine($\"Found {discoveredDevices.Count()} device(s):\");\n        foreach (var device in discoveredDevices)\n        {\n            Console.WriteLine($\"  - IP: {device.IpAddress,-15} | Type: {device.Type}\");\n            // Display PLC details if they were retrieved\n            if (device.Details != null)\n            {\n                Console.WriteLine($\"    - Module: {device.Details.Module}\");\n                Console.WriteLine($\"    - Serial Number: {device.Details.SerialNumber}\");\n            }\n        }\n    }\n}\ncatch (Exception ex)\n{\n    Console.WriteLine($\"An error occurred: {ex.Message}\");\n}\n```\n\n## 🖥️ Command-Line Interface (CLI)\n\nThe project includes a pre-built command-line tool for immediate use.\n\n### Usage\n\n```bash\nS7Scanner.CLI.exe --ip-range \u003cRANGE\u003e [--output-file \u003cPATH\u003e] [--timeout \u003cMS\u003e] [--parallelism \u003cCOUNT\u003e]\n```\n\n### Options\n\n| Option                 | Description                                                  | Required | Default |\n| ---------------------- | ------------------------------------------------------------ | :------: | :-----: |\n| `--ip-range`           | The IP range to scan (e.g., '192.168.1.1-192.168.1.254').     |   Yes    |   N/A   |\n| `--output-file`        | Optional. Path to save the results as a JSON file.           |    No    |   N/A   |\n| `--timeout`            | Connection timeout in milliseconds for each IP.              |    No    |   500   |\n| `--parallelism`        | Number of IPs to scan concurrently.                          |    No    |   100   |\n\n### Example\n\n```bash\n# Scan a C-class network and print results to the console\n./S7Scanner.CLI.exe --ip-range \"192.168.0.1-192.168.0.254\"\n\n# Scan with higher timeout and save results to a file\n./S7Scanner.CLI.exe --ip-range \"10.0.0.1-10.0.255.254\" --timeout 1000 --parallelism 200 --output-file \"scan_results.json\"\n```\n\n### Example Output\n\n```bash\n# Scan a C-class network and print results to the console\n./S7Scanner.CLI.exe --ip-range \"192.168.0.1-192.168.0.254\"\n\n# Example Console Output:\n# Starting Siemens Device Scanner...\n# ...\n# Found 3 device(s):\n#   - 192.168.0.2     | Type: PLC\n#     Module:               6ES7 315-2EH14-0AB0\n#     Serial Number:        S C-U9B12345678\n#     ...\n#   - 192.168.0.3     | Type: HMI\n#   - 192.168.0.5     | Type: PLC\n#     Module:               Potential S7-1200/-1500\n#     Serial Number:        Potential S7-1200/-1500\n#     ...\n```\n\n## 📖 Documentation\n- **[S7ScannerService](./S7Scanner.Lib/S7ScannerService/S7ScannerService.cs)**: The `S7ScannerService` is the primary entry point for all scanning operations.\n- **[CLI Example](./S7Scanner.CLI/Program.cs)**: A runnable console application demonstrating library usage in detail.\n- **[Integration Tests](./S7Scanner.IntegrationTests/IpScanner/S7ScannerServiceIntegrationTests.cs)**: These tests showcase real-world usage patterns against a live network and serve as excellent, practical examples.\n\n## 🤝 Contributing\n\nContributions are welcome! Whether it's bug reports, feature requests, or pull requests, your help is appreciated.\n\n1.  **Fork** the repository.\n2.  Create a new **branch** for your feature or bug fix.\n3.  Make your changes.\n4.  Add or update **unit/integration tests** to cover your changes.\n5.  Submit a **Pull Request** with a clear description of your changes.\n\nPlease open an issue first to discuss any major changes.\n\n## ⚖️ License\n\nThis project is licensed under the **MIT License**. See the [LICENSE](LICENSE.txt) file for details. You are free to use, modify, and distribute this software in commercial and private applications.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipp2604%2Fs7scanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilipp2604%2Fs7scanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipp2604%2Fs7scanner/lists"}