The two, rubber tapper Hassan Ali, 47, and construction worker Din Abdilla, 34, were also ordered to be given a stroke of the rotan.
Both pleaded guilty before Sessions Court judge Azreena Aziz to charges under Section 6(1)(c) of the Immigration Act 1959/63 for having no documents in their possession.
The court also ordered that the duo be referred to the Immigration Department for deportation and have their biometric details recorded.
Hassan, a father of 10 children, has been living in Sabah for the last 38 years, while Din, who has six children, has been living in the state for the last 13 years.
The two, who were brought to the Kota Kinabalu courthouse Tuesday (Nov 27) under a tight security ring, were arrested on Nov 1 at Kampung Unggusan in Tenom about 200km from here during anti-terror operation by Bukit Aman.
The prosecution was led by Asst Supt Sabrina Jimius, while the duo were not represented.
On Nov 16, Inspector-General of Police Tan Sri Mohamad Fuzi Harun said that seven Filipino-based Abu Sayyaf Group militants and a Malaysian Islamic State member were rounded up by the federal police in anti-terror swoops in Putrajaya and Sabah.
He said that the suspects were arrested by the Bukit Aman Special Branch Counter Terrorism Division between Oct 30 and Nov 12.
Hassan and Din were among three Filipinos arrested in Tenom whom police suspect were members of the kidnap-for-ransom group linked to the southern Philippines-based Abu Sayyaf group.