添加tools

This commit is contained in:
宋帮诚晋 2022-11-21 14:03:38 +08:00
parent f39b31a3fa
commit 41b25f8199
8 changed files with 18 additions and 124 deletions

View File

@ -16,7 +16,8 @@ amd64
* examples : 使用示例目录
* image : 存放图片
* misc : 其他
* utils : 实用工具目录
* utils : 实用程序/脚本目录
* tools: 辅助工具
* z-container : 临时存放目录
* z-testsuit : 存放测试小程序的目录
* z-trash : 垃圾桶目录

18
logfile
View File

@ -1,18 +0,0 @@
2022/11/16 17:01:43 检测为liunx系统
2022/11/16 17:41:37 检测为liunx系统
2022/11/16 17:41:37 frameWork sure
2022/11/16 17:41:37 ssh connect succ
2022/11/16 18:05:23 检测为liunx系统
2022/11/16 18:05:23 frameWork sure
2022/11/16 21:27:32 检测为liunx系统
2022/11/16 21:27:32 frameWork sure
2022/11/16 21:27:49 检测为liunx系统
2022/11/16 21:27:49 frameWork sure
2022/11/16 21:28:02 检测为liunx系统
2022/11/16 21:28:02 frameWork sure
2022/11/16 21:37:56 检测为liunx系统
2022/11/16 21:37:56 frameWork sure
2022/11/16 21:41:19 检测为liunx系统
2022/11/16 21:41:19 frameWork sure
2022/11/16 21:48:49 检测为liunx系统
2022/11/16 21:48:49 frameWork sure

View File

@ -4,6 +4,7 @@ import(
"fmt"
"regexp"
"strconv"
"strings"
)
func ArgCheck(targetString string)(LegalValue string){
@ -18,12 +19,20 @@ func ArgCheck(targetString string)(LegalValue string){
//IP校验
func IPCheck(IP string)(matchResult string){
match, err := regexp.MatchString(`^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9]
checkIP:=strconv.FormatBool(strings.Contains(IP, "/24"))
if checkIP =="true"{
fmt.Println(1)
}
return
match, err := regexp.MatchString(`^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/.){3}([0-9]|[1-9]
[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`, IP)
if err != nil {
fmt.Println("IP 不合法请修改")
fmt.Println(IP," 不合法请修改")
}
// fmt.Println(match)
matchResult=strconv.FormatBool(match)
return matchResult
}
func IPParser(){
}

View File

@ -16,8 +16,7 @@ type Cache struct{
SystemCache map[string]string
}
func SiteCache() *cache.Cache {
func SiteCache() *cache.Cache{
// 创建一个不会过期的缓存
c := cache.New(0,0)
// 声明map
@ -28,6 +27,7 @@ func SiteCache() *cache.Cache {
cacheVul.SystemCache = make(map[string]string)
cacheVul.KernelCache["1"] = "宋江"
cacheVul.KernelCache["2"] = "李逵"
cacheVul.SystemCache["1"] = "李逵2"
//kernel 的poc存储到缓存
c.Set("kernel", &MyStruct{Msg: cacheVul.KernelCache}, cache.DefaultExpiration)

View File

@ -55,7 +55,9 @@ func CoprogramPool(Nums int , Request map[string]string) {
if len(Request["kernel"]) > 0 {
//获 取 kernel 缓 存 值
if kernel, found := cache.Get("kernel"); found {
fmt.Println(kernel)
// My:=kernel
kernelVul:=*(kernel.(*Cache.MyStruct))
fmt.Println(kernelVul)
}
}else{
log.Println("未加载kernel模块缓存")

View File

@ -1,12 +0,0 @@
2022/11/18 12:12:11 检测为liunx系统
2022/11/18 12:12:11 frameWork sure
2022/11/18 12:12:11 缓存中.......
2022/11/18 12:12:11 未加载kernel模块缓存
2022/11/18 12:12:11 未加载web模块缓存
2022/11/18 12:12:11 未加载kernel模块缓存
2022/11/18 12:17:04 检测为liunx系统
2022/11/18 12:17:04 frameWork sure
2022/11/18 12:17:04 缓存中.......
2022/11/18 12:17:04 未加载kernel模块缓存
2022/11/18 12:17:04 未加载web模块缓存
2022/11/18 12:17:04 未加载kernel模块缓存

BIN
src/main

Binary file not shown.

View File

@ -1,88 +0,0 @@
package main
import (
"fmt"
"sync"
"main/genmai/Cache"
)
// Pool goroutine Pool
type Pool struct {
queue chan int
wg *sync.WaitGroup
}
// New 新建一个协程池
func New(size int) *Pool {
if size <= 0 {
size = 1
}
return &Pool{
queue: make(chan int, size),
wg: &sync.WaitGroup{},
}
}
// Add 新增一个执行
func (p *Pool) Add(delta int) {
// delta为正数就添加
for i := 0; i < delta; i++ {
p.queue <- 1
}
// delta为负数就减少
for i := 0; i > delta; i-- {
<-p.queue
}
p.wg.Add(delta)
}
// Done 执行完成减一
func (p *Pool) Done() {
<-p.queue
p.wg.Done()
}
func (p *Pool) Wait() {
p.wg.Wait()
}
type MyStruct struct {
Msg map[string]string
}
func main() {
cache:=Cache.SiteCache()
if kernel, found := cache.Get("kernel"); found {
fmt.Println(kernel)
// ...
}
return
// 自定义并发数量
var Nums int
var NumsNeed int
NumsNeed=1000
Nums=500
pool := New(Nums) // sync.WaitGroup{}
//计算好缓存中需要执行的poc数量
for i := 0; i < NumsNeed; i++ {
pool.Add(1)
go func(i int) {
// resp, err := http.Get("127.0.0.1:80")
// if err != nil {
// fmt.Println(i, err)
// } else {
// defer resp.Body.Close()
// result, _ := ioutil.ReadAll(resp.Body)
// fmt.Println(i, string(result))
// }
pool.Done()
}(i)
}
pool.Wait()
}