A ninja (忍者?) or shinobi (忍び?) was a covert agent or mercenary of feudal Japan specializing in unorthodox arts of war. The functions of the ninja included espionage, sabotage, infiltration, and assassination, as well as open combat in certain situations. The ninja, using covert methods of waging war, were contrasted with the samurai, who had strict rules about honor and combat. In his Buke Myōmokushō, military historian Hanawa Hokinoichi writes of the ninja:
“ They travelled in disguise to other territories to judge the situation of the enemy, they would inveigle their way into the midst of the enemy to discover gaps, and enter enemy castles to set them on fire, and carried out assassinations, arriving in secret. ”
The origin of the ninja is obscure and difficult to determine, but can be surmised to be around the 14th century.However, the antecedents to the Ninja may have existed as early as the Heian[5] and early Kamakura eras.Few written records exist to detail the activities of the ninja. The word shinobi did not exist to describe a ninja-like agent until the 15th century[citation needed], and it is unlikely that spies and mercenaries prior to this time were seen as a specialized group. In the unrest of the Sengoku period (15th - 17th centuries), mercenaries and spies for hire arose out of the Iga and Kōga regions of Japan, and it is from these clans that much of later knowledge regarding the ninja is inferred. Following the unification of Japan under the Tokugawa shogunate, the ninja descended again into obscurity. However, in the 17th and 18th centuries, manuals such as the Bansenshukai (1676) — often centered around Chinese military philosophy — appeared in significant numbers. These writings revealed an assortment of philosophies, religious beliefs, their application in warfare, as well as the espionage techniques that form the basis of the ninja's art. The word ninjutsu would later come to describe a wide variety of practices related to the ninja.