-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbirbtool.cpp
More file actions
206 lines (197 loc) · 5.51 KB
/
birbtool.cpp
File metadata and controls
206 lines (197 loc) · 5.51 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
#include <direct.h>
#include "libs/sha256.h"
void print(std::string str){
std::cout << str << std::endl;
};
void wait(int sec){
Sleep(sec * 1000);
};
int main(){
system("cls");
SetConsoleTitle("BirbTool");
wait(3);
print("Checking for missing folders...");
mkdir("users");
mkdir("apps");
wait(1);
print("BirbTool v0.1");
print(
"Boot options:\n"
"Use \"shutdown\" to shutdown birbTool.\n"
"Use \"launch\" to launch default BirbOS mode.\n"
"Use \"usrtool\" to start up the UserTool.\n"
"Use \"dsktool\" to check the birbOS installation.\n"
"Use \"changepass\" to change the password for your account.\n"
"Use \"deluser\" to delete your account.\n"
);
ldr:
std::string ldr;
std::cout << "BirbTool>";
getline(std::cin, ldr);
if(ldr=="shutdown"){
system("cls");
print("Shutting down the system, please wait...");
wait(5);
return 0;
};
if(ldr=="launch"){
print("Booting from {3f79bb7-b435b05321-651daefd3}...");
wait(2);
try {
ShellExecute(NULL, "open", "birbOS.exe", NULL, NULL, SW_SHOWDEFAULT);
}
catch (...) {
print("Can't find birbOS.exe. Did you rename it?");
wait(3);
return(1);
}
return(0);
};
if(ldr=="usrtool"){
print("birbOS UserTool");
std::string u;
std::string c;
std::string p;
std::cout << "Enter username: ";
getline(std::cin, u);
std::string folder =
"users/" +
u + "/";
if(GetFileAttributes(folder.c_str()) != INVALID_FILE_ATTRIBUTES){
print("User exists.");
goto ldr;
}
std::cout << "Do you want to set a password? (Y/N): ";
getline(std::cin, c);
if(c=="N") {
mkdir(folder.c_str());
print("Done!");
goto ldr;
}
if(c=="n") {
mkdir(folder.c_str());
goto ldr;
}
std::cout << "Enter password: ";
getline(std::cin, p);
if(p.empty()) {
print("Please enter a password.");
goto ldr;
}
mkdir(folder.c_str());
std::string pwordfile =
"users/" +
u + "/.birbuser";
char *cp = &p[0u];
std::ofstream pass(pwordfile.c_str());
pass << SHA256(cp) << std::endl;
pass.close();
print("Done!");
goto ldr;
};
if(ldr=="dsktool"){
print("This command is in development...");
goto ldr;
};
if(ldr=="changepass"){
std::string u;
std::string p;
std::string np;
std::cout << "Please enter your username: ";
getline(std::cin, u);
std::string folder =
"users/" +
u + "/";
if(GetFileAttributes(folder.c_str()) != INVALID_FILE_ATTRIBUTES){
}
else{
print("User does not exist.");
goto ldr;
};
std::string pwordfile =
"users/" +
u + "/.birbuser";
ifstream ifile(pwordfile.c_str());
if (ifile) {
std::cout << "Please enter your old password: ";
getline(std::cin, p);
char *cp = &p[0u];
std::ifstream ifs (pwordfile.c_str());
std::string s;
getline (ifs, s, (char) ifs.eof());
std::string s1 = s.erase(64,3);
std::string s2 = SHA256(cp);
char *str1 = &s1[0u];
char *str2 = &s2[0u];
if(strcmp(str1, str2) != 0){
print("Password is incorrect!");
goto ldr;
};
}
ifile.close();
std::cout << "New password: ";
getline(std::cin, np);
remove(pwordfile.c_str());
char *cp2 = &np[0u];
std::ofstream pass(pwordfile.c_str());
pass << SHA256(cp2) << std::endl;
pass.close();
print("Done!");
goto ldr;
}
if(ldr == "deluser"){
string u;
string p;
cout << "Username: ";
getline(std::cin, u);
std::string folder =
"users/" +
u + "/";
if(GetFileAttributes(folder.c_str()) != INVALID_FILE_ATTRIBUTES){
}
else{
print("User does not exist.");
goto ldr;
};
std::string pwordfile =
"users/" +
u + "/.birbuser";
ifstream ifile(pwordfile.c_str());
if (ifile) {
cout << "Password: ";
getline(std::cin, p);
char *cp = &p[0u];
std::ifstream ifs (pwordfile.c_str());
std::string s;
getline (ifs, s, (char) ifs.eof());
ifs.close();
std::string s1 = s.erase(64,3);
std::string s2 = SHA256(cp);
char *str1 = &s1[0u];
char *str2 = &s2[0u];
if(strcmp(str1, str2) != 0){
print("Password is incorrect!");
goto ldr;
};
}
ifile.close();
std::string folder2 =
"users\\" +
u + "\\";
string dir = "del /f /q /s " + folder2 + ">nul";
system(dir.c_str());
string dir2 = "rd /q " + folder2 + ">nul";
system(dir2.c_str());
print("Done!");
goto ldr;
}
if(ldr.empty()){
goto ldr;
}
print("Invalid choice!");
goto ldr;
}