我花了3个月研究基于图像的攻击。
I Spent 3 Months Researching Image-Based Attacks

原始链接: https://zero-trust-web.vercel.app/

这段代码演示了如何使用“zero-trust-api.p.rapidapi.com”端点重建图像,并在多种编程语言中展示。核心功能涉及通过POST请求将图像文件(例如JPG)发送到API,包括API密钥和host头部进行身份验证。 提供了JavaScript(浏览器和Node.js)、Python、Java、React和cURL的实现。每个版本都读取输入图像,准备带有适当头部(指定内容类型)的请求,将图像数据发送到API,然后保存或显示重建的图像(通常为PNG)。 API似乎处理图像并返回重建的版本,然后将其写入文件或在浏览器中显示。所有示例都遵循共同模式:读取图像、POST到API以及保存/显示结果,并以“✅ Image rebuilt!”消息确认重建成功。

## 基于图像的攻击 API 总结 一位开发者在朋友的 SaaS 应用因恶意图像文件被攻击后,构建了一个安全 API “零信任 API”。传统的图像“清理”方法(如去除元数据)不足以应对隐藏在图像文件中的威胁——多语言文件、隐写术和图像炸弹。 实施的解决方案是内容解除与重构 (CDR):提取安全的像素数据并重建图像,创建数学上“干净”的文件。该 API 使用 Rust 和 WebAssembly 构建,以确保内存安全、速度以及通过 Cloudflare Workers 进行边缘部署。它提供慷慨的免费层级以建立信任并鼓励采用。 开发者强调了专注细分市场的重要性,将有价值的文档作为营销手段,以及构建长期可靠性。一位评论者建议专注于集成,例如浏览器扩展和代理服务器插件,以触达企业客户,并通过专利和许可攻击数据来保护知识产权。
相关文章

原文

📋 Copy

// JavaScript (Browser)
const fileInput = document.getElementById('imageInput');
const file = fileInput.files[0];

const response = await fetch('https://zero-trust-api.p.rapidapi.com/', {
  method: 'POST',
  headers: {
    'x-rapidapi-key': 'YOUR_API_KEY',
    'x-rapidapi-host': 'zero-trust-api.p.rapidapi.com',
    'Content-Type': file.type
  },
  body: file
});

const rebuiltBlob = await response.blob();
const url = URL.createObjectURL(rebuiltBlob);
document.getElementById('result').src = url;

📋 Copy

// Node.js
const fs = require('fs');
const axios = require('axios');

const imageBuffer = fs.readFileSync('input.jpg');

const response = await axios.post(
  'https://zero-trust-api.p.rapidapi.com/',
  imageBuffer,
  {
    headers: {
      'x-rapidapi-key': 'YOUR_API_KEY',
      'x-rapidapi-host': 'zero-trust-api.p.rapidapi.com',
      'Content-Type': 'image/jpeg'
    },
    responseType: 'arraybuffer'
  }
);

fs.writeFileSync('rebuilt.png', response.data);
console.log('✅ Image rebuilt!');

📋 Copy

# Python
import requests

with open('input.jpg', 'rb') as f:
    image_data = f.read()

response = requests.post(
    'https://zero-trust-api.p.rapidapi.com/',
    headers={
        'x-rapidapi-key': 'YOUR_API_KEY',
        'x-rapidapi-host': 'zero-trust-api.p.rapidapi.com',
        'Content-Type': 'image/jpeg'
    },
    data=image_data
)

with open('rebuilt.png', 'wb') as f:
    f.write(response.content)
print('✅ Image rebuilt!')

📋 Copy

// Java
import java.net.http.*;
import java.nio.file.*;

HttpClient client = HttpClient.newHttpClient();

byte[] imageBytes = Files.readAllBytes(Path.of("input.jpg"));

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://zero-trust-api.p.rapidapi.com/"))
    .header("x-rapidapi-key", "YOUR_API_KEY")
    .header("x-rapidapi-host", "zero-trust-api.p.rapidapi.com")
    .header("Content-Type", "image/jpeg")
    .POST(HttpRequest.BodyPublishers.ofByteArray(imageBytes))
    .build();

HttpResponse<byte[]> response = client.send(request, 
    HttpResponse.BodyHandlers.ofByteArray());

Files.write(Path.of("rebuilt.png"), response.body());
System.out.println("✅ Image rebuilt!");

📋 Copy

// React Component
import { useState } from 'react';

function ImageRebuilder() {
  const [result, setResult] = useState(null);

  const rebuildImage = async (e) => {
    const file = e.target.files[0];
    
    const response = await fetch('https://zero-trust-api.p.rapidapi.com/', {
      method: 'POST',
      headers: {
        'x-rapidapi-key': 'YOUR_API_KEY',
        'x-rapidapi-host': 'zero-trust-api.p.rapidapi.com',
        'Content-Type': file.type
      },
      body: file
    });
    
    const blob = await response.blob();
    setResult(URL.createObjectURL(blob));
  };

  return (
    <div>
      <input type="file" accept="image/*" onChange={rebuildImage} />
      {result && <img src={result} alt="Rebuilt" />}
    </div>
  );
}

📋 Copy

# cURL
curl -X POST 'https://zero-trust-api.p.rapidapi.com/' \
  -H 'x-rapidapi-key: YOUR_API_KEY' \
  -H 'x-rapidapi-host: zero-trust-api.p.rapidapi.com' \
  -H 'Content-Type: image/jpeg' \
  --data-binary @input.jpg \
  --output rebuilt.png

echo "✅ Image rebuilt!"
联系我们 contact @ memedata.com