-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
190 lines (170 loc) · 4.42 KB
/
main.go
File metadata and controls
190 lines (170 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package main
/*
TODO: Logout
TODO: Encrypt Password
*/
import (
"PassGo/dialog"
imaalum "PassGo/imaalum"
userstruct "PassGo/model/user"
"crypto/tls"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"io/fs"
"log"
"net/http"
"net/url"
"os"
"sync"
"syscall"
"golang.org/x/term"
)
func main() {
fmt.Println(`
***IIUM WIFI LOGIN***
AUTOMATE LOGIN TO IIUM-STUDENT WITH 2 EASY STEPS
1. STORE YOUR CREDENTIALS
2. CONNECT TO NETWORK
***CREDENTIALS ARE SAVED IN YOUR PC***
`)
ws := new(sync.WaitGroup)
fmt.Println("Select Function\n1.Store Creds\n2.Connect To Network\n3.Logout\n4.Login To iMaalum\n5.Results")
var user_input int = 0
_, err := fmt.Scan(&user_input)
if err != nil {
log.Fatal(err)
}
eval_choice(user_input,ws)
}
func eval_choice(choice int,ws *sync.WaitGroup){
switch choice {
case 1:
store_pass()
case 2:
connect_network()
case 3:
logout_network()
case 4:
dialog.XPlatMessageBox("TEST", "TEST")
var client = imaalum.Imaalum_login()
ws.Add(3)
go imaalum.GetFinance(ws, &client)
go imaalum.GetConfimationSlip(ws, &client)
go imaalum.GetGeneralExamTimeTable(ws, &client)
ws.Wait()
case 5:
checkResult()
}
}
func checkResult(){
var UserStruct userstruct.User
file, err := os.ReadFile("indexxx.json")
if err != nil {
log.Fatal(err)
panic(err)
}
var session_val string = ""
fmt.Println("Session i.e 2021/2022")
_, err = fmt.Scan(&session_val)
if err != nil {
log.Fatal(err)
}
var semester_val string = ""
fmt.Println("Semester")
_, err = fmt.Scan(&semester_val)
if err != nil {
log.Fatal(err)
}
json.Unmarshal(file, &UserStruct)
decodeUser, _ := base64.StdEncoding.DecodeString(UserStruct.User)
decodePass, _ := base64.StdEncoding.DecodeString(UserStruct.Password)
form_val := url.Values{
"mat_no" : {string(decodeUser)},
"pin_no" : {string(decodePass)},
"sessi" : {session_val},
"semester" : {semester_val},
"login" :{"Login"},
}
resp,err := http.PostForm("https://myapps.iium.edu.my/anrapps/viewResult.php", form_val)
if resp.StatusCode == 200 {
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
dialog.XPlatMessageBox("ERROR", err.Error())
os.Exit(1)
}
_ = os.WriteFile("result.html", bodyBytes, 0644)
dialog.XPlatMessageBox("Done", "Download Result Complete")
}
}
func store_pass() {
userVal := ""
passwordVal := ""
fmt.Println("Insert Username")
fmt.Scan(&userVal)
encodeUser := base64.StdEncoding.EncodeToString([]byte(userVal))
fmt.Println("Insert Password")
bytepw, err := term.ReadPassword(int(syscall.Stdin))
if err != nil {
log.Fatal(err)
}
passwordVal = string(bytepw)
encodePass := base64.StdEncoding.EncodeToString([]byte(passwordVal))
data := userstruct.User{
User: encodeUser,
Password: encodePass,
}
// fmt.Println(data)
file, _ := json.MarshalIndent(data, "", " ")
err2 := os.WriteFile("indexxx.json", file, fs.ModePerm)
if err2 != nil {
log.Fatal(err2)
}
}
func logout_network() {
transCfg := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // ignore expired SSL certificates
}
client := &http.Client{Transport: transCfg}
_, err := client.Get("https://captiveportalmahallahgombak.iium.edu.my/auth/logout.html")
if err != nil {
dialog.XPlatMessageBox("ERROR", "UNABLE TO LOGOUT (I GUESS)")
panic(err)
}
dialog.XPlatMessageBox("SUCCESS", "YOU ARE LOGGED OUT OF IIUM-STUDENT")
}
func connect_network() {
var UserStruct userstruct.User
file, err := os.ReadFile("indexxx.json")
if err != nil {
log.Fatal(err)
panic(err)
}
json.Unmarshal(file, &UserStruct)
decodeUser, _ := base64.StdEncoding.DecodeString(UserStruct.User)
decodePass, _ := base64.StdEncoding.DecodeString(UserStruct.Password)
formVal := url.Values{
"user": {string(decodeUser)},
"password": {string(decodePass)},
"url": {"http://www.iium.edu.my/"},
"cmd": {"authenticate"},
"Login": {"Log In"},
}
transCfg := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // ignore expired SSL certificates
}
client := &http.Client{Transport: transCfg}
resp, err := client.PostForm("https://captiveportalmahallahgombak.iium.edu.my/cgi-bin/login", formVal)
formVal = nil
if err != nil {
dialog.XPlatMessageBox("ERROR", err.Error())
log.Fatal(err)
panic(err)
}
var res map[string]interface{}
json.NewDecoder(resp.Body).Decode(&res)
dialog.XPlatMessageBox("SUCCESS", "You are now connected to IIUM-Student")
fmt.Println(res)
}
// MessageBox of Win32 API.