Is it illegal to use a random Social Security number?

In general, legally speaking, it is illegal to use a SSN that was not assigned to you by the Social Security Administration.  Thus, it is a good idea not to use a SS# that is not yours, and definitely not use even your own valid number to work if you do not have the authorization from DHS.  Having said that, laws are always a lot more complex, and there have been some cases in which an illegal immigrant who used a fake SSN that caused no harm to the rightful owner of that number (or to no one if that number was never assigned), the penalty is a lot less.  It still does not justify engaging in this crime because most likely when you will be caught doing this, this will not be the only charge against you, and one way or the other, you will be convicted.