{"id":13694184,"url":"https://github.com/Ullaakut/nmap","last_synced_at":"2025-05-03T01:31:34.597Z","repository":{"id":37677369,"uuid":"166558054","full_name":"Ullaakut/nmap","owner":"Ullaakut","description":"Idiomatic nmap library for go developers","archived":false,"fork":false,"pushed_at":"2024-10-11T15:08:25.000Z","size":1645,"stargazers_count":936,"open_issues_count":11,"forks_count":104,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-11-12T12:11:12.955Z","etag":null,"topics":["audit","golang","hacking","idiomatic","infosec","netsec","network-analysis","network-mapping","nmap","penetration-testing","pentesting"],"latest_commit_sha":null,"homepage":"","language":"Go","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/Ullaakut.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":"2019-01-19T14:52:59.000Z","updated_at":"2024-11-11T07:18:16.000Z","dependencies_parsed_at":"2024-01-13T23:01:39.040Z","dependency_job_id":"832ee60f-20a5-4ed9-b4ee-f74568ad97cc","html_url":"https://github.com/Ullaakut/nmap","commit_stats":{"total_commits":189,"total_committers":25,"mean_commits":7.56,"dds":0.4656084656084656,"last_synced_commit":"58d93393be5926c8b541e049cc357b6cb9e3eb5e"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ullaakut%2Fnmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ullaakut%2Fnmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ullaakut%2Fnmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ullaakut%2Fnmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ullaakut","download_url":"https://codeload.github.com/Ullaakut/nmap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224346344,"owners_count":17296199,"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":["audit","golang","hacking","idiomatic","infosec","netsec","network-analysis","network-mapping","nmap","penetration-testing","pentesting"],"created_at":"2024-08-02T17:01:26.220Z","updated_at":"2024-11-12T20:31:32.357Z","avatar_url":"https://github.com/Ullaakut.png","language":"Go","funding_links":[],"categories":["Misc","开源类库","Open source library","Go"],"sub_categories":["安全","Security"],"readme":"# nmap\n\n\u003cp align=\"center\"\u003e\n    \u003cimg width=\"350\" src=\"img/logo.png\"/\u003e\n\u003cp\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg?style=flat\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/Ullaakut/nmap/v3\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/Ullaakut/nmap/v3\" alt=\"PkgGoDev github.com/Ullaakut/nmap/v3\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/Ullaakut/nmap/v3\"\u003e\n        \u003cimg src=\"https://goreportcard.com/badge/github.com/Ullaakut/nmap/v3\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/Ullaakut/nmap/actions/workflows/build.yml\"\u003e\n        \u003cimg src=\"https://github.com/Ullaakut/nmap/actions/workflows/build.yml/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/Ullaakut/nmap/actions/workflows/test.yml\"\u003e\n        \u003cimg src=\"https://github.com/Ullaakut/nmap/actions/workflows/test.yml/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href='https://coveralls.io/github/Ullaakut/nmap'\u003e\n        \u003cimg src='https://coveralls.io/repos/github/Ullaakut/nmap/badge.svg' alt='Coverage Status' /\u003e\n    \u003c/a\u003e\n\n\u003cp\u003e\n\nThis library aims at providing idiomatic `nmap` bindings for go developers, in order to make it easier to write security audit tools using golang.\n\n## What is nmap\n\nNmap (Network Mapper) is a free and open-source network scanner created by [Gordon Lyon](https://en.wikipedia.org/wiki/Gordon_Lyon). Nmap is used to discover hosts and services on a computer network by sending packets and analyzing the responses.\n\nNmap provides a number of features for probing computer networks, including host discovery and service and operating system detection. These features are extensible by scripts that provide more advanced service detection, vulnerability detection, and other features. Nmap can adapt to network conditions including latency and congestion during a scan.\n\n## Why use go for penetration testing\n\nMost pentest tools are currently written using Python and not Go, because it is easy to quickly write scripts, lots of libraries are available, and it's a simple language to use. However, for writing robust and reliable applications, Go is the better tool. It is statically compiled, has a static type system, much better performance, it is also a very simple language to use and goroutines are awesome... But I might be slighly biased, so feel free to disagree.\n\n## Supported features\n\n- [x] All of `nmap`'s native options.\n- [x] Additional [idiomatic go filters](examples/service_detection/main.go#L19) for filtering hosts and ports.\n- [x] Helpful enums for nmap commands. (time templates, os families, port states, etc.)\n- [x] Complete documentation of each option, mostly insipred from nmap's documentation.\n- [x] Run a nmap scan asynchronously.\n- [x] Scan progress can be piped through a channel.\n- [x] Write the nmap output to a given file while also parsing it to the struct.\n- [x] Stream the nmap output to an `io.Writer` interface while also parsing it to the struct.\n- [x] Functionality to show local interfaces and routes.\n\n## Simple example\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"time\"\n\n    \"github.com/Ullaakut/nmap/v3\"\n)\n\nfunc main() {\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\n\tdefer cancel()\n\n\t// Equivalent to `/usr/local/bin/nmap -p 80,443,843 google.com facebook.com youtube.com`,\n\t// with a 5-minute timeout.\n\tscanner, err := nmap.NewScanner(\n\t\tctx,\n\t\tnmap.WithTargets(\"google.com\", \"facebook.com\", \"youtube.com\"),\n\t\tnmap.WithPorts(\"80,443,843\"),\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"unable to create nmap scanner: %v\", err)\n\t}\n\n\tresult, warnings, err := scanner.Run()\n\tif len(*warnings) \u003e 0 {\n\t\tlog.Printf(\"run finished with warnings: %s\\n\", *warnings) // Warnings are non-critical errors from nmap.\n\t}\n\tif err != nil {\n\t\tlog.Fatalf(\"unable to run nmap scan: %v\", err)\n\t}\n\n\t// Use the results to print an example output\n\tfor _, host := range result.Hosts {\n\t\tif len(host.Ports) == 0 || len(host.Addresses) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tfmt.Printf(\"Host %q:\\n\", host.Addresses[0])\n\n\t\tfor _, port := range host.Ports {\n\t\t\tfmt.Printf(\"\\tPort %d/%s %s %s\\n\", port.ID, port.Protocol, port.State, port.Service.Name)\n\t\t}\n\t}\n\n\tfmt.Printf(\"Nmap done: %d hosts up scanned in %.2f seconds\\n\", len(result.Hosts), result.Stats.Finished.Elapsed)\n}\n```\n\nThe program above outputs:\n\n```bash\nHost \"172.217.16.46\":\n    Port 80/tcp open http\n    Port 443/tcp open https\n    Port 843/tcp filtered unknown\nHost \"31.13.81.36\":\n    Port 80/tcp open http\n    Port 443/tcp open https\n    Port 843/tcp open unknown\nHost \"216.58.215.110\":\n    Port 80/tcp open http\n    Port 443/tcp open https\n    Port 843/tcp filtered unknown\nNmap done: 3 hosts up scanned in 1.29 seconds\n```\n\n## Advanced example\n\n[Cameradar](https://github.com/Ullaakut/cameradar) already uses this library at its core to communicate with nmap, discover RTSP streams and access them remotely.\n\n\u003cp align=\"center\"\u003e\n   \u003cimg src=\"https://raw.githubusercontent.com/Ullaakut/cameradar/master/images/Cameradar.gif\" width=\"100%\"/\u003e\n\u003c/p\u003e\n\nMore examples:\n\n- [Basic scan](examples/basic_scan/main.go)\n- [Basic scan but asynchronously](examples/basic_scan_async/main.go)\n- [Basic scan with nmap progress piped through](examples/basic_scan_progress/main.go)\n- [Basic scan with output to a streamer](examples/basic_scan_streamer_interface/main.go)\n- [Count hosts for each operating system on a network](examples/count_hosts_by_os/main.go)\n- [Service detection](examples/service_detection/main.go)\n- [IP address spoofing and decoys](examples/spoof_and_decoys/main.go)\n- [List local interfaces](examples/list_interfaces/main.go)\n\n## External resources\n\n- [Official nmap documentation](https://nmap.org/docs.html)\n- [Nmap reference guide](https://nmap.org/book/man.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUllaakut%2Fnmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUllaakut%2Fnmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUllaakut%2Fnmap/lists"}