Tushar
It will not go inside the other scope inside main()
Roberto
Mihail
that's what it does, but that probably isn't the best way to do it
Dima
Dima
Can you show this file?
Roberto
Roberto
Anonymous
yeah I finished read the rules and I will post about the topics very carefully
Roberto
Indeed the first line is not useful
Mihail
pictures of screens aren't allowed
Mihail
i'll warn you next time
Roberto
Sorryyyyy
Roberto
Ok seems legit
Mihail
Roberto
Mihail
requires <limits>
Roberto
I see, thanks
Dima
Dima
What the.. 🤷♀️
Dima
Roberto
Dima
I know maybe this is an assignment/text thing, but don’t you dare to store data like that 😂
Mihail
tbh idk what's worse the way it's stored or the fact it isn't actaully aligned
Roberto
😂
Dima
Dima
Roberto
I agree
Anonymous
Ok
Anonymous
Yeah
Anonymous
MᏫᎻᎯᎷᎷᎬᎠ
Lol
Reusability of my thanking function without my permission to is a bad attitude
Anonymous
MᏫᎻᎯᎷᎷᎬᎠ
professor
why it works with letters and not numbers?
int game(int user_pick) {
int rand_pick;
if ((user_pick < 1) || (user_pick > 32000)) {
printf("Playing the game of chance..\n");
rand_pick = (rand() % 32000) + 1;
printf("You picked: %d\n", user_pick);
printf("Random Value: %d\n", rand_pick);
if (user_pick == rand_pick)
jackpot();
else
printf("Sorry, you didn't win this time..\n");
}
else {
printf("You must pick a value from 1 - 32000\n");
printf("Use help or -h for help\n");
return 0;
}
}
int jackpot() {
printf("You just won!\n");
printf("Congratulations!\n");
return 0;
}
void foo(char* input) {
int(*function_ptr) (int user_pick);
char buffer[20];
srand(time(NULL));
function_ptr = game;
strcpy(buffer, input);
if ((!strcmp(buffer, "help")) || (!strcmp(buffer, "-h")))
{
printf("Help Text:\n\n");
printf("This is a game of chance.\n");
printf("To play, simply guess a number 1 through 32000\n");
printf("If you guess the number I am thinking of you win.\n");
}
else
function_ptr(atoi(buffer));
}
int main(int argc, char* argv[]) {
if (argc < 2) {
printf("Usage: %s <a number 1 - 32000>\n", argv[0]);
printf("use %s help or %s -h for more help.\n", argv[0], argv[0]);
exit(0);
}
foo(argv[1]);
return 0;
}
C:\Users\xxxx>C:\Users\xxxx\Desktop\functionoverwrite.exe 1
You must pick a value from 1 -32000
Use help or -h for help
C:\Users\xxxxx>C:\Users\xxxx\Desktop\functionoverwrite.exe aa
Playing the game of chance..
You picked: 0
Random Value: 7181
Sorry, you didn't win this time..
olli
why it works with letters and not numbers?
int game(int user_pick) {
int rand_pick;
if ((user_pick < 1) || (user_pick > 32000)) {
printf("Playing the game of chance..\n");
rand_pick = (rand() % 32000) + 1;
printf("You picked: %d\n", user_pick);
printf("Random Value: %d\n", rand_pick);
if (user_pick == rand_pick)
jackpot();
else
printf("Sorry, you didn't win this time..\n");
}
else {
printf("You must pick a value from 1 - 32000\n");
printf("Use help or -h for help\n");
return 0;
}
}
int jackpot() {
printf("You just won!\n");
printf("Congratulations!\n");
return 0;
}
void foo(char* input) {
int(*function_ptr) (int user_pick);
char buffer[20];
srand(time(NULL));
function_ptr = game;
strcpy(buffer, input);
if ((!strcmp(buffer, "help")) || (!strcmp(buffer, "-h")))
{
printf("Help Text:\n\n");
printf("This is a game of chance.\n");
printf("To play, simply guess a number 1 through 32000\n");
printf("If you guess the number I am thinking of you win.\n");
}
else
function_ptr(atoi(buffer));
}
int main(int argc, char* argv[]) {
if (argc < 2) {
printf("Usage: %s <a number 1 - 32000>\n", argv[0]);
printf("use %s help or %s -h for more help.\n", argv[0], argv[0]);
exit(0);
}
foo(argv[1]);
return 0;
}
C:\Users\xxxx>C:\Users\xxxx\Desktop\functionoverwrite.exe 1
You must pick a value from 1 -32000
Use help or -h for help
C:\Users\xxxxx>C:\Users\xxxx\Desktop\functionoverwrite.exe aa
Playing the game of chance..
You picked: 0
Random Value: 7181
Sorry, you didn't win this time..
you probably want
if ((user_pick >= 1) && (user_pick <= 32000))
instead of
if ((user_pick < 1) || (user_pick > 32000))
?
professor
let me check it
professor
C:\Users\blackleitus>C:\Users\blackleitus\Desktop\functionoverwrite.exe aa
Playing the game of chance..
You picked: 0
Random Value: 13215
Sorry, you didn't win this time..
C:\Users\blackleitus>C:\Users\blackleitus\Desktop\functionoverwrite.exe 22
Playing the game of chance..
You picked: 22
Random Value: 13225
Sorry, you didn't win this time..
professor
it should if I write aa back to printf("Usage: %s <a number 1 - 32000>\n", argv[0]);
professor
I fix it like this user_pick > 0 && user_pick <= 32000
Mihail
Mihail
what is that if meant to do?
Wim
If the user picked a number, tell which number the user picked, so to see?
Pro
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
So
Now you are a C++ developer
professor
how can I disbale all protections on devc++ at compiler?
Anonymous
I want to learn c and c++ program anyone can teach me🙏
Anonymous
Anonymous
Anonymous
😑
Daniele°
Daniele°
was abandoned by its developers in 2005
Daniele°
professor
It is easy to build software exploitation for new people
Daniele°
Move on a modern compiler
Ariana
professor
Daniele°
If you use a Windows the best choise is Visual Studio
professor
I could find the solution using cl
Ariana
firstly, why would you want to do that
professor
I like to break software 😂
professor
It is fun how software developers think it is so secure
Ariana
aslr can be disabled depending on what os you’re using
the rest ik gcc -fno-stack-protector -z execstack
Ariana
Ariana
Dude
Ariana
it is enabled to make it secure
Ariana
professor
Nx, aslr , cookies , doesnt stop arbitrary code
Ariana
it does
Ariana
Nx prevents wx
Ariana
Meaning only chance is rop or jop
professor
Nx = rop gadgets , aslr=2 byte overwrite, bruteforce address, non-aslr
Ariana
alsr makes it such that you need to find like a libc leak
Ariana
Wtf