Anyway, this is the part where I get to talk to you about the history of the real-life ninja!
Japan is an interesting place, you know. For the longest time, this was a society where it was entirely comon for feudal lords and warlords to be embroiled in constant warfare and games of dominionship against each other, their warriors egged on into fighting each other and starting new wars by a culture that had a huge need for glorious deeds being recorded for posterity because of their religion being dominated by ancestor worship, and having done glorious deeds in your life that would be later recorded was more important than anything else. This led to absurd cases of warriors fighting personal duels before battle with 'whistling arrows' on horseback and on foot with swords, breaking ranks to get glory and losing their side a battle, and a lot of betrayal, backstabbing, duelling, and honour killings in attempts to get glory and avenge some real or imagined slight to themselves or their ancestors and the honour they associated.
Ever wonder why we have these ridiculously ornate armours, demon masks, and flags mounted on the backs of samurai? That's because samurai were preeny peacocks that wanted everyone to see how big their...
flagpole was, tell others about it, and thus spread their glory far and wide so they would be worshipped in the afterlife. Also, they painted their horses weird colours. No, I'm not joking. Purple, crimson, sky blue, and
chartreuse.
Total attention whore murderhobos with swag.
To quote two samurai commenting from the 13th century:
As translated by Thomas Donald Conlan in State of War: The Violent Order of Fourteeth Century Japan said: said:
"If I were to advance alone, in midst of the enemy, and die in a place where none could witness my deeds, then my death would be as pointless as a dog's death."
"To go forth to the field of battle and miss death by an inch; to leave behind one's name for a myriad generations; all in all, this is the way."
It's as ridiculously bonkers and both tragically and (yet also
hilariously) fucked up as it sounds.
(Fun tidbit: what modern pop culture calls "bushido" was a reaction to the excesses of these times, demanding personal loyalty and subservience to a lord's goals instead of the warrior's own personal glory. It was also born in a time where samurai where no longer doing great martial deeds, but where this more low-key philosophy allowed the state to function without constant bloodshedding and gaudy personal excesses of previous eras.)
Anyway, you will probably see the problem that presents itself: if you have a bunch of murder-happy maniacs, how will you make like Sun Tzi and get enough info to fight a successful war and to deceive your enemy?
Here's the fact where we learn that the Japanese are a very pragmatic people, and honour aside, try to be smart enough to fight to win. While also being justifiably paranoid about suddenly getting murder-stabbed and betrayed. Because if you can't trust peasants because they don't have samurai virtues, who do you turn to? Well...
Some samurai decide to learn enough skills to become their warlords' spies, saboteurs, and assassins, getting rewarded with glory, fame, and lands for it by their lords and comrades for their cunning, strength, and smarts. While also trying to downplay or whitewash the whole "dishonourable" bit.
A lot of the people we would today call "ninja" were members of the samurai (or bushi) who would decide to serve their masters by doing the dishonourable things other samurai wouldn't dare to do, but it was often also an attempt to earn personal glory and respect from peers in daring actions to try and take over entire fortresses or set things on fire for an invading force to come on, sneak into an enemy leader's room to kill him and then escape to brag about it, disguising themselves as peasants to get info and then return later in armour and weapons to murder dudes, and others such crazy things.
Ninja in some eras were part of the ruling class, allowed poorer non-samurai to join the ruling class by making a name for themselves, many had some basic skillset in ninja arts because it was just useful when fighting a war, and some samurai even
specialised in the sort of subterfuge, sabotage, ambushing, and assassination we would today call "ninja arts".
It's a rarely talked-about facet of ninja history, but nonetheless quite interesting.