I have an executable C code binary which asks for 2 inputs. And I want to write a python code which gives the input automatically. What i mean is when i run python code.py | ./ones-and-zeroes
It give inputs to the executable. I tried using print(INPUT)
but it only works if the input asked in next line, not in same line. Here is image
I tried:
print(-1)
print(something)
a bit more brief is- i tried:
print(1)
print(2)
print(3)
it worked here because the input asked in new line
but it did not work for other executable because input is asking input in the same line.
i may not be clear here, sorry. I simply want to input: -1 in the first question(How long is your secret:) and input: test or some string in second question(Enter your secret:). However i want to do it using python code. not manually
Edit: I don’t have the exact C code, however i managed to reverse engineer it and here is something which might help.
void getFlag(void)
{
ushort secret_len;
char your_secret[1936];
printf("\nHow long is your secret: ");
__isoc99_scanf(&DAT_0804a0dc,&secret_len);
if(1927 < (short)secret_len) {
puts("\nYour Secret is too long");
exit(0);
}
printf("\nEnter your secret: ");
getchar();
fgets(your_secret, (uint)secret_len, stdin);
puts("\nThe Enclave will shield your secrets!\n");
return;
}
Thanks everyone for help