-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathpseudocode.cc
157 lines (143 loc) · 3.28 KB
/
pseudocode.cc
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
FILE *stream;
char *change_id(const char *a1)
{
size_t v1; // rax
char v3; // [rsp+10h] [rbp-B0h]
char v4[8]; // [rsp+70h] [rbp-50h]
int64_t v5; // [rsp+78h] [rbp-48h]
int64_t v6; // [rsp+80h] [rbp-40h]
int64_t v7; // [rsp+88h] [rbp-38h]
char v8; // [rsp+90h] [rbp-30h]
char v9[28]; // [rsp+A0h] [rbp-20h]
int i; // [rsp+BCh] [rbp-4h]
*(int64_t *)v4 = 0LL;
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
v8 = 0;
MD5_Init(&v3);
v1 = strlen(a1);
MD5_Update(&v3, a1, v1);
MD5_Final(v9, &v3);
for ( i = 0; i <= 15; ++i )
sprintf(&v4[2 * i], "%02X", (unsigned __int8)v9[i]);
return strdup(v4);
}
int print_banner()
{
puts(
"\n"
" # # #### ##### ######\n"
" # # # # # #\n"
"### ### # # #####\n"
" # # # # #\n"
" # # # # # #\n"
" #### # #\n"
"\n");
setvbuf(stdout, 0LL, 2, 0LL);
setvbuf(stdin, 0LL, 2, 0LL);
return chdir("/tmp");
}
int print_menu()
{
puts("=====MENU======");
puts("1. Edit note");
puts("2. Show note");
puts("3. Save note");
puts("4. Change ID");
return puts("5. Exit");
}
char *load_note()
{
char s; // [rsp+0h] [rbp-100h]
if ( !stream )
return 0LL;
fseek(stream, 0LL, 0);
_isoc99_fscanf(stream, "%256s", &s);
return strdup(&s);
}
int save_note(const char *a1)
{
int result; // eax
if ( a1 )
{
fseek(stream, 0LL, 0);
result = fputs(a1, stream);
}
return result;
}
char *edit_note()
{
char s; // [rsp+0h] [rbp-100h]
_isoc99_scanf("%256s", &s);
return strdup(&s);
}
FILE *load_id()
{
FILE *result; // rax
const char *filename; // [rsp+8h] [rbp-8h]
printf("Input your ID:");
_isoc99_scanf("%256s", &unk_602040);
filename = change_id((const char *)&unk_602040);
stream = fopen(filename, "r+");
result = stream;
if ( !stream )
{
result = fopen(filename, "w+");
stream = result;
}
return result;
}
void main(int64_t a1, char **a2, char **a3)
{
char *v3; // rax
int64_t *v4; // [rsp-8h] [rbp-28h]
int v5; // [rsp+Ch] [rbp-14h]
const char *v6; // [rsp+10h] [rbp-10h]
char *v7; // [rsp+18h] [rbp-8h]
int64_t savedregs; // [rsp+20h] [rbp+0h]
v4 = &savedregs;
print_banner();
v6 = "%d";
load_id();
v7 = load_note();
print_menu();
while ( 1 )
{
printf("> ", a2);
a2 = (char **)&v5;
if ( (signed int)_isoc99_scanf(v6, &v5) <= 0 )
break;
switch ( v5 )
{
case 1:
printf("Note:", &v5);
v7 = edit_note();
break;
case 2:
a2 = (char **)v7;
printf("Note:%s\n", v7);
break;
case 3:
save_note(v7);
puts("Saved!");
break;
case 4:
fclose(stream);
v3 = change_id((const char *)&unk_602040);
unlink(v3);
load_id();
puts("Done!");
break;
case 5:
if ( stream )
fclose(stream);
exit(0);
return;
default:
puts("Invalid choice");
break;
}
}
exit(0);
}