- 博客(23)
- 收藏
- 关注
原创 匹配例子
package mainimport ( "bufio" "crypto/md5" "encoding/hex" "encoding/json" "fmt" "io" "log" "os" "strings" "github.com/fearful-symmetry/garlic" ac "github.com/cloudflare/ahocorasick" "gi...
2019-11-18 01:19:20
271
原创 进程md5值
package mainimport ( "crypto/md5" "encoding/hex" "fmt" "io" "log" "os")func filemd5(filePath string) string { file, _ := os.Open(filePath) defer file.Close() h := md5.New() io.Copy(h, f...
2019-11-17 21:06:04
1106
原创 获取本地ip地址
package mainimport ( "fmt" "net" "strings")func main() { conn, _ := net.Dial("tcp", "baidu.com:80") fmt.Println(strings.Split(conn.LocalAddr().String(),":")[0])}
2019-11-16 11:01:04
323
原创 获取网卡link状态
获取网卡link状态package mainimport ( "fmt" "log" "net" "github.com/safchain/ethtool")func main() { ethHandle, err := ethtool.NewEthtool() if err != nil { panic(err.Error()) } defer ethHand...
2019-11-11 16:11:33
1012
原创 docker执行命令和返回
import dockerclientl = docker.APIClient(base_url='unix://var/run/docker.sock')ex = clientl.exec_create("ef8b2201699b",cmd="cat /etc/passwd")response = clientl.exec_start(ex)print(response)
2019-05-28 11:55:01
2016
原创 boltdb存储容器实例信息
package mainimport (“fmt”“log”“strconv”"github.com/boltdb/bolt"docker "github.com/fsouza/go-dockerclient")func AddPid(db *bolt.DB, pid string, containerid string) error {err := db.Update(fun...
2019-05-23 16:15:59
436
原创 列出容器的pid
package mainimport ( "fmt" "log" docker "github.com/fsouza/go-dockerclient")func main() { client, err := docker.NewClient("unix:///var/run/docker.sock") if err != nil { log.Fatal(err) }...
2019-05-23 15:33:05
550
原创 golang bash执行命令并返回结果
package mainimport ( "bytes" "fmt" "os/exec")func exec_shell(s string) (string, error) { //函数返回一个*Cmd,用于使用给出的参数执行name指定的程序 cmd := exec.Command("/bin/bash", "-c", s) //读取io.Writer类型的cmd.Std...
2019-05-23 09:32:50
4709
原创 golang随机生成hostname
func genHostName() string { str := "0123456789abcdefghijklmnopqrstuvwxyz" bytes := []byte(str) hostname := []byte{} r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < 12; i++...
2019-05-21 13:57:24
910
原创 golang随机生成ip地址
func genIpaddr() string { rand.Seed(time.Now().Unix()) ip := fmt.Sprintf("%d.%d.%d.%d", rand.Intn(255), rand.Intn(255), rand.Intn(255), rand.Intn(255)) return ip}
2019-05-21 13:48:40
3641
转载 ASCII table in golang
#包 https://github.com/olekukonko/tablewriter#例子package mainimport ( "os" "github.com/olekukonko/tablewriter")func main() { data := [][]string{ []string{"1/1/2014", "Domain name", "2233"...
2019-05-21 10:39:19
340
原创 yaml规则匹配
test.yamlrule: author: osk created: 2019-5-14 description: information collection actions: 1: cat /etc/passwd 2: cat /etc/issueos: Linuxname: Reconuuid: 01dfdaa3-0e14-467d-9bc8-e0...
2019-05-17 23:33:32
1536
原创 garlic实现进程监控
#依赖包github.com/fearful-symmetry/garlic#原理netlink_connectorpackage mainimport ( "bufio" "fmt" "log" "os" "github.com/fearful-symmetry/garlic")func getCmdLine(pid uint32) string { path ...
2019-05-16 16:15:45
298
原创 InspectContainer networksetting
package mainimport ( "fmt" "log" docker "github.com/fsouza/go-dockerclient")func main() { client, err := docker.NewClient("unix:///var/run/docker.sock") if err != nil { log.Fatal(err) }...
2019-05-16 14:44:55
173
原创 InspectContainer pid
package mainimport ( "fmt" "log" docker "github.com/fsouza/go-dockerclient")func main() { client, err := docker.NewClient("unix:///var/run/docker.sock") if err != nil { log.Fatal(err) }...
2019-05-16 14:41:13
106
原创 golang解析snort规则
package mainimport ( "fmt" "github.com/google/gonids")func main() { rule := `alert tcp $HOME_NET any -> $EXTERNAL_NET 80 (msg:"GONIDS TEST hello world"; flow:established,to_server; content...
2019-05-16 14:32:30
492
原创 golang获取网卡信息
package mainimport ( "fmt" "os/exec" "strings" "github.com/safchain/ethtool")func main() { baseNicPath := "/sys/class/net/" cmd := exec.Command("ls", baseNicPath) buf, err := cmd.Output()...
2019-05-16 14:31:39
5467
原创 InspectContainer例子
package mainimport ( "fmt" "log" docker "github.com/fsouza/go-dockerclient")func main() { client, err := docker.NewClient("unix:///var/run/docker.sock") if err != nil { log.Fatal(err) }...
2019-05-16 14:15:46
219
原创 golang string2hex
package mainimport ( "encoding/hex" "fmt")func main() { str := "Hello Gopher!" src := []byte(str) dst := hex.EncodeToString(src) var output string for i := 0; i < len(dst); i++ { if i...
2019-05-15 15:46:07
1137
原创 docker api实现dockerversion
package mainimport ( "fmt" "log" docker "github.com/fsouza/go-dockerclient")func main() { client, err := docker.NewClient("unix:///var/run/docker.sock") if err != nil { log.Fatal(err) }...
2019-05-15 14:29:06
585
原创 docker client api实现docker info
package mainimport ( "fmt" "log" docker "github.com/fsouza/go-dockerclient")func main() { client, err := docker.NewClient("unix:///var/run/docker.sock") if err != nil { log.Fatal(err) }...
2019-05-15 14:20:01
817
原创 docker clinent api实现docker exec
#docker clinent api实现docker execpackage mainimport ( "log" "os" docker "github.com/fsouza/go-dockerclient")func main() { client, err := docker.NewClient("unix:///var/run/docker.sock") if ...
2019-05-15 13:40:08
1046
原创 获取macthine id的方法
获取macthine id的方法第三方模块原理第三方模块https://github.com/denisbrodbeck/machineid原理BSD uses /etc/hostid and smbios.system.uuid as a fallbackLinux uses /var/lib/dbus/machine-id /etc/machine-idOS X uses IO...
2019-05-14 20:37:40
1562
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人