{"id":16989981,"url":"https://github.com/matzefriedrich/amsi","last_synced_at":"2026-02-02T11:32:25.964Z","repository":{"id":66218453,"uuid":"115736425","full_name":"matzefriedrich/amsi","owner":"matzefriedrich","description":"A library to integrate the Microsoft Windows Anti-Malware Scan Interface (AMSI) into any .NET application.","archived":false,"fork":false,"pushed_at":"2024-09-27T20:29:39.000Z","size":40,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T20:47:00.918Z","etag":null,"topics":["amsi","dotnet","malware-detection","malware-scan","net8","pinvoke","windows-api"],"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/matzefriedrich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2017-12-29T16:12:37.000Z","updated_at":"2024-09-27T20:27:38.000Z","dependencies_parsed_at":"2024-11-28T12:38:48.044Z","dependency_job_id":null,"html_url":"https://github.com/matzefriedrich/amsi","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matzefriedrich%2Famsi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matzefriedrich%2Famsi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matzefriedrich%2Famsi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matzefriedrich%2Famsi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matzefriedrich","download_url":"https://codeload.github.com/matzefriedrich/amsi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085477,"owners_count":21210267,"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","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":["amsi","dotnet","malware-detection","malware-scan","net8","pinvoke","windows-api"],"created_at":"2024-10-14T03:08:39.355Z","updated_at":"2026-02-02T11:32:20.941Z","avatar_url":"https://github.com/matzefriedrich.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/matzefriedrich/amsi/actions/workflows/dotnet.yml/badge.svg)\n![GitHub Tag](https://img.shields.io/github/v/tag/matzefriedrich/amsi)\n![GitHub License](https://img.shields.io/github/license/matzefriedrich/amsi)\n\n\n# Antimalware Scan Interface for .NET\n\nThis is a .NET 8.0 library project providing functionality to integrate the [Microsoft Windows Antimalware Scan Interface (AMSI)](https://learn.microsoft.com/en-us/windows/win32/amsi/antimalware-scan-interface-portal?redirectedfrom=MSDN) into any .NET application.\n\n## Build\n\n```sh\n$ dotnet build --configuration Release\n```\n\n### Run tests\n\n\u003e **The library uses the AMSI interface, which is only available on Windows desktop versions.** You will encounter several failing tests if you run the tests on a non-Desktop version of Windows.\n\n```sh\n$ dotnet test --framework net8.0-windows --configuration Release --verbosity normal\n```\n\n\n## Usage\n\nScan a string for malware in C#.\n\n```csharp\nconst string appName = \"myapp\";\nusing (AmsiContext context = AmsiContext.Create(appName))\n{\n    const string input = \"Pure air\";\n    AmsiScanResult result = context.Scan(input, \"\");\n    if (result == AmsiScanResult.Clean)\n    {\n        // seems to be okay\n    }\n}\n```\n\nScanning a buffer full of content for malware is as easy as scanning a `string`; use the overload that accepts a `byte` array.\n\n```csharp\nMemoryStream stream = ...\nbyte[] buffer = stream.ToArray();\nAmsiScanResult result = context.Scan(buffer, \"\");\n```\n\nIt is also possible to perform correlated scan requests. In the following example, the `ScanFile` method is used to scan file contents for malware.\n\n```csharp\nusing (AmsiSession scanSession = AmsiSession.Create(context))\n{\n    string[] files = Directory.GetFiles(...);\n    foreach (string file in files)\n    {\n        AmsiScanResult fileResult = scanSession.ScanFile(file)\n        if (fileResult == AmsiScanResult.Block)\n        {\n            // this file should be blocked...\n        }\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatzefriedrich%2Famsi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatzefriedrich%2Famsi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatzefriedrich%2Famsi/lists"}