package com.optix.android.tools.exploit

import com.optix.android.domain.model.ParamType
import com.optix.android.domain.model.ToolCategory
import com.optix.android.domain.model.ToolEvent
import com.optix.android.domain.model.ToolMetadata
import com.optix.android.domain.model.ToolParam
import com.optix.android.tools.registry.BaseTool

/** ARP Spoofer — requires root. Stub implementation. */
class ArpSpooferTool : BaseTool() {

    override val metadata = ToolMetadata(
        name = "arp_spoofer",
        displayName = "ARP Spoofer",
        description = "Perform ARP spoofing for MITM attacks (requires root)",
        category = ToolCategory.EXPLOITATION,
        requiresRoot = true,
        parameters = listOf(
            ToolParam("target_ip", ParamType.STRING, "Target IP to spoof"),
            ToolParam("gateway_ip", ParamType.STRING, "Gateway IP"),
            ToolParam("interface", ParamType.STRING, "Network interface", required = false, defaultValue = "wlan0"),
        ),
    )

    override suspend fun execute(params: Map<String, Any>, emit: suspend (ToolEvent) -> Unit) {
        emit(ToolEvent.Error("ARP Spoofer requires root access. Device is not rooted or root was denied."))
        emit(ToolEvent.ChainSuggestion("packet_sniffer", mapOf("interface" to "wlan0")))
        emit(ToolEvent.Done)
    }
}
