Skip to content

fofapro/vulfocus-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vulfocus-go

GitHub (pre-)release stars license

中文文档

Vulfocus API

Vulfocus API is the RESUFul API interface provided by Vulfocus for development, allowing Developers integrate Vulfocus in their own projects.

Vulfocus SDK

The GO version of SDK written based on the Vulfocus API makes it easy for Golang developers to quickly integrate Vulfocus into their projects.

Add dependency

go get github.com/fofapro/vulfocus-go

Use

field description
addr Vulfocus URL
username User login Vulfocus userbox username
licence Please go to the personal center to view API licence

Pull Images

package main

import (
    "fmt"
    "github.com/fofapro/vulfocus-go"
)

const (
    addr     = "http://vulfocus.fofa.so"
    username = ""
    licence  = ""
)

func main() {
    client := vulfocus.NewClient(addr, username, licence)
    err, images := client.GetImages()
    if err != nil {
        return
    }
    fmt.Printf("get %d images", len(images))
    if len(images) == 0 {
        return
    }
}

Start

package main

import (
	"fmt"
	"github.com/fofapro/vulfocus-go"
)

const (
    addr     = "http://vulfocus.fofa.so"
    username = ""
    licence  = ""
)

func main() {
    client := vulfocus.NewClient(addr, username, licence)
    err, images := client.GetImages()
    if err != nil {
        return
    }
    fmt.Printf("get %d images", len(images))
    if len(images) == 0 {
        return
    }
    err, exposed := client.Start(images[0].Name)
    if err != nil {
        return
    }
    println(exposed.Host, exposed.Port)
}

Stop

package main

import (
    "fmt"
    "github.com/fofapro/vulfocus-go"
)

const (
	addr     = "http://vulfocus.fofa.so"
	username = ""
	licence  = ""
)

func main() {
    client := vulfocus.NewClient(addr, username, licence)
    err, images := client.GetImages()
    if err != nil {
        return
    }
    fmt.Printf("get %d images", len(images))
    if len(images) == 0 {
        return
    }
    err = client.Stop(images[0].Name)
    if err != nil {
        return
    }
}

Delete

package main

import (
    "fmt"
    "github.com/fofapro/vulfocus-go"
)

const (
    addr     = "http://vulfocus.fofa.so"
    username = ""
    licence  = ""
)

func main() {
    client := vulfocus.NewClient(addr, username, licence)
    err, images := client.GetImages()
    if err != nil {
        return
    }
    fmt.Printf("get %d images", len(images))
    if len(images) == 0 {
        return
    }
    err = client.Delete(images[0].Name)
    if err != nil {
        return
    }
}

Update Log

2021-11-25

- Version release