Created
January 25, 2018 14:13
-
-
Save lujiajing1126/b7f8ee4e6d9eecc7b5c8ee958b5c64d3 to your computer and use it in GitHub Desktop.
Fudan Network Auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io/ioutil" | |
"flag" | |
"fmt" | |
"net/http" | |
"net/url" | |
"os" | |
"crypto/tls" | |
) | |
const URL = "https://10.108.255.249/include/auth_action.php" | |
var ( | |
username string | |
password string | |
ip string | |
) | |
func init() { | |
flag.StringVar(&username, "username", "", "urp username") | |
flag.StringVar(&password, "password", "", "urp password") | |
flag.StringVar(&ip, "ip", "", "ip") | |
} | |
func main() { | |
flag.Parse() | |
if username == "" || password == "" || ip == "" { | |
fmt.Println("invalid configuration") | |
os.Exit(1) | |
} | |
q := url.Values{} | |
q.Add("action", "login") | |
q.Add("username", username) | |
q.Add("password", password) | |
q.Add("ac_id", "1") | |
q.Add("user_ip", ip) | |
q.Add("nas_ip", "") | |
q.Add("user_mac", "") | |
q.Add("save_me", "1") | |
q.Add("ajax", "1") | |
tr := &http.Transport{ | |
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, | |
} | |
client := &http.Client{Transport: tr} | |
resp, err := client.PostForm(URL, q) | |
if err != nil { | |
fmt.Println(err.Error()) | |
os.Exit(1) | |
} | |
if resp.StatusCode != 200 { | |
fmt.Sprintf("return code %d", resp.StatusCode) | |
os.Exit(1) | |
} | |
b, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
fmt.Println("read resp body fail") | |
os.Exit(1) | |
} | |
fmt.Println(fmt.Sprintf("login success: %s", string(b))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment