"Brain doping": Can drugs compensate a lack of concentration while learning?
The available evidence certainly supports the view that Methylphenidate/Ritalin boosts cognitive abilities while being somewhat safer than amphetamines. Note that if you are caught in possession of this drug without a prescription you will suffer considerably more than the consequences of the drug itself in most countries.

Personally, I doubt that the boost given by Methylphenidate/Ritalin can be significant enough to make a difference in your grades. Note that it will do absolutely nothing to cure your lack of interest in the topic. If you aren't studying enough hours, you won't make it no matter how hopped up you are.

This probably doesn't help much, but my own strategy as an undergraduate student was to simply neglect studying those topics I was not interested in, and simply take the hit to my grade.