{"id":1132,"date":"2015-06-06T08:28:24","date_gmt":"2015-06-06T08:28:24","guid":{"rendered":"http:\/\/www.gironsec.com\/blog\/?p=1132"},"modified":"2015-06-06T08:33:54","modified_gmt":"2015-06-06T08:33:54","slug":"anti-debugger-trick-quicky","status":"publish","type":"post","link":"https:\/\/www.gironsec.com\/blog\/2015\/06\/anti-debugger-trick-quicky\/","title":{"rendered":"Anti-Debugger Trick Quicky"},"content":{"rendered":"<p>Howdy all!<\/p>\n<p>Long time no updates. Sorry about that, the life of the AV reverse engineer is a busy one, but busy is good right?<\/p>\n<p>Anywho, I come bearing gifts. An anti-debugger trick I learned (while coding skiddy AV tool). <\/p>\n<p>The way it works is simple &#8211; under normal circumstances, the working set (amount of memory a process needs at a given time) is never very big, however when being debugged, that working set size is huge. By checking the working set size, I was able to see if I was in a debugger. Neato.<\/p>\n<p>Oh right, the code:<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #111111; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #ff0007; font-weight: bold; font-style: italic; background-color: #0f140f\">#include &lt;windows.h&gt;<\/span>\r\n<span style=\"color: #ff0007; font-weight: bold; font-style: italic; background-color: #0f140f\">#include &lt;Psapi.h&gt;<\/span>\r\n<span style=\"color: #cdcaa9; font-weight: bold\">int<\/span> <span style=\"color: #ff0086; font-weight: bold\">main<\/span><span style=\"color: #ffffff\">(<\/span><span style=\"color: #cdcaa9; font-weight: bold\">void<\/span><span style=\"color: #ffffff\">)<\/span>\r\n<span style=\"color: #ffffff\">{<\/span>\r\n<span style=\"color: #ffffff\">PROCESS_MEMORY_COUNTERS<\/span> <span style=\"color: #ffffff\">pmc;<\/span>\r\n<span style=\"color: #ffffff\">GetProcessMemoryInfo(GetCurrentProcess(),<\/span> <span style=\"color: #ffffff\">&amp;pmc,<\/span> <span style=\"color: #fb660a; font-weight: bold\">sizeof<\/span><span style=\"color: #ffffff\">(pmc));<\/span>\r\n  <span style=\"color: #fb660a; font-weight: bold\">if<\/span><span style=\"color: #ffffff\">(pmc.WorkingSetSize&lt;=<\/span><span style=\"color: #0086f7; font-weight: bold\">3456789<\/span><span style=\"color: #ffffff\">)<\/span>\r\n  <span style=\"color: #ffffff\">{<\/span>\r\n   <span style=\"color: #ffffff\">MessageBox(GetDesktopWindow(),<\/span><span style=\"color: #0086d2\">&quot;No Debugger Here&quot;<\/span><span style=\"color: #ffffff\">,<\/span><span style=\"color: #0086d2\">&quot;KEK&quot;<\/span><span style=\"color: #ffffff\">,MB_OK);<\/span>\r\n  <span style=\"color: #ffffff\">}<\/span>\r\n  <span style=\"color: #fb660a; font-weight: bold\">else<\/span>\r\n  <span style=\"color: #ffffff\">{<\/span>\r\n   <span style=\"color: #ffffff\">MessageBox(GetDesktopWindow(),<\/span><span style=\"color: #0086d2\">&quot;GTFO with that debugger&quot;<\/span><span style=\"color: #ffffff\">,<\/span><span style=\"color: #0086d2\">&quot;ICEBP FOR YOU&quot;<\/span><span style=\"color: #ffffff\">,MB_OK);<\/span>\r\n\t<span style=\"color: #fb660a; font-weight: bold\">__asm<\/span> \r\n\t<span style=\"color: #ffffff\">{<\/span>\r\n\t <span style=\"color: #ffffff\">_emit<\/span> <span style=\"color: #0086f7; font-weight: bold\">0xF1<\/span>\r\n\t<span style=\"color: #ffffff\">}<\/span>\r\n  <span style=\"color: #ffffff\">}<\/span>\r\n<span style=\"color: #fb660a; font-weight: bold\">return<\/span> <span style=\"color: #0086f7; font-weight: bold\">0<\/span><span style=\"color: #ffffff\">;<\/span>\r\n<span style=\"color: #ffffff\">}<\/span>\r\n<\/pre>\n<\/div>\n<p>Next week (or hell maybe even tomorrow), I&#8217;m gonna pop out a new longer better blog post on one of my more favorite topics &#8211; shellcode. <\/p>\n<p>Until then, happy hacking!<\/p>\n<p><a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2015\/06\/1246927674442.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2015\/06\/1246927674442.jpg\" alt=\"1246927674442\" width=\"600\" height=\"243\" class=\"alignnone size-full wp-image-1133\" srcset=\"https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2015\/06\/1246927674442.jpg 600w, https:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2015\/06\/1246927674442-300x122.jpg 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Howdy all! Long time no updates. Sorry about that, the life of the AV reverse engineer is a busy one, but busy is good right? Anywho, I come bearing gifts. An anti-debugger trick I learned (while coding skiddy AV tool). The way it works is simple &#8211; under normal circumstances, the working set (amount of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,7],"tags":[82],"_links":{"self":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/1132"}],"collection":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/comments?post=1132"}],"version-history":[{"count":3,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/1132\/revisions"}],"predecessor-version":[{"id":1136,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/1132\/revisions\/1136"}],"wp:attachment":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/media?parent=1132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/categories?post=1132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/tags?post=1132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}