FOFA EX

repository·master·Indexed 42 days ago

https://github.com/10cks/fofaex

A red team utility designed to enhance FOFA API capabilities. Written in Java 11, it provides a GUI for advanced searching, automated asset probing via a bidirectional plugin system (supporting tools like httpx, nuclei, and dirsearch), and efficient data management. Features include iconHash calculation, custom search rule buttons, and support for importing CSV, XLSX, and JSON data.

Tokens
5.6K
Snippets
11
Records
33
Agent score
53%

What's inside FOFA EX

  1. How the plugin system works in fofaEX

    master

    fofaEX uses a bidirectional plugin architecture. It can act as a consumer of third-party tools (input-type plugins) or as a provider for them (output-type plugins).

    Input-type plugins: Third-party tools (like fofa-hack, httpX, or dirsearch) provide data to fofaEX via a JSON configuration file located in fofaExPluginLog/. The flow is: Third-party tool -> toolName.json -> fofaEX.

    Output-type plugins: fofaEX provides data to third-party tools. The flow is: fofaEX -> toolName.json -> Third-party tool.

  2. Create a new plugin for fofaEX

    master

    To register a new plugin (e.g., named httpX), you must follow the plugin registration template which automates the generation of UI elements.

    When a plugin is correctly registered, fofaEX automatically generates:

    1. Plugin Mode Additions: New entries for 'Run' (运行), 'Settings' (设置), and 'About' (关于).
    2. UI Components: A new entry in the JTabbedPane and new options in the right-click context menu.

    The application discovers plugins by reading ./plugins/AllPlugins.txt, which points to the specific setting files (e.g., httpx/httpxSetting.txt).

  3. Install and use plugins in fofaEX

    master

    fofaEX supports an extensible plugin system. You can extend the functionality of the tool by downloading and installing public plugins.

    Available plugins include:

    • fofa-hack
    • httpX
    • nuclei
    • ip2domain (IP to domain reverse lookup)
    • domain2icp (Domain to ICP filing reverse lookup)

    Plugins can be downloaded from the official public plugins repository.

    https://github.com/10cks/fofaEX_PublicPlugins
  4. Configure and use plugins (e.g., httpx)

    master

    FOFA EX supports a plugin mode for automated asset detection (e.g., httpx for live probing).

    Directory Structure:

    .
    ├── fofaEX.jar
    ├── plugins
    │   ├── AllPlugins.json
    │   └── httpx
    │       ├── httpx.exe
    │       └── httpxSetting.json
    ├── rules.txt
    └── run.bat

    1. Enable/Disable Plugins: Edit plugins/AllPlugins.json to toggle plugins on or off:

    {
        "dirsearch": false,
        "httpx": true
    }

    2. Configure Plugin Settings: Each plugin requires a configuration file named <plugin_name>Setting.json (e.g., httpxSetting.json). For the httpx plugin, the configuration includes:

    • Path: Path to the plugin executable.
    • Params: Default command-line arguments.
    • InputFile: The data file generated by FOFA EX (./coredata/FofaEX.json).
    • InputTarget: Defines which column from the FOFA data to use as input (e.g., selectColumn: "link").
    • OutputFile: Where the plugin saves its results.
    • OutputTarget: Which columns from the plugin output should be displayed in the FOFA EX interface.

    macOS Support: To use plugins on macOS:

    1. Download the macOS binary for the tool (e.g., httpx) from its official repository.
    2. Replace the .exe file in plugins/httpx/ with the macOS binary.
    3. Update httpxSetting.json so the Path points to the macOS binary (e.g., ./plugins/httpx/httpx).
    4. Ensure the binary has execution permissions (chmod +x).
    {
        "Run":{
            "Path":"./plugins/httpx/httpx.exe",
            "Params":{
                "-duc":"",
                "-l":"./plugins/httpx/input.txt",
                "-status-code":"",
                "-o":"./plugins/httpx/HttpX.json",
                "-nc":"",
                "-j":""
            },
            "InputFile":"./coredata/FofaEX.json",
            "InputTarget":{
                "selectParam":"-l",
                "selectColumn":"link"
            },
            "OutputFile":"./plugins/httpx/HttpX.json",
            "OutputTarget":["url","port","title","status_code"]
        }
    }
  5. Configure FOFA account settings

    master

    To use FOFA API features, you must enter your email and API key in the client.

    • FOFA API: Currently, you only need to input your FOFA key to call the API; setting an email is optional for FOFA.
    • Persistence: Once logged in, your account information is saved locally in a file named accounts.txt.
    • Account Check: You can use the 'Check Account' feature to view your current account status. Note that for some membership types, the points may display as -1, which is normal behavior.
  6. Manage quick input rules

    master

    You can save frequently used search syntaxes as quick-access buttons.

    • Usage: Click a button to quickly input the syntax (the button will highlight in red). Click it again to undo the input.
    • Customization: You can add, edit, or delete these buttons in real-time.
    • Configuration: The button definitions are stored in the rules.txt file located in the current directory.
  7. Install and run FOFA EX

    master

    FOFA EX is a red team tool based on the FOFA API. It is written in Java 11 and is optimized for that runtime.

    Requirements:

    • Java 11 (Recommended for best UI and features)
    • Java 8 (Supported only up to version 2.2)

    Manual Execution: To ensure correct character encoding, run the JAR file using the following command:

    java "-Dfile.encoding=UTF-8" -jar ./fofaEX.jar
    java "-Dfile.encoding=UTF-8" -jar ./fofaEX.jar
  8. Use the Plugin Mode and Experimental Features

    master

    The application includes a "实验功能" (Experimental Features) menu which hosts several advanced capabilities:

    • 插件模式 (Plugin Mode): Loads external plugins using CommonTemplate.addMenuItemsFromFile. This includes sub-modes like:
      • Auto-Mode: For automated task execution.
      • Fofa-Hack: A specialized suite of tools.
    • iconHash 计算: A tool for calculating icon hashes.
    • 打开文件 (Open File): For importing data.
    • 测试模式 (Test Mode): Includes focus and jump testing utilities.
  9. Manage FOFA API credentials and settings

    master

    The application provides a menu for managing FOFA API credentials. Through the "账户设置" (Account Settings) menu, users can access the "FOFA API" configuration. The application internally tracks several configuration files:

    • rules.txt: Stores custom search rule buttons (key-value pairs).
    • accounts.json: Stores account-related information.

    During initialization, the GUI provides input fields for fofaUrl, fofaEmail, and fofaKey to facilitate API authentication.

  10. Use Auto Mode for command sequences

    master

    Auto Mode allows you to execute a sequence of commands defined in a flow string.

    Flow Format: Commands are separated by -> and can include parenthetical metadata, e.g., CommandA(metadata) -> CommandB.

    Behavior:

    1. The application parses the flow and extracts command names.
    2. It executes commands sequentially using item.doClick().
    3. It waits for each command to finish by monitoring the isCurrentCommandFinished flag.
    4. The UI provides visual feedback by highlighting the current command in red and completed commands in green.
  11. How search results are processed and displayed

    master

    The application follows a specific lifecycle to fetch and render FOFA data:

    1. Query Construction: The application builds a comma-separated string of requested fields (fieldsTotal) based on user selections.
    2. API Execution: It calls FofaAPI.getAllJsonResult(...) using the provided domain, email, API key, query, and pagination parameters.
    3. Data Extraction: The JSON response is parsed. The application extracts the results list and the total size (size).
    4. Column Mapping: Results are mapped into a SearchResults object. The application uses FofaAPI.getColumn(allShow, i) to extract specific columns from the 2D results array.
    5. Table Rendering: The showResultsInTable method constructs a DefaultTableModel with the selected columns and populates it with the retrieved data. It also applies a TableRowSorter to allow users to sort the data within the GUI.
  12. Configure fofahack settings

    master
    To configure the fofahack plugin, the application attempts to open the configuration file located at .\plugins\fofahack\FofaHackSetting.txt using the system's default text editor. If the file does not exist, an error message is displayed.