As Mr. Money Money Mustache once said:
IF YOU HAVE CREDIT CARD DEBT, YOU SHOULD FEEL LIKE YOUR HAIR IS ON FIRE
Although student loan debt is different than credit card debt, it could be argued that it's even worse: if ever have to file for bankruptcy, your student loans will not be erased, unlike most credit card debt.
Pay your debts off as quickly as you can. "Investing" in stocks the way you are proposing is not investing. It's gambling.