{"id":24822132,"url":"https://github.com/z3robyte/cswsh-lab","last_synced_at":"2026-05-10T16:10:07.117Z","repository":{"id":274898675,"uuid":"924424401","full_name":"z3rObyte/CSWSH-lab","owner":"z3rObyte","description":"Laboratorio para aprender y explotar la vulnerabilidad Cross-Site WebSocket Hijacking","archived":false,"fork":false,"pushed_at":"2025-02-11T11:30:55.000Z","size":77,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-02T01:37:20.662Z","etag":null,"topics":["cybersecurity","hacking","nodejs","websecurity","websocket"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/z3rObyte.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":"2025-01-30T01:08:34.000Z","updated_at":"2025-06-13T23:08:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"95ec2099-6c1f-4cd2-9e1c-315dfd85fa3e","html_url":"https://github.com/z3rObyte/CSWSH-lab","commit_stats":null,"previous_names":["z3robyte/cswsh-lab"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/z3rObyte/CSWSH-lab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z3rObyte%2FCSWSH-lab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z3rObyte%2FCSWSH-lab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z3rObyte%2FCSWSH-lab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z3rObyte%2FCSWSH-lab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/z3rObyte","download_url":"https://codeload.github.com/z3rObyte/CSWSH-lab/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z3rObyte%2FCSWSH-lab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273218420,"owners_count":25065913,"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-09-01T02:00:09.058Z","response_time":120,"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":["cybersecurity","hacking","nodejs","websecurity","websocket"],"created_at":"2025-01-30T18:26:35.850Z","updated_at":"2026-05-10T16:10:02.077Z","avatar_url":"https://github.com/z3rObyte.png","language":"JavaScript","funding_links":["https://buymeacoffee.com/z3robyte"],"categories":[],"sub_categories":[],"readme":"# CSWSH Lab\n\nLaboratorio vulnerable a **Cross-Site WebSocket Hijacking** (*CSWSH*) inspirado en una aplicación bancaria.\n\n![public](screenshots/public.png)\n\n\n\n- [CSWSH Lab](#cswsh-lab)\n  - [Setup](#setup)\n      - [Requisitos previos](#requisitos-previos)\n      - [Instalación](#instalación)\n      - [Run it!](#run-it)\n  - [Write Up](#write-up)\n  - [Donaciones](#donaciones)\n\n## Setup\n\n#### Requisitos previos\n+ Linux\n```bash\nsudo apt update\nsudo apt install nodejs npm libnss3-tools \nsudo apt install mkcert\nnpm install --global http-server\n```\n* Windows\n - Descarga [NodeJS](https://nodejs.org/en)\n - Descarga [mkcert](https://github.com/FiloSottile/mkcert?tab=readme-ov-file)\n - Descarga [http-server](https://www.npmjs.com/package/http-server)\n\n#### Instalación\n```bash\ngit clone https://github.com/z3robyte/CSWSH-lab\ncd CSWSH-lab\nnpm install\n```\nPara que sea posible la vulnerabilidad en este lab, el servidor local debe usar **HTTPS**, debido a que las cookies tienen que tener el atributo `SameSite=None`, y por requerimiento de este, el atributo `secure`. Más info [aquí](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#none).\n\nA continuación veremos como generar e instalar los certificados necesarios ello:\n```bash\nmkdir certificates\ncd certificates\nmkcert install # si da problemas, ejecutar como admin o root\nmkcert localhost\n```\n#### Run it!\n+ Para levantar la aplicación:\n```bash\nnode app.js\n# https://localhost:3000\n```\nHay 2 usuarios, cuyas credenciales son: ``victim:pass123`` y ``attacker:haxxor1``\n+ Para levantar el servidor del atacante:\n```bash\ncd exploit\nhttp-server -S -C \"../certificates/localhost.pem\" -K \"../certificates/localhost-key.pem\"\n# https://localhost:8080\n```\n\n\u003e Acordarse acceder a los servidores por HTTPS\n\n## Write Up\n\nLa aplicación web usa [websockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) para realizar transacciones de dinero ficticio entre usuarios. Sin embargo, el **handshake** del _websocket_ depende únicamente de la cookie de sesión para establecerse (la cual tiene `sameSite=None`), por lo que podemos crear un sitio malicioso para que cuando una víctima lo visite se establezca una conexión _websocket_ de forma silenciosa con javascript y nos enviemos dinero a nuestra cuenta. \n\nEste ataque es parecido a un [CSRF](https://es.wikipedia.org/wiki/Cross-site_request_forgery) pero aplicado a los _websockets_.\n\nAquí tienes un video mostrando la explotación de la vulnerabilidad (haz click en la imagen):\n\n[![Video](https://img.youtube.com/vi/Ifmx0qfPqdw/0.jpg)](https://www.youtube.com/watch?v=Ifmx0qfPqdw)\n\n\n## Donaciones\n\nSi este proyecto te ha ayudado a aprender algo, considera aportar tu granito de arena para hacer más labs como este.\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoffee.com/z3robyte)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz3robyte%2Fcswsh-lab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fz3robyte%2Fcswsh-lab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz3robyte%2Fcswsh-lab/lists"}