Skip to main content
Glama

SpiderFoot MCP Server

inspect-scan-form.js5.63 kB
// Script to inspect the SpiderFoot scan form submission import axios from 'axios'; import * as cheerio from 'cheerio'; import { CookieJar } from 'tough-cookie'; import { wrapper as axiosCookieJarSupport } from 'axios-cookiejar-support'; const SPIDERFOOT_URL = 'http://localhost:5001'; async function inspectScanForm() { try { console.log('Inspecting SpiderFoot scan form...'); // Create a cookie jar to maintain session const cookieJar = new CookieJar(); // Create axios instance with cookie support const client = axios.create({ baseURL: SPIDERFOOT_URL, headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5', }, jar: cookieJar, // Use the cookie jar withCredentials: true, maxRedirects: 0, validateStatus: null // Allow all status codes }); // Enable cookie support axiosCookieJarSupport(client); // 1. First, get the new scan page to get the form console.log('\n1. Fetching new scan page...'); const newScanResponse = await client.get('/newscan'); console.log('Status:', newScanResponse.status); // Parse the HTML const $ = cheerio.load(newScanResponse.data); // 2. Find the form const form = $('form'); if (form.length === 0) { throw new Error('No form found on the page'); } console.log('\n2. Found form with the following details:'); console.log('Action:', form.attr('action') || '(default)'); console.log('Method:', form.attr('method') || 'GET'); // 3. Find all input fields in the form const inputs = form.find('input, select, textarea, button'); console.log(`\n3. Found ${inputs.length} form inputs:`); const formData = new URLSearchParams(); inputs.each((i, input) => { const $input = $(input); const name = $input.attr('name'); const type = $input.attr('type') || 'text'; const value = $input.attr('value') || ''; const id = $input.attr('id') || ''; const checked = $input.is(':checked') || false; console.log(`\nInput #${i + 1}:`); console.log('- Type:', type); console.log('- Name:', name || '(unnamed)'); console.log('- ID:', id || 'N/A'); console.log('- Value:', value); console.log('- Checked:', checked); // Add to form data if it has a name if (name) { // Handle checkboxes and radio buttons if ((type === 'checkbox' || type === 'radio') && !checked) { // Skip unchecked checkboxes/radios return; } formData.append(name, value); } }); // 4. Print the form data that would be submitted console.log('\n4. Form data that would be submitted:'); console.log(formData.toString()); // 5. Try to submit the form with minimal required fields console.log('\n5. Attempting to submit the form with minimal data...'); // Create minimal form data with required fields const minimalFormData = new URLSearchParams(); minimalFormData.append('scanname', `test-scan-${Date.now()}`); minimalFormData.append('scantarget', 'example.com'); // Try to find and add required fields if (formData.has('type')) { minimalFormData.append('type', formData.get('type')); } if (formData.has('usecase')) { minimalFormData.append('usecase', formData.get('usecase')); } else { minimalFormData.append('usecase', 'all'); } // Submit the form const submitResponse = await client.post( form.attr('action') || '/startscan', minimalFormData.toString(), { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Referer': `${SPIDERFOOT_URL}/newscan`, }, maxRedirects: 0 } ); console.log('\n6. Form submission response:'); console.log('Status:', submitResponse.status); console.log('Headers:', submitResponse.headers); if (submitResponse.status === 302) { console.log('Redirecting to:', submitResponse.headers.location); // Follow the redirect const redirectResponse = await client.get(submitResponse.headers.location, { maxRedirects: 5 }); console.log('\n7. Followed redirect:'); console.log('Status:', redirectResponse.status); console.log('Final URL:', redirectResponse.request.res.responseUrl); // Check if we're on the scans page if (redirectResponse.request.res.responseUrl.includes('/scans')) { console.log('\nSuccessfully submitted scan!'); } else { console.log('\nUnexpected redirect. Response data:'); console.log(redirectResponse.data); } } else { console.log('\nUnexpected response. Status:', submitResponse.status); console.log('Response data:', submitResponse.data); } } catch (error) { console.error('Error inspecting form:', error.message); if (error.response) { console.error('Response status:', error.response.status); console.error('Response headers:', error.response.headers); console.error('Response data (first 500 chars):', typeof error.response.data === 'string' ? error.response.data.substring(0, 500) : JSON.stringify(error.response.data).substring(0, 500)); } } } inspectScanForm();

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/CorbettCajun/Spiderfoot-MCP-Server'

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