I do know the password length is 24.
I also do know the search space: lower case, upper case and digits.
The combinations should be (26+26+10)^24 = 62^24, right?
I've tried with hashcat to set the charset and the mask
-1 ?l?u?d filename_to_crack ?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1?1
but it won't start because of an integer overflow error due to a huge keyspace; I guess the mask is too large!
Someone can suggest another solution? I was thinking maybe I could write a script that generate a file of random (24 length) strings and then using this to perform a dictionary attack.
Your idea to pre-generate random strings to get around the integer overflow would work. It's not really a dictionary attack at that point, more a rainbow table approach. It's going to take up a lot of space too.
I might suggest trying a dictionary attack of 24 character passwords before generating your brute force list. Perhaps with the lists from https://crackstation.net/ or somewhere else, filtered for length 24, of course. If you want to get creative/more thorough, you could add rules to the passwords from these lists, like l33tspeak substitutions.