The masses of the quarks can be measured in several ways.
For the up, down, and strange quarks, one can use a quirk of QCD called "chiral symmetry breaking", and measure their masses using the masses of the pions and kaons:
mpi2 ~ (mu + md)*EQCD
mK+2 ~ (mu + ms)*EQCD
mK02 ~ (md + ms)*EQCD
One has to do lattice QCD to get the results, and that has the problem that one cannot make the up and down masses too small, or else the pions' Compton wavelengths will cover the entire lattice. So one does the calculations with larger masses, and extrapolates down to observed values.
For the charm and bottom quarks, one can get approximate masses from their bound states, like the J/psi, D, upsilon, and B mesons, since those quarks are nonrelativistic in those states. To improve those estimates, one must calculate those states' binding energies with lattice QCD.
For the top quark, one must get its mass from the total energy of its decay products, since it decays before it can hadronize. andrien's paper is an example of doing that.