If you entered the U.S. unlawfully, you could not apply for a green card from inside the United States. Instead, you have to apply from your home country through consular processing. If you stayed in the U.S. illegally for less than 180 days, you will not be challenged with a reentry ban. Unfortunately, if you stay longer than 180 days, you will likely face a three or ten-year bar when you submit the green card application. If the latter describes your situation, it is essential to consult an immigration attorney.