{"id":120,"date":"2010-04-21T23:19:49","date_gmt":"2010-04-22T06:19:49","guid":{"rendered":"https:\/\/vernon.mauery.com\/content\/?p=120"},"modified":"2010-04-21T23:19:49","modified_gmt":"2010-04-22T06:19:49","slug":"defeating-a-ninja","status":"publish","type":"post","link":"https:\/\/vernon.mauery.com\/content\/2010\/04\/21\/defeating-a-ninja\/","title":{"rendered":"Defeating a Ninja"},"content":{"rendered":"<p>I was recently asked if I had ever used <a href='http:\/\/forkbomb.org\/ninja\/'>Ninja<\/a> on any of my machines.  I had not even heard of such a thing.  I found that it was available in the Lucid repository, so I installed it and configured it for my system.  The two changes I made were to have it constantly poll, instead of waiting 1 second between polls; and to kill the offending tasks, instead of merely warning about them.  I whipped up a little back door application that gets root.  I ran it and sure enough, it was instantly killed by the Ninja.  But how instantly?  There is a race there to be sure.  I had my w00t process run &#8216;killall -9 ninja&#8217; instead of giving me a root shell.  Sure enough, my hack was faster than the Ninja.  It must only be a wannabe or maybe a Ninja Apprentice.  Whatever it is, I defeated the Ninja in less than ten minutes.  Without even breaking a sweat.<\/p>\n<p>Ninja may be good in concept, but poor in execution (I&#8217;m so punny!!!)  The race window that exists is wide enough to easily defeat it.  What it needs to do is something along these lines:<\/p>\n<p>1) Run the critical section in the kernel as a kprobe parked on the fork, exec, setuid, setgid syscalls.<br \/>\n2) On each watched syscall, check for escalation and pause execution while we pop out to userspace (probably via the kprobe print functions) and do a bit of testing.<br \/>\n3) If we pass muster, let the task go, otherwise kill it.<\/p>\n<p>This way, we can pause the questionable tasks in the kernel before they get a chance to do anything malicious.<\/p>\n<p>Right now, all Ninja does is make you <b>think<\/b> you are safe, while really, it does very little for you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was recently asked if I had ever used Ninja on any of my machines. I had not even heard of such a thing. I found that it was available in the Lucid repository, so I installed it and configured it for my system. The two changes I made were to have it constantly poll, &hellip; <a href=\"https:\/\/vernon.mauery.com\/content\/2010\/04\/21\/defeating-a-ninja\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Defeating a Ninja<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[15,35],"class_list":["post-120","post","type-post","status-publish","format-standard","hentry","category-hobbies","tag-linux","tag-security"],"_links":{"self":[{"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/posts\/120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":0,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"wp:attachment":[{"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}