Candy Box 2 ascii art is released under the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0). This means that you are free to:
Under the following conditions :
You can get more information about this license here.
You can view all the ascii art used in the game here.
At the beginning of most ascii art files, there is a special notice which begins with "@author" followed by the name of the ascii artist(s) you need to credit if you want to use the ascii art. Just put somewhere in your project that the ascii art you use was originally created by the authors specified in this notice, that's all! :)
If there is no "@author" notice, it means that the ascii art isn't original enough to be copyrighted, and therefore you can just use it however you want.