<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mahmoud Elfawair on Medium]]></title>
        <description><![CDATA[Stories by Mahmoud Elfawair on Medium]]></description>
        <link>https://medium.com/@mahmoudelfawair?source=rss-d2c5d814b841------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Opf1Ott-ZIcjLNZ9QgBNcw.jpeg</url>
            <title>Stories by Mahmoud Elfawair on Medium</title>
            <link>https://medium.com/@mahmoudelfawair?source=rss-d2c5d814b841------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 10:23:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mahmoudelfawair/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Azure Data Explorer Magic]]></title>
            <link>https://mahmoudelfawair.medium.com/azure-data-explorer-magic-468c69a7eebb?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/468c69a7eebb</guid>
            <category><![CDATA[kql]]></category>
            <category><![CDATA[log-ingestion]]></category>
            <category><![CDATA[azure-data-explorer]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Wed, 04 Dec 2024 12:56:31 GMT</pubDate>
            <atom:updated>2024-12-04T22:39:11.476Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello You,</p><p>In today’s blog, we will talk about Azure Data Explorer and how we can use it to ingest logs and query data using a super-efficient and fast query language called Kusto Query Language (KQL).</p><p>The idea started when I was solving some HTB Sherlock challenges and was provided with logs like Zeek logs and Windows Event Logs. I had to use tools such as jq, Get-WinEvent, and grep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*GHg6S6RQEQfpI4Ot" /></figure><p>To be honest, I didn’t get it why we were using these kinds of tools when we have powerful query languages like KQL, SPL, and etc…</p><p>That’s when I started looking for a way to ingest the logs I had into some kind of data analytics tool, and the first thing that came to mind was Azure Data Explorer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*P8aESkPf_BIJguMseqk_Aw.png" /></figure><p>So, Let’s get to it.</p><h3>Ingesting Logs to ADX</h3><p>First, you need an Outlook account to sign in to <a href="https://dataexplorer.azure.com/publicfreecluster">https://dataexplorer.azure.com/publicfreecluster</a> and create a free cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hclWNjfy-gugsm_Bh5x7HQ.png" /></figure><p>After creating a cluster and a database you can either create a table with the schema you want then ingest data into it, or you can just ingest a local file (you can ingest up to 1000 files where each of them less than 1 gigabyte)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JtAOEd9KsvjTdz8g6tqxFg.png" /><figcaption>Click on ingest then local file</figcaption></figure><p>In my case I wanted to ingest the conn.log file from zeek logs which is one of the most important logs Zeek creates</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mj03M0MjSFbdLUD71fPlfw.png" /><figcaption>about conn.log</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TWYfoCoWNXP8iAZJbPwSqA.png" /><figcaption>Name your table and drag&amp;drop your file</figcaption></figure><p>Now sometimes Azure Data Explorer won’t be able to recognize your data format if there is some changes to it, but you can clean the data and get the right format</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JlW5CatYCzyHappXTUndpQ.png" /></figure><p>even though that the file format is TSV I got an error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2i6worcxQZqYg2vW-3kgoQ.png" /></figure><p>In my case it was because of the leading #, so I asked chatgpt to write me a script to clean all Zeek logs by removing the lines that starts with # except the one starting with #fields to keep the naming of the columns names</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*vSRffos4mVvFeyXQQUIoKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LDZs93NuhGch8m0lV-Jggw.png" /></figure><p>Then just go through the process again and upload your cleaned logs</p><p>now each column contained the correct data, ensuring the rows and columns were properly aligned and formatted for ingestion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ut9RRSoDU-ISCZvoinD8nA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UVAC2XqdDy7SqdXyk1L4Ig.png" /></figure><p>Then you can query the data as you wish</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VEaGW3VPy6Vmq54AhQ8_YQ.png" /></figure><p>And yeah this is it for today’s blog :3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/165/0*fKjypYJBR0FPaWM1.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=468c69a7eebb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BAUCTFv1 OSINT/orosin official write up]]></title>
            <link>https://mahmoudelfawair.medium.com/bauctfv1-osint-orosin-official-write-up-72336c37178f?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/72336c37178f</guid>
            <category><![CDATA[osint]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Thu, 23 May 2024 21:02:09 GMT</pubDate>
            <atom:updated>2024-05-23T21:02:09.830Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello You.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*etb_f26P8lhwWNCzz4FBsA.png" /><figcaption>Challenge Description</figcaption></figure><p>For some reason this challenge got zero solves :(</p><h4>Now let’s get our hands dirty…</h4><p>From the poem, you might think that I want you to search for the author of the poem but it is AI generated (It’s just for trolling, guys C’mon)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MY24-59YVCCxRaZcU5NBtA.png" /><figcaption>zeroGPT</figcaption></figure><p>knowing that and after reading the poem you should understand that it is talking about someone which is `عثمان سيشا` which I also focused on in the hint.</p><p>If you start looking for his name in Arabic you will get no result and you will fall down the rabbit hole. So, if you’ve considered searching for his name in English, that would be the right move</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uD_cQ4s2fiC-nfPH36KPmQ.png" /></figure><p>now searching for Usman Sisha will yield nothing useful and you’ll find that no one has that name, but google search gives you a hint to search for the correct name which is more popular</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*GPI-JeWAIyF1ZD3VpMwPtg.png" /></figure><p>Here if you keep digging you will find a twitter account with the username usmanshisha</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*d74ImDZ5O2oEHfZP1Tbalg.png" /><figcaption>:3</figcaption></figure><p>There is only two posts and there is a wired link if you try to open that link on your normal browser you’ll find that it doesn’t exists and that is because it is a tor link</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*REPKreO3Eg4OLjm8B2W3Ag.gif" /></figure><p>You don’t have to worry about it though ;)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2MTKM9Dxl-Cbo7F12kgslQ.png" /><figcaption>Tor from brave</figcaption></figure><p>Oh great, it is a ZeroBin which something similar to <a href="https://pastebin.com/">PasteBin</a> but on the dark net, here you can see that the data is encrypted, if you refresh the page it will ask you for a password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-mw-TcBsddhFLg2CKjE2Q.png" /></figure><p>Now we need to start looking for the password…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*Niq7UIdkDPjvTLCdbVy2lQ.gif" /></figure><p>Going back the the twitter account, there is nothing except the link that would attract your eyes (+ we have no other leads), the account is the only thing that we have.</p><p>One of the thoughts that may come to mind is that the user usmanshisha might have posted something and then deleted it. We can use the wayback machine to check if there is a record for that account or not</p><p>Doing so we can see that there is a record in 2023 of that account, if you go and check that <a href="https://web.archive.org/web/20231007182639/https://twitter.com/usmanshisha">snapshot</a>, you’ll find that usmanshisha has posted something to his brother Muhammad Sumbul</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bE_Q7rhaH_dz3ct4D6LOJQ.png" /></figure><p>and here you will find this text:</p><blockquote>Unlock the gates with the passphrase: <strong>WinterIsComing</strong>, my brother Sumbul. If you discover this secret, you’re truly my kin. This tweet shall vanish upon your success.</blockquote><p>from here we go back to ZeroBin and we get the flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oaPN7QOzaqOcKjsFSmy69w.png" /></figure><pre>BAU{y0u_kn0w_n0th1n6_j0n_5n0w_:3}</pre><p>And that is the story of an easy challenge that was turned into a broken challenge because of a poem lol</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72336c37178f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[METACTF Quals 24 Rev/Starkore]]></title>
            <link>https://mahmoudelfawair.medium.com/metactf-quals-rev-starkore-7b5a81f4951b?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b5a81f4951b</guid>
            <category><![CDATA[regex]]></category>
            <category><![CDATA[elf]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Sat, 18 May 2024 22:19:19 GMT</pubDate>
            <atom:updated>2024-05-18T22:23:16.396Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello You.</p><p>Let’s get right to solving this <a href="https://github.com/mahmoudelfawair/CTF/tree/main/starkore">challenge</a></p><pre>$ file starkore             <br>starkore: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b74e95dd371d2e8cf28958feb4afd0cb5fe9a586, for GNU/Linux 3.2.0, not stripped</pre><p>Executing strings will yield this</p><pre>^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$<br>%04X<br>HELLO, PLEASE ENTER A VALID KEY: <br>WELCOME, MR STARK! BOOTING UP...<br>flag.txt<br>Couldn&#39;t open file<br>KEY INCORRECT!<br>SHUTTING DOWN</pre><p>here we can see regex for something, we don’t know yet what it is, but it super interesting, if you are new to regex you can use <a href="http://regex101.com/">regex101</a> to understand what it is about</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*tDB736cx2RUQ5dVN8sXvPQ.png" /></figure><p>Knowing that a possible value that fits this regex would be ASDF-QWER-ZXCV-1234-as12</p><p>executing ltrace yields this</p><pre>$ ltrace ./starkore <br>printf(&quot;HELLO, PLEASE ENTER A VALID KEY:&quot;...)                                                                                     = 33<br>fgets(HELLO, PLEASE ENTER A VALID KEY: key<br>&quot;key\n&quot;, 100, 0x7f6e790c1aa0)                                                                                               = 0x7ffd874f51d0<br>strcspn(&quot;key\n&quot;, &quot;\n&quot;)                                                                                                            = 3<br>strcpy(0x7ffd874f50d0, &quot;key&quot;)                                                                                                     = 0x7ffd874f50d0<br>regcomp(0x7ffd874f50f0, 0x5601b6ecc008, 1, 0x5601b6ecc008)                                                                        = 0<br>strtok(&quot;key&quot;, &quot;-&quot;)                                                                                                                = &quot;key&quot;<br>sprintf(&quot;0&quot;, &quot;%d&quot;, 0)                                                                                                             = 1<br>strlen(&quot;0&quot;)                                                                                                                       = 1<br>sprintf(&quot;3653&quot;, &quot;%04X&quot;, 0x3653)                                                                                                   = 4<br>strcmp(&quot;3653&quot;, &quot;key&quot;)                                                                                                             = -56<br>sprintf(&quot;1&quot;, &quot;%d&quot;, 1)                                                                                                             = 1<br>strlen(&quot;1&quot;)                                                                                                                       = 1<br>sprintf(&quot;2672&quot;, &quot;%04X&quot;, 0x2672)                                                                                                   = 4<br>strcmp(&quot;2672&quot;, &quot;key&quot;)      <br>...<br>...                                                                                                       = -57</pre><p>we’ll get to this later, however</p><h4>Now let’s start reversing</h4><p>Here you can use any decompiler you want, I used IDA</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2guO5chdZmZ7iWytpemq1w.png" /><figcaption>main</figcaption></figure><p>It is super simple main, it just takes user input then sends it to checkKey and if it’s correct it opens the flag.txt file and print its content, other than that, it will print Incorrect... and exit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5f5DXknLzMc9Eyj72WL6g.png" /><figcaption>checkKey</figcaption></figure><p>IDA did me wrong here and didn’t identify the array, but in line 48 the expression &amp;v6 + k gave me a hint to revisit the block where the v6, v7 ... were initialized, and you can see they are adjacent.</p><p>In this function you can see the use of <a href="https://linux.die.net/man/3/regcomp">regcomp</a> &amp; <a href="https://www.tutorialspoint.com/c_standard_library/c_function_strtok.htm">strtok</a>. However, in the for loop it takes each part and compares it with a value that gets out of the wired long named function Crc... I didn’t really care what it does but I knew that it is the function that generates the values that I saw from the ltrace output.</p><p>So, It comapres the value that gets generated from Crc… to the part of the key and if it is the same it will put the value of the j which goes from 0 to 100 in 1.1 sec lol nvm,,, and breaks out of the loop 5 times</p><p>In the last line there is a simple equation, I used z3 to get the values that satisfies the result which is 1337</p><pre>from z3 import *<br><br>v = [Int(f&#39;v{i}&#39;) for i in range(6, 11)]<br><br>solver = Solver()<br><br>solver.add(v[2] + v[1] * v[0] - v[3] + v[4] == 1337)<br>for var in v:<br>    solver.add(var &gt;= 0, var &lt;= 100)<br><br>if solver.check() == sat:<br>    model = solver.model()<br>    solution = [model[var].as_long() for var in v]<br>    print(f&quot;Solution: {solution}&quot;)<br>else:<br>    print(&quot;No solution found&quot;)</pre><p>As you know z3 won’t give you the best solution but it will give you a solution, and here it doesn’t really matter any solution is good</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*1vnUaoDwBNo2hlMABnIYPQ.gif" /></figure><pre>Solution: [99, 12, 95, 42, 96]</pre><p>Here I went back to ltrace output, I wrote this line to get the values</p><pre>$ egrep -io &#39;strcmp\(&quot;(.*)&quot;\,|strlen\(&quot;[^&quot;]*&quot;&#39; ltrace.out | egrep -o &#39;[0-9A-Z]{1,4}&#39;</pre><p>then I wrote another python script:</p><pre>l = &quot;&quot;&quot;0<br>3653<br>1<br>2672<br>2<br>1611<br>...<br>...<br>97<br>F9B9<br>98<br>0856<br>99<br>1877<br>100<br>C153&quot;&quot;&quot;<br><br>l = l.split()<br>sol = [99, 12, 95, 42, 96]<br><br>key = &#39;-&#39;.join([l[l.index(str(i)) + 1] for i in sol])<br>print(key)<br><br></pre><p>And that’s how I got the flag</p><pre>$ nc challenges.cscpsut.com 10528<br>HELLO, PLEASE ENTER A VALID KEY: 1877-20B5-D9FB-DF40-E998<br>WELCOME, MR STARK! BOOTING UP...<br><br>METACTF{31381fe3-7f32-4e72-bb21-1b91da559501}</pre><p>I hope you enjoyed reading the write up, have a great day cya…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b5a81f4951b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frida 101]]></title>
            <link>https://mahmoudelfawair.medium.com/frida-101-8e1e63b778bd?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e1e63b778bd</guid>
            <category><![CDATA[mobile-pentesting]]></category>
            <category><![CDATA[frida]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Fri, 05 Apr 2024 22:28:53 GMT</pubDate>
            <atom:updated>2024-04-05T22:28:53.777Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello you.</p><p>The last couple days I was learning about Frida, and it is super interesting. That’s why I’m writing this article, but before I start go and check out this <a href="https://github.com/DERE-ad2001/Frida-Labs?tab=readme-ov-file">repo</a>, it’s the best I’ve ever read about Frida.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*S8a24CHgfKjXXjPwDGVglg.png" /></figure><h3>Setup</h3><p>To set up Frida install frida-tools using pip3 install frida-tools and then download frida server to push it on our android emulator, you can find them <a href="https://github.com/frida/frida/releases">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*oQRTSt6POzpzSe7t7npwaQ.png" /></figure><p>There is so many releases but look for the frida-server and choose the one that suite your computer architecture.</p><p>Then we need to unzip the file and push it on our Android emulator, me personally I’m using genymotion</p><pre>unzx frida-server-16.1.4-android-x86_64.xz<br>adb push frida-server-16.1.4-android-x86_64 /data/local/tmp/</pre><p>make sure to have the latest version of XZ to avoid backdoors</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lSAfNN0akJ1PBKDE.jpg" /></figure><p>However, now that we have pushed frida-server go and chmod +x and run it to start the magic.</p><h4>Frida tools</h4><p>To get the list of packages installed on your devices, we’ll use frida-ps</p><pre>frida-ps -Uai </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*05QwdLpc1fmUKAwDT-QoLA.png" /><figcaption>frida-ps result</figcaption></figure><p>go the the manual page and check what these switches are used for.</p><p>Now, let’s attach frida with an application.</p><pre>frida -U -f com.amaze.filemanager</pre><p>After executing this command, you’ll notice that the file managerhas started.</p><h4>Hooking</h4><p>Hooking refers to the process of intercepting and modifying the behavior of functions or methods in an application or the Android system itself.</p><p>This is the template to hook a function</p><pre>Java.perform(function() {<br><br>  var &lt;class_reference&gt; = Java.use(&quot;&lt;package_name&gt;.&lt;class&gt;&quot;);<br>  &lt;class_reference&gt;.&lt;method_to_hook&gt;.implementation = function(&lt;args&gt;) {<br><br>    console.log(`meh`)<br>    // continue editing on this function<br>    // using the this here we can call the same function <br>    ret_val = this.&lt;method_to_hook&gt;()<br>    return ret_val;<br><br>  }<br>})</pre><p>if the function you are hooking needs arguments to function we can use the overload(arg_type) keyword.</p><pre>&lt;class_reference&gt;.&lt;method_to_hook&gt;.overload(&#39;int&#39;, &#39;int&#39;).implementation = function(&lt;args&gt;)</pre><h4>Calling static function template</h4><pre>Java.perform(function() {<br><br>    var &lt;class_reference&gt; = Java.use(&quot;&lt;package_name&gt;.&lt;class&gt;&quot;);<br>    &lt;class_reference&gt;.&lt;static_method&gt;();<br><br>})</pre><h4>Changing static variable value template</h4><pre>Java.perform(function (){<br><br>    var &lt;class_reference&gt; = Java.use(&quot;&lt;package_name&gt;.&lt;class&gt;&quot;);<br>    &lt;class_reference&gt;.&lt;variable&gt;.value = &lt;value&gt;;<br><br>})</pre><h4>Instantiating a class template</h4><pre>Java.perform(function() {<br><br>  var &lt;class_reference&gt; = Java.use(&quot;&lt;package_name&gt;.&lt;class&gt;&quot;);<br>  var &lt;class_instance&gt; = &lt;class_reference&gt;.$new(); // Class Object<br>  &lt;class_instance&gt;.&lt;method&gt;(); // Calling the method<br><br>})</pre><h4>Finding MainActivity instance template</h4><pre>Java.performNow(function() {<br>  Java.choose(&#39;&lt;Package&gt;.&lt;class_Name&gt;&#39;, {<br>    onMatch: function(instance) {<br><br>      instance.&lt;method&gt;();<br><br>    },<br>    onComplete: function() {}<br>  });<br>});</pre><h4>Hooking a class constructor template</h4><pre>Java.perform(function() {<br>  var &lt;class_reference&gt; = Java.use(&quot;&lt;package_name&gt;.&lt;class&gt;&quot;);<br>  &lt;class_reference&gt;.$init.implementation = function(&lt;args&gt;){<br><br>    this.$init(&lt;args&gt;);<br>    // ...<br>  }<br>});</pre><h4>Hooking a native function template</h4><pre>Interceptor.attach(targetAddress, {<br>    onEnter: function (args) {<br>        console.log(&#39;Entering &#39; + functionName);<br>      <br>        // Modify or log arguments if needed<br>      <br>        // for reading a string from the memory we use<br>        var arg0 = Memory.readUtf8String(args[0]);<br>        console.log(`arg0 - ${arg0}`);<br>    },<br>    onLeave: function (retval) {<br>        console.log(&#39;Leaving &#39; + functionName);<br>        // Modify or log return value if needed<br><br>        // to return a value of your choice <br>        retval.replace(0xdeadbeef)<br>    }<br>});</pre><p>Note: to get the targetAddress you can use a number of Frida API calls such as:</p><pre>Module.enumerateExports()<br>Module.getExportByName()<br>Module.findExportByName()<br>Module.enumerateImports()<br>Module.getBaseAddress()</pre><p>Like this</p><pre>[A10::com.ad2001.frida0x8 ]-&gt; Module.enumerateExports(&#39;libfrida0x8.so&#39;)<br>[<br>    {<br>        &quot;address&quot;: &quot;0x78c2fb3898c0&quot;,<br>        &quot;name&quot;: &quot;Java_com_ad2001_frida0x8_MainActivity_cmpstr&quot;,<br>        &quot;type&quot;: &quot;function&quot;<br>    },<br>    {<br>        &quot;address&quot;: &quot;0x78c2fb389aa0&quot;,<br>        &quot;name&quot;: &quot;_ZN7_JNIEnv17GetStringUTFCharsEP8_jstringPh&quot;,<br>        &quot;type&quot;: &quot;function&quot;<br>    },<br>    {<br>        &quot;address&quot;: &quot;0x78c2fb389ae0&quot;,<br>        &quot;name&quot;: &quot;_ZN7_JNIEnv21ReleaseStringUTFCharsEP8_jstringPKc&quot;,<br>        &quot;type&quot;: &quot;function&quot;<br>    }<br>]<br><br>// then you can get the function address by doing this <br>[A10::com.ad2001.frida0x8 ]-&gt; var addr = Module.enumerateExports(&#39;libfrida0x8.so&#39;)[0][&#39;address&#39;]<br>[A10::com.ad2001.frida0x8 ]-&gt; addr<br>&quot;0x78c2fb3898c0&quot;</pre><p>That’s it for today, I really recommend you go and check this repo <a href="https://github.com/DERE-ad2001/Frida-Labs?tab=readme-ov-file">https://github.com/DERE-ad2001/Frida-Labs?tab=readme-ov-file</a> they did a really amazing job demonstrating Frida and with hands-on labs. cya</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e1e63b778bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 0x5]]></title>
            <link>https://mahmoudelfawair.medium.com/malware-analysis-series-0x5-a0bea578dcb8?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0bea578dcb8</guid>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 17:57:57 GMT</pubDate>
            <atom:updated>2024-03-24T11:20:28.664Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello You.</p><p>Today we are going to continue talking about the basic dynamic analysis approach. We’ll discuss tools like Regshot, ApateDNS, Wireshark, netsh …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*AptrKCFYjCyeYWeI3DCMsA.png" /></figure><p>Let’s dive in</p><p>Yeah I know I’m a little bit late. sorry about that :P</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*csozwddVPUoo_EJdJlIweA.gif" /></figure><h4>RegsHot</h4><p>Regshot is a tool used to take a snapshot of the registry hive, before and after you execute the malicious file then you can use it to compare these two snapshots to check any changes, there will be a lot of noise but it is easily identifiable and we can filter them out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*eCtmxxtr9iztYnfH1iMFew.png" /></figure><p>After taking the first shot and the second one (after executing the malware, duh) we can compare them and this how the output would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*SEbVmuqNaXzv-LuE7K9kPw.png" /></figure><h4>Wireshark</h4><p>We use wireshark to make network-based signatures, and the way we do it is by sniffing the network traffic and examining the content of the packets or to where they’re going.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*b87dV9f9xw-Xd3FDIC2j8w.png" /></figure><p>Firstly we need to choose the interface, here I’ll use Ethernet interface,when you click on it you will be faced by another screen that will capture all traffic that is going through this interface</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mW8wQCo3WB1yd7Me2Mkgsg.png" /></figure><p>if you are smart enough, you would ask me this question (Why there are no DNS queries before the TCP or HTTP packets?) that’s because I’m using another tool called ApateDNS, but let’s see what’s going on here before we move on to another tool.</p><p>I used curl mahmoud.me\thatismeto get the content of that page on that website. You can see in wireshark that it sniffed that packet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*_xE863s69phj7QhgmRufhw.png" /></figure><p>You can see here it is the same content that we got in the curl result.</p><h4>ApateDNS</h4><p>It is a tool written by Mandiant team used to spoof DNS responses to a user-specified IP address (in my case I put my REMnux VM IP address), It listens on UDP port 53 on the local machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*5Zbx6ZiK_LXGIJyQY8cWpg.png" /></figure><p>on my REMnux VM I installed INetSim which is a software used for simulating common internet services. so now any request that will initiated from my windows machine will be redirected to the REMnux VM.</p><p>One of ApateDNS cool features is the NXDOMAIN which is an option that can trick malware into giving us additional domains it has in its configurations.</p><h4>netsh</h4><p>Why I’m even mentioning this? Imagine that you are suspecting that there is a malware on one of your critical machines (something like a vital server for a business you are working for), and you need to do packet sniffing to check what is going on, but there is a policy preventing you from installing Wireshark or any other external tool that may affect the critical server, the only option you have is to use built-in tools in windows to do the same job.</p><p>Here is where Netsh comes. Using Netsh we can sniff packets on going through the network.</p><p>But there is a problem the file that will be generated using netsh have teh .etl extention.</p><pre>C:\&gt; netsh trace start capture=yes tracefile=C:\logFiles\mfnettrace.etl<br>C:\&gt; # to stop the trace <br>C:\&gt; netsh trace stop</pre><p>our goal is to to retrive the .etl file from the server and modify it so that it can be opened with tools such as wireshark, for the task of modyfing it we will use <a href="http://etl2pcapng.exe in.etl out.pcapng">etl2pcapng.exe</a></p><pre>etl2pcapng.exe in.etl out.pcapng</pre><p>and that’s how we get that task done without getting fired.</p><h4>My Virtual Network</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0y-g7PBEi22C6KU4q0QGA.png" /></figure><p>I tried to mimic this virtual network which was mentioned in the Practical Malware Analysis book.</p><p>Now in my VirtualBox I have two VMs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*Uuxz7PvvUC1iy6Pi4V6Dsw.png" /></figure><p>which they are on the same network.</p><p>Note: I followed <a href="https://www.youtube.com/watch?v=qA0YcYMRWyI&amp;list=PLztJUeY-ptJ7ZWxrzk2dKQBTT1Uq_RWMI&amp;index=1&amp;t=1629s">this guy</a> instruction to build almost everything.</p><p>And yeah that’s it, thanks for reading :3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0bea578dcb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 0x4]]></title>
            <link>https://mahmoudelfawair.medium.com/malware-analysis-series-0x4-c94865344d36?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/c94865344d36</guid>
            <category><![CDATA[malware-analysis]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Mon, 18 Mar 2024 12:57:25 GMT</pubDate>
            <atom:updated>2024-03-20T12:03:09.338Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello You. Today will expand our knowledge about basic dynamic analysis with the use of popular tools like Procmon, Process Explorer, and others</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*xXVL-bgfOfGyIXZhdAK2_g.png" /></figure><p>Let’s dive in</p><h3>Basic Dynamic Analysis</h3><p>We start this type of analysis when we reach a dead end in static analysis, and it simply involves examining the artifices of the malware when it is running. For example, the files it edits on, the processes it creates, the network connections it creates and many others.</p><p>The book author gave a good example if we have a malware which type is keylogger using dynamic analysis we can locate the keylogger&#39;s log file on the system (the file that stores the keystrokes you type)</p><h4>Sandbox</h4><p>the quick and dirty way, simply a sandbox is a virtual machine that emulate a real environment, by doing things like simulating a network service to ensure that the malware will function correctly.</p><p>There is a lot of sandboxes out there, but on of the most popular ones is Cuckoo. you can read its documentation right <a href="https://cuckoo.readthedocs.io/en/latest/introduction/what/"><em>here</em></a><em>. </em>I Personally use <a href="https://hybrid-analysis.com/">Hybrid Analysis</a>.</p><p>NOTE: Even though the sandboxes are automated, you might choose not to submit malware that contains company information to a public website.</p><h4>Sandbox drawbacks</h4><p>Some of the drawbacks are:</p><ol><li>When malware requires arguments to run properly, sandboxes may struggle because they execute the executable without any command-line inputs.</li><li>If the malware has some nasty Sleep functions, the sandbox may not be able to patch them to reduce the waiting time.</li></ol><h4>Running the malware</h4><p>It’s easy to run an EXE file, but what if it’s a DLL what will you do then huh?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F23903554&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fel-papu-sdlg-gato-sad-meme-papu-gif-23903554&amp;image=https%3A%2F%2Fmedia.tenor.com%2FiL1-s5TP0yQAAAAF%2Fel-papu-sdlg.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3dcd63e2a2a80337fd234c474f64ba82/href">https://medium.com/media/3dcd63e2a2a80337fd234c474f64ba82/href</a></iframe><p>Luckily you are reading this article, so by default Windows doesn’t know how to run a DLL automatically. But we can use rundll32.exe to run it</p><p>Per Microsoft “rundll32 loads and runs 32-bit dynamic-link libraries (DLLs). You must run the rundll32 command from an elevated command prompt.”</p><ul><li>rundll32 syntax</li></ul><pre>C:\&gt; rundll32.exe DLLname, Export arguments</pre><p>Let’s say that we have a malicious DLL called m.dll and it has some export functions that we found in dependency walker called install &amp; uninstall, to install we’ll do the following</p><pre>C:\&gt; rundll32.exe m.dll, install </pre><p>DLL malware may also need to be installed as a service. sometimes there will be an export function like InstallService and hence the name you know what it will do</p><pre>C:\&gt; rundll32 m.dll, installService ServiceName<br>C:\&gt; net start ServiceName</pre><p>The use of net start here is just to start a service in Windows OS</p><p>Note: The ServiceName argument must be provided to the malware so it can be installed and run.</p><p>Rundll32.exe is not the only way to run a DLL file, we can patch the file using PEviewer and wipe the IMAGE_FILE_DLL (0x2000) flag from the characteristics field in the IMAGE_FILE_HEADER. this change won’t run any imported functions but it will run DLLMain, which is the function that is called from the DLL entry point and it is executed whenever the DLL file is called.</p><h4>Procmon</h4><p>Procmon or process monitor is one of the sysinternal tools that is super powerful in malware analysis, it shows real-time file system, registry and process/thread activity. It is a must to have within our malware hunting toolkit.</p><p>You have to be careful when using it, especially when using a virtual machine with limited resources. Because it will exhaust the RAM and that is because it collects all the events that happens in your system and stores them in the RAM (it can collect 100 thousands of logs in less than a minute)</p><p>That’s why we need to learn some Procmon tricks</p><ol><li>CTRL + E or FILE &gt; CAPTURE EVENTS to stop it from logging new events</li><li>CTRL + X or EDIT &gt; CLEAR DISPLAY to clear all events</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*6DEkNbcDk2BOhJk9b94imw.png" /></figure><p>This is how Procmon looks like, you can see from this picture the number of events and the number showed events. And there is a Filter option, this is your go-to option when using Procmon because it collects so many events that it freaking hard to go through them all.</p><h4>Filtering in Procmon</h4><p>We can set Procmon to filter on one executable running on the system. You can also filter on individual system calls such as RegSetValue, CreateFile, WriteFile or other suspicious destructive calls.</p><p>Note: when Procmon filter is turned on, it filters through recorded events only. All recorded events are still available even though the filter shows only a limited display. so setting up a filter won’t prevent the Procmon from exhausting your RAM and crashing your VM :3</p><ul><li>Now, let’s learn how to set a filter:</li></ul><p>You can use CTRL + L to open the filter option or just by click on it, do whatever you like. It will present you with this screen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*VIvC0G-VoJQgNKBWXAswEA.png" /></figure><p>where you can select the thing you are looking for. For example Process Name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*4WcXXPU6th9bGDcOPUA_WA.png" /></figure><p>Then we select the condition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*ds7D9uDVc1OGzDwgQbbRMA.png" /></figure><p>Then we provide the name of the process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*w6TAkbN97wiFF2qA0kQlBw.png" /></figure><p>and if you want to include | exclude, after applying the filter and starting Processhacker.exe, this is what we will see</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*zf9SkqLjan2cSaiBx-Kixw.png" /></figure><ul><li>Procmon provides another filter on its toolbar</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dB8moJ93VXIkSsMN_Q5RSA.png" /></figure><ol><li>Registry activity — by examining registry operations, you can tell how a piece of malware installs itself in the registry</li><li>File system activity — exploring file system interaction can show all file that the malware creates or configuration files it uses.</li><li>Network activity — identifying network connections can show you any ports on which the malware is listening</li><li>Process and thread activity — investigating process activity can tell you whether the malware spawned additional processes</li></ol><p>respectively as show in the picture.</p><blockquote>Analysis of procmon’s recorded events takes practice and patience, since many events are simply part of the standard way that executables start up. The more you use procmon, the easier you will find it to quickly review the event listing.</blockquote><h4>Process explorer</h4><p>It is a super enhanced alternative of task manager, that is also a part of the sysinteral tools that is written by <strong>Mark Russinovich, </strong>useing this tool we can see all active processes, DLLs loaded by a process, various process properties.</p><p>We can use it to kill a process, log out users, and launch and validate processes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yyZPNG4Gx8jG_F1mEzANiQ.png" /></figure><p>Let’s discuss the colors:</p><ol><li>Services are highlighted in pink</li><li>Processes in blue</li><li>New processes in green</li><li>Terminated processes in red</li></ol><p>green and red highlights are temporary</p><h4>Process explorer verify feature</h4><p>By double clicking on any of the processes, you will be presented with this windows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*Wqhs9dUIz6liaRU2-1TttA.png" /></figure><p>By clicking on the verify button on the Image tab, it will verify that image on disk and check if it is a Microsoft signed binary. Because Microsoft uses digital signatures for most of its core executables, when Process explorer verifies that a signature is valid, you can be sure that the file is actually the executables from Microsoft. but there is a tiny problem that Process explorer checks the image on the disk not in memory so if that process is injected with a malicious code (which is called Process replacement) it will also be verified if the attacker injected a verified image.</p><h4>Comparing Strings</h4><p>This one of the ways to check if a process is injected or not, by comparing the strings of the image on disk and in memory, and you can do so by toggling between Image &amp; Memory buttons in the Strings tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*3JABXK-gdNIfdXZwQZjpJQ.png" /></figure><p>In this image we can see that the strings in memory differ than the one on disk, so that is an indicator of Process replacement</p><p>in the next article I’ll talk about Regshot &amp; wireshark when doing basic dynamic analysis, I hope you enjoy reading this article cya</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c94865344d36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 0x3]]></title>
            <link>https://mahmoudelfawair.medium.com/malware-analysis-series-0x3-f5dd5b471234?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5dd5b471234</guid>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Thu, 14 Mar 2024 12:48:26 GMT</pubDate>
            <atom:updated>2024-03-14T12:49:23.726Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello You.</p><p>Today I’m going to talk about malware analysis in virtual machines, and how can we execute a malware in a safe environment, without affecting our host machine (hopefully)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*pavr-88fxk8RtSLr1ezYfA.png" /></figure><blockquote>Fresh malware can be full of surprises, that’s why before any dynamic analysis we must set up a safe environment</blockquote><p>Some malware analysts use a physical machine to analyse a malware and they put it in something called air-grapped network which is an isolated network with machines that are also disconnected from the internet or any other networks to prevent the malware from spreading.</p><p>But there’re some disadvantages of this technique which are:</p><ol><li>You won’t have access to the internet and some malware needs access to the C2 server or another server to get updates.</li><li>It is difficult to remove the malware, but some malware anlysts use Norton Ghost to manage backup images of their OS.</li></ol><p>The main advantage of running the malware on a physical machine is that the malware may execute differently on a virtual machine, that’s because some malware has some capabilities to detect if it is ran on a virtual machine or on a normal one. (malware authors are getting smarter and smarter)</p><h4>Virtual machine</h4><p>We are not going to use this approach and we’ll use a virtual machine, let’s me explain how it works, You have your main computer, which is called the host machine, and then you have a virtual machine inside it. This virtual machine has its own operating system, which we call the guest OS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*YfPsHR0pEoAI3WXpEmIzUQ.png" /></figure><p>If the malware damages the Guest OS we can simply restore the VM to a clean state using something called Snapshotting which will allow us go back in time and revert the Clean state, I wish we could do this in real life; I would have said something else to her. However, it is a super interesting feature that exists in most tools that allows us to create a virtual machine like VMware, Virtual Box, etc...</p><p>Note: obviously we will use a windows OS, the author talked about Windows XP which is wired but he explained that it is the most popular OS and the traget for most malware :p</p><h4>Networking in the VM</h4><p>Regarding the network setup for the VM, we have multiple options like using the host-only networking or NAT or attach it to nothing if we want the VM to not be connected to the Internet while analyzing the malware.</p><p>For example in Virtual Box we can go to our malware analysis VM and from <strong>Network &gt; Attached to </strong>and then choose the network adapter we want to choose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*1Ryk7j8u95GdG0u6-EeqgQ.png" /></figure><p>So what are the differences between Host-only networking, NAT, bridging, and not attaching it to anything?</p><ol><li>Host-only networking creates a separate private LAN between the host OSand the guest OS and it’s commonly used for malware analysis.</li><li>NAT will make the host OS to act as a router and translate all requests from the VM so that they come from the host&#39;s IP address.</li><li>Bridge network adapter allows the virtual machine to be connected to the same network interface as the physical machine.</li><li>Having no adapter or attaching it to nothing means that there will be not network connection to anything, which is you may need to do that sometimes.</li></ol><h4>Snapshot</h4><p>Let’s talk more about snapshotting and how we will make use of it, you are going to create a snapshot of your virtual machine whatever software you are using, but in Virtual Box we do it this way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKBoC4ot6Y6JK3ASrk0fFQ.png" /></figure><p>by clicking on Take you will take a snapshot as simple as that, but make sure that you have installed the necessary tools and you have done proper configuration, in the future we will download new tools and we will have to take another snapshot for that and you may delete the previous snapshot if you wish.</p><p>now let’s say you have took the snapshot at 8:00 , shortly after than, you run the malware sample, at 10:00 you revert to the snapshot. The OS, Software, and other applications will return to the same state they were in at 8:00, and everything that happened between 8:00 and 10:00 is erased as it never happened.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*gbJ12kr1ZrK19ZkKMf_9CA.png" /></figure><h4>Transfering files from a VM</h4><p>There is a feature of drag-and-drop in both VMware and Virtual Box</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*pimUcfkkDG8fYAV0dT9CAA.png" /></figure><p>I sat the shared clipboard and drag&#39;n&#39;drop to bidirectional , if you aren’t isolating the machine you can use python http.server by doing this</p><pre>python -m http.server</pre><p>Doing so will open port 8000 on the machine, and you can access the directory from which you executed this command from your own machine.</p><h4>The risk of using VM for malware analysis</h4><p>As I said before some malware can detect when it is running within a virtual machine, and many techniques have been published to detect such a situation. And like all software, VMware and Virtal Box occasionally have some vulnerabilities that can be exploited. So you should avoid performing malware analysis on any critical or sensitive machine.</p><p>And yeah that’s it for today thanks for reading :3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5dd5b471234" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 0x2]]></title>
            <link>https://mahmoudelfawair.medium.com/malware-analysis-series-0x2-72b070f8e020?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/72b070f8e020</guid>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Fri, 08 Mar 2024 09:49:06 GMT</pubDate>
            <atom:updated>2024-03-08T09:49:06.351Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello You.</p><p>In the previous article I wrote about chapter one of the great Practical Malware Analysis book, but today it’s time to solve chapter one challenges, so let’s get going</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*F0R34l9opIJsd85tM5Ydmg.png" /></figure><p>I’m certain that one of you guys is still looking for the labs (they are in front of you man c’mon) you can find them <a href="https://nostarch.com/malware">here</a>, they’re in a git repo use the git clone to download them to your system</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*yukRbiBt_ieOCUxfXk5RXg.png" /><figcaption>git clone that repo</figcaption></figure><p>Note: before you do any of that as the author said Do not be stupid and use a virtual machine and disable Windows defender, because we are dealing with a malware :3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*-V_S_e6whICQ-o2CGyhNIA.png" /><figcaption>in the labs directory</figcaption></figure><p>you will notice that there is only one exe file which is wired, but you are a malware analyst, so let’s see what the heck is that, by using our faviourate tool strings.exe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*VvzmkI55p-h8bvwt8Vnnag.png" /></figure><p>we have executed strings.exe on it and we can see that it might be the labs, it is actually so let’s run it and do not trust any one even the author so use a virtual machine for god sake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*uETQk9eaV2B1_g3iUm7DFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*WpfLKkLnKzFRGf97lc-r7g.png" /></figure><p>you accept the license and whatever and then you extract the labs and GG, you have done it.</p><p>Now let’s get started with the actual labs, the nice thing about the labs is the author is giving us little or no information about the program to make it as <strong>real</strong> as possible</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F25404686&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fblade-runner2049-snow-gif-25404686&amp;image=https%3A%2F%2Fmedia.tenor.com%2FiVL9VpBhrlQAAAAF%2Fblade-runner2049-snow.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2975f1217adf1c9dc5939b63425b6ff/href">https://medium.com/media/f2975f1217adf1c9dc5939b63425b6ff/href</a></iframe><h3>Lab 1–1</h3><p>This lab uses the files Lab01–01.exe and Lab01–01.dll. Use the tools and techniques described in the chapter to gain information about the files and<br>answer the questions below.</p><h4>Q1</h4><p>Upload the files to <a href="http://www.virustotal.com/">http://www.VirusTotal.com/</a> and view the reports. Does either file match any existing antivirus signatures?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*uoBETTRhCZsJFCsBBFKN9g.png" /><figcaption>lab01–01.dll</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*q0mODIstK5qEPLiBhGi_Ig.png" /><figcaption>Lab01–01.exe</figcaption></figure><p>As you can see most of the malware have signatures for those file</p><h4>Q2</h4><p>When were these files compiled?</p><p>for this question I’ll use PEview</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pUzeVKLrELV-vkeXp1i1ig.png" /></figure><p>In the IMAGE_FILE_HEADER you can see that the compile time is 2010/12/19 the same thing goes for the dll file</p><h4>Q3</h4><p>Are there any indications that either of these files is packed or obfuscated?<br>If so, what are these indicators?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gxHPK6sDsIjmbthvBl5zSQ.png" /><figcaption>why to use one tool when you can use two :P</figcaption></figure><p>as you can see, I used Detect it easy and PEiD and it seems clear with no obfuscation to me</p><h4>Q4</h4><p>Do any imports hint at what this malware does? If so, which imports<br>are they?</p><p>Here I used Dependency Walker</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBOT2YflBuV2TpzU2vKkQA.png" /><figcaption>lab01–01.exe</figcaption></figure><p><strong>Kernel32.dll </strong>— This is a very common DLL that contains core functionality, such as access and manipulation of memory, files, and hardware. blah blah blah</p><p>here we have FindFirstFile &amp; FindNextFile which are used to search through directories, and there is also CopyFile &amp; CreateFile &amp; CreateFileMapping which are all related to file creation and manipulation (copying files) from Lab01-01.exe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ln_oOFC2FhGeZYgHXJkvcg.png" /><figcaption>lab01–01.dll</figcaption></figure><p>here we can see Sleep &amp; CreateProcess which means we need to expect this malware to create another process</p><h4>Q5</h4><p>Are there any other files or host-based indicators that you could look for<br>on infected systems?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*tClIjEc_QChHWIdfoQXb-w.png" /></figure><p>Using Strings.exe I saw a wired dll file that is not Kernel32.dll but Kerne132.dll you can see the subtle misspelling there, 1 instead of l(it might be used to hide rogue DLLs in plain sight)</p><h4>Q6</h4><p>What network-based indicators could be used to find this malware on<br>infected machines?</p><p>Using strings.exe on the dll file you will see an IP address, this is the only network based indicator I was able to find but it’s enough you maybe not, we’ll figure out in the future</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*MCJCn1dn0FOi32VPY263Dg.png" /></figure><h4>Q7</h4><p>What would you guess is the purpose of these files?</p><p>Based on the knowledge I got from the static analysis I can’t really determine what type of malware is this <strong>but</strong> since it’s copying files and there is an IP so it might be sending data to the attacker which indicates that this is a <strong>Information-stealing malware.</strong></p><p>but my answer was totally wrong</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F10338804311867949447&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fryan-gossling-blade-runner-blade-runner-2049-purple-based-gif-10338804311867949447&amp;image=https%3A%2F%2Fmedia.tenor.com%2Fj3rPvosqgYcAAAAN%2Fryan-gossling-blade-runner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c9fea71efbba027c659cd315083612f/href">https://medium.com/media/3c9fea71efbba027c659cd315083612f/href</a></iframe><p>but it is totally ok we are learning, this is the answer correct answer: The .dll file is probably a backdoor. The .exe file is used to install or run<br>the DLL.</p><p>and he’s explaining that CreateProcess and Sleep are common in backdoors, so yup take notes so you don’t guess wrong the next time.</p><h3>Lab 1–2</h3><p>Analyze the file Lab01–02.exe.</p><h4>Q1</h4><p>Upload the Lab01–02.exe file to <a href="http://www.virustotal.com/">http://www.VirusTotal.com/</a>. Does it match<br>any existing antivirus definitions?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TzUxewAjoskxZ3uQQl2_Uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f65sEkefUw3xYC_SHt0uYQ.png" /><figcaption>Packed!</figcaption></figure><p>Yes it does, and not only that we knew that 55 antivirus have signture for this file but we now know that it is packed and it’s using UPX</p><h4>Q2</h4><p>Are there any indications that this file is packed or obfuscated? If so,<br>what are these indicators? If the file is packed, unpack it if possible.</p><p>Let’s say that we didn’t that it’s packed from virustotal let’s check DIE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*ywAB4-y6YkS23zRNHPntyw.png" /></figure><p>DIE it telling us that it is packed so let’s unpack it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jnGYMWuO8b94DPmg9E7sTA.png" /></figure><p>I created a backup file before unpacking it but in the next time I’ll probably use -k to keep a backup file</p><h4>Q3</h4><p>Do any imports hint at this program’s functionality? If so, which imports<br>are they and what do they tell you?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*dUICW2AeViqZo0iHZyyOWw.png" /></figure><p><strong>Advapi32.dll</strong> — This DLL provides access to advanced core Windows components such as the Service Manager and Registry. <strong>Wininet.dll</strong> — This DLL contains higher-level networking functions that implement protocols such as FTP, HTTP, and NTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*0MYcozo52NTx98M1c6ECeg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*6BQR5NGIoQTUR_-8PJzSgg.png" /></figure><p>No indicators of a GUI so it is a CLI and it is probably creating a service using CreateService which adds a new service to the service control manager, and allows the caller to specify whether the service will start automatically at boot time or must be started manually (maybe for persistence). AndInternetOpen which is a function that initializes an application’s use of the WinINet functions. It enables the application to perform various operations like connecting to URLs, sending HTTP requests, and managing internet connections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*0emTNbqXG73gkgNaHn0O4A.png" /><figcaption>lab2 strings</figcaption></figure><p>It’s not a backdoor for sure and it’s accessing a website so it might be downloading something, It might be a Downloader but still it is creating a service and it’s using CreateThread. I’m staying with Downloader let me see the answer and come right back</p><blockquote>We can’t be sure what this program is doing, but we’ve found some indicators to help search for this malware across a network.</blockquote><p>:3</p><h4>Q4</h4><p>What host- or network-based indicators could be used to identify this<br>malware on infected machines?</p><p>The URL we found in the strings is the network-based indicator and the host-based it would be the service since it is using CreateService and there is a Malservice in the strings</p><p>Sheesh that was a lot of work, btw I’m sorry about the delay I was supposed to publish this yesterday but I had to go to work so yeah you know life I’ll do solve the other labs by myself the only purpose of this article is to teach how i used the tools that I talked about in the previous article.</p><p>that’s it thanks for reading :3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72b070f8e020" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 0x1]]></title>
            <link>https://mahmoudelfawair.medium.com/malware-analysis-series-0x1-f822234d3ce1?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/f822234d3ce1</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 22:21:16 GMT</pubDate>
            <atom:updated>2024-03-04T22:21:16.382Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello You.</p><p>This is the second article of the malware analysis series, and you may wonder why it is labeled 0x1 (we programmers start counting from zero). So, if you haven’t read the previous article go back and read <a href="https://medium.com/@mahmoudelfawair/malware-analysis-series-0x0-7b7935338dda">it</a>, it is only 3 minutes read.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*Oayah7IxBXnaMilxtlPNrg.png" /></figure><p>Today, I’m writing about the chapter number 1 of the Practical Malware Analsys Book, And it’s about Basic Static Techniques, Let’s dive in</p><h3>Basic Static Techniques</h3><p>It is the first step of analyzing a malware and it’s about analyzing the code or structure of a program to determine its function</p><p>The topics we are going to discuss today are:</p><ol><li>Using antivirus tools to confirm maliciousness</li><li>Using hashes to identify malware</li><li>gleaning information from a file’s strings, functions and headers</li></ol><p>Each techniques has its own features and each one of them provide different information.</p><h4>Using Antivirus Tools To Confirm Maliciousness</h4><p>It’s a good idea to use VirusTotal which is a website that allows us to upload a file for scanning by multiple antivirus engines. You may find that some antiviruses have identified it.</p><p>But you have to know that antiviruses are not prefect they have 2 methods to determine if a file is malicious or not, <strong>the first one </strong>is relying on a database of hashes or indicators of known suspicious files, <strong>the second one</strong> is relying on behavioral and pattern matching analysis (heuristics).</p><p>the problem with the first method is that malware authors can easily modify their code, thereby changing their programs’ signature and evading virus scanners.</p><p>the problem with the second method is new and unique malware may be able to bypass it (but it is much better than the first method)</p><h4>Using Hashes To Identify Malware</h4><p>To the ones who do not know what a hash is, it is like a mathematical equation that has no inverse and every value it generates is a unique one, so if we use it on a file it would generate a hash value (sort of a fingerprint) to that malware. remember hash is irreversible.</p><p>We have so many hashing algorithms but we will work with the Message-Digest Algorithm 5 (MD5), let’s see how we can do it in windows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFdzUFnQvOtr3g1kFXwsuw.png" /></figure><p>I used the Get-FileHash cmdlet.</p><p>Note: sometimes we are dealing with a sensitive data and the sensitive data could be the malware so we don’t want to upload the file to anyone else especially any service online like VirusTotal so we get the has and use the hash instead of uploading the file.</p><h4>Gleaning Information From A File’s Strings</h4><p>Before we do that let’s understand what strings are? they are a sequence of characters in a program as simple as that, it could be a URL or data used in the program or IP etc…</p><p>To get the strings of a file you need to download the binary first, you can download it from here <a href="https://learn.microsoft.com/en-us/sysinternals/downloads/strings">https://learn.microsoft.com/en-us/sysinternals/downloads/strings</a> , and I really suggest you download the whole sysinternal suite because we will use some of its tools later on.</p><p>the strings command will search for characters that are typically stored in either ASCII or unicode format, there some differences between them like the ASCII only take one byte for a character but unicode format takes two bytes for one character. But they both end with something called a NULL terminator which is a byte of zeros that indicates the end of a string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sTRUdgUkZuFPxiKhDrAJ5w.png" /><figcaption>ASCII</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fMb-9kPEzY08cHRVvMqQow.png" /><figcaption>Unicode</figcaption></figure><p>Now let’s use strings cmdlet on one of the files we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*doXZaQkcMpBRa0SItkqjcg.png" /><figcaption>there is more</figcaption></figure><p>strings searches for a three-letter or greater sequence of ASCII or unicode characters followd by a string termination character.</p><p>as you can see not all the strings are useful, but we can easily identify those useful strings like UPX which will talk about latter, a possible URL and MalService which gives us a clue that this malware might be using something related to mail.</p><h4>Packed &amp; Obfuscated Malware</h4><p>Malware writers may use packing or obfuscation to make their files more difficult to detect or analyze using static analysis. packing is the process of compressing the code section where you won’t be able to see and understand the purpose of the code.</p><p>Note: legitimate programs almost always include many strings. Malware that is packed or obfuscated contains very few string.</p><p>Packed and obfuscated code will often include on of these functions LoadLibrary and GetProcAddress which are used to gain access to additional functions.</p><p>When the packed program is run, a small wrapper program also runs to decompress the packed file and then run the unpacked file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7RisZyLK3lvusGOH_mLsA.png" /></figure><p>When a packed program is analyzed statically, only the small wrapper program can be dissected.</p><h4>Detecting Packers With PEiD</h4><p>The author uses this program to detect packers but I don’t really recommend using it it is freaking old and has a lot of bugs but since the book is using it I’m going to do the same here, let’s say you have installed the program and supplied it with the file you are analyzing, this is how it would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ja1rlpC7DF00Q4Qf3scjA.png" /></figure><p>me personally I’ll use <a href="https://www.unpac.me/#/">unpac.me</a> website. it will basically unpack the file if it is packed and give you rich report about the file itself.</p><h4>Portable Executable File Format</h4><p>Like ELF files in linux, windows has the PE file format. The file format can reveal a lot about the program’s functionality.</p><p>The Portable Executable (PE) file format is used by Windows executables, object code, and DLLs (Dynamic Linked Libraries). It is a data structure that consists of necessary information for the windows OS loader to manage the wrapped executable code.</p><h4>Linked Libraries &amp; Functions</h4><p>One of the most useful pieces of information that we can gather about executable is the list of functions that it imports. Imports are functions used by one program that are stored in a different program, such as code libraries that contain functionality common to many programs. Code libraries can be connected to the main executable by Linking</p><p>Imports are linked into programs by programmers to avoid having to re-implement particular functionality. It is possible to connect code libraries dynamically, at runtime, or statically.</p><h4>Static, Runtime, and Dynamic Linking</h4><p><strong>Static linking</strong> is popular in UNIX like OSs and the idea behind it is that all the libraries that are being used by the binary are going to be added to the binary code itself, this linking type makes the binary bigger and harder to find the user code.</p><p><strong>Runtime linking </strong>is unpopular in friendly programs, and the idea behind it is that the program will only connect to libraries when one a function from them is needed, using this linking technique is popular when dealing with packed or obfuscated binaries.</p><p><strong>Dynamic linking</strong> will load all needed functions when the program starts, and when the program calls the function executes within the library.</p><h4>Functions</h4><p>Several Microsoft Windows functions allow programmers to import linked functions not listed in a program’s file header. the most commonly used are LoadLibrary, GetProcAddress, LdrGetProcAddress, LdrLoadDll these functions allow the program to access any function in any library which makes it very hard for us to understand what is going on using only static analysis.</p><p>Knowing the functions that are being used in the program allows us to make an educated guess on what is the type of the malware and what it is doing.</p><p>For example, if a program imports the function URLDownloadToFile you might guess that it is downloading something from the internet, when it’s using CreateProcessA you may guess that it is creating another process, so you should watch out for the launch of aditional programs.</p><h4>Function Naming Conventions</h4><p>You might see functions with an Ex suffix; this indicates that Microsoft has updated the old function without the Ex suffix and the new function is incompatible with the old one.</p><p>Other suffix like the A and W in functions like CreateDirectoryW which means that this function <strong>takes strings as parameters, </strong>note these letters do not appear in documentation so when searching for them remember to drop the trailing A, W</p><h4>Common DLLs</h4><ol><li><strong>Kernel32.dll </strong>— This is a very common DLL that contains core functionality, such as access and manipulation of memory, files, and hardware.</li><li><strong>Advapi32.dll</strong> — This DLL provides access to advanced core Windows components such as the Service Manager and Registry.</li><li><strong>User32.dll </strong>— This DLL contains all the user-interface components, such as buttons, scroll bars, and components for controlling and responding to user actions.</li><li><strong>Gdi32.dll </strong>— This DLL contains functions for displaying and manipulating graphics.</li><li><strong>Ntdll.dll </strong>— The Windows kernel can be accessed with this DLL. This file is always imported indirectly by Kernel32.dll, but executables rarely import it directly. The author wanted to leverage functionality that is not typically available to Windows applications if an executable imports this file. This interface will be used for some tasks, such as hiding functionality or changing processes.</li><li>.<strong>WSock32.dll and Ws2_32.dll </strong>— These are networking DLLs. A program that accesses either of these most likely connects to a network or performs network-related tasks.</li><li><strong>Wininet.dll</strong> — This DLL contains higher-level networking functions that implement protocols such as FTP, HTTP, and NTP.</li></ol><h4>PE File Sections</h4><ul><li><strong>.text :</strong> This section contains the executable code.</li><li><strong>.rdata </strong>: This section holds read-only data that can be accessed globally within the program.</li><li><strong>.data :</strong> Global data that is accessed throughout the program is stored in this section.</li><li><strong>.idata:</strong> This section, sometimes present, stores import function information. If absent, import function information is stored in the .rdata section.</li><li><strong>.edata :</strong> Sometimes present, this section stores export function information. If not found, export function information is stored in the .rdata section.</li><li><strong>.pdata :</strong> Present only in 64-bit executables, this section stores exception-handling information.</li><li><strong>.rsrc :</strong> This section stores resources needed by the executable.</li><li><strong>.reloc :</strong> Information for relocating library files is contained in this section.</li></ul><h4>Other Tools</h4><ul><li>PEview — tool used to inspect and analyze the structure and properties of Portable Executable (PE) files, we can get the time of compilation of the program even though it is not reliable because the malware author could easily change it and some comiplers like Delphi put a specific time.</li><li>resource hacker — allows us to examine the data in the .rsrc section. data in this section can be icons, images, other binaries or even drivers and etc…</li></ul><p>I will explain using the tools I talked about today when releasing the solutions of the labs.</p><p>and yeah that’s it, thanks for reading. cya</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f822234d3ce1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Series 0x0]]></title>
            <link>https://mahmoudelfawair.medium.com/malware-analysis-series-0x0-7b7935338dda?source=rss-d2c5d814b841------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b7935338dda</guid>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <dc:creator><![CDATA[Mahmoud Elfawair]]></dc:creator>
            <pubDate>Thu, 29 Feb 2024 20:24:46 GMT</pubDate>
            <atom:updated>2024-03-04T13:41:42.064Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*iTSBgXn-AQNjb9ry5h6SZg.png" /></figure><p>Hello You.</p><p>This is the first blog of this series where I’ll be writing about malware analysis and reverse engineering, where I’ll be explaining and summarizing what I learned from books related to this topic, like the great Practical Malware Analysis and Practical Binary Analysis. I’ll be posting every Monday and Thursday, and let’s dive in.</p><h3>Chapter 0 of Practical Malware Analysis</h3><blockquote>Before we get into the specifics of how to analyze a malware, we need to define some terminology, cover some types of malware, and introduce the fundamental approaches to malware analysis</blockquote><p>Let’s start with defining <strong>what is a malware?</strong></p><p>A Malware is any software intentionally designed to cause disruption to a computer, server, client, or computer network, leak private info, gain unauthorized access to info.</p><p>The <strong>goal of malware analysis</strong> is to find the source of the malware and examine what it is doing to the system so you can write host-based signatures and network-based signatures to try to respond to the intrusion.</p><p>Host-based signatures hence the name are used to detect malware on the victim computer. These indicators often identify files created or modified by the malware or specific change that it makes to register.</p><p>Network-based signatures are used to detect malicious code by monitoring network traffic.</p><h4>Malware Analysis Techniques</h4><p>We have two fundamental approaches to malware analysis: static and dynamic</p><p>They both go from basic to advanced so for example <strong>static basic</strong> analysis would be executing the command strings on the binary to try to find useful strings, on the other hand with <strong>advanced static</strong> analysis we may use other tools to disassembly and decompile the binary like ghidra, IDA, etc... and try to make sense of the disassembled or decompiled code.</p><p>Basic dynamic analysis is about running the malware and observing its behavior on the system, Advanced dynamic analysis is the same but with using debuggers.</p><h4>Types of Malware</h4><p>You MUST be familiar with the types of malware, because that would help making educated guesses on what the malware is, which will help speed up the process of analyzing the binary.</p><p>Here are the categories that most malware falls into:</p><ol><li><strong>Backdoor</strong>: A malicious code allows unauthorized access to a computer.</li><li><strong>Botnet</strong>: A hacked computer network under the command of a single server (C2).</li><li><strong>Downloader</strong>: A malicious code only exists to download other malware.</li><li><strong>Information-stealing malware</strong>: Collects info from victim’s computer and sends it to the attacker, examples include keyloggers, password hash grabbers, etc…</li><li><strong>Launcher</strong>: This application runs other harmful programs covertly.</li><li><strong>Ransomware</strong>: Demands a ransom to be paid in order to decrypt ciphered data.</li><li><strong>Rootkit</strong>: Gives attackers remote access while concealing harmful code.</li><li><strong>Scareware</strong>: Attempts to terrify consumers into purchasing needless services or software.</li><li><strong>Spam sending malware</strong>: Converts a user’s computer into a spam-producing device.</li><li><strong>Virus/Worm</strong>: replicates and spreads to other computers, infecting more computers.</li></ol><p><strong>Note </strong>that a malware may spans multiple categories. It could be a rootkit with a backdoor.</p><p>Another way to classify malware is based on attacker’s objective which might be a <strong>mass </strong>or <strong>targeted.</strong> Mass malware such as scareware, takes the shotgun approach and it is designed to affect as many machines as possible. On the other hand targeted malware like a special and specified to a specific organization.</p><h4>General rules for malware analysis</h4><ol><li>Focus on key feature — Don’t get lost in the details, instead focus on understanding the main aspects</li><li>Use different tools and approaches — each situation may require different tools and techniques, if one tool is not working try another.</li></ol><p>Yeah I know all of that was just talking and I didn’t analyze any malware but these concepts are important to understand at the beginning, in the next blog post I’ll talk about chapter 1 of practical malware analysis which is talking about static analysis, so stay tuned for it on monday cya :3</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b7935338dda" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>