Skip to content

Commit

Permalink
Merge pull request #21 from 0xTeles/dev
Browse files Browse the repository at this point in the history
Update jsleak v2.2
  • Loading branch information
0xTeles authored Oct 20, 2021
2 parents f1f351d + 450ef9c commit 4e2cbb4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Compiled: [release page](https://github.com/0xTeles/jsleak/releases/tag/jsleak_
```
-json string
[+] Json output file
-pattern string
-pattern string
[+] File contains patterns to test
-timeout int
-timeout int
[+] Timeout for request in seconds (default 5)
-verbose
-verbose
[+] Verbose Mode
```
### Demo
Expand Down
53 changes: 40 additions & 13 deletions v2/jsleak/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,37 @@ type JsonReturn struct {
Match string
}

func getLeak(url string, data string, pattern string, jsonArray *[]JsonReturn) {
re := pcre.MustCompile(pattern, 0)
matches := re.MatcherString(data, 0).Group(0)
//fmt.Println(len(matches))
if len(matches) != 0 {
fmt.Printf("[+] Url: %v\n[+] Pattern: %v\n[+] Match: %v\n", url, pattern, string(matches))
jsn := JsonReturn{url, pattern, string(matches)}
*jsonArray = append(*jsonArray, jsn)
func getLeak(url string, data string, c_patterns []pcre.Regexp, raw_patterns []string, jsonArray *[]JsonReturn) {

for i,pattern := range c_patterns {

// Match function
regex_ := func(i int, pattern pcre.Regexp, data_i *string) (bool){
data_b := *data_i
matches := pattern.MatcherString(data_b, 0)
matches_index := matches.Index()
matches_str := matches.GroupString(0)

if len(matches_str) != 0 {
fmt.Printf("[+] Url: %v\n[+] Pattern: %v\n[+] Match: %v\n", url, raw_patterns[i], matches_str)

//JSON Output
jsn := JsonReturn{url, raw_patterns[i], matches_str}
*jsonArray = append(*jsonArray, jsn)

//Remove match value from data
data_b = (data_b[:matches_index[0]]+data_b[matches_index[1]:])
*data_i = data_b
return true

}else {
return false
}
}

// Loop same pattern until find no more
for regex_(i,pattern, &data) { fmt.Printf("") }

}
}

Expand Down Expand Up @@ -73,7 +96,7 @@ func main() {
jsonOutput := flag.String("json", "", "[+] Json output file")
timeout := flag.Int("timeout", 5, "[+] Timeout for request in seconds")
flag.Parse()

stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) != 0 {
fmt.Println("[+] Use in Pipeline")
Expand All @@ -86,10 +109,17 @@ func main() {

patterns := bufio.NewScanner(file)
jsonArray := make([]JsonReturn, 1)

for patterns.Scan() {
lines = append(lines, patterns.Text())
}

// Compile all patterns
c_patterns := []pcre.Regexp{}
for _, pattern := range lines {
c_patterns = append(c_patterns, pcre.MustCompile(pattern, 0))
}

if err != nil {
log.Fatal(err)
}
Expand All @@ -98,12 +128,9 @@ func main() {
if *verbose {
fmt.Println("[-] Looking: " + url)
}

data := req(url,*timeout)
getLeak(url, data, c_patterns, lines, &jsonArray)

for _, pattern := range lines {
getLeak(url, data, pattern, &jsonArray)
}
}

if *jsonOutput != "" {
Expand Down

0 comments on commit 4e2cbb4

Please sign in to comment.