<?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 Ayşegül Arpacık on Medium]]></title>
        <description><![CDATA[Stories by Ayşegül Arpacık on Medium]]></description>
        <link>https://medium.com/@aysegul.arpacik?source=rss-587734470471------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lhEzARktzIRa5XGDd09aNg.jpeg</url>
            <title>Stories by Ayşegül Arpacık on Medium</title>
            <link>https://medium.com/@aysegul.arpacik?source=rss-587734470471------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:28:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aysegul.arpacik/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[The Concept of Virtual Threads in Java 21]]></title>
            <link>https://medium.com/n11-tech/java-21-ile-virtual-thread-kavram%C4%B1-9e765d73703b?source=rss-587734470471------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e765d73703b</guid>
            <category><![CDATA[java21]]></category>
            <category><![CDATA[java-spring-boot]]></category>
            <category><![CDATA[virtual-threads]]></category>
            <category><![CDATA[daemon-thread]]></category>
            <category><![CDATA[platform-thread]]></category>
            <dc:creator><![CDATA[Ayşegül Arpacık]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 14:17:14 GMT</pubDate>
            <atom:updated>2025-08-11T06:02:32.546Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qREta6sQo3kfu81shfe2hA.png" /></figure><p>In this article, I will focus on one of the most fundamental features introduced with Java 21: the concept of Virtual Threads. After clarifying the concepts of process and thread at the operating system level, I will try to discuss the importance of Virtual Threads and their areas of use. I wish you an enjoyable read.</p><h4><strong>Process and Thread Concepts in Operating Systems</strong></h4><h4><strong>What is a Process?</strong></h4><blockquote>Each running program is called a process. Processes are created by the operating system. In modern operating systems commonly used today (Windows, macOS, Linux), processes are created through system calls such as fork(), exec(), and createProcess(). The <strong>code, data, stack,</strong> and <strong>heap</strong> segments of a created process are placed in RAM, either physically or virtually.</blockquote><p>Each process needs CPU (Central Processing Unit) time in order to run. When the operating system wants to execute a process, it sends the process’s instructions to the CPU. The CPU then executes the machine instructions of that process sequentially.</p><p>Processes play an important role in resource management in modern operating systems. However, because creating or terminating them is costly, they are considered heavyweight structures.</p><h4>What is a Thread?</h4><blockquote>A thread is the smallest unit of execution within a process. A process can contain multiple threads, which share the <strong>same memory space </strong>and can run <strong>concurrently</strong> and independently from each other.</blockquote><p>A thread has its own program counter, a set of registers, and a stack structure. Threads share operating system resources such as program code, data segments, and files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*wS1cUv_sMCvAtzDzlOldVw.png" /><figcaption>A sample diagram of the shared and non-shared resources used by threads</figcaption></figure><p>While a process is a structure where resources come together, a thread is the structure where execution takes place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1ZTkFiUjOPzrede7Jt0Lg.png" /><figcaption>An example diagram explaining the concepts of process and thread</figcaption></figure><p>As shown above, processes are entirely isolated from one another, whereas threads share the address space and other resources within their own process.</p><h4>Scheduler and Thread Execution</h4><p>The scheduler is the CPU scheduler that runs in operating systems. Its job is to determine when and for how long a process or thread will run on the CPU. In short, it fairly, efficiently, and evenly allocates the limited CPU resources among multiple processes or threads.</p><p>When the scheduler switches from one process to another, it performs a CPU context switch:</p><ul><li>The state of the current process is saved.</li><li>The state of the new process is loaded.</li><li>CPU control is given to this new process.</li></ul><p>This operation is called <strong>context switching</strong>.</p><p><strong><em>So, why do we need a scheduler?</em></strong></p><p>Because many processes want to run at the same time, but the CPU is limited. The scheduler gives these processes short <strong>CPU time slices</strong>. This way, the CPU never stays idle and the system behaves like it supports <strong>multitasking</strong>.</p><h4>What is a Kernel Thread?</h4><p>The thread structure explained so far refers to kernel threads at the operating system level. Threads in Java are also kernel threads by default. That is, the JVM (Java Virtual Machine) uses the operating system’s native thread API, and each Java thread is represented as a kernel thread at the OS level. Since a kernel thread is created and executed by the operating system, it can also be called an OS thread.</p><p>For example, when we create a thread in Java like the following, a kernel thread is created in the operating system:</p><pre>Thread t = new Thread(() -&gt; {<br>    // operation<br>});<br>t.start();</pre><blockquote>In the context of Java, Platform thread and OS thread refer to the same thing. However, starting with Java 19 and later, when the concept of Virtual Thread emerged, these two terms were distinguished by name. The main reason for this is:<br> An OS thread is a thread created and executed directly by the operating system. A Platform thread, on the other hand, is a thread that Java directly maps to the operating system, with each Platform thread corresponding 1:1 to an OS thread.</blockquote><p>More details will be discussed in the following sections.</p><h4>What are the Disadvantages of Platform (OS) Threads?</h4><ol><li><strong>They are heavyweight structures</strong> because each OS thread is represented by a separate kernel data structure in the operating system. This means they occupy more memory.</li><li><strong>They have high creation and destruction costs.</strong> Creating a new thread requires an OS system call, which takes time and consumes resources. Therefore, frequent creation and destruction of threads degrades performance.</li><li><strong>They incur high context switch costs.</strong> When the CPU switches from one thread to another, data such as registers, program counter, and stack pointer must be saved and loaded. This process consumes CPU cycles because the CPU cache is disrupted, increasing latency.</li><li><strong>They can experience blocking issues.</strong> If an OS thread blocks while waiting for an operation like I/O, the CPU may remain idle. This causes scalability problems in systems with high I/O traffic.</li><li><strong>A limited number of OS threads should be created.</strong> While operating systems can support thousands of threads, creating millions of threads is not practical. The default stack size is large (around 1 MB), which can rapidly increase memory consumption.</li></ol><p>The inadequacy of OS threads in these situations paved the way for the emergence of the virtual thread concept.</p><h3><strong>What Are Java Virtual Threads?</strong></h3><p>After discussing the disadvantages of Platform (OS) threads, when introducing the concept of virtual threads, it should not be misunderstood that virtual threads are meant to replace OS threads.</p><blockquote>Virtual threads are not used to replace OS threads but to provide lighter and more flexible task management on top of them. In fact, when these two structures are used together, we can build high-performance and scalable systems. Virtual threads still rely on OS threads to run.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m-vUhWxXVZ1y4GurBoXZhw.png" /></figure><p>Traditional (Platform) threads correspond one-to-one with an OS thread on the operating system side, blocking that thread for the duration of the process, whereas virtual threads are managed by the JVM and do not block OS threads.</p><p>Virtual threads can be used with the classic Thread APIs (Runnable, start(), join()), but unlike platform threads, they are created as lightweight structures on the Java heap rather than at the operating system level. This allows millions of virtual threads to be created with low resource consumption.</p><p><strong>Main Goal:</strong> To run hundreds of thousands or even millions of concurrent tasks at a low cost.<br><strong>How does it work?:</strong> With an MxN threading model.</p><p><strong>M:</strong> A large number of virtual threads (e.g., 1,000,000)</p><p><strong>N:</strong> A smaller number of platform threads / OS threads (e.g., 8–16)</p><h4>Why is it more efficient?</h4><ul><li><strong>They are very lightweight,</strong> with low creation cost.</li><li><strong>Their stack is small,</strong> occupying much less space than the 1 MB typical of platform threads.</li><li><strong>They start very quickly,</strong> much faster than thread.start().</li><li><strong>They are resilient to blocking.</strong> When encountering I/O, they can be suspended, freeing the OS thread they are tied to so other threads can run.</li><li><strong>They have high scalability.</strong> Since they are not directly tied to OS threads like platform threads, they can handle thousands or even millions of concurrent tasks.</li><li><strong>They are fully compatible with the existing Java thread API</strong>, allowing code to be used without modification.</li></ul><p>In our Java Spring Boot project, they can be enabled in the YAML file as follows:</p><pre>spring:<br>  threads:<br>    virtual:<br>      enabled: true</pre><p>In Java, a virtual thread can be created using Thread.ofVirtual():</p><pre>@Test<br>public void createVirtualThreadTest() {<br>    Thread.ofVirtual().start(() -&gt; {<br>        System.out.println(&quot;A Virtual Thread has been created&quot;);<br>    });<br>}<br><br>// console output:<br>// A Virtual Thread has been created</pre><p>Additionally, the isVirtual() method added to Java&#39;s Thread class is used to check whether a thread is virtual. It returns a boolean value: true if the thread is virtual, and false otherwise.</p><pre>@Test<br>public void checkVirtualThreadTest() {<br>    Thread thread1 = Thread.ofVirtual().start(() -&gt; {});<br>    Thread thread2 = Thread.ofPlatform().start(() -&gt; {});<br>    System.out.println(thread1.isVirtual()); // return true<br>    System.out.println(thread2.isVirtual()); // return false<br>}</pre><h4>Things to Keep in Mind When Using</h4><ol><li><strong>CPU-bound operations</strong></li></ol><p>In these cases, Platform threads are still preferred. A CPU-bound task is one that performs long computations on the processor without waiting for other resources (disk, network, user input, etc.). Examples include cryptographic calculations, video processing, numerical simulations, large matrix operations, and so on.</p><p>Virtual threads do not run directly on the CPU. Therefore, if a virtual thread stays on the CPU via an OS thread for a long time, it blocks other virtual threads from running. The JVM scheduler cannot perform fair scheduling in this situation.</p><p>To illustrate this with a real-life example:</p><p><em>Virtual thread = A shared service desk at a bank;</em> everyone takes turns doing their short tasks (mostly I/O). But if someone sits at the desk and works for hours, others have to wait.</p><p><em>Platform thread = A personal desk at a bank;</em> if you know your task will take a long time, you work at your own desk. You don’t affect others. However, the number of such desks (workers) is limited.</p><p>2. <strong>Usage with</strong> <strong>Synchronized</strong></p><p>If a virtual thread is written as shown below, the JVM cannot suspend this virtual thread:</p><pre>synchronized (someObject) {<br>    emailService.sendEmail();  // this I/O operation occupies (blocks) the platform thread<br>}</pre><p>Because the operation inside synchronized appears to the JVM as an &quot;atomic&quot; native operation. While a virtual thread performs I/O at the OS level, it occupies the platform thread. Therefore, when the virtual thread is blocked, the platform thread is also locked.</p><p><em>As a result, a performance issue arises.</em> We mentioned that virtual threads use a small number of platform threads sequentially to run. If one of these few threads gets blocked inside a <em>synchronized</em> block for a long time, other virtual threads become unable to run. In this case, the MxN model breaks down. While M threads should be running, some of the N threads are waiting.</p><p>Instead of using synchronized, the following approach can be used:</p><pre>lock.lock();<br>try {<br>    // offload the I/O to a separate virtual thread to avoid blocking<br>    emailService.sendEmail();<br>} finally {<br>    lock.unlock();<br>}</pre><p>3. <strong>Usage with</strong> <strong>ThreadLocal</strong></p><p>Virtual threads work compatibly with the ThreadLocal class. Each virtual thread, just like platform threads, can have its own ThreadLocal map.</p><p>When millions of virtual threads are created, each will have its own ThreadLocal. Considering that ThreadLocal stores data throughout a thread&#39;s lifecycle, if large objects are kept in ThreadLocal and are not properly cleared when no longer needed, memory leak problems may occur.</p><p>Therefore, if you are switching to virtual threads, special care should be taken with ThreadLocal usage.</p><p><strong>Note:</strong> As an alternative to ThreadLocal, ScopedValue can be used. However, since ScopedValue is a preview API in Java 21 (still experimental), caution is advised when using it in critical operations.</p><p>For this reason, if you absolutely need to carry a variable throughout the program’s lifecycle and virtual threads are involved, it is possible to pass the value by changing the method signature, i.e., by passing it as a parameter.</p><h4>What is a Daemon Thread?</h4><p>Before diving into the use of virtual threads, I want to touch on daemon threads since they are related.</p><p>A daemon thread is a thread used by the JVM for background tasks. When the main thread finishes its job, the JVM terminates the application even if there are live daemon threads running.</p><p>Let’s say we are making a game and want music to play in the background. The music will play on a separate thread. When the game ends — that is, when our main thread finishes — we want the music to stop as well. The JVM should not wait for the music thread to finish; even if the music keeps playing, once the game ends and the application closes, the music should also stop. In this case, we can use the music thread as a daemon thread.</p><p>A daemon thread can be created by calling setDaemon(true) on a platform thread. This must be done before the thread is started. If setDeamon(true) is called after the thread has started, it will throw an IllegalThreadStateException.</p><pre>Thread t = new Thread(() -&gt; {<br>    // platform thread operation<br>});<br>t.setDaemon(true); // valid usage<br>t.start();</pre><p><strong>Virtual threads are created as daemon threads by default.</strong> But why? Because the JVM designs virtual threads to be lightweight and short-lived. The JVM’s design states, “If only daemon (background) threads remain, the JVM can terminate the application.”</p><p>This means:</p><blockquote><em>If only virtual threads are running but the main thread or platform threads have finished, the JVM can </em>immediately terminate the application.</blockquote><p>Since virtual threads are created as daemon threads by default, setDeamon() should not be called on them. If called, it will throw an UnsupportedOperationException.</p><p>Example of incorrect usage:</p><pre>Thread vt = Thread.ofVirtual().unstarted(() -&gt; {<br>    // virtual thread operation<br>});<br>vt.setDaemon(true);  // invalid usage, java.lang.UnsupportedOperationException<br>vt.start();</pre><p><strong>What are daemon threads not used for?</strong></p><p>Threads that provide direct service to the user should not be daemon threads because daemon threads are forcibly terminated when the JVM shuts down, without waiting for them to complete their work.</p><p><strong>So, if virtual threads are defined as daemon threads by default, how safe is it to use virtual threads in our Java code?</strong></p><p>The fact that virtual threads are daemon threads by default brings some important lifecycle and safety issues when using them. If a long and critical task is started inside a virtual thread, and the main thread finishes, the task inside the virtual thread may be left incomplete.</p><p>For example, in the following situation, when the main thread finishes its work, the operation in the <em>doImportantFileBackup()</em> method will be interrupted halfway.</p><pre>Thread.ofVirtual().start(() -&gt; {<br>    doImportantFileBackup(); // along-running and important task<br>});<br>System.out.println(&quot;End of main thread&quot;);</pre><h4>How should virtual threads be used safely?</h4><ol><li><strong><em>Using join():</em></strong></li></ol><p>If a virtual thread is created and then join() is called, the JVM waits until the virtual thread completes its work. An example usage is given below:</p><pre>Thread vt = Thread.ofVirtual().start(() -&gt; {<br>    doImportantWork();<br>});<br>vt.join(); // The JVM waits until the virtual thread finishes its work</pre><p>2. <strong><em>Using</em></strong> <strong><em>StructuredTaskScope:</em></strong></p><p>This structure starts virtual threads as a group and guarantees that they complete. In this way, the JVM does not exit the application before the virtual threads finish. However, since it is introduced as a preview API in Java 21, caution is advised when using it. An example usage is given below:</p><pre>@Test<br>public void structuredTaskScopeTest() {<br>    try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {<br>        StructuredTaskScope.Subtask&lt;Integer&gt; subtask1 = scope.fork(() -&gt; 1);<br>        StructuredTaskScope.Subtask&lt;Integer&gt; subtask2 = scope.fork(() -&gt; {<br>            Thread.sleep(100);<br>            return 2;<br>        });<br>        scope.join(); // waits until all of them finish<br>        scope.throwIfFailed(); // throws exceptions<br>        System.out.println(&quot;subtask1: &quot; + subtask1);<br>        System.out.println(&quot;subtask2: &quot; + subtask2);<br>    }<br>}<br><br>// console output:<br>// subtask1: 1<br>// subtask2: 2</pre><p>3. <strong><em>Using</em></strong> <strong><em>ExecutorService:</em></strong></p><p>ExecutorService is a <strong>thread pool</strong> <strong>interface</strong> in Java used to simplify multithreading management. In other words, ExecutorService handles creating, starting, managing, and waiting for threads on our behalf. The JVM does not terminate the application until shutdown() is called on the created executor. Therefore, it is a safe alternative for virtual threads.</p><p>The classic usage with platform threads using newFixedThreadPool() is as follows:</p><pre>@Test<br>public void executorServiceWithPlatformThreadTest() {<br>    ExecutorService executor = Executors.newFixedThreadPool(2);<br><br>    executor.submit(() -&gt; {<br>        System.out.println(&quot;Task 1&quot;);<br>    });<br>    executor.submit(() -&gt; {<br>        System.out.println(&quot;Task 2&quot;);<br>    });<br><br>    executor.shutdown();<br>}<br><br>// console output:<br>// Task 1<br>// Task 2</pre><p>In virtual threads, it can be used as follows with newVirtualThreadPerTaskExecutor():</p><pre>@Test<br>public void executorServiceWithVirtualThreadTest() {<br>    ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();<br><br>    executor.submit(() -&gt; {<br>        System.out.println(&quot;Task 1&quot;);<br>    });<br>    executor.submit(() -&gt; {<br>        System.out.println(&quot;Task 2&quot;);<br>    });<br><br>    executor.shutdown();<br>}<br><br>// console output:<br>// Task 1<br>// Task 2</pre><h4>Using Thread Methods with Virtual Threads</h4><ol><li><strong><em>The interrupt() method:</em></strong></li></ol><p>interrupt() is a classic thread method and can be used with virtual threads. In platform threads, calling interrupt() interrupts the OS thread. Similarly, a running virtual thread can be terminated by calling interrupt(). An example usage is shown below:</p><pre>@Test<br>public void interruptVirtualThreadTest() {<br>    Thread thread1 = Thread.ofVirtual().start(() -&gt; {});<br>    while (!thread1.isInterrupted()) {<br>        System.out.println(&quot;The virtual thread continues running...&quot;);<br>        thread1.interrupt();<br>    }<br>    System.out.println(&quot;The virtual thread has been terminated.&quot;);<br>}<br><br>// console output<br>// The virtual thread continues running...<br>// The virtual thread has been terminated.</pre><p>2. <strong><em>The</em></strong> <strong><em>join() method:</em></strong></p><p>As mentioned in the section on the safe use of virtual threads in Java, the join() method is compatible with virtual threads just as it is with platform threads. <strong>The purpose of this method is to wait for a thread to complete its execution.</strong></p><p>3. <strong><em>The</em></strong> <strong><em>sleep() method:</em></strong></p><p>Using Thread.sleep(int); suspends the thread. Its meaning and usage are the same for virtual threads. The JVM continues running other virtual threads, and the platform thread is not blocked.</p><p>4. <strong><em>The</em></strong> <strong><em>setPriority() method:</em></strong></p><p>In classic platform threads in Java, the setPriority() method is used to indicate how important or prioritized a thread is. This helps the operating system’s scheduler.</p><p>However, this method is <strong>not supported for virtual threads.</strong> Priority information is not significant for virtual threads because the JVM scheduler does not consider it. All virtual threads have equal priority. The default priority for virtual threads is set to Thread.NORM_PRIORITY = 5.</p><p>In the example below, two threads are defined — one virtual thread and one platform thread. Both threads are requested to have a priority value of 8. However, while the platform thread’s priority is set to 8, the virtual thread’s priority remains 5:</p><pre>@Test<br>public void priorityPlatformAndVirtualThreadTest() {<br>    Thread virtualThread = Thread.ofVirtual().start(() -&gt; {});<br>    Thread platformThread = Thread.ofPlatform().start(() -&gt; {});<br>    virtualThread.setPriority(8);<br>    platformThread.setPriority(8);<br><br>    System.out.println(&quot;virtualThread priority: &quot; + virtualThread.getPriority());<br>    System.out.println(&quot;platformThread priority: &quot; + platformThread.getPriority());<br>}<br><br>// console output<br>// virtualThread priority: 5<br>// platformThread priority: 8</pre><p>Virtual threads offer leaner and more efficient solutions to the concurrency needs of modern applications. Especially in I/O-intensive operations, they utilize system resources more effectively, improving both performance and developer experience. Of course, like any new tool, they reveal their true potential when used carefully and in the right context. Before starting to experiment with virtual threads in our applications, evaluating their suitability for your architectural needs is the healthiest approach for this transition.</p><p>See you in new articles…</p><p><em>References</em></p><p><a href="https://www.geeksforgeeks.org/operating-systems/difference-between-process-and-thread/">https://www.geeksforgeeks.org/operating-systems/difference-between-process-and-thread/</a></p><p><a href="https://www.geeksforgeeks.org/operating-systems/introduction-of-process-management/">https://www.geeksforgeeks.org/operating-systems/introduction-of-process-management/</a></p><p><a href="https://examradar.com/thread-thread-structure-questions-answers/">https://examradar.com/thread-thread-structure-questions-answers/</a></p><p><a href="https://quarkus.io/blog/virtual-thread-1/">https://quarkus.io/blog/virtual-thread-1/</a></p><p><a href="https://medium.com/@victorhsr/java-21-structured-concurrency-powering-data-orchestration-with-virtual-threads-and-scopes-739781b1817d">https://medium.com/@victorhsr/java-21-structured-concurrency-powering-data-orchestration-with-virtual-threads-and-scopes-739781b1817d</a></p><p><a href="https://medium.com/@himani.prasad016/thread-pools-in-java-b19ea1af7c4c">https://medium.com/@himani.prasad016/thread-pools-in-java-b19ea1af7c4c</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e765d73703b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/n11-tech/java-21-ile-virtual-thread-kavram%C4%B1-9e765d73703b">The Concept of Virtual Threads in Java 21</a> was originally published in <a href="https://medium.com/n11-tech">n11 Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sherlock ile Windows Privilege Escalation]]></title>
            <link>https://medium.com/cloudnesil/sherlock-ile-windows-privilege-escalation-2d8621b58470?source=rss-587734470471------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d8621b58470</guid>
            <category><![CDATA[sherlock]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[kali-linux]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <dc:creator><![CDATA[Ayşegül Arpacık]]></dc:creator>
            <pubDate>Fri, 17 Jul 2020 19:57:24 GMT</pubDate>
            <atom:updated>2020-07-18T08:27:31.738Z</atom:updated>
            <content:encoded><![CDATA[<h3>Windows Privilege Escalation with Sherlock</h3><p>In this article, the privilege escalation will be performed on Kali Linux and Windows 7, which is already installed on a virtual machine. VMware Workstation was preferred as the virtual machine. It will be assumed that basic terminal commands are known and setups are made throughout the lecture.</p><h3>What is Privilege Escalation ?</h3><p>As we know, the main purpose in penetration test studies is to be the most authorized user. If we accessed the system with most authoritative user in a word system administrator, or the application or service that includes the vulnerability that allows us to system works administrator rights, there is no problem. However, if the service or system we want to infiltrate has low rights from the system administrator or works with a user account with lower rights, we need to follow a number of methods so that we can have the system administrator rights. This includes recovering a system in a dangerous situation. As we can understand from here, the main purpose in privilege escalation is to access data that ordinary users cannot access.</p><p>There are many privilege escalation methods. Some of them are:</p><ul><li>Sherlock</li><li>JAWS — Just Another Windows (Enum) Script</li><li>Windows Privesc Check (WPC-PS)</li><li>PowerUp</li><li>BeRoot</li><li>DLL Injection</li><li>Token Manipulation</li><li>SessionGopher</li><li>Windows Kernel Exploit</li><li>DLL Hijacking …</li></ul><p>In this article, Sherlock method will be explained practically.</p><h3>What is Sherlock ?</h3><p><strong><em>Sherlock</em></strong> is a <strong><em>Powershell</em></strong> script used to privilege escalation, quickly finding vulnerabilities in the system. Vulnerability scanning is done through Kali Linux and the required codes are run with Powershell on Windows system.</p><h4>Downloading the Sherlock module</h4><p>First, we download our Sherlock file from Kali Linux terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*OriuUR1TkwWBW-JaIj44oA.png" /></figure><h4>Learning the IP address of Windows system</h4><p>In order to access the openings in Kali Linux and Windows 7 system, the network settings of these two operating systems must be the same on our virtual machine. You can set the network setting for both systems as NAT or Custom VMnet from “Network Adapter” in the “Settings” option of the operating systems we install in our virtual machine. In this narrative, NAT is used for both systems as the network setting.</p><p>Since both operating systems are set up on the same network, we can easily learn the IP address of the Windows system on Kali Linux via the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*MILBKcW7j_boxXRARFMVhQ.png" /></figure><p><strong><em>nbtscan</em></strong> is a tool that comes installed with Kali Linux, by requesting the nbt protocols of the computers on the network and determining whether they are alive or not.</p><p>With the nbtscan command, we can see that the IP address of Windows system is “192.168.119.132”.</p><h4>Get meterpreter shell on Windows system</h4><p>As a next step, we need to get the meterpreter shell from the Windows system.</p><p><strong><em>Shell</em></strong> is an interface where users use the operating system, enter commands, and transmit these commands to the operating system. <strong><em>Meterpreter</em></strong> is a tool written for Metasploit Framework that facilitates penetration tests.</p><p>First of all, we are launching the Metasploit Framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*X_oO_QYQo1h_wwHgVyrnog.png" /></figure><p>Then we list the list of <strong><em>eternalblue</em></strong> exploits. If we talk briefly about Eternalblue, it is a cyber attack exception developed by the Malware National Security Agency (NSA) and leaked by Shadow Brokers in April 2017.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fkGF8_wa8LSxCRcK9gxddQ.png" /></figure><p>We select the draft module we will use from the “Name” section listed on the left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*hdFNE0rPnSUsQYtEW-ZZow.png" /></figure><p>Now we need to enter a <strong><em>payload</em></strong> to get the meterpreter session. Briefly, payload is the code or software snippets we send to exploit the vulnerability to be abused.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*2MqEtwVgLbM4OZ_rR6sAFA.png" /></figure><p>As a last step, we enter the IP addresses of the Windows 7 machine and Kali Linux machine as parameters, whose vulnerabilities we want to see.</p><p>We enter the IP address of the system we attack as <strong><em>lhost</em></strong> and the victim IP address as <strong><em>rhost</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*4HbvfrNqJhG-CUUNAtKjqA.png" /></figure><p>And <strong><em>exploit</em></strong>…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*EApmlGFA3rmA79CtZ1Xs-g.png" /></figure><p>After seeing the <em>WIN</em> warning, the meterpreter shell command line appears successfully.</p><h4>Listing vulnerabilities with Powershell</h4><p>As mentioned first, Sherlock is a Powershell script that scans vulnerability in Windows systems for privilege escalation. Therefore, Powershell commands will be run.</p><p>First of all, we load Powershell from the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*B44XEEy1yzdKI9UjHfDbMA.png" /></figure><p>We import the <em>Sherlock.ps1</em> file in the <em>Sherlock</em> folder that we downloaded previously by giving the path we downloaded the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*b1t-RGGidWN7Ar8FhZMsnA.png" /></figure><p>Now we can list the vulnerabilities in the Windows system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*VktoBtzI6EPkMBuYHdEYzw.png" /></figure><p>We see that the names of the vulnerabilities, the dates they were found, the links containing the information about these vulnerabilities, and whether the vulnerabilities are supported according to whether they are 64-bit or 32-bit are listed.</p><p><em>VulnStatus</em> may not be successful in every vulnerability that is <strong><em>Appears</em></strong> <strong><em>Vulnerable</em></strong>. Being successful even one of them is enough to create an authorized user in the system.</p><p>We can use the MS16–032 and MS16–135 vulnerabilities of the <em>Appears Vulnerable</em> ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*Rcislk26Bw0E_cnefVuRQg.png" /></figure><p>In order to use MS16–032 vulnerability, we go to the address given as Link and save the codes in the notebook with the name <em>ms16–032.ps1</em>. Then we copy this saved file to the Windows desktop.</p><h4>Implementation of vulnerabilities in Windows system</h4><p>On the Windows system, we can see our username and the domain we belong to, if available. Here we see the unauthorized user belonging to the domain I created with my own name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*6N5C8gN74GAmXdu3S7e8ng.png" /></figure><p>We <strong><em>bypass</em></strong> <em>Powershell</em> with <em>execution policy</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*2JYTZtcvZ51pA0QIplxaWA.png" /></figure><p>We import and run the <em>ms16–032.ps1</em> file that we copied to the Windows desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*j-txq_z9LUCHqlBJRMudwQ.png" /></figure><p>Before the import process, while our user was an unauthorized domain user, after the import process, the system administrator right was reached as <strong><em>nt authority/system</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*dj9jYT_LaocRUq-yG_y9rw.png" /></figure><p>After this step, we can now create an authorized user and add it to the administrator group.</p><p>First, we create a user named <em>Yetkili</em> and set his password as we want, and then we add this user to the administrator group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*J1Q0thvohqCqG8FngrC8EQ.png" /></figure><p>We can create an authorized user in the same way by following the steps we followed in MS16–032 vulnerability in MS16–135 vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*-CuAsSlY96N3tK15eCTTlQ.png" /></figure><h3><strong>Result</strong></h3><p>As a result, we created an authorized user on a Windows system signed in with an unauthorized user and made an application to prevent possible dangers or data loss. Thanks for reading this article ! See you in next applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d8621b58470" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudnesil/sherlock-ile-windows-privilege-escalation-2d8621b58470">Sherlock ile Windows Privilege Escalation</a> was originally published in <a href="https://medium.com/cloudnesil">cloudnesil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>