Skip to content

Commit

Permalink
Fix Layers
Browse files Browse the repository at this point in the history
  • Loading branch information
destan0098 committed Sep 30, 2023
1 parent f4c2e2e commit 46e4114
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 176 deletions.
176 changes: 0 additions & 176 deletions checkwpjson.go

This file was deleted.

86 changes: 86 additions & 0 deletions cmd/Part1/Part1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package Part1

import (
"crypto/tls"
"encoding/json"
"fmt"
"github.com/TwiN/go-color"
"github.com/destan0098/checkwpjson/cmd/Part2"
"io/ioutil"
"net/http"
"os"
)

type Author struct {
ID int `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Link string `json:"link"`
Slug string `json:"slug"`
AvatarURLs struct {
Size24 string `json:"24"`
Size48 string `json:"48"`
Size96 string `json:"96"`
} `json:"avatar_urls"`
Meta []interface{} `json:"meta"`
ACF []interface{} `json:"acf"`
// Add more fields here as needed
}

var outlast []string
var authors []Author
var err error

func Part1(path string, fo *os.File, InputText string) {
fmt.Println(path)
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
// Do not verify certificates, do not follow redirects.
client := &http.Client{
Transport: tr,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}}

req, _ := http.NewRequest("GET", path, nil)
//Send Request To Address
resp, erer := client.Do(req)

if erer != nil {
fmt.Println(color.Colorize(color.Red, "[-] Error:"+erer.Error()))
recover()
}
if resp.StatusCode == 200 {
//Check Response status Code
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(color.Colorize(color.Red, "[-] Error:"+err.Error()))
recover()
}
err = json.Unmarshal(body, &authors)
//Parse Json Values To Show
if err != nil {
fmt.Println(color.Colorize(color.Red, "[-] Line 91 Error:"+err.Error()))
recover()
}
fmt.Println(color.Colorize(color.Green, "[+] Find In : "+path))
outlast = append(outlast, path+"\n")
for _, author := range authors {
outlast = append(outlast, " User Name :\n"+author.Slug+"\n")
fmt.Println(color.Colorize(color.Green, "[+] UserNames : "+author.Slug))

}
outlast = append(outlast, "********************************************\n")

_, err = fmt.Fprint(fo, outlast)
//Save In output File
if err != nil {
fmt.Println(color.Colorize(color.Red, "[-] Line 100 Error:"+err.Error()))
recover()
}
} else {
Part2.Part2(fo, InputText)
}
}
97 changes: 97 additions & 0 deletions cmd/Part2/Part2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package Part2

import (
"crypto/tls"
"encoding/json"
"fmt"
"github.com/TwiN/go-color"
"io/ioutil"
"net/http"
"os"
"strings"
)

type Author struct {
ID int `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Link string `json:"link"`
Slug string `json:"slug"`
AvatarURLs struct {
Size24 string `json:"24"`
Size48 string `json:"48"`
Size96 string `json:"96"`
} `json:"avatar_urls"`
Meta []interface{} `json:"meta"`
ACF []interface{} `json:"acf"`
// Add more fields here as needed
}

var outlast []string
var authors []Author
var err error
var path string

func Part2(fo *os.File, InputText string) {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
Transport: tr,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}}

//Send Request To Address

if !strings.HasSuffix(InputText, "/") {
//It puts the values of the file line by line into the variable.
path = fmt.Sprintf(InputText+"/%s", "?rest_route=/wp/v2/users/")
// Add WP-json Directory To your Address

} else {
path = fmt.Sprintf(InputText+"%s", "?rest_route=/wp/v2/users/")

}
reqs, _ := http.NewRequest("GET", path, nil)
//Send Request To Address
resps, erers := client.Do(reqs)

if erers != nil {
fmt.Println(color.Colorize(color.Red, "[-] Error:"+erers.Error()))
recover()
}
if resps.StatusCode == 200 {
//Check Response status Code
body, errs := ioutil.ReadAll(resps.Body)
if errs != nil {
fmt.Println(color.Colorize(color.Red, "[-] Error:"+err.Error()))
recover()
}
err = json.Unmarshal(body, &authors)
//Parse Json Values To Show
if err != nil {
fmt.Println(color.Colorize(color.Red, "[-] Line 91 Error:"+err.Error()))
recover()
}
fmt.Println(color.Colorize(color.Green, "[+] Find In : "+path))
outlast = append(outlast, path+"\n")
for _, author := range authors {
outlast = append(outlast, " User Name :\n"+author.Slug+"\n")
fmt.Println(color.Colorize(color.Green, "[+] UserNames : "+author.Slug))

}
outlast = append(outlast, "********************************************\n")

_, err = fmt.Fprint(fo, outlast)
//Save In output File
if err != nil {
fmt.Println(color.Colorize(color.Red, "[-] Line 100 Error:"+err.Error()))
recover()
}
} else {
fmt.Println(color.Colorize(color.Red, "[-] Not Find any users"))

}
}
Loading

0 comments on commit 46e4114

Please sign in to comment.