Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
update version v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rootphantomer committed Sep 7, 2022
1 parent 169501a commit e863d6f
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 47 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: ph4nt0mer
* @Date: 2022-09-01 18:39:52
* @LastEditors: rootphantomer
* @LastEditTime: 2022-09-07 14:55:42
* @LastEditTime: 2022-09-07 16:50:09
* @FilePath: /quake_go/README.md
* @Description:
*
Expand Down Expand Up @@ -32,7 +32,8 @@ rust 项目代码 移步这里——https://github.com/360quake/quake_rs/
- 2022-09-07 v1.4:

- 替换 hflag 来解析命令行参数,使参数拓展开发更简单
- 简化逻辑代码
- 更新 query 接口为 search
- 支持 -fq 参数,可以使用载入一个逐行有搜索语法的 txt 文本,然后统一结果输出 ip:port

- 2022-09-07 v1.3:

Expand All @@ -58,21 +59,22 @@ rust 项目代码 移步这里——https://github.com/360quake/quake_rs/

```bash
Starting Quake Cli...
usage: quake [pos] [-e,end_time time=2022-09-07 14:18:23] [-fe,field string] [-h,help bool] [-ic,ignore_cache bool=false] [-sz,size string=10] [-st,start string=0] [-s,start_time time=2022-01-01]
usage: quake [option] [-e,end_time time=2022-09-07 16:47:32] [-fe,field string] [-h,help bool] [-ic,ignore_cache bool=false] [-qt,query_txt string] [-sz,size string=10] [-st,start string=0] [-s,start_time time=2022-01-01]

positional options:
pos [string] pos flag
option [string] init,info,search

options:
-e, --end_time [time=2022-09-07 14:18:23] end time flag
-fe, --field [string] field flag
-e, --end_time [time=2022-09-07 16:47:32] -e time to end time flag
-fe, --field [string] -fe body to show body infomation
-h, --help [bool] show usage
-ic, --ignore_cache [bool=false] ignore_cache value (true or false)
-sz, --size [string=10] size flag
-st, --start [string=0] start flag
-s, --start_time [time=2022-01-01] start time flag
-ic, --ignore_cache [bool=false] -ic true or false,default false
-qt, --query_txt [string] -qt ./file.txt file to query search
-sz, --size [string=10] -sz to size number
-st, --start [string=0] -st to start number
-s, --start_time [time=2022-01-01] -s time flag , default time is time.now.year
```

## 案例
## 用例

![alt](./iShot_2022-09-07_14.19.19.jpg)
![alt](./iShot_2022-09-07_16.48.13.jpg)
Binary file removed iShot_2022-09-07_14.19.19.jpg
Binary file not shown.
Binary file added iShot_2022-09-07_16.48.13.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 13 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: ph4nt0mer
* @Date: 2022-08-31 17:03:03
* @LastEditors: rootphantomer
* @LastEditTime: 2022-09-07 15:01:50
* @LastEditTime: 2022-09-07 16:46:26
* @FilePath: /quake_go/main.go
* @Description:
*
Expand All @@ -29,23 +29,24 @@ func main() {

func hflag_init() {
fmt.Println("Starting Quake Cli...")
hflag.AddFlag("start", "start flag", hflag.Shorthand("st"), hflag.Type("string"), hflag.DefaultValue("0"))
hflag.AddFlag("size", "size flag", hflag.Shorthand("sz"), hflag.Type("string"), hflag.DefaultValue("10"))
hflag.AddFlag("ignore_cache", "ignore_cache value (true or false)", hflag.Shorthand("ic"), hflag.Type("bool"), hflag.DefaultValue("false"))
hflag.AddFlag("start_time", "start time flag", hflag.Shorthand("s"), hflag.Type("time"), hflag.DefaultValue(strconv.Itoa(time.Now().Year())+"-01-01"))
hflag.AddFlag("end_time", "end time flag", hflag.Shorthand("e"), hflag.Type("time"), hflag.DefaultValue(time.Now().Format("2006-01-02 15:04:05")))
hflag.AddFlag("field", "field flag", hflag.Shorthand("fe"), hflag.Type("string"))
hflag.AddPosFlag("pos", "pos flag")
hflag.AddFlag("start", "-st to start number", hflag.Shorthand("st"), hflag.Type("string"), hflag.DefaultValue("0"))
hflag.AddFlag("size", "-sz to size number ", hflag.Shorthand("sz"), hflag.Type("string"), hflag.DefaultValue("10"))
hflag.AddFlag("ignore_cache", "-ic true or false,default false", hflag.Shorthand("ic"), hflag.Type("bool"), hflag.DefaultValue("false"))
hflag.AddFlag("start_time", "-s time flag , default time is time.now.year", hflag.Shorthand("s"), hflag.Type("time"), hflag.DefaultValue(strconv.Itoa(time.Now().Year())+"-01-01"))
hflag.AddFlag("end_time", "-e time to end time flag", hflag.Shorthand("e"), hflag.Type("time"), hflag.DefaultValue(time.Now().Format("2006-01-02 15:04:05")))
hflag.AddFlag("field", "-fe body to show body infomation", hflag.Shorthand("fe"), hflag.Type("string"), hflag.DefaultValue(""))
hflag.AddFlag("query_txt", "-qt ./file.txt file to query search", hflag.Shorthand("qt"), hflag.Type("string"), hflag.DefaultValue(""))
hflag.AddPosFlag("option", "init,info,search")
if err := hflag.Parse(); err != nil {
panic(err)
}
num := len(os.Args)
if num < 2 {
if num < 3 {
fmt.Println("./quake -h get help!")
return
}

switch strings.ToLower(hflag.GetString("pos")) {
switch strings.ToLower(hflag.GetString("option")) {
case "version":
fmt.Println("version:1.4")
case "init":
Expand All @@ -60,7 +61,7 @@ func hflag_init() {
return
}
apis.InfoGet(token.Token)
case "query":
case "search":
token, status := utils.ReadYaml("./config.yaml")
if !status {
return
Expand All @@ -73,6 +74,7 @@ func hflag_init() {
reqjson.End_time = hflag.GetTime("end_time")
reqjson.Ignore_cache = hflag.GetBool("ignore_cache")
reqjson.Field = hflag.GetString("field")
reqjson.Query_txt = hflag.GetString("query_txt")
apis.SearchServicePost(reqjson, token.Token)
case "host":
fmt.Println("主机数据接口待完成。。。")
Expand Down
21 changes: 18 additions & 3 deletions src/apis/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: ph4nt0mer
* @Date: 2022-09-01 15:36:10
* @LastEditors: rootphantomer
* @LastEditTime: 2022-09-07 15:39:06
* @LastEditTime: 2022-09-07 16:43:50
* @FilePath: /quake_go/src/apis/api.go
* @Description:
*
Expand All @@ -17,6 +17,7 @@ import (
"quake/src/setting"
"quake/src/tools"
"quake/src/utils"
"strconv"
"strings"
)

Expand All @@ -36,11 +37,25 @@ func SearchServicePost(reqjson Reqjson, token string) {
// "start_time": "2021-01-01 00:00:00",
// "end_time": "2021-02-01 00:00:00"
// }'
uri := "/search/quake_service"
if reqjson.Query == "" || reqjson.Query == "?" {
fmt.Println("No query specified")
return
}
uri := "/search/quake_service"
if reqjson.Query_txt != "" {
bytedata, _ := utils.ReadLine(reqjson.Query_txt)
tmp := ""
for _, v := range bytedata {
if tmp == "" {
tmp = v
} else {
tmp += " OR " + v
}

}
fmt.Println(tmp)
reqjson.Query = tmp
}
// payload := "{\"query\":\"" + req.Query +
// "\",\"start\":\"" + req.Start + "\",\"size\":\"" + req.Size +
// "\"}"
Expand All @@ -62,7 +77,7 @@ func SearchServicePost(reqjson Reqjson, token string) {
}
}
for _, value := range data {
fmt.Println("@@", value.IP, ":", value.Port)
fmt.Println("@@@", value.IP+":"+strconv.Itoa(value.Port))
}
// for _, value := range data {
// fmt.Println(value.IP + ":" + strconv.Itoa(value.Port))
Expand Down
3 changes: 2 additions & 1 deletion src/model/reqjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: rootphantomer [email protected]
* @Date: 2022-09-06 17:58:31
* @LastEditors: rootphantomer
* @LastEditTime: 2022-09-07 12:38:07
* @LastEditTime: 2022-09-07 16:19:32
* @FilePath: /quake_go/src/model/reqjson.go
* @Description:model
*
Expand All @@ -20,4 +20,5 @@ type Reqjson struct {
Start_time Time `json:"start_time,omitempty"`
End_time Time `json:"end_time,omitempty"`
Field string `json:"-"`
Query_txt string `json:"-"`
}
38 changes: 19 additions & 19 deletions src/model/respjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: rootphantomer [email protected]
* @Date: 2022-09-06 18:10:53
* @LastEditors: rootphantomer
* @LastEditTime: 2022-09-07 11:19:02
* @LastEditTime: 2022-09-07 16:43:31
* @FilePath: /quake_go/src/model/respjson.go
* @Description:
*
Expand All @@ -12,9 +12,9 @@
package model

type ServiceJson struct {
Code int64 `json:"code"`
Code int `json:"code"`
Data []struct {
Asn int64 `json:"asn"`
Asn int `json:"asn"`
Cdn struct {
Domain string `json:"domain"`
IsCdn bool `json:"is_cdn"`
Expand Down Expand Up @@ -52,7 +52,7 @@ type ServiceJson struct {
Org string `json:"org"`
OsName string `json:"os_name"`
OsVersion string `json:"os_version"`
Port int64 `json:"port"`
Port int `json:"port"`
Service struct {
Banner string `json:"banner"`
Cert string `json:"cert"`
Expand All @@ -69,7 +69,7 @@ type ServiceJson struct {
Path string `json:"path"`
ResponseHeaders string `json:"response_headers"`
Server string `json:"server"`
StatusCode int64 `json:"status_code"`
StatusCode int `json:"status_code"`
Title string `json:"title"`
XPoweredBy string `json:"x_powered_by"`
} `json:"http"`
Expand All @@ -85,22 +85,22 @@ type ServiceJson struct {
Message string `json:"message"`
Meta struct {
Pagination struct {
Count int64 `json:"count"`
PageIndex int64 `json:"page_index"`
PageSize int64 `json:"page_size"`
Total int64 `json:"total"`
Count int `json:"count"`
PageIndex int `json:"page_index"`
PageSize int `json:"page_size"`
Total int `json:"total"`
} `json:"pagination"`
} `json:"meta"`
}

type InfoJson struct {
Code int64 `json:"code"`
Code int `json:"code"`
Data struct {
AvatarID string `json:"avatar_id"`
BanStatus string `json:"ban_status"`
Baned bool `json:"baned"`
ConstantCredit int64 `json:"constant_credit"`
Credit int64 `json:"credit"`
ConstantCredit int `json:"constant_credit"`
Credit int `json:"credit"`
Disable struct {
DisableTime interface{} `json:"disable_time"`
StartTime interface{} `json:"start_time"`
Expand All @@ -110,17 +110,17 @@ type InfoJson struct {
Name interface{} `json:"name"`
Status string `json:"status"`
} `json:"enterprise_information"`
FreeQueryAPICount int64 `json:"free_query_api_count"`
FreeQueryAPICount int `json:"free_query_api_count"`
ID string `json:"id"`
InvitationCodeInfo struct {
Code string `json:"code"`
InviteAcquireCredit int64 `json:"invite_acquire_credit"`
InviteNumber int64 `json:"invite_number"`
InviteAcquireCredit int `json:"invite_acquire_credit"`
InviteNumber int `json:"invite_number"`
} `json:"invitation_code_info"`
IsCashedInvitationCode bool `json:"is_cashed_invitation_code"`
MobilePhone string `json:"mobile_phone"`
MonthRemainingCredit int64 `json:"month_remaining_credit"`
PersistentCredit int64 `json:"persistent_credit"`
MonthRemainingCredit int `json:"month_remaining_credit"`
PersistentCredit int `json:"persistent_credit"`
PersonalInformationStatus bool `json:"personal_information_status"`
PrivacyLog struct {
AnonymousModel bool `json:"anonymous_model"`
Expand All @@ -130,9 +130,9 @@ type InfoJson struct {
Time string `json:"time"`
} `json:"privacy_log"`
Role []struct {
Credit int64 `json:"credit"`
Credit int `json:"credit"`
Fullname string `json:"fullname"`
Priority int64 `json:"priority"`
Priority int `json:"priority"`
} `json:"role"`
RoleValidity struct {
} `json:"role_validity"`
Expand Down
2 changes: 1 addition & 1 deletion src/tools/commond.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: ph4nt0mer
* @Date: 2022-09-01 10:49:31
* @LastEditors: rootphantomer
* @LastEditTime: 2022-09-07 15:36:09
* @LastEditTime: 2022-09-07 15:47:47
* @FilePath: /quake_go/src/tools/commond.go
* @Description:
*
Expand Down
38 changes: 38 additions & 0 deletions src/utils/ReadLine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* @Author: rootphantomer [email protected]
* @Date: 2022-09-07 16:27:34
* @LastEditors: rootphantomer
* @LastEditTime: 2022-09-07 16:31:15
* @FilePath: /quake_go/src/utils/ReadLine.go
* @Description:逐行读取内容
*
* Copyright (c) 2022 by rootphantomer, All Rights Reserved.
*/
package utils

import (
"bufio"
"io"
"os"
"strings"
)

func ReadLine(fileName string) ([]string, error) {
f, err := os.Open(fileName)
if err != nil {
return nil, err
}
buf := bufio.NewReader(f)
var result []string
for {
line, err := buf.ReadString('\n')
line = strings.TrimSpace(line)
if err != nil {
if err == io.EOF { //读取结束,会报EOF
return result, nil
}
return nil, err
}
result = append(result, line)
}
}

0 comments on commit e863d6f

Please sign in to comment.