Skip to content

Commit

Permalink
QoL improvents + added ability to look for results
Browse files Browse the repository at this point in the history
  • Loading branch information
PlashSpeed-Aiman committed Feb 22, 2023
1 parent 250f99f commit f7deb24
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 45 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
/Financial.pdf
/timetable.pdf
/cs.html
gopher.png
PassGo.exe - Shortcut.lnk
PassGo.zip
hello
New Text Document.bat
.gitignore
result.html
23 changes: 18 additions & 5 deletions imaalum/imaalum.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
userstruct "PassGo/model/user"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
Expand Down Expand Up @@ -77,7 +78,7 @@ func Imaalum_login() ImaalumClient {
}
return MClient
}
func GetGeneralExamTimeTable(ws *sync.WaitGroup, client ImaalumClient) {
func GetGeneralExamTimeTable(ws *sync.WaitGroup, client *ImaalumClient) {
response, _ := client.client.Get("https://imaluum.iium.edu.my/MyAcademic/course_timetable")
if response.StatusCode == 200 {
bodyBytes, err := io.ReadAll(response.Body)
Expand All @@ -95,8 +96,20 @@ func GetGeneralExamTimeTable(ws *sync.WaitGroup, client ImaalumClient) {
client.client.Get("https://cas.iium.edu.my:8448/cas/logout?service=http://imaluum.iium.edu.my/")
ws.Done()
}
func GetConfimationSlip(ws *sync.WaitGroup, client ImaalumClient) {
response, _ := client.client.Get("https://imaluum.iium.edu.my/confirmationslip?ses=2021/2022&sem=1")
func GetConfimationSlip(ws *sync.WaitGroup, client *ImaalumClient) {
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)
}
response, _ := client.client.Get(fmt.Sprintf("https://imaluum.iium.edu.my/confirmationslip?ses=%s&sem=%s",session_val,semester_val))
if response.StatusCode == 200 {
bodyBytes, err := io.ReadAll(response.Body)
if err != nil {
Expand All @@ -112,7 +125,7 @@ func GetConfimationSlip(ws *sync.WaitGroup, client ImaalumClient) {
client.client.Get("https://cas.iium.edu.my:8448/cas/logout?service=http://imaluum.iium.edu.my/")
ws.Done()
}
func GetFinance(ws *sync.WaitGroup, client ImaalumClient) {
func GetFinance(ws *sync.WaitGroup, client *ImaalumClient) {
response, _ := client.client.Get("https://imaluum.iium.edu.my/MyFinancial")
if response.StatusCode == 200 {
bodyBytes, err := io.ReadAll(response.Body)
Expand All @@ -122,7 +135,7 @@ func GetFinance(ws *sync.WaitGroup, client ImaalumClient) {
}
_ = os.WriteFile("Finance.pdf", bodyBytes, 0644)

dialog.XPlatMessageBox("Done", "Download Complete")
dialog.XPlatMessageBox("Done", "Finance.PDF Download Complete")
}

client.client.Get("https://cas.iium.edu.my:8448/cas/logout?service=http://imaluum.iium.edu.my/")
Expand Down
115 changes: 75 additions & 40 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"io/fs"
"log"
"net/http"
"net/url"
"os"
"sync"
"syscall"
"unsafe"

"golang.org/x/term"
)
Expand All @@ -35,34 +35,80 @@ AUTOMATE LOGIN TO IIUM-STUDENT WITH 2 EASY STEPS
***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")
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)
}
switch user_input {
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()
}
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 read_pass() {
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 Complete")
}
}

func store_pass() {
userVal := ""
Expand All @@ -89,23 +135,28 @@ func store_pass() {
}
}
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)

}
var UserStruct userstruct.User

json.Unmarshal(file, &UserStruct)
decodeUser, _ := base64.StdEncoding.DecodeString(UserStruct.User)
decodePass, _ := base64.StdEncoding.DecodeString(UserStruct.Password)
Expand All @@ -120,11 +171,13 @@ func connect_network() {
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)

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{}

Expand All @@ -135,21 +188,3 @@ func connect_network() {
}

// MessageBox of Win32 API.
func MessageBox(hwnd uintptr, caption, title string, flags uint) int {
ret, _, _ := syscall.NewLazyDLL("user32.dll").NewProc("MessageBoxW").Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))),
uintptr(flags))

return int(ret)
}

// MessageBoxPlain of Win32 API.
func MessageBoxPlain(title, caption string) int {
const (
NULL = 0
MB_OK = 0
)
return MessageBox(NULL, caption, title, MB_OK)
}

0 comments on commit f7deb24

Please sign in to comment.