Skip to main content
Glama
abdessamad-elamrani

MalwareAnalyzerMCP

strings

Extract printable strings from files to analyze malware by revealing embedded text, URLs, and configuration data for security investigation.

Instructions

Extract printable strings from a file

Example usage:

  • Basic strings extraction: { "target": "suspicious.exe" }

  • With minimum length: { "target": "suspicious.exe", "minLength": 10 }

  • With encoding: { "target": "suspicious.exe", "encoding": "l" }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesTarget file or data to analyze
optionsNoAdditional command-line options
minLengthNoMinimum string length to display
encodingNoString encoding (s=7-bit, S=8-bit, b=16-bit big-endian, l=16-bit little-endian, etc.)

Implementation Reference

  • The buildCommand function constructs the shell command string for the 'strings' tool by incorporating optional parameters like minLength and encoding.
    buildCommand: (args) => {
      let options = args.options ? args.options : '';
      
      if (args.minLength) {
        options += ` -n ${args.minLength}`;
      }
      
      if (args.encoding) {
        options += ` -e ${args.encoding}`;
      }
      
      return `strings ${options} ${args.target}`;
    },
  • Zod schema definition for the 'strings' tool inputs, extending base schema with minLength and encoding parameters.
    strings: {
      name: 'strings',
      description: 'Extract printable strings from a file',
      schema: baseCommandSchema.extend({
        minLength: z.number().optional().describe("Minimum string length to display"),
        encoding: z.enum(['s', 'S', 'b', 'l', 'B', 'L']).optional().describe("String encoding (s=7-bit, S=8-bit, b=16-bit big-endian, l=16-bit little-endian, etc.)")
      }),
  • serverMCP.js:112-121 (registration)
    Dynamically registers all specialized tools, including 'strings', in the MCP tools list response using their configuration from commands.js.
    // Generate tools from commands configuration
    const specializedTools = Object.values(commands).map(cmd => ({
      name: cmd.name,
      description: cmd.description + (cmd.helpText ? '\n' + cmd.helpText : ''),
      inputSchema: zodToJsonSchema(cmd.schema),
    }));
    
    return {
      tools: [...basicTools, ...specializedTools],
    };
  • MCP tool call handler for specialized commands like 'strings': schema validation, command building, execution via terminalManager, and result formatting.
    // Check if this is a specialized command
    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,
        };
      }
    }

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