How to modify /etc/hosts file in iphone program?
Is it possible to modify /etc/hosts file in iphone program?
How about for Jailbrea开发者_开发技巧ked iphone?
How to do that? Do I need to call specific API? or just use file operations API.
Thanks.
For a non-jailbroken app, the answer is no.
For a jailbroken app, you're no longer bound by Apple's sandbox, so you can interact with the system directly, for example via file operations (fopen
and friends).
For a non-jailbroken phone the only way I managed to do this was to change the /etc/hosts file on the wireless router I was connecting to or use a custom DNS server that would in fact cause a DNS poisoning (this is illegal, afaik).
精彩评论