I borrowed my friend's DSO to complete my project(Hantek DSO5072), but on scope it says CAT II/400V. So is it safe to measure 220Vrms@50Hz with it?
I see several "scary" elements in your question.
This isn't your DSO, you should use it only to measure "safe" (low voltage) things. When in doubt: only things that are battery powered.
CAT II/400V says something about what the oscilloscope can handle at its inputs. It doesn't tell you anything about your safety.
Also: Why would you need to measure mains voltage?
If that really is your goal, measure the output of a power adapter that outputs a low value AC voltage (so not DC) of 15 V AC for example. These are rare nowadays but were more common 20 years ago.
The issue is that the oscilloscope has inputs that are grounded on one side. Grounded meaning connected to Earth, assuming it is connected to the mains properly, so using a cable with Earth and using a proper Earthed socket. If you then would "measure the mains" there's a large chance that you will get a big spark when you connect the scope. And if you're lucky the Ground Fault detection (if that is present in your house and working) will switch off the mains power.
If you're unlucky you can connect the mains to the scope and then your scope could be mains live meaning you will get an electric shock when you touch it.
You should watch EEVBlog Dave Jones' video on this subject: How NOT To Blow Up Your Oscilloscope
After your added comment: you might need a high voltage probe specifically designed for these kinds of measurements. Most of these are quite expensive, often more than the listed price of your friend's scope.