gofofa

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2022 License: MIT Imports: 12 Imported by: 0

README

gofofa

fofa client in Go

背景

之前官方的库功能不全,代码质量差,完全没有社区活跃度,不符合开源项目的基本要求。因此,想就fofa的客户端作为练手,解决上述问题。

需求列表

  • 跨平台
    • Windows
    • Linux
    • Mac
  • 完善的文档
  • 代码测试覆盖度超过80%
  • 可以作为SDK
  • 子命令
    • 用户信息 account
    • 搜索原始数据 search
      • 指定查询语句 query
      • 指定字段 fields
      • 指定获取的数据量 size
      • 输出格式 outFormat
        • 输出csv格式
        • 输出json格式
        • 输出xml格式
        • 输出table格式
    • 查询聚合结果
    • 单IP聚合查询
  • 完善的版本管理
  • 完善的Issue管理
  • 支持终端颜色
  • 支持发布到各平台
    • brew
    • apt
    • yum
    • github
  • 配置形式多样化
    • 支持环境变量设置fofa配置
      • FOFA_CLIENT_URL 格式:/?email=&key=&version=
      • FOFA_SERVER
      • FOFA_EMAIL
      • FOFA_KEY
    • 支持命令行设置fofa配置
      • fofaURL
      • deductMode 扣费的模式下提醒用户是否继续
  • 子命令自动提示

API设计规范v2

  • 所有接口都应该满足如下定义:
错误
{
    "error": true,
    "errmsg": "Account Invalid",
    "code": -700
}
正确
{
    "error": false,
    "data": {
        "fcoin": 1000
    }
}
  • 分为几个基础模块
    • account
      • profile
    • host
  • 账号认证设计
    • 是header传递还是url传递好一点?
    • 是只传递key还是传递email/key好一点?

使用场景

获取版本信息

版本信息跟代码tag一致

获取用户信息

获取vip等级,积分信息等

获取原始数据

Documentation

Overview

Package gofofa fofa client in Go

env settings: - FOFA_CLIENT_URL full fofa connnection string, format: <url>/?email=<email>&key=<key>&version=<v2> - FOFA_SERVER fofa server - FOFA_EMAIL fofa account email - FOFA_KEY fofa account key

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FofaURLFromEnv

func FofaURLFromEnv() string

Types

type AccountInfo

type AccountInfo struct {
	Error    bool   `json:"error"`     // error or not
	ErrMsg   string `json:"errmsg"`    // error string message
	FCoin    int    `json:"fcoin"`     // fcoin count
	IsVIP    bool   `json:"isvip"`     // is vip
	VIPLevel int    `json:"vip_level"` // vip level
}

AccountInfo fofa account info

func (AccountInfo) String

func (ai AccountInfo) String() string

type Client

type Client struct {
	Server     string // can set local server for debugging, format: <scheme>://<host>
	APIVersion string // api version
	Email      string // fofa email
	Key        string // fofa key

	Account    AccountInfo // fofa account info
	DeductMode DeductMode  // 扣费提醒默认
	// contains filtered or unexported fields
}

Client of fofa connection

func NewClient

func NewClient(configURL string) (*Client, error)

NewClient from fofa connection string to config and with env config merge configURL format: <url>/?email=<email>&key=<key>&version=<v2>&tlsdisabled=false&debuglevel=0

func (*Client) AccountInfo

func (c *Client) AccountInfo() (ac AccountInfo, err error)

AccountInfo fetch account info from fofa

func (*Client) HostSearch

func (c *Client) HostSearch(query string, size int, fields []string) (res [][]string, err error)

HostSearch search fofa host data query fofa query string size data size: -1 means all,0 means just data total info, >0 means actual size fields field of fofa host struct

func (*Client) URL

func (c *Client) URL() string

func (*Client) Update

func (c *Client) Update(configURL string) error

Update merge config from config url

type DeductMode

type DeductMode int // 扣费模式
const (
	DeductModeFree  DeductMode = 0 // 不自动扣费
	DeductModeFCoin            = 1 // 自动扣除F币
)

func ParseDeductMode

func ParseDeductMode(v string) DeductMode

type HostResults

type HostResults struct {
	Mode    string
	Error   bool
	Errmsg  string
	Query   string
	Page    int
	Size    int
	Results [][]string
}

Directories

Path Synopsis
cmd
fofa command
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL