As explained by Wikipedia and Asylum in Europe, applying for naturalisation in Portugal, like in many other countries, requires a period of legal residence (five years in this case). A person who crossed the border irregularly will therefore first need to secure a legal basis for residence before anything else and does not seem to be at an advantage here.
I could not find any details regarding Portugal but other countries (e.g. France) do have special naturalisation procedures for refugees. That would cover many of the people who recently crossed the Mediterranean by boat and might be the reason for the confusion behind this question. But it's important to note that naturalisation is not easier merely because the person crossed the border irregularly or was undocumented for a time.
It's rather the other way around: It is because these people are refugees that they are prepared to go to such length to reach Europe and are then able to secure legal residence in spite of crossing the border irregularly (non-refugees, including graduated students who failed to transition to another status, would be at risk of removal back to their country of citizenship). But even in this case, applying for citizenship first requires becoming a legal resident by having one's claim to asylum recognized by the country of refuge.