Allah the Almighty commands:
“Believers! Obey Allah and obey the Messenger, and those from among you who are invested with authority. If you were to dispute with them (the authorities) about anything, refer it to Allah and the Messenger if you indeed believe in Allah and the Last Day. That is better and turns out well.” (4:59)
You have to follow the laws and regulations of the authorities as long as they are not contradictory to the laws of Allah. Therefore, you shouldn’t go abroad illicitly. Try to do your work by legal means. But about your earnings: It won’t be unlawful unless the work you did is something forbidden.