Skip to content
KitploitKITPLOIT
FerramentasExploitsBlog
Log in
Enviar
FerramentasExploitsBlog
Enviar

Ferramentas de Hacking, PenTest e Cibersegurança para o seu Arsenal de Segurança!

Kitploit é um diretório de ferramentas de hacking, cibersegurança e pentesting. Descubra as últimas atualizações de projetos para encontrar vulnerabilidades, analisar sistemas, automatizar testes e fortalecer sua segurança.

FeedsContatoPrivacidade© 2026 Kitploit

Diretório de Ferramentas

Categorias

Ver todas as categorias
Loading categories
js-xss — Sanitize HTML não confiável (para prevenir XSS) com uma configuração especificada por uma Whitelist | Kitploit
Ferramentas/GitHubGitHub/leizongmin/js-xss
Ferramentas DefensivasExploração de Aplicações WebSegurança WebUtilitários e Frameworks
GitHubleizongmin/js-xss

js-xss

Sanitize HTML não confiável (para prevenir XSS) com uma configuração especificada por uma Whitelist

Ver Repositório
5.3k63024 de out. de 2026Revisado pelo Kitploit
Compartilhar
Site

Versão NPM Node.js CI Cobertura de testes Dependências David Versão do node Downloads npm Licença npm

Sanitize HTML não confiável (para prevenir XSS) com uma configuração especificada por uma Whitelist.

Selo Greenkeeper

xss


xss é um módulo usado para filtrar a entrada dos usuários e prevenir ataques XSS. (O que é um ataque XSS?)

Página inicial do projeto: http://jsxss.com

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

中文版文档


Recursos

  • Especifica tags HTML e seus atributos permitidos por meio de whitelist
  • Trata quaisquer tags ou atributos usando uma função personalizada.

Referência

  • XSS Filter Evasion Cheat Sheet
  • Data URI scheme
  • XSS with Data URI Scheme

Benchmark (apenas para referência)

  • o módulo xss: 22,53 MB/s
  • função xss() do módulo [email protected]: 6,9 MB/s

Para o código de teste, consulte o diretório benchmark.

Quem usa o módulo xss

  • nodeclub - Um fórum Node.js usando MongoDB - https://github.com/cnodejs/nodeclub
  • cnpmjs.org - Registro npm privado e web para empresas - https://github.com/cnpm/cnpmjs.org
  • cocalc.com - Cálculo Colaborativo e Ciência de Dados - https://cocalc.com

Instalação

NPM

npm install xss

Bower

bower install xss

Ou

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

Usos

No Node.js

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

Obter HTML sanitizado e elementos removidos

Você pode usar filterXSSWithResult para obter tanto o HTML sanitizado quanto uma lista de tags/atributos removidos:

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()" }
// ]

No Navegador

Modo Shim (arquivo de referência 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>

Modo 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>

Notas: por favor, não use a URL https://rawgit.com/leizongmin/js-xss/master/dist/xss.js em ambiente de produção.

Ferramenta de Linha de Comando

Processar Arquivo

Você pode usar a ferramenta de linha de comando xss para processar um arquivo. Uso:

xss -i <input_file> -o <output_file>

Exemplo:

xss -i origin.html -o target.html

Teste Ativo

Execute o seguinte comando, depois você pode digitar código HTML na linha de comando e verificar a saída filtrada:

xss -t

Para mais detalhes, execute $ xss -h para visualizá-lo.

Regras de filtro personalizadas

Ao usar a função xss(), o segundo parâmetro pode ser usado para especificar regras personalizadas:

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

Para evitar passar options toda vez, você também pode fazer isso de uma forma mais rápida criando uma instância de FilterXSS:

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

Os detalhes dos parâmetros em options serão descritos abaixo.

Lista de permissões

Ao especificar um whiteList, por exemplo { 'tagName': [ 'attr-1', 'attr-2' ] }. Tags e atributos que não estejam na lista de permissões serão filtrados. Por exemplo:

// 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>

Para a lista de permissões padrão, consulte xss.whiteList.

allowList também é suportado e tem a mesma função que whiteList.

Personalizar a função de manipulador para tags correspondentes

Ao especificar a função de manipulador com 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
}

Personalize a função handler para atributos de tags correspondentes

Ao especificar a função handler com 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
}

Personalizar a função de manipulador para tags que não estão na lista de permissões

Ao especificar a função de manipulador com onIgnoreTag:

Baixar ferramenta

Ferramentas relacionadas

  • wazuh

    Plataforma XDR e SIEM de código aberto para detecção de ameaças, análise de logs, monitoramento de integridade de arquivos, avaliação de vulnerabilidades e gerenciamento de conformidade em endpoints e cargas de trabalho na nuvem.

  • suricata

    Mecanismo open-source de IDS/IPS/NSM de rede para inspeção de tráfego em tempo real, detecção e prevenção de intrusões, análise de protocolos e caça a ameaças baseada em regras.

  • zeek

    Zeek é um poderoso framework de análise de rede que é muito diferente do IDS típico que você pode conhecer.

Mais Populares

Ver todos →

Descubra as ferramentas mais usadas pela nossa comunidade.

  • 1

    Callisto

    jetp1ane/callisto

    Ferramenta automatizada de análise de vulnerabilidades binárias que descompila executáveis via Ghidra, verifica código pseudo-C com Semgrep e valida descobertas usando GPT-3.5-Turbo para reduzir falsos positivos.

    2.2k
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    # Aplicativo de Execução em Um Toque GhostLock (CVE-2026-43499)

    841
  • 3

    DFRoot

    a2333c/dfroot

    Ferramenta de root para Android para Samsung Galaxy S25 Ultra (SM-S938B) que encadeia DirtyFrag CVE-2026-43284 e CVE-2026-43499 para obter root automaticamente no boot via KernelSU.

    446
  • 4

    ARTEX

    baarai/artex

    Plataforma autônoma de testes de penetração multiagente com LLM, com agentes planejador/executor, grafos de ativos e de exploração, registro de tráfego MITM e reteste de vulnerabilidades.

    386
  • 5

    OsintHunter

    letox4/osinthunter

    🎯 O kit definitivo de OSINT: grafo de investigação, pontuação de confiança, famílias de alias, mapa, linha do tempo e relatórios. 49 módulos, mais de 400 sites, sem necessidade de chaves de API.

    350
  • 6

    faraday

    infobyte/faraday

    Ferramentas de cibersegurança de código aberto e com IA para segurança ofensiva, gestão de vulnerabilidades e pentesting autônomo. Criadas por hackers na América Latina, usadas no mundo todo.

    333

Explore todas as ferramentas

Navegue pela nossa coleção de ferramentas

Ver todas as ferramentas →