Skip to content

x #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 3, 2022
Merged

x #67

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ mkdir ~/MyWork/;cd ~/MyWork/;git clone https://github.com/hktalent/log4j-scan
````
- Intelligently identify honeypots and skip targets. This function is disabled by default. You can set EnableHoneyportDetection=true to enable
- Highly customizable: allow to define your own dictionary through config/config.json configuration, or control more details, including but not limited to: nuclei, httpx, naabu, etc.
- support HTTP Request Smuggling: CL-TE、TE-CL、TE-TE
- support HTTP Request Smuggling: CL-TE、TE-CL、TE-TE、CL_CL、BaseErr
<img width="968" alt="image" src="https://user-images.githubusercontent.com/18223385/182503765-1307a634-61b2-4f7e-9631-a4184ec7ac25.png">
- Support via parameter Cookie='PHPSession=xxxx' ./scan4all -host xxxx.com, compatible with nuclei, httpx, go-poc, x-ray POC, filefuzz, http Smuggling
# work process
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ require (
github.com/projectdiscovery/nuclei/v2 v2.7.5
github.com/projectdiscovery/subfinder/v2 v2.5.2
github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil/v3 v3.22.7
github.com/sijms/go-ora/v2 v2.4.25
github.com/simonnilsson/ask v0.2.0
github.com/spf13/viper v1.12.0
github.com/stacktitan/smb v0.0.0-20190531122847-da9a425dceb8
github.com/tj/go-update v2.2.5-0.20200519121640-62b4b798fd68+incompatible
Expand Down Expand Up @@ -241,8 +243,6 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/shirou/gopsutil/v3 v3.22.6 // indirect
github.com/simonnilsson/ask v0.2.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,9 @@ github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c
github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shirou/gopsutil/v3 v3.21.7/go.mod h1:RGl11Y7XMTQPmHh8F0ayC6haKNBgH4PXMJuTAcMOlz4=
github.com/shirou/gopsutil/v3 v3.22.6 h1:FnHOFOh+cYAM0C30P+zysPISzlknLC5Z1G4EAElznfQ=
github.com/shirou/gopsutil/v3 v3.22.6/go.mod h1:EdIubSnZhbAvBS1yJ7Xi+AShB/hxwLHOMz4MCYz7yMs=
github.com/shirou/gopsutil/v3 v3.22.7 h1:flKnuCMfUUrO+oAvwAd6GKZgnPzr098VA/UJ14nhJd4=
github.com/shirou/gopsutil/v3 v3.22.7/go.mod h1:s648gW4IywYzUfE/KjXxUsqrqx/T2xO5VqOXxONeRfI=
github.com/sijms/go-ora/v2 v2.4.25 h1:PtyMsRGHd6FNttdaMEg4NdHuRYxg29NKwsxPuTmCEJ4=
github.com/sijms/go-ora/v2 v2.4.25/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk=
github.com/simonnilsson/ask v0.2.0 h1:CpiQtuLyRlrPNVk6aQjaFL51XmBlCIxaqssxentXBBA=
Expand Down
171 changes: 171 additions & 0 deletions lib/util/sysinfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
package util

import (
"fmt"
"github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/disk"
"github.com/shirou/gopsutil/v3/host"
"github.com/shirou/gopsutil/v3/mem"
"github.com/shirou/gopsutil/v3/net"
systemNet "net"
"strconv"
"time"
)

// 分区
type Part struct {
Path string `json:"path"`
FsType string `json:"fstype"`
Total float64 `json:"total"`
Free float64 `json:"free"`
Used float64 `json:"used"`
UsedPercent int `json:"usedPercent"`
}

// 分区集合
type Parts []Part

// CPU
type CpuSingle struct {
Num string `json:"num"`
Percent int `json:"percent"`
}

type CpuInfo struct {
CpuAvg float64 `json:"cpuAvg"`
CpuAll []CpuSingle `json:"cpuAll"`
}

const GB = 1024 * 1024 * 1024

func decimal(v string) float64 {
value, _ := strconv.ParseFloat(v, 64)
return value
}

// 1.主机IP
func GetLocalIP() (ip string) {
addresses, err := systemNet.InterfaceAddrs()
if err != nil {
return ""
}
for _, addr := range addresses {
ipAddr, ok := addr.(*systemNet.IPNet)
if !ok {
continue
}
if ipAddr.IP.IsLoopback() {
continue
}
if !ipAddr.IP.IsGlobalUnicast() {
continue
}
return ipAddr.IP.String()
}
return ""
}

// 2.主机信息
func GetHostInfo() (result *host.InfoStat, err error) {
result, err = host.Info()
return result, err
}

// 3.磁盘信息
func GetDiskInfo() (result Parts, err error) {
parts, err := disk.Partitions(true)
if err != nil {
return result, err
}
for _, part := range parts {
diskInfo, err := disk.Usage(part.Mountpoint)
if err == nil {
result = append(result, Part{
Path: diskInfo.Path,
FsType: diskInfo.Fstype,
Total: decimal(fmt.Sprintf("%.2f", float64(diskInfo.Total/GB))),
Free: decimal(fmt.Sprintf("%.2f", float64(diskInfo.Free/GB))),
Used: decimal(fmt.Sprintf("%.2f", float64(diskInfo.Used/GB))),
UsedPercent: int(diskInfo.UsedPercent),
})
} else {
return result, err
}
}
return result, err
}

// 4.CPU使用率
func GetCpuPercent() (result CpuInfo, err error) {
infos, err := cpu.Percent(1*time.Second, true)
if err != nil {
return result, err
}
var total float64 = 0
for index, value := range infos {
result.CpuAll = append(result.CpuAll, CpuSingle{
Num: fmt.Sprintf("#%d", index+1),
Percent: int(value),
})
total += value
}
result.CpuAvg = decimal(fmt.Sprintf("%.1f", total/float64(len(infos))))
return result, err
}

// 5.内存信息
func GetMemInfo() (float64, []map[string]interface{}) {
info, err := mem.VirtualMemory()
if err != nil {
fmt.Println(err)
return 0, nil
}
return decimal(fmt.Sprintf("%.1f", info.UsedPercent)), []map[string]interface{}{
{"key": "使用率[%]", "value": decimal(fmt.Sprintf("%.1f", info.UsedPercent))},
{"key": "总量[GB]", "value": int(info.Total / GB)},
{"key": "使用量[GB]", "value": int(info.Used / GB)},
{"key": "剩余量[GB]", "value": int(info.Free / GB)},
}
}

// 6.获取网卡信息
func GetNetInfo() (result []net.IOCountersStat, err error) {
info, err := net.IOCounters(true)
if err != nil {
return result, err
}
return info, err
}

// 7.计算上下行带宽
func GetNetSpeed() (speed map[string]map[string]uint64, err error) {
speed = map[string]map[string]uint64{}
info, err := net.IOCounters(true)
if err != nil {
return speed, err
}
for _, item := range info {
if item.BytesSent != 0 {
speed[item.Name] = map[string]uint64{
"send": item.BytesSent,
"recv": item.BytesRecv,
}
}
}

time.Sleep(1 * time.Second)

info, err = net.IOCounters(true)
if err != nil {
return speed, err
}
for _, item := range info {
if item.BytesSent != 0 {
speed[item.Name] = map[string]uint64{
"send": item.BytesSent - speed[item.Name]["send"],
"recv": item.BytesRecv - speed[item.Name]["recv"],
}
}
}
return speed, nil
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions vendor/github.com/shirou/gopsutil/v3/cpu/cpu.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 96 additions & 0 deletions vendor/github.com/shirou/gopsutil/v3/disk/disk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading