File size: 4,352 Bytes
d89b239
 
 
 
7095e83
d89b239
7095e83
 
 
 
 
 
 
 
 
 
2e0d7a4
7095e83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d89b239
 
2e0d7a4
 
a5342a3
2e0d7a4
821299e
2e0d7a4
4ce8c1f
2e0d7a4
7095e83
 
 
 
 
 
 
 
4ce8c1f
 
2e0d7a4
821299e
2e0d7a4
 
 
4ce8c1f
2e0d7a4
 
7095e83
 
 
2e0d7a4
 
 
a6b025b
2e0d7a4
 
 
 
 
a4da194
a5342a3
 
 
a4da194
 
2e0d7a4
 
7095e83
 
 
821299e
a6b025b
821299e
 
 
 
 
a5342a3
821299e
424eeda
821299e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7095e83
a5342a3
cb6f2bb
7095e83
2e0d7a4
d89b239
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>WebSSH</title>
    <link href="static/img/favicon.png" rel="icon" type="image/png">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .container {
            background-color: #ffffff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .error-popup {
            display: none;
            color: #721c24;
            background-color: #f8d7da;
            border-color: #f5c6cb;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid transparent;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div id="error-popup" class="error-popup">
            <i class="fas fa-exclamation-circle"></i>
        </div>

        <div class="user-container">
        <form action="/app" method="post">
            <h1>Create New User</h1>
            <div class="form-group">
                <label for="username">Username:</label>
                <input type="text" id="username" name="username" class="form-control" required>
            </div>
            <div class="form-group">
                <label for="password">Password:</label>
                <input type="password" id="password" name="password" class="form-control" required>
            </div>
            <button type="submit" class="btn btn-primary" >Get Key</button>
        </form>
        </div>

        <div class="command-container">
            <div class="form-group">
                <label for="command">Command:</label>
                <input type="text" id="command" name="command" class="form-control" placeholder="Not Implemented yet" required>
            </div>
            <button type="button" id="execute-button" class="btn btn-success" onclick="run_commands()">Execute</button>
        </div>

    <script>
        function run_commands() {
            const command = document.getElementById('command').value;
            fetch('/commands', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ command: command })
            })
            .then(response => {
                console.log("Response :",response)
                document.getElementById('error-popup').style.display = 'block';
                document.getElementById('error-popup').innerHTML = response;
                return response.text();
            })
        }
        function get_privatekey() {
            event.preventDefault();
            var username = document.getElementById('username').value;
            var password = document.getElementById('password').value;
            fetch('/get_key', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ username: username, password: password })
            })
            /*
            .then(response => {
                console.log(response)
                if (!response.ok) {
                    throw new Error('Network response was not ok');
                }
                return response.blob();
            })
            .then(blob => {
                const url = window.URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.style.display = 'none';
                a.href = url;
                a.download = 'id_rsa';
                document.body.appendChild(a);
                a.click();
                window.URL.revokeObjectURL(url);
            })
            .catch(error => {
                console.error('There was a problem with the fetch operation:', error);
                document.getElementById('error-popup').style.display = 'block';
            });*/
        };
    </script>
    </div>
</body>
</html>