Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xKoda WireMCP plaintext credential reconstruction

From Leeroopedia
Knowledge Sources
Domains Security, Credential_Extraction
Last Updated 2026-10-28 00:00 GMT

Overview

Concrete tool for reconstructing plaintext credentials (HTTP Basic Auth, FTP, Telnet) from raw tshark field output, implemented as a pattern within the `extract_credentials` tool handler.

Description

The plaintext credential reconstruction pattern processes parsed tshark field rows to reconstruct usable credential pairs:

  • HTTP Basic Auth: Decodes the base64-encoded `http.authbasic` field with `Buffer.from(authBasic, 'base64').toString()`, then splits on `:` to get `username:password`.
  • FTP: Detects `USER` commands to create a credential entry, then pairs subsequent `PASS` commands using `Array.prototype.findLast` to find the most recent FTP entry lacking a password.
  • Telnet: Detects `login:`/`password:` prompt strings to create a "Telnet Prompt" marker, then pairs subsequent single-token data lines (no spaces, no `Word:` pattern) as the username or password response.

This is a user-defined pattern (not a library API) that reconstructs credential state from sequential packet artifacts.

Usage

Use this pattern when you have tab-separated tshark field output containing plaintext credential artifacts and need to reconstruct username/password pairs for each protocol.

Code Reference

Source Location

  • Repository: WireMCP
  • File: index.js
  • Lines: L403-444 (HTTP Basic Auth L408-414, FTP L416-425, Telnet L427-444)

Signature

const credentials = { plaintext: [], encrypted: [] };

// HTTP Basic Auth: decode base64 → username:password
packets.forEach(p => {
  if (p.authBasic) {
    const [username, password] = Buffer.from(p.authBasic, 'base64').toString().split(':');
    credentials.plaintext.push({ type: 'HTTP Basic Auth', username, password, frame: p.frameNumber });
  }
});

// FTP: pair USER with subsequent PASS
packets.forEach(p => {
  if (p.ftpCmd === 'USER') {
    credentials.plaintext.push({ type: 'FTP', username: p.ftpArg, password: '', frame: p.frameNumber });
  }
  if (p.ftpCmd === 'PASS') {
    const lastUser = credentials.plaintext.findLast(c => c.type === 'FTP' && !c.password);
    if (lastUser) lastUser.password = p.ftpArg;
  }
});

// Telnet: detect prompts, pair subsequent tokens
packets.forEach(p => {
  if (p.telnetData) {
    const telnetStr = p.telnetData.trim();
    if (telnetStr.toLowerCase().includes('login:') || telnetStr.toLowerCase().includes('password:')) {
      credentials.plaintext.push({ type: 'Telnet Prompt', data: telnetStr, frame: p.frameNumber });
    } else if (telnetStr && !telnetStr.match(/[A-Z][a-z]+:/) && !telnetStr.includes(' ')) {
      const lastPrompt = credentials.plaintext.findLast(c => c.type === 'Telnet Prompt');
      if (lastPrompt && lastPrompt.data.toLowerCase().includes('login:')) {
        credentials.plaintext.push({ type: 'Telnet', username: telnetStr, password: '', frame: p.frameNumber });
      } else if (lastPrompt && lastPrompt.data.toLowerCase().includes('password:')) {
        const lastUser = credentials.plaintext.findLast(c => c.type === 'Telnet' && !c.password);
        if (lastUser) lastUser.password = telnetStr;
        else credentials.plaintext.push({ type: 'Telnet', username: '', password: telnetStr, frame: p.frameNumber });
      }
    }
  }
});

Import

// Buffer is a built-in Node.js global; Array.prototype.findLast is ES2023

I/O Contract

Inputs

Name Type Required Description
packets Array<Object> Yes Parsed tshark rows: `{ authBasic, ftpCmd, ftpArg, telnetData, frameNumber }`

Outputs

Name Type Description
credentials.plaintext Array<Object> `{ type, username, password, frame }` (or `{ type: 'Telnet Prompt', data, frame }`)

Usage Examples

Reconstruct HTTP Basic Auth

// p.authBasic = "dXNlcjpwYXNz" (base64 of "user:pass")
const [username, password] = Buffer.from(p.authBasic, 'base64').toString().split(':');
// username = "user", password = "pass"
credentials.plaintext.push({ type: 'HTTP Basic Auth', username, password, frame: p.frameNumber });

Reconstruct FTP USER/PASS Pair

// Packet 1: ftpCmd="USER", ftpArg="anonymous"
credentials.plaintext.push({ type: 'FTP', username: 'anonymous', password: '', frame: '42' });

// Packet 2: ftpCmd="PASS", ftpArg="user@example.com"
const lastUser = credentials.plaintext.findLast(c => c.type === 'FTP' && !c.password);
if (lastUser) lastUser.password = 'user@example.com';
// Result: { type: 'FTP', username: 'anonymous', password: 'user@example.com', frame: '42' }

Reconstruct Telnet Login

// Packet 1: telnetData = "login:"
// → creates Telnet Prompt marker
credentials.plaintext.push({ type: 'Telnet Prompt', data: 'login:', frame: '100' });

// Packet 2: telnetData = "root" (no spaces, no "Word:" pattern)
const lastPrompt = credentials.plaintext.findLast(c => c.type === 'Telnet Prompt');
if (lastPrompt && lastPrompt.data.toLowerCase().includes('login:')) {
  credentials.plaintext.push({ type: 'Telnet', username: 'root', password: '', frame: '101' });
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment