Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Yep, version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
superfashi committed Nov 6, 2016
1 parent 393cbae commit 8501a4e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 12 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 SuperFashi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
# Yun-Brute
[![rcard](https://goreportcard.com/badge/github.com/hanbang-wang/Yun-Brute)](https://goreportcard.com/report/github.com/hanbang-wang/Yun-Brute)

A working brute-force machine for BaiduYun private share links.

# Example
![Example-GIF](https://superfashi.b0.upaiyun.com/wp-content/uploads/2016/11/a.gif)

Try running this link on your own computer/server!

# Compilation

Firstly you have to `go get -u` two packages I used in this projext:

- `gopkg.in/alecthomas/kingpin.v2`
- `gopkg.in/cheggaaa/pb.v1`

Then clone this project to run.
```bash
git clone https://github.com/hanbang-wang/Yun-Brute
go run brute.go
```
Or simply uses pre-compiled binaries downloaded [here](https://github.com/hanbang-wang/Yun-Brute/releases).

# Usage
```bash
brute [<flags>] <link>

Flags:
-h, --help Show context-sensitive help.
-p, --preset="0000" The preset start of key to brute.
-t, --thread=1000 Number of threads.

Args:
<link> URL of BaiduYun file you want to get.
```

# Feature
- **Resolver**
You can use 2 types of BaiduYun links in the out-of-the-box version. If there's more types of private share links, you can add the resolver yourself, or let me know by sending a PR or taking an issue.

- **Interrupt-friendly:**
When you press `Ctrl-C` to interrupt the program, it will output the current progress, which allow you to use `-p` flag to continue working later.

- **Logging:**
Unfortunately the logging would mess up with the progress bar, use `2> /dev/null` to disable logging, or you can try `1>&2`.

- **Proxying:**
This program contains 4 methods of acquiring proxies, with repetition and failure proxies correction. When there're no proxies left, threads will auto hang up to wait for more proxies to come in. And you can add your own source of proxies easily.

# License
This little project uses `MIT License`, for more info please visit [LICENSE](LICENSE).
24 changes: 12 additions & 12 deletions main.go → brute.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
var (
link = kingpin.Arg("link", "URL of BaiduYun file you want to get.").Required().String()
preset = kingpin.Flag("preset", "The preset start of key to brute.").Short('p').Default("0000").String()
thread = kingpin.Flag("thread", "Number of thread.").Short('t').Default("10").Int64()
thread = kingpin.Flag("thread", "Number of threads.").Short('t').Default("1000").Int64()
resolver []*Resolve
bar *pb.ProgressBar
shareid, uk string
Expand Down Expand Up @@ -190,7 +190,7 @@ func saveProxies() {
&Proxies{
func() {
for {
resp, err := http.Get("http://free-proxy-list.net/")
resp, err := http.Get("https://free-proxy-list.net/")
if err != nil || resp.Body == nil {
log.Println(err)
time.Sleep(RETRY_TIME)
Expand Down Expand Up @@ -345,11 +345,11 @@ func tester(work int64) {
if resp.StatusCode == 200 {
if err = json.NewDecoder(resp.Body).Decode(info); err == nil {
if info.Errno == 0 {
log.Println("Key found!", now)
log.Printf("Key found: %04s!", now)
os.Exit(0)
} else if info.Errno != -9 {
increProxy(pro)
log.Println("Unknown error! Service returned", info.Errno, "with message:", info.ErrMsg)
log.Printf("Unknown error! Service returned %d with message: \"%s\"", info.Errno, info.ErrMsg)
} else {
addProxy(pro) // Set the counter to zero
break
Expand All @@ -359,10 +359,10 @@ func tester(work int64) {
deleteProxy(pro)
} else {
increProxy(pro)
log.Println("Unknown error! Server returned", resp.StatusCode)
log.Printf("Unknown error! Server returned %d!", resp.StatusCode)
}
resp.Body.Close()
} else if strings.Contains(err.Error(), "error connecting to proxy") {
} else if strings.Contains(err.Error(), "error connecting to proxy") { // ugly but works
increProxy(pro)
}
time.Sleep(RETRY_TIME)
Expand All @@ -377,11 +377,6 @@ func init() {
kingpin.CommandLine.HelpFlag.Short('h')
kingpin.Parse()
saveResolver() // For future expansion of resolver
mapLocker = new(sync.Mutex)
useable = new(AtomBool)
useable.lock = new(sync.Mutex)
proxies = make(map[Proxy]int)
saveProxies() // For future expansion of proxy
var indi int
for indi = 0; indi < len(resolver); indi++ {
if resolver[indi].re.MatchString(*link) {
Expand All @@ -392,6 +387,11 @@ func init() {
if indi == len(resolver) {
log.Fatal("No proper resolver found!")
}
mapLocker = new(sync.Mutex)
useable = new(AtomBool)
useable.lock = new(sync.Mutex)
proxies = make(map[Proxy]int)
saveProxies() // For future expansion of proxy
for _, i := range updater {
go i.update()
}
Expand All @@ -414,7 +414,7 @@ func init() {
}

func main() {
log.SetPrefix("\n") // For compatibility with indicator
log.SetPrefix("\r") // For compatibility with indicator
wg.Add(int(*thread))
for i := int64(0); i < *thread; i++ {
go tester(start + i)
Expand Down

0 comments on commit 8501a4e

Please sign in to comment.