分享自建FOFA 基于 Cloudflare Worker

之前用过论坛自建的fofa站点,感觉挺不错。跟风做了个。内置了闲鱼入的API 剩余20天。
(轻量使用,每日一些额度。完全失效了本帖会改标题)

https://009fofa.112210.xyz/

文本框ip那里=输出形式,可以改为host
默认输出100行,可改1万行内
点击查询后等5秒后出结果

CF Worker代码如下

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
  // HTML content
  const html = `
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>FOFA 查询工具</title>
    <style>
        body {
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            font-family: Arial, sans-serif;
        }
        .container {
            border: 1px solid #ddd;
            padding: 20px;
            border-radius: 5px;
        }
        .input-group {
            margin-bottom: 15px;
        }
        input[type="text"], input[type="number"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
        }
        button:hover {
            background-color: #45a049;
        }
        #results {
            margin-top: 20px;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            min-height: 100px;
            white-space: pre-wrap;
            font-family: monospace;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>FOFA 查询工具</h2>
        
        <div class="input-group">
            <input type="text" id="query" name="query" placeholder="请输入关键词">
        </div>
        
        <div class="input-group">
            <input type="text" id="field" name="field" placeholder="field:例如host,link,ip,country_name" value="ip">
        </div>
        
        <div class="input-group">
            <input type="number" id="size" name="size" value="100" placeholder="size">
        </div>
        
        <div class="input-group">
            <input type="number" id="page" name="page" value="1" hidden>
        </div>
        
        <button onclick="query()">查询</button>
        
        <div id="results" title="点击复制内容" onclick="copyResults()"></div>
    </div>

    <script>
        async function query() {
            const query = document.getElementById('query').value;
            const field = document.getElementById('field').value;
            const size = document.getElementById('size').value;
            const page = document.getElementById('page').value;

            if (!query) {
                document.getElementById('results').innerHTML = '错误: 关键词不能为空';
                return;
            }

            document.getElementById('results').innerHTML = '查询中...';

            try {
                const response = await fetch('/api/fofa', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        query,
                        field,
                        size,
                        page
                    })
                });

                const data = await response.json();

                if (!data.error && data.results) {
                    const resultsHtml = data.results.join('\\n');
                    
                    document.getElementById('results').innerHTML = resultsHtml || 'No results found';
                } else if (data.errmsg) {
                    document.getElementById('results').innerHTML = '错误: ' + data.errmsg;
                } else {
                    document.getElementById('results').innerHTML = '错误: ' + (data.error || '未知错误');
                }
            } catch (error) {
                document.getElementById('results').innerHTML = '查询出错: ' + error.message;
            }
        }

        function copyResults() {
            const results = document.getElementById('results');
            navigator.clipboard.writeText(results.innerText.replace(/^\d+\. /, ''))
                .then(() => alert('已复制到剪贴板'))
                .catch(err => alert('复制失败: ' + err));
        }
    </script>
</body>
</html>
  `;

  // Handle API requests
  if (request.url.includes('/api/fofa')) {
    if (request.method === 'POST') {
      try {
        const { query, field, size, page } = await request.json();
        
        if (!query) {
          return new Response(JSON.stringify({ error: '关键词不能为空' }), {
            headers: { 
              'Content-Type': 'application/json',
              'Access-Control-Allow-Origin': '*'
            }
          });
        }

        const email = "[email protected]";  
        const apiKey = "cxxxxx【你的FOFA -API-KEY】xxxxxxxx";

        const encodedQuery = btoa(query);
        const url = `https://fofa.info/api/v1/search/all?email=${encodeURIComponent(email)}&key=${encodeURIComponent(apiKey)}&qbase64=${encodedQuery}&fields=${field}&size=${size}&page=${page}`;
        
        const response = await fetch(url);
        const data = await response.json();

        if (data.error) {
          return new Response(JSON.stringify({ error: data.errmsg || '查询失败' }), {
            headers: { 
              'Content-Type': 'application/json',
              'Access-Control-Allow-Origin': '*'
            }
          });
        }
        
        return new Response(JSON.stringify(data), {
          headers: { 
            'Content-Type': 'application/json',
            'Access-Control-Allow-Origin': '*'
          }
        });
      } catch (error) {
        return new Response(JSON.stringify({ error: error.message }), {
          headers: { 
            'Content-Type': 'application/json',
            'Access-Control-Allow-Origin': '*'
          }
        });
      }
    }
  }

  // Return the HTML page for all other requests
  return new Response(html, {
    headers: {
      'Content-Type': 'text/html',
    },
  });
}

基于↓此html源代码+claude加工

36 个赞

感谢大佬分享

1 个赞

感谢大佬分享

2 个赞

好东西,感谢佬友的分享Good stuff, thanks for sharing

1 个赞

显示查询速度过快

1 个赞

偶尔会出现,F5再试一次就好了

1 个赞

感谢你的分享

感谢分享
但是用不了

感谢分享,真不错

我在想是否可以通过CF Worker直接撸免费的FOFA……
Worker自带跳IP特性

注册机放worker上跑应该可以

感谢大佬分享

1 个赞

刚看到就已经上限了 :smiling_face_with_tear:

2 个赞

感谢大佬的分享

1 个赞

感谢佬的分享,暂时还没有用上

1 个赞

感谢大佬分享

感谢分享,灰常有用

不过,貌似不太知道怎么用。例如坛里这个扫deeplx的:

body='{"code":200,"message":"DeepL Free API, Developed by sjlleo and missuo. Go to /translate with POST. http://github.com/OwO-Network/DeepLX"}'

可以在fofa网页版上扫几百个

https://009fofa.112210.xyz/ 上全是空的

感谢分享大佬厉害啊

很实用,感谢大佬分享 :xhs_033:

感谢大佬的分享!