{"id":22535845,"url":"https://github.com/ik5/port_scanner","last_synced_at":"2026-04-08T23:34:16.531Z","repository":{"id":66772558,"uuid":"156956750","full_name":"ik5/port_scanner","owner":"ik5","description":"Example for creating a naive port scanner","archived":false,"fork":false,"pushed_at":"2018-11-16T19:11:08.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-30T11:55:14.870Z","etag":null,"topics":["golang","javascript","perl","php","port-scanner","python3","ruby","socket","tcp-ip","tcp-socket","tutorial"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ik5.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,"zenodo":null}},"created_at":"2018-11-10T07:04:29.000Z","updated_at":"2018-11-16T19:13:28.000Z","dependencies_parsed_at":"2023-07-01T01:20:38.846Z","dependency_job_id":null,"html_url":"https://github.com/ik5/port_scanner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ik5/port_scanner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ik5%2Fport_scanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ik5%2Fport_scanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ik5%2Fport_scanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ik5%2Fport_scanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ik5","download_url":"https://codeload.github.com/ik5/port_scanner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ik5%2Fport_scanner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31579056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","javascript","perl","php","port-scanner","python3","ruby","socket","tcp-ip","tcp-socket","tutorial"],"created_at":"2024-12-07T10:08:43.524Z","updated_at":"2026-04-08T23:34:16.516Z","avatar_url":"https://github.com/ik5.png","language":"Ruby","readme":"# Port Scanner\n\nExample for creating a naive TCP port scanner.\n\n## What is this 'Naive' ?\n\nPort scanning is a way to detect if there is a server that listen to a port\nat a given address.\n\nThe current examples are checking TCP connections. The reason for scanning TCP\nis simple - TCP have a mechanism to know if a port is open or not.\nThat mechanism is implemented using SYNchronize and called 3 way handshake.\n\n### 3 way handshake\n\nWhen reading network specifications, there are at least two characters involved\nand I'm not going to stop doing that, so meet Alice and Bob :-)\n\nAlice wishes to contact with Bob, on a given channel (port), so Alice sends `SYN`.\nBob, if wishes, answer Alice with `SYN-ACK`.\nThen Alice sends `ACK`, and there is a handshake between the two, and got the\nname of 3 way handshake\n\n### TCP vs UDP\n\n3 way handshake exists for TCP but not for UDP. UDP does not sends a handshake\nand if the server answers with the proper payload, then you know that the server\nis alive.\nIf the server does not sends any answer, there is no way to know if there is an\naccess for the server or not.\n\n### The Naive way\n\nIn order to know if a port is open, there is a need to open a connection for :-)\n\nHowever, the current implementation that I've created is to first resolve IP from\nDNS records, then using `timeout` for a connection.\nWhen a connection that is initiated does not have the proper 3 way handshake, it\nmight not return for a long time (almost forever), so the `timeout` will kick in\nand we \"know\" that the connection is `closed`.\n\nWhen an open request is back, something is filtering the request (firewall?).\n\nThe \"naive\" way, is guessing the meaning of each type of \"error\" and translate it\nto the status of a request.\n\n# License\n\nThe aim of this repo is to teach, so I have choosen the \"The Unlicense\" license.\n\n```\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \u003chttp://unlicense.org\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fik5%2Fport_scanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fik5%2Fport_scanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fik5%2Fport_scanner/lists"}