It is not illegal, to be precise, it is an illegal operation, which has certain risks for personal credit reporting. The specific points are as follows:
The original intention of paying by card at POS machine is to promote the convenience and safety of consumption. However, in reality, many people set up their own POS and swipe their own or other people's cards to get cash. I play the roles of merchant and consumer. This behavior is actually common in reality, but the bank's rules are there, and this is indeed an illegal operation. But as long as you don't get caught and pay your credit card back on time, it's not illegal.