Skip to content
KitploitKITPLOIT
StrumentiExploitsBlog
Log in
Invia
StrumentiExploitsBlog
Invia

Strumenti di Hacking, PenTest e Cybersecurity per il tuo Arsenale di Sicurezza!

Kitploit è una directory di strumenti di hacking, cybersecurity e pentesting. Scopri gli ultimi aggiornamenti dei progetti per trovare vulnerabilità, analizzare sistemi, automatizzare i test e rafforzare la tua sicurezza.

FeedContattoPrivacy© 2026 Kitploit

Directory degli strumenti

Categorie

Vedi tutte le categorie
Loading categories
js-xss — Sanifica HTML non attendibile (per prevenire XSS) con una configurazione specificata da una Whitelist | Kitploit
Strumenti/GitHubGitHub/leizongmin/js-xss
Strumenti DifensiviSfruttamento di Applicazioni WebSicurezza WebUtilità e Framework
GitHubleizongmin/js-xss

js-xss

Sanifica HTML non attendibile (per prevenire XSS) con una configurazione specificata da una Whitelist

Vedi Repository
5.3k63024 ott 2026Revisionato da Kitploit
Condividi
Sito web

Versione NPM Node.js CI Copertura dei test Dipendenze David versione node download npm licenza npm

Sanifica l'HTML non attendibile (per prevenire XSS) con una configurazione specificata da una Whitelist.

Badge Greenkeeper

xss


xss è un modulo utilizzato per filtrare l'input degli utenti al fine di prevenire attacchi XSS. (Che cos'è un attacco XSS?)

Homepage del progetto: http://jsxss.com

Prova online: http://jsxss.com/en/try.html

中文版文档


Funzionalità

  • Specifica i tag HTML e i relativi attributi consentiti tramite whitelist
  • Gestisce qualsiasi tag o attributo tramite una funzione personalizzata.

Riferimenti

  • XSS Filter Evasion Cheat Sheet
  • Schema Data URI
  • XSS con schema Data URI

Benchmark (solo a titolo di riferimento)

  • il modulo xss: 22,53 MB/s
  • la funzione xss() del modulo [email protected]: 6,9 MB/s

Per il codice di test fare riferimento alla directory benchmark.

Stanno usando il modulo xss

  • nodeclub - Un bbs Node.js che utilizza MongoDB - https://github.com/cnodejs/nodeclub
  • cnpmjs.org - Registry npm privato e web per le aziende - https://github.com/cnpm/cnpmjs.org
  • cocalc.com - Calcolo collaborativo e data science - https://cocalc.com

Installazione

NPM

npm install xss

Bower

bower install xss

O

bower install https://github.com/leizongmin/js-xss.git

Utilizzi

Su Node.js

var xss = require("xss");
var html = xss('<script>alert("xss");</script>');
console.log(html);

Ottenere HTML sanitizzato ed elementi rimossi

Puoi usare filterXSSWithResult per ottenere sia l'HTML sanitizzato sia un elenco di tag/attributi rimossi:

var xss = require("xss");
var result = xss.filterXSSWithResult('<script>alert("xss");</script><a href="#" onclick="evil()">click</a>');
console.log(result.html);
// Output: "&lt;script&gt;alert(\"xss\");&lt;/script&gt;<a href=\"#\">click</a>"
console.log(result.removed);
// Output: [
//   { type: "tag", tag: "script", html: "<script>", isClosing: false },
//   { type: "tag", tag: "script", html: "</script>", isClosing: true },
//   { type: "attr", tag: "a", attr: "onclick", value: "evil()" }
// ]

Nel browser

Modalità Shim (file di riferimento test/test.html):

<script src="https://rawgit.com/leizongmin/js-xss/master/dist/xss.js"></script>
<script>
  // apply function filterXSS in the same way
  var html = filterXSS('<script>alert("xss");</scr' + "ipt>");
  alert(html);
</script>

Modalità AMD - shim:

<script>
  require.config({
    baseUrl: "./",
    paths: {
      xss: "https://rawgit.com/leizongmin/js-xss/master/dist/xss.js",
    },
    shim: {
      xss: { exports: "filterXSS" },
    },
  });
  require(["xss"], function (xss) {
    var html = xss('<script>alert("xss");</scr' + "ipt>");
    alert(html);
  });
</script>

Nota: non utilizzare l'URL https://rawgit.com/leizongmin/js-xss/master/dist/xss.js in ambiente di produzione.

Strumento da riga di comando

Elaborazione di un file

È possibile utilizzare lo strumento da riga di comando xss per elaborare un file. Utilizzo:

xss -i <input_file> -o <output_file>

Esempio:

xss -i origin.html -o target.html

Test attivo

Esegui il seguente comando, poi puoi digitare codice HTML nella riga di comando e controllare l'output filtrato:

xss -t

Per maggiori dettagli, esegui $ xss -h per visualizzarlo.

Regole di filtro personalizzate

Quando si utilizza la funzione xss(), il secondo parametro può essere usato per specificare regole personalizzate:

options = {}; // Custom rules
html = xss('<script>alert("xss");</script>', options);

Per evitare di passare options ogni volta, puoi anche farlo in modo più rapido creando un'istanza FilterXSS:

options = {}; // Custom rules
myxss = new xss.FilterXSS(options);
// then apply myxss.process()
html = myxss.process('<script>alert("xss");</script>');

I dettagli dei parametri in options sono descritti di seguito.

Whitelist

Specificando un whiteList, ad esempio { 'tagName': [ 'attr-1', 'attr-2' ] }. I tag e gli attributi non presenti nella whitelist verranno filtrati. Ad esempio:

// only tag a and its attributes href, title, target are allowed
var options = {
  whiteList: {
    a: ["href", "title", "target"],
  },
};
// With the configuration specified above, the following HTML:
// <a href="#" onclick="hello()"><i>Hello</i></a>
// would become:
// <a href="#">&lt;i&gt;Hello&lt;/i&gt;</a>

Per la whitelist predefinita, fare riferimento a xss.whiteList.

È supportato anche allowList, che ha la stessa funzione di whiteList.

Personalizzare la funzione handler per i tag corrispondenti

Specificando la funzione handler con onTag:

function onTag(tag, html, options) {
  // tag is the name of current tag, e.g. 'a' for tag <a>
  // html is the HTML of this tag, e.g. '<a>' for tag <a>
  // options is some addition informations:
  //   isWhite    boolean, whether the tag is in whitelist
  //   isClosing  boolean, whether the tag is a closing tag, e.g. true for </a>
  //   position        integer, the position of the tag in output result
  //   sourcePosition  integer, the position of the tag in input HTML source
  // If a string is returned, the current tag would be replaced with the string
  // If return nothing, the default measure would be taken:
  //   If in whitelist: filter attributes using onTagAttr, as described below
  //   If not in whitelist: handle by onIgnoreTag, as described below
}

Personalizza la funzione handler per gli attributi dei tag corrispondenti

Specificando la funzione handler con onTagAttr:

function onTagAttr(tag, name, value, isWhiteAttr) {
  // tag is the name of current tag, e.g. 'a' for tag <a>
  // name is the name of current attribute, e.g. 'href' for href="#"
  // isWhiteAttr whether the attribute is in whitelist
  // If a string is returned, the attribute would be replaced with the string
  // If return nothing, the default measure would be taken:
  //   If in whitelist: filter the value using safeAttrValue as described below
  //   If not in whitelist: handle by onIgnoreTagAttr, as described below
}

Personalizza la funzione handler per i tag non presenti nella whitelist

Specificando la funzione handler con onIgnoreTag:

Scarica lo strumento

Strumenti correlati

  • wazuh

    Piattaforma XDR e SIEM open-source per rilevamento delle minacce, analisi dei log, monitoraggio dell'integrità dei file, valutazione delle vulnerabilità e gestione della conformità su endpoint e carichi di lavoro cloud.

  • suricata

    Motore open-source IDS/IPS/NSM di rete per l'ispezione del traffico in tempo reale, rilevamento e prevenzione delle intrusioni, analisi dei protocolli e caccia alle minacce basata su regole.

  • zeek

    Zeek è un potente framework di analisi di rete molto diverso dal tipico IDS che potresti conoscere.

Più Popolari

Vedi tutti →

Scopri gli strumenti più utilizzati dalla nostra community.

  • 1

    Callisto

    jetp1ane/callisto

    Strumento automatizzato di analisi delle vulnerabilità binarie che decompila eseguibili tramite Ghidra, esegue la scansione del pseudo-codice C con Semgrep e convalida i risultati utilizzando GPT-3.5-Turbo per ridurre i falsi positivi.

    2.2k
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    # App di esecuzione con un tocco GhostLock (CVE-2026-43499)

    841
  • 3

    DFRoot

    a2333c/dfroot

    Strumento di root per Android per Samsung Galaxy S25 Ultra (SM-S938B) che concatena DirtyFrag CVE-2026-43284 e CVE-2026-43499 per ottenere i privilegi di root automaticamente all'avvio tramite KernelSU.

    446
  • 4

    ARTEX

    baarai/artex

    Piattaforma di penetration testing autonoma multi-agente basata su LLM con agenti planner/worker, grafi di asset e di esplorazione, registrazione del traffico MITM e retesting delle vulnerabilità.

    386
  • 5

    OsintHunter

    letox4/osinthunter

    🎯 Il toolkit OSINT definitivo: grafo di indagine, punteggio di affidabilità, famiglie di alias, mappa, timeline e report. 49 moduli, oltre 400 siti, nessuna chiave API richiesta.

    350
  • 6

    faraday

    infobyte/faraday

    Strumenti di cybersecurity open-source e basati sull'IA per la sicurezza offensiva, la gestione delle vulnerabilità e il pentesting autonomo. Creati da hacker in America Latina, utilizzati in tutto il mondo.

    333

Esplora tutti gli strumenti

Sfoglia la nostra collezione di strumenti

Vedi tutti gli strumenti →