{"id":20879213,"url":"https://github.com/7c/p0f-client","last_synced_at":"2025-06-12T12:33:50.170Z","repository":{"id":254433403,"uuid":"846519408","full_name":"7c/p0f-client","owner":"7c","description":"p0f api client for NodeJS","archived":false,"fork":false,"pushed_at":"2024-09-19T16:42:00.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T09:42:52.398Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/7c.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-08-23T11:37:27.000Z","updated_at":"2024-09-19T16:42:02.000Z","dependencies_parsed_at":"2024-09-15T01:01:20.318Z","dependency_job_id":"e5204182-2dad-4cef-82c6-ecf062f8667d","html_url":"https://github.com/7c/p0f-client","commit_stats":null,"previous_names":["7c/p0f-client"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Fp0f-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Fp0f-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Fp0f-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Fp0f-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/7c","download_url":"https://codeload.github.com/7c/p0f-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258153,"owners_count":20262296,"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":[],"created_at":"2024-11-18T07:15:35.850Z","updated_at":"2025-03-12T16:44:12.293Z","avatar_url":"https://github.com/7c.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## p0f nodejs api client implementation\nBased on https://lcamtuf.coredump.cx/p0f3/README but also supports https://github.com/7c/p0f-v3-api2 (patched version of p0f with api2 support)\n\n\n## Some important comments from the original README\n```\n  - The maximum number of simultaneous API connections is capped to 20. The\n    limit may be adjusted with the -S parameter, but rampant parallelism may\n    lead to poorly controlled latency; consider a single query pipeline,\n    possibly with prioritization and caching.\n\n  - Cache entries with no activity for more than 120 minutes will be dropped\n    even if the cache is nearly empty. The timeout is adjustable with -t, but\n    you should not use the API to obtain ancient data; if you routinely need to\n    go back hours or days, parse the logs instead of wasting RAM.\n```\n\n## Installation\n```bash\nnpm i --save https://github.com/7c/p0f-client\n```\n## Starting p0f with socket and logs(optional for testing only, otherwise it grows indefinitely)\n```bash\n./p0f -s /var/run/p0f.socket -o /tmp/p0f.log\n```\n\n## Usage\nAssume you have started it with `-s` and `-o` flags you can use following code to find a random client from the logfile and query it with p0f\n\n```typescript\nimport { P0fClient,P0fLogfile } from \"@7c/p0f-client\"\n\nconst logs = new P0fLogfile('/tmp/p0f.log')\nconst p0f = new P0fClient('/var/run/p0f.socket')\n\nasync function start() {\n    try {\n        const module = await logs.tailModule('mtu',1000)\n        const randomClient = module.find((m:any) =\u003e m.subj='cli')\n        const res = await p0f.query(randomClient.cli_ip)\n        console.log(res)\n    } catch(err) {\n        console.log(err)\n    }\n    process.exit(0)\n}\n\nstart()\n```\n\nand the output should be something like this\n```json\n// version2 output demonstration\n{\n  version: 2,\n  status: 16,\n  first_seen: 2024-08-14T15:15:17.000Z,\n  last_seen: 2024-08-14T15:15:32.000Z,\n  total_conn: 160,\n  uptime_min: 41423,\n  up_mod_days: 49,\n  last_nat: 1726326931,\n  last_chg: 1726326932,\n  distance: 0,\n  bad_sw: 0,\n  os_match_q: 2,\n  os_name: 'Linux',\n  os_flavor: '2.2.x-3.x',\n  http_name: 'nginx',\n  http_flavor: '0.x',\n  link_type: 'Ethernet or modem',\n  language: '',\n  last_mtu: 1500,\n  last_freq: 1000\n}\n```\n\n\n## Testing\n```bash\n# optimized for linux\n## start p0f with socket and logs\n./p0f -s /var/run/p0f.socket -o /tmp/p0f.log\n## run tests\nnpm run test\n```\n\n## P0fManager\nthis manager is designed for high performance queries with fault toleration (todo: caching). Designed to never throw and detecting down times automatically.\n```typescript\nimport { P0fManager } from \"@7c/p0f-client\"\n// constructor\n// new P0fManager(socketFile: string, socket_timeout: number = 2000)\n\n// methods\n// async query(ip: string, query_timeout: number = 100): Promise\u003ctQueryResponse | string | null\u003e\n// public isReady(): boolean\n```\n\n## P0fSocketTester\ndesigned for testing the p0f socket, acts as mockup like random respond p0f compatible socket server, you can switch modes with `randomOK`, `randomNoMatch`, `randomBadQuery`, `modeTimeout` methods\n\n```typescript\nimport { P0fSocketTester,P0fClient } from \"@7c/p0f-client\"\n\nconst socketFile = '/var/run/p0f.socket'\nconst mockSocketServer = new P0fSocketTester(socketFile)\nmockSocketServer.randomOK()\nconst p0f = new P0fClient(socketFile)\nawait p0f.query('1.2.3.4')\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7c%2Fp0f-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F7c%2Fp0f-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7c%2Fp0f-client/lists"}