Numerical modelling in rock engineering and mechanics often requires inputting multiple sets of strength parameters, such as the commonly encountered tensile strength, cohesion, and friction angle. Usually, obtaining these parameters requires performing different types of rock mechanics experiments on certain rock specimens, such as tension tests and triaxial tests, which are time-consuming and labor-intensive. Uniaxial compression testing is simpler and requires less demanding equipment. This paper proposes a solution that relies solely on uniaxial compression testing to obtain multiple sets of rock strength parameters. The basic idea is to treat the process of acquiring multiple parameters as a problem of solving a set of mathematical equations. The uniaxial tests with different geometric specimens provide known quantities and the corresponding equations that link these known quantities (e.g., peak loads) with unknown quantities (e.g., strength parameters). We established three-dimensional numerical tests to represent the relationship between input strength parameters and the peak load. By transforming it into an optimization problem, numerical modelling is embedded into the objective function of the optimization algorithm, thereby achieving the automatic extraction of strength parameters. This method is verified through uniaxial compression tests using red sandstone specimens with various geometries. The results show that by changing the geometry of the rock specimens, multiple sets of strength parameters can be obtained. These parameters are successfully used to predict (extrapolate) peak loads of other geometric specimens. This method holds promise for achieving the automated extraction of material parameters for the numerical modelling of rock.