bad influencing friends

hi there, i am really worried about my 17 yr old daughter who has reverted back to her old friends who use and take advantage of her. I cant exactly ground her, nearly 18!! She is lonely and wants friends so her vunerability attracts the wrong type of person. Any suggestions are welcome. A few weeks ago my daughters cousin contacted her to go out and with this big step for her she gained a bit of confidence and met some nice people. She was happy and smiling which was amazing to see, then the cousin fell out with the group and my daughter no longer had any visitors or calls which depressed her grately. It was a massive step her going out and having friends round, first time and she was alive and excited.She shut  herself in her room under the duvet felling depressed and didnt eat or drink. Now out of desperation i beleive, she has contacted the people from the past who use her, just to have someone. She has agreed with me that she has contacted them because she wants friends. I dont know how to go about helping her find decent friends. thanks for your time and any ideas are welcome.