Skip to main content
Glama
abdessamad-elamrani

MalwareAnalyzerMCP

xxd

Analyze binary files by creating hexdumps with ASCII representation to inspect file contents for malware analysis.

Instructions

Create a hexdump with ASCII representation

Example usage:

  • Standard xxd dump: { "target": "suspicious.exe" }

  • With length limit: { "target": "suspicious.exe", "length": 256 }

  • With column formatting: { "target": "suspicious.exe", "cols": 16 }

  • Binary bits mode: { "target": "suspicious.exe", "bits": true }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesTarget file or data to analyze
optionsNoAdditional command-line options
lengthNoNumber of bytes to display
offsetNoStarting offset in the file
colsNoFormat output into specified number of columns
bitsNoSwitch to bits (binary) dump

Implementation Reference

  • Core handler for executing the 'xxd' tool (and other specialized commands): validates input against schema, builds command string using tool-specific buildCommand, executes via terminalManager.shellCommand, and returns result.
    if (commands[name]) {
      try {
        const cmdConfig = commands[name];
        
        // Validate arguments against schema
        const validationResult = cmdConfig.schema.safeParse(args);
        if (!validationResult.success) {
          return {
            content: [{ 
              type: "text", 
              text: `Error: Invalid parameters for ${name} command.\n${JSON.stringify(validationResult.error.format())}`
            }],
            isError: true,
          };
        }
        
        // Build the command string
        const commandStr = cmdConfig.buildCommand(validationResult.data);
        console.error(`Executing specialized command: ${commandStr}`);
        
        // Execute the command via the terminal manager
        const result = await terminalManager.shellCommand(commandStr);
        console.error(`${name} command executed with PID: ${result.pid}, blocked: ${result.isBlocked}`);
        
        return {
          content: [{ type: "text", text: JSON.stringify(result) }],
        };
      } catch (error) {
        console.error(`Error executing ${name} command:`, error);
        return {
          content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }],
          isError: true,
        };
      }
    }
  • xxd-specific logic to construct the xxd shell command from input parameters.
    buildCommand: (args) => {
      let options = args.options ? args.options : '';
      
      if (args.length) {
        options += ` -l ${args.length}`;
      }
      
      if (args.offset) {
        options += ` -s ${args.offset}`;
      }
      
      if (args.cols) {
        options += ` -c ${args.cols}`;
      }
      
      if (args.bits) {
        options += ' -b';
      }
      
      return `xxd ${options} ${args.target}`;
    },
  • Zod input schema for the xxd tool, defining parameters like length, offset, cols, bits extending baseCommandSchema.
    schema: baseCommandSchema.extend({
      length: z.number().optional().describe("Number of bytes to display"),
      offset: z.number().optional().describe("Starting offset in the file"),
      cols: z.number().optional().describe("Format output into specified number of columns"),
      bits: z.boolean().optional().describe("Switch to bits (binary) dump")
    }),
  • serverMCP.js:113-118 (registration)
    Registers 'xxd' (and other commands) as MCP tools dynamically from the commands configuration, providing name, description, and inputSchema.
    const specializedTools = Object.values(commands).map(cmd => ({
      name: cmd.name,
      description: cmd.description + (cmd.helpText ? '\n' + cmd.helpText : ''),
      inputSchema: zodToJsonSchema(cmd.schema),
    }));
  • commands.js:132-170 (registration)
    Configuration object for the 'xxd' tool, including name, description, schema, buildCommand, and helpText, exported as part of commands.
      // XXD command - hexdump with ASCII representation
      xxd: {
        name: 'xxd',
        description: 'Create a hexdump with ASCII representation',
        schema: baseCommandSchema.extend({
          length: z.number().optional().describe("Number of bytes to display"),
          offset: z.number().optional().describe("Starting offset in the file"),
          cols: z.number().optional().describe("Format output into specified number of columns"),
          bits: z.boolean().optional().describe("Switch to bits (binary) dump")
        }),
        buildCommand: (args) => {
          let options = args.options ? args.options : '';
          
          if (args.length) {
            options += ` -l ${args.length}`;
          }
          
          if (args.offset) {
            options += ` -s ${args.offset}`;
          }
          
          if (args.cols) {
            options += ` -c ${args.cols}`;
          }
          
          if (args.bits) {
            options += ' -b';
          }
          
          return `xxd ${options} ${args.target}`;
        },
        helpText: `
    Example usage:
      - Standard xxd dump: { "target": "suspicious.exe" }
      - With length limit: { "target": "suspicious.exe", "length": 256 }
      - With column formatting: { "target": "suspicious.exe", "cols": 16 }
      - Binary bits mode: { "target": "suspicious.exe", "bits": true }
        `
      }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/abdessamad-elamrani/MalwareAnalyzerMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server