This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
/
summary.go
56 lines (47 loc) · 1.7 KB
/
summary.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"github.com/Ullaakut/disgo"
"github.com/Ullaakut/disgo/style"
)
func printSummary(targets []vulnerableDockerAPI) {
term := disgo.NewTerminal()
if len(targets) == 0 {
term.Errorln(style.Failure(style.SymbolCross), "No vulnerable Docker containers were found. Please make sure that your target is on an accessible network.")
return
}
for _, target := range targets {
term.Infoln(style.Success(style.SymbolRightTriangle), "Vulnerable docker API found:")
term.Infof(" Endpoint address:\t%s\n", style.Link(target.Host))
term.Infof(" Endpoint API port:\t%v\n", target.Port)
term.Infof(" Docker version:\t%s\n", target.DockerVersion)
if target.SocketError != nil {
term.Infof(" Docker API was unreachable:\t%s\n", style.Failure(target.SocketError))
} else {
term.Infof(" Operating system:\t%s\n", target.Info.OS)
if len(target.Containers) > 0 {
term.Infof("\n %s running containers:\n", style.Success(len(target.Containers)))
for _, container := range target.Containers {
term.Infof(" %s %+v\n", container.Image, container.Ports)
}
} else {
fmt.Println(" No running containers")
}
if len(target.Images) > 0 {
term.Infof("\n %s available images:\n", style.Success(len(target.Images)))
for _, image := range target.Images {
term.Infof(" %s\n", image)
}
} else {
fmt.Println(" No available images")
}
}
}
var summaryStr string
if len(targets) == 1 {
summaryStr = "\n%s Successful attack: %s device was accessed"
} else {
summaryStr = "\n%s Successful attack: %s devices were accessed"
}
term.Infof(summaryStr, style.Success(style.SymbolCheck), style.Success(len(targets)))
}