—Botnets have always been a formidable cybersecurity threat. Internet of Things (IoT) has become animportant technique and the number of internet-connectedsmart devices has been increasing by more than 15% everyyear. It is for this reason that botnets are growing rapidly.Although the antivirus on Personal Computer (PC) has beingapplied for a long time, the threats from the botnets still cannotbe eliminated. Smart devices and IOT are still in their initialstages, hence there are uncertainties about the security issues.In the foreseeable future, more devices will become victims ofbotnets. In this paper, we propose a system for detectingpotential botnets by analyzing their flows on the Internet. Thesystem classifies similar flow traffic into groups, and thenextracts the behavior patterns of each group for machinelearning. The system not only can analyze P2P botnets, butalso extracts the patterns to application layer and can analyzebotnets using HTTP protocols.