2024 Guide: Hacking APIs

NahamSec
20 Mar 202420:21

Summary

TLDRThis five-week program concludes with an in-depth tutorial on API hacking, covering two main approaches: analyzing applications with accessible APIs and those with limited UIs. The video demonstrates techniques such as intercepting HTTP requests, examining JavaScript files, and brute-forcing to uncover API routes. It also highlights the importance of setting objectives, understanding API functionality, and leveraging API tokens to access additional endpoints. The presenter uses practical examples and encourages hands-on learning through hacking Hub, aiming to improve viewers' API hacking skills.

Takeaways

  • πŸŽ“ The script is the conclusion of a five-week program aimed at educating individuals on becoming better hackers, particularly in the area of API hacking.
  • πŸ” Two main approaches to API hacking are discussed: one with access to the application and the ability to capture HTTP requests, and the other based on UI, which may involve broken or partial interfaces.
  • πŸ›  The 'half approach' involves using JavaScript files to uncover API routes, which can be a stepping stone to discovering additional APIs.
  • πŸ”‘ The importance of understanding API naming conventions and how to interact with them through tools like proxies is highlighted.
  • πŸ“ The speaker demonstrates creating an account on a website to intercept and analyze API calls, emphasizing the process of observing and inserting payloads.
  • 🎯 Setting objectives, such as making another user's post public, is a strategic way to approach hacking and uncover vulnerabilities.
  • πŸ€– The use of AI models like chat GPT to generate valid HTTP requests from JavaScript functions is suggested as a timesaving technique.
  • πŸ”’ The significance of API tokens in authentication and the potential for unauthorized access if they can be reused across different applications is discussed.
  • πŸ”„ The process of API versioning and the potential risks of newer versions, such as V2, having different and possibly less secure endpoints is covered.
  • πŸ“š Finding and leveraging API documentation can provide a wealth of information about how an application's API works, which is crucial for hacking.
  • πŸ“ˆ The value of using tools for recursive and brute force methods to discover additional endpoints and paths within an API is emphasized.

Q & A

  • What is the main focus of the video script?

    -The main focus of the video script is to discuss different approaches to API hacking and to provide insights on how to approach an API, especially when dealing with an unfamiliar application.

  • What are the two primary approaches to API hacking mentioned in the script?

    -The two primary approaches to API hacking mentioned are: 1) Having access to an application that connects to and interacts with an API, allowing one to capture and analyze HTTP requests; 2) Using JavaScript files to uncover more API routes or brute forcing for files and parameters.

  • How can one find additional API routes based on the UI?

    -One can find additional API routes based on the UI by examining the JavaScript files, breaking them apart to uncover API calls and routes, which might reveal additional APIs that are available.

  • What is the purpose of using API documentation in API hacking?

    -API documentation can be used to understand the functionality of an API, including its endpoints, parameters, and expected responses, which can help in identifying potential vulnerabilities or misconfigurations.

  • What is the significance of API token in the context of the video script?

    -The API token is significant as it is used for authentication with the API. It can also be tested for reuse across different applications or environments to identify vulnerabilities related to unauthorized access.

  • How can one test the functionality of an API without knowing the exact request format?

    -One can use tools like curl, Burp Suite, or even AI models like Chat GPT to create valid HTTP requests by providing sample functions or endpoints extracted from the application's JavaScript files.

  • What is the importance of observing the response format from an API?

    -Observing the response format is important because it can reveal whether the API is returning data in a format that can be manipulated, such as HTML, which could lead to vulnerabilities like HTML injection.

  • What is the 'blackbox' approach mentioned in the script and why is it useful?

    -The 'blackbox' approach involves testing an API without prior knowledge of its structure or functionality. It is useful for uncovering hidden endpoints and understanding how the API behaves under different conditions, which can lead to the discovery of vulnerabilities.

  • Why is it recommended to look for API documentation even though it is not a vulnerability by itself?

    -API documentation is not a vulnerability by itself, but it can provide valuable information about the API's structure and functionality, which can be leveraged to better understand the application and identify potential security issues.

  • What is the significance of error codes like 405, 403, and 401 in the context of API fuzzing?

    -Error codes like 405 (Method Not Allowed), 403 (Forbidden), and 401 (Unauthorized) can indicate the presence of hidden or restricted endpoints. Including these codes in fuzzing can help uncover endpoints that require different methods or authentication.

  • How can one use the information from the video script to improve their API hacking skills?

    -By following the approaches and techniques discussed in the script, such as analyzing applications, using API documentation, testing API tokens, and conducting blackbox testing, one can improve their understanding of APIs and enhance their ability to identify and exploit vulnerabilities.

Outlines

00:00

πŸ˜€ Final Week of the Five-Week Program

The script begins with a congratulatory message for reaching the final week of a five-week program focused on improving hacking skills. The speaker intends to discuss various approaches to API hacking, acknowledging the complexity of the subject and the difficulty of condensing it into a single video. The main goal is to enhance the viewer's understanding of API interaction, especially with unfamiliar applications. Two primary methods of API hacking are introduced: one involving direct access to an application that connects to an API, and the other a 'half approach' based on UI interaction that may lead to discovering additional API routes.

05:01

πŸ” Exploring API Hacking Techniques

This paragraph delves deeper into API hacking methods, emphasizing the importance of understanding the functionality of a website to identify potential vulnerabilities. It discusses using JavaScript files and brute-forcing to uncover API routes and parameters, as well as seeking documentation through tools like Swagger UI or GitHub. The speaker also introduces the idea of setting objectives when hacking, such as manipulating the visibility of a post, and demonstrates how to use proxy tools to intercept and analyze API calls, providing a practical example of account creation and profile page loading.

10:03

πŸ“š Leveraging API Documentation and Token Reuse

The speaker continues with strategies for finding and utilizing API documentation, which can be a treasure trove of information for understanding an API's functionality. The paragraph highlights the potential for reusing API tokens across different applications within a company's ecosystem, which can sometimes lead to unauthorized access to additional APIs or endpoints. The importance of testing these tokens and exploring various domains is emphasized, along with practical steps for doing so, including changing domain names and using tools like Fuzzing to discover new endpoints.

15:03

πŸ”‘ API Token Authentication and Cross-Application Access

This section focuses on the authentication process within APIs and the potential for using the same token to access different applications or environments, such as development instances. The speaker shares a personal anecdote about creating a CTF and demonstrates how to swap domain names to test cross-application access using the same API token. The discovery of additional content and the exploration of different API versions (V1 and V2) are discussed, along with the use of Fuzzing to uncover hidden endpoints and the examination of API documentation for V2 to find new functionalities.

20:05

πŸ’‘ Blackbox API Hacking and Content-Type Manipulation

The final paragraph introduces a blackbox approach to API hacking, where the speaker shares insights on how to handle APIs without prior knowledge of their structure. The process involves changing host names, using the same API token, and employing Fuzzing to identify endpoints that return error codes like 405, 403, and 401. The importance of observing the server's response, particularly the content type, is highlighted, with examples of how to manipulate the request method and body to interact with the API effectively. The speaker also discusses the implications of different content types, such as JSON versus HTML, and the potential for HTML injection attacks.

πŸ‘‹ Wrapping Up the Five-Week Series

In the conclusion, the speaker expresses gratitude for the viewers' engagement over the past five weeks and encourages them to continue practicing API hacking by using the provided resources on hacking Hub. The aim is to help viewers become more adept at understanding APIs, uncovering endpoints, creating valid requests, and identifying vulnerabilities. The session ends on a positive note, with the speaker looking forward to future interactions and wishing the viewers well.

Mindmap

Keywords

πŸ’‘API Hacking

API Hacking refers to the process of identifying and exploiting vulnerabilities within an application's API (Application Programming Interface). In the video, the theme revolves around teaching viewers how to approach API hacking, including understanding different methods and strategies to uncover and potentially exploit weaknesses in an API's security.

πŸ’‘HTTP Request

An HTTP Request is a message sent from a client to a server to request access to a resource. In the context of the video, capturing and analyzing HTTP requests is a fundamental step in API hacking, allowing the hacker to understand the data being sent and received by the API.

πŸ’‘UI (User Interface)

User Interface, or UI, is the space where interactions between the user and a digital device occur. The script mentions a 'half UI', which likely refers to a partially functional or broken user interface that might still provide clues to API endpoints through examination of the JavaScript files.

πŸ’‘JavaScript

JavaScript is a programming language that enables interactive web pages. The video discusses using JavaScript files to uncover API routes, suggesting that by examining and dissecting these files, one can gain insights into the API's structure and functionality.

πŸ’‘API Documentation

API Documentation provides detailed information about an API's endpoints, the requests they handle, the data they require, and the responses they return. The script mentions looking for API documentation as a method to understand an API's functionality, which can be found through tools like Swagger UI or OpenAPI.

πŸ’‘Proxy Tool

A Proxy Tool is a software that acts as an intermediary for requests from clients seeking resources from other servers. In the video, the use of a proxy tool is highlighted as a means to intercept and analyze API calls, helping to understand and manipulate the requests and responses.

πŸ’‘Payload

A Payload in the context of hacking refers to the data sent by an attacker to exploit a vulnerability in a system. The script describes inserting payloads into API requests to test for potential security weaknesses within the application.

πŸ’‘Vulnerability

A Vulnerability is a weakness in a system that can be exploited by an attacker. The video is centered around finding vulnerabilities within APIs, such as those that might allow unauthorized access to data or functionality.

πŸ’‘Brute Forcing

Brute Forcing is a trial-and-error method used to crack a password or encryption key by trying all possible combinations. In API hacking, as mentioned in the script, brute forcing can be used to discover hidden API endpoints or files by systematically trying different parameters or paths.

πŸ’‘Fuzzing

Fuzzing is a technique used in software testing to discover coding errors by inputting massive amounts of random data to the system and monitoring the response. In the script, fuzzing is discussed as a method to explore an API's endpoints, potentially uncovering new paths or identifying points of failure.

πŸ’‘Content-Type

The Content-Type header in HTTP requests specifies the nature of the data being sent to the server, such as 'application/json' or 'text/html'. The video script discusses the importance of setting the correct Content-Type when crafting API requests, as it informs the server how to interpret the data being sent.

πŸ’‘HTML Injection

HTML Injection is a type of web security vulnerability where an attacker can inject malicious HTML code into a web application. The video mentions the potential for HTML injection when an API returns data as 'text/html', allowing for the possibility of manipulating the response with HTML content.

Highlights

Introduction to the final week of a five-week program focusing on API hacking.

Congratulating participants for making it through the program and hoping it has helped them become better hackers.

Emphasizing the importance of understanding how to approach an API, especially for unfamiliar applications.

Describing two main approaches to API hacking: one with access to the application and another based on the UI.

Explaining the half-approach of using JavaScript files to uncover API routes.

Mentioning the use of brute forcing for files and parameters as part of the API hacking process.

Highlighting the importance of looking for API documentation, such as Swagger UI, for more information.

Demonstrating how to use hacking Hub and the 5we program to practice API hacking.

Discussing the process of creating an account to intercept API calls for analysis.

Showing how to examine API naming conventions and endpoints by inspecting app.js.

Exploring the idea of setting objectives when hacking, such as making another user's post public.

Discussing the process of editing API requests to understand and exploit their functionality.

Exploring the use of JavaScript files to uncover additional API routes and endpoints.

Describing how to test API tokens for access to other applications or APIs within the same domain.

Using API tokens to access different versions of an API, such as V1 and V2, to find new endpoints.

The significance of finding API documentation as a gold mine for understanding an application's functionality.

Using a blackbox approach to API hacking by assuming the validity of an API token on different domains.

The importance of observing the server's response, especially the content type, for potential HTML injection vulnerabilities.

Encouraging practice on hacking Hub to improve API hacking skills and understanding of creating valid API requests.

Closing remarks thanking participants for their engagement over the past five weeks and looking forward to future interactions.

Transcripts

play00:00

this is the fifth and final week of the

play00:02

five week program and if you've made it

play00:04

this far congratulations and I really

play00:06

hope the last 5 weeks have helped you or

play00:08

push you towards becoming a better

play00:10

hacker and hopefully you are one of the

play00:12

select lucky people that had the ability

play00:14

to find a vulnerability within the last

play00:17

5 weeks in this video I'm going to talk

play00:20

about the different approaches to API

play00:23

hacking and I know is really hard to try

play00:25

and put everything about AP hacking in

play00:27

one video so bear with me I'm going to

play00:29

try and un p a lot and hopefully by the

play00:31

end of this video you get a better

play00:33

understanding of how to approach an API

play00:36

especially when it comes down to an

play00:38

application that you have never worked

play00:39

with when it comes down to looking at

play00:41

apis there typically I want to say two

play00:43

maybe two and a half different

play00:44

approaches the half approach I'll

play00:45

explain it just a bit but there are two

play00:47

different approaches one is your typical

play00:49

approach of having access to some sort

play00:51

of an application this could be whether

play00:53

the main application actually connects

play00:55

to an API and interacts with it where

play00:57

you can actually capture the HTP request

play00:59

and look at it or it could be that you

play01:02

have maybe a half UI or a broken UI that

play01:05

loads a wide screen or maybe shows up a

play01:07

little bit of information but you don't

play01:09

get to have access to the full

play01:11

application itself so that's like the

play01:12

one and a half approach to API hacking

play01:14

based on the UI then you can kind of

play01:16

like go through the Javascript file and

play01:18

break it apart and maybe get some of

play01:20

those calls and base on those API routes

play01:22

maybe you can uncover the additional APS

play01:25

that are available the second approach

play01:27

is very similar to using JavaScript

play01:30

files to uncover more API routes and

play01:32

it's just by brute forcing for files and

play01:34

parameters and but you can also go after

play01:37

looking for documentation whether it's

play01:39

looking on GitHub or actually going on

play01:40

that API set or your Target and looking

play01:43

for API documentation through swager UI

play01:46

or just any of these open API

play01:48

documentation so in this video what

play01:50

we're going to do is we're going to go

play01:51

on to hacking Hub and launch our Hub

play01:54

again you can always go into the 5we

play01:57

program Hub on hacking Hub click on API

play01:59

hack and follow along or if you just

play02:01

want to watch me do my magic you're more

play02:03

than welcome to do that and then you can

play02:04

later on go and take a look at that Hub

play02:06

yourself as I mentioned earlier you're

play02:08

going to have times where you have the

play02:10

actual application presented to you so

play02:12

in this case I am looking at a website

play02:14

and it's giving us everything we need we

play02:16

can click on get started and maybe

play02:17

create an account but sometimes you're

play02:19

going to also see an application where

play02:21

then it's not going to show you the

play02:23

whole app it's going to be broken maybe

play02:24

it just shows you an index file with

play02:26

nothing being visible and you can right

play02:27

click and look at the JavaScript I'll

play02:29

show you that in just a SEC but here we

play02:31

can actually see the application so I'm

play02:32

going to just create an account really

play02:33

quickly the hom SEC

play02:36

test so now we can quickly fill this out

play02:39

and sign up for an account and hit

play02:40

register and now that we have an account

play02:42

what I want to do is I want to make sure

play02:44

we are intercepting everything for our

play02:46

proxy tool right here and I'm going to

play02:47

quickly just go to intercept and start

play02:50

queuing because I want to kind of look

play02:51

at what happens once I load the profile

play02:54

page for example what are the different

play02:56

API calls that that happen so in this

play02:57

case what I can see is that app that the

play03:00

domain that we have is making a request

play03:02

to profile which is probably just a

play03:04

static page but eventually it's going to

play03:06

hit app.js we'll go look at that in just

play03:08

a bit but now we can see that the API

play03:10

naming convention is app- API domain

play03:14

name and it's connecting to an API

play03:16

version one it's heading me we're just

play03:18

going to pass that forward maybe we can

play03:20

actually use a respones to also see what

play03:22

the response looks like so it's going to

play03:23

come back we're going to go to response

play03:25

Tab and we can see that the response is

play03:27

just giving us our username our first

play03:29

name all last name and date of birth so

play03:31

we kind of can see what are the

play03:33

different settings that it's allowing

play03:34

what are the different methods that's

play03:36

allowed for that particular endpoint but

play03:37

we're just going to continue and drop

play03:39

all this and see kind of what everything

play03:41

else looks like so now we can kind of

play03:42

take a look at creating post this

play03:44

approach is what I do usually when I'm

play03:46

given a application to hack on a lot of

play03:49

times people just start looking at these

play03:51

applications and they start filling it

play03:52

out with a lot of different payloads but

play03:55

what my Approach is when something has

play03:57

an API behind it is just browsing the

play03:59

website looking at how does it actually

play04:01

create these different content while I

play04:03

also insert my payload so right now I'm

play04:05

going to create this post actually we're

play04:07

not intercepting so we're going to make

play04:08

another one we're going to oops let's go

play04:10

back we're going to go back and edit

play04:12

this now and see what it looks like so

play04:14

if we edit what is the request look like

play04:17

it'ss like it's sending a put request to

play04:19

post that's the ID forour post and it

play04:21

has a title and content but I want to

play04:23

also look at what the response looks

play04:24

like so I'm going to forward that come

play04:26

here and see what the response is here I

play04:28

can see public is is false and there's a

play04:30

share URL so here is where objectives

play04:33

become something in mind instead of

play04:35

looking for vulnerabilities I start to

play04:38

set myself objectives if I wanted to

play04:40

hack this application and I see that

play04:42

there is a public uh false or true for a

play04:45

specific post how can I make another

play04:48

user's post public while creating a

play04:51

share URL for it so what we're going to

play04:53

do here is we're going to make ours

play04:54

public we're going to cue make it public

play04:57

and we're going to take a look at the

play04:58

response so the first and options we

play05:00

don't care we're just going to send that

play05:02

out then there's the share which is

play05:03

public is true it's making a request to

play05:06

the share endpoint on that specific post

play05:09

and it's going to just flip that public

play05:11

to true and right off the bat if we look

play05:13

at the response we can kind of tell that

play05:15

it's going to give us the share URL

play05:17

which is probably how you can access

play05:20

this specific post so in other ways what

play05:22

I want to do here is how do I create a

play05:25

post for another user and make it public

play05:27

if that becomes a really good V ability

play05:30

to look at so here's where you're going

play05:31

to need to make two accounts test the

play05:33

same functionality and see if you can

play05:35

idore that share ID leak the URL for the

play05:38

share post and then see if you can

play05:40

access it so that's kind of the

play05:41

objective that it comes with when you're

play05:44

look at an API I see that this

play05:45

functionality exists how do I abuse it

play05:48

hacking apis isn't always about looking

play05:49

for ssrf xss and just this basic Ido

play05:53

vulnerabilities this is what people mean

play05:55

when they say you want to understand the

play05:57

functionality of a website understand

play05:59

what it's supposed to do and what is it

play06:00

not supposed to do and make that exactly

play06:02

work so if it's not supposed to leak

play06:04

another user's post for example you want

play06:07

to exactly set that your objective to be

play06:09

able to leak and other users for example

play06:11

post in this case so the the other

play06:13

approach is you actually have access to

play06:16

look at the source of this so a lot of

play06:18

times what you would see is you go to a

play06:20

website maybe you you maybe you hit the

play06:22

root folder and it brings you a blank

play06:24

page and you don't see anything else but

play06:26

if you click on the source of the page

play06:28

and you navigate down below you can see

play06:29

JavaScript out sometime it's app.js it

play06:32

could be things like main with a has. JS

play06:34

and when you click on it it is going to

play06:36

bring you a very much uglier version of

play06:39

what we have in front of us and

play06:40

sometimes you can use things like JS

play06:42

link finder you can use other

play06:43

applications or BB Suite plugins to kind

play06:46

of extract data from it one of the

play06:48

things that I like to do usually is look

play06:49

for keywords like get maybe keywords

play06:52

like post put and see what it comes up

play06:54

with so we can actually see if we can

play06:56

come up with anything in here so we can

play06:58

look for something like put and see what

play07:00

comes up with it and we can put it in

play07:01

quotes you can see right here it shows

play07:03

API V1 meet takes a put request and you

play07:07

can actually send this entire request to

play07:09

it and this is how the request works if

play07:10

you're not sure how to read JavaScript I

play07:12

highly recommend getting familiar enough

play07:14

at least to a point where you can read

play07:16

this JavaScript code and go okay this is

play07:18

the endo and this is what it requires

play07:19

for me to do in order to have a valid

play07:21

request but you also have the option to

play07:23

just go into uh a chat GPT or an AI

play07:26

model give it your entire request so in

play07:29

this case I've copied one of the

play07:30

functions in there and I'm just telling

play07:31

it hey provide a valid HTP request for

play07:34

this function you don't have to do

play07:35

something fancy like this one you can

play07:36

honestly just go into chat GPT and write

play07:38

that out and it's going to come back and

play07:39

say hey this is what you sent to API V1

play07:43

me and this is the request body that

play07:45

it's expecting and it's giving you a

play07:46

sample version of it with email first

play07:48

name last name and date of birth so

play07:50

that's just an example of looking at it

play07:51

the second thing that you want to take a

play07:53

look at is also how do we authenticate

play07:55

to this application when we reloaded

play07:57

this page it does send a request to an

play08:00

API but also it authenticates us with

play08:03

this API token so what I will do usually

play08:06

is send this request to my

play08:09

repeater and you can actually test and

play08:12

see if you can access some of this

play08:14

information without having your API

play08:16

token so if it actually loads this in

play08:18

this case it didn't do it but sometimes

play08:20

if that works without the API token you

play08:22

also have found a vulnerability when

play08:24

you're authorizing yourself to retrieve

play08:26

data without being authenticated so this

play08:28

is kind of like a having onof access to

play08:31

an endpoint that leaks maybe pii or post

play08:33

information or whatever it is but the

play08:35

point of the API token is to also see if

play08:37

you can find other apis within this

play08:40

company's domain and access them with

play08:42

that API token sometimes they make this

play08:44

valid and it's being reused within other

play08:46

applications where you can actually sign

play08:48

into that other app or the other API

play08:50

whether it's a Dev environment or some

play08:51

other applications API because they you

play08:54

reuse and assign the same token format

play08:56

so in this case what we're going to do

play08:57

is I know that since I've helped create

play08:59

this CTF there is actually a second

play09:02

domain I'm going to pull that up really

play09:03

quickly so in this case we're going to

play09:05

go to our second application and right

play09:06

here we can see that if I hit this

play09:09

domain it's going to come back and say

play09:11

API server so this kind of looks like it

play09:13

is a Dev instance of the last API and

play09:15

what we want to do is want to try and

play09:17

see if we can actually use this so what

play09:19

I'm going to do here is I'm going to

play09:21

actually go back to kaido and I am going

play09:24

to just Swap this name right here to API

play09:29

that's what the name of the domain is

play09:30

right here oops let me go back one time

play09:32

this is the a name of a domain right

play09:34

here and we're going to change the host

play09:37

name as well so we're going to add dashd

play09:39

here and see if we can actually just hit

play09:42

this API in point with the same

play09:44

authentication token and see if it comes

play09:46

back with anything and you can see right

play09:47

here the same data is available on the

play09:50

API Dev site as it is on the regular set

play09:53

but a lot of times what people don't

play09:55

expect to do here is look for additional

play09:57

content so one of my favorite tricks to

play09:59

do here here is I like to run this

play10:00

through F so you can actually grab this

play10:02

right here if you watch last week's

play10:03

video you should kind of have an

play10:05

understanding of how this works but I'm

play10:06

going to just send it to word list my

play10:08

custom word list maybe all. txt and I'm

play10:11

going to say hey I want you to hit this

play10:12

URL and we're going to actually give it

play10:14

https and what we're going to do here is

play10:16

we're going to authenticate ourselves so

play10:17

I'm going to go in here and I'm going to

play10:19

grab this Heather and say Hey I want to

play10:22

send this custom Heather and I want to

play10:25

also fuss for things here and now we're

play10:26

going to be able to fuss for things and

play10:28

we can see it's coming back with ap API

play10:29

V1 that also exists an API V2 which if

play10:33

we go back to our original post so right

play10:35

here back to the app API without the dev

play10:38

if I type in V2 we're going to see if it

play10:40

exists or not and it looks like it

play10:43

exists on this

play10:45

site and we can do the same thing on the

play10:47

other one so we can go back here API

play10:53

V2 oops test out one more time it exists

play10:56

on both what we want to do here is we

play10:57

want to see if we can find additional

play10:58

information on API V1 or V2 so I'm going

play11:01

to just start with uh actually here I'm

play11:04

going to let it do its thing and I'm

play11:05

going to add recursion but actually

play11:07

because I want to save some time on this

play11:08

video I'm going to go directly to some

play11:10

of the solution where which is in V2 so

play11:12

I'm going to send this request to API V2

play11:15

fuzz and it's going to come back and

play11:17

find us API docs we already know post

play11:19

existed but I want to kind of look at

play11:20

what this API docs looks like a lot of

play11:22

times finding an API docks is a gold

play11:26

mine of information about a company's

play11:28

API so I want to make it clear that

play11:30

having API documentation on its own is

play11:32

not a vulnerability however it is

play11:34

something you can leverage to understand

play11:36

how an application works in this case

play11:38

you can see that we have V1 and V2 for

play11:41

me there's also V1 V2 all these new

play11:44

functionality all this actually old

play11:45

functionality works on V1 and

play11:48

V2 all the way down we can see there's

play11:50

V2 API docs but this is when it gets

play11:53

interesting because now we're uncovering

play11:55

actual endpoints that is only accessible

play11:59

through through V2 so it says V2 user ID

play12:02

token and there is also ID reset and

play12:05

these were things that we didn't see in

play12:06

the past so it is very important for us

play12:09

to be able to test them and we're just

play12:10

going to keep this uh API token right

play12:12

here and we're going to try one of these

play12:13

end points and see if it actually works

play12:16

now it come back and says method not

play12:17

allowed so we can make make a post

play12:19

request actually it shows that oh it

play12:22

shows it right here this is what it

play12:23

expects is to put post and option so

play12:25

right here we can see that we're able to

play12:26

reset a user's token by hitting that API

play12:30

so the point that I make in this

play12:31

scenario is that if you find an API if

play12:34

you find maybe a Dev environment Brute

play12:37

Force for any leads that you can either

play12:39

it's recursively going after the

play12:41

different paths and finding different

play12:42

paths and endpoints for that API looking

play12:44

for API documentation look for them and

play12:47

actually put your API token in the

play12:49

header and see if it works so that's

play12:51

approach number two but there's also one

play12:52

small little approach that I wanted to

play12:54

cover before we wrap up this video and

play12:56

that is actually looking at a blackbox

play12:59

approach so now what we're going to do

play13:00

is we're going to take a look at another

play13:02

API we have created API d r and we're

play13:05

going to do the same thing to our host

play13:07

right here and again I know this

play13:09

information because I've done my quote

play13:10

unquote Recon on this target the Recon

play13:12

here is that I've created this room

play13:14

actually but I want to show you how it

play13:16

works when you have another API under

play13:19

another website that actually allows you

play13:22

to use the same API token to access it

play13:24

so right now we can hit API red maybe

play13:26

it's Red API one more time red

play13:32

API again we're getting an API server

play13:35

this time I highly doubt that we're

play13:36

going to get API documentation so what

play13:38

we're going to do now here is we're

play13:39

going to assume that our API token is

play13:41

good this is kind of when you find out

play13:42

and the more you screw around and the

play13:44

more you find out we're going to send

play13:46

this we're going to say fuzz for it it's

play13:47

going to come back right off the bat

play13:48

it's going to say hey API V1 and V2

play13:50

exists there are different approaches

play13:52

here you can Brute Force for both I

play13:53

actually recommend doing it but for the

play13:55

sake of this video and to save some time

play13:57

what I'm going to do here is I'm going

play13:58

to skip doing a AP I V1 because I do

play14:00

know that api2 is the one that we're

play14:02

after here but again if you're watching

play14:04

this you want to go after api1 I highly

play14:06

recommend it but we're going to fuzz for

play14:08

our next one here the cool thing to do

play14:10

here is actually you can actually do a

play14:12

get request and see what comes back but

play14:15

one of the things that I highly

play14:16

recommend doing here is actually doing a

play14:18

match and looking for anything that

play14:20

comes back for 405

play14:23

403 and 401 we can actually have 200 in

play14:26

there as well and we actually do 41 52

play14:29

let's do that one more time just in case

play14:31

and the reason why we do this is again

play14:33

we want when we look at hacking on apis

play14:36

we want to look for objectives we want

play14:38

to find endpoints that maybe we don't

play14:39

have access to that we can later find a

play14:41

way to access them and also if by adding

play14:43

405 in here you're actually going to

play14:46

uncover API endpoints that require

play14:49

something other than a get request so if

play14:51

you see right here if I didn't have my

play14:52

45 I wouldn't find my register or

play14:56

articles endpoint and that would have

play14:58

been a missed opportunity so you want to

play15:00

put the 405 and 415 those error codes in

play15:03

there to make sure it uncovers and finds

play15:05

you these different endpoints so what

play15:08

you want to do now here we see that

play15:09

articles exist you can actually do this

play15:11

in burb seed or kaido whatever proxy

play15:13

tools you use I actually like to do it

play15:14

with curl I'm just going to quickly grab

play15:17

uh grab my URL

play15:20

here I'm going to actually add an ik to

play15:22

this just so I can see their response

play15:24

and ignore any SSL issues that we have

play15:27

API V2 articles is the one that we're

play15:30

going to take a look at it came back and

play15:31

said 405 I want to kind of show you what

play15:33

my Approach is when I see an endpoint

play15:35

that says 405 what do I do what do I try

play15:37

a lot of times I know people talk about

play15:39

parameter brute forcing that is an

play15:41

option you can do but what else you can

play15:42

do here is we actually send this request

play15:45

and kind of see and observe what it does

play15:48

what is this wanting from us it says

play15:50

first of all the method is not allowed

play15:52

so we're going to go back and we're

play15:53

going to add an X and specify what kind

play15:56

of request you want to send it looks

play15:58

like if we send an options maybe it

play16:00

could tell us what it

play16:02

expects it doesn't so we're going to go

play16:04

back and maybe do a put request this

play16:07

time we do Post first and now it says

play16:11

required variable title this is what I

play16:13

mean when I say you don't have to over

play16:15

complicate things so in this example you

play16:17

don't have to go ahead and do parameter

play16:19

brute forcing sometimes a lot of these

play16:21

apis are verbose enough to tell you

play16:23

what's just missing so now we can

play16:24

actually send the data for it we're

play16:25

going to actually do a content type

play16:29

added to this we're going to do Dash our

play16:32

content type would be application Json

play16:35

and the data would be actually sending

play16:39

our

play16:41

title let's just make sure we're doing

play16:43

it right it's title and we want to send

play16:45

test one two 3 and we're going to close

play16:48

it out and see what comes back now it

play16:50

says body cannot be empty so it looks

play16:52

like it looks for a body here so we're

play16:53

going to send body and we're going to

play16:56

send another test one two three

play16:59

and now it says article one created and

play17:02

now we can actually go back to the

play17:03

Articles and we're going to send the

play17:05

same request we're going to go back to

play17:07

the most basic form of it we no longer

play17:09

need X options we're going to send it to

play17:12

articles one and we can see that our

play17:14

article was created and sometimes

play17:16

actually a lot of times if you are going

play17:18

from one application to another if this

play17:20

application is not referenced anywhere

play17:21

else and you kind of see it getting

play17:24

access to n out of 10 times there is

play17:26

functionality on there that is

play17:27

vulnerable but what's really Co about

play17:29

this one specifically that I want to

play17:30

point out is if we hit our article V1 it

play17:34

is really important to look at what does

play17:36

this API come back and return my data in

play17:39

and you can see right here it is coming

play17:41

back as content text HTML which means

play17:45

that if we actually are able to insert

play17:48

HTML within this page it's no longer

play17:50

going to look at this as a text format

play17:52

so a lot of times when you see in a lot

play17:54

of our previous tries right here for

play17:56

example you can see the content type is

play17:57

Json it's coming back it says text/html

play18:00

in this case I cannot manipulate what

play18:03

the server responds with let's look at

play18:04

another one in the past that we looked

play18:05

at here is another example we hit reset

play18:10

but it's coming back and it's saying

play18:11

application is Json and the content type

play18:14

is Json which means if I replay this

play18:16

request in my

play18:18

browser and look at it on here you can

play18:20

see that there's no HTML here that we

play18:23

can manipulate this but also it's not

play18:24

going to render this as HTML versus this

play18:27

request right here if I put it in my

play18:28

browser and I open it right here there's

play18:30

no HTML currently but I'm going to send

play18:32

that out with one more example let's do

play18:34

this one more time hold if I send that

play18:37

out with one more example right here and

play18:38

we actually add some HTML into it and we

play18:41

send it out for Article

play18:44

2 we can say it's actually rendering our

play18:47

HTML so this is a case of paying

play18:50

attention to the small details that

play18:51

comes back from this web server so if

play18:53

you notice somewhere that an application

play18:55

that is supposed to be an API and it's

play18:57

expecting to return Pon format request

play19:00

it's returning HTML how can I manipulate

play19:03

the response whether it's causing an

play19:04

error with our text that's reflected in

play19:06

there or actually adding content that's

play19:08

HTML within it and seeing if you can get

play19:10

HTML back in the objective of getting

play19:13

HTML injection which could be later

play19:14

leverage for an account takeover

play19:16

whatever else we're going to do within

play19:17

this API I know there was a lot to

play19:19

unpack this video but I wanted to kind

play19:20

of showcase the different approaches

play19:22

that comes to API and some of the common

play19:25

mistakes that I've seen being made by a

play19:28

lot of the hackers when it comes down to

play19:30

looking at apis so if you're watching

play19:32

this and you want to get better at API

play19:33

hacking go to hacking Hub go launch this

play19:35

exact Hub and kind of play around with

play19:37

the API learn what an API looks like

play19:39

what is it like to find and uncover

play19:41

different endpoints and how to actually

play19:43

create a valid request for an API

play19:47

whether it's by using curl or using your

play19:49

proxy like burp or kaido and and kind of

play19:51

see if you can get used to creating your

play19:52

own API request and then later translate

play19:55

that into looking for vulnerabilities

play19:58

all right that's it thank you so much

play19:59

for sticking around for the last 5 weeks

play20:01

I really hope this past 5 weeks have

play20:03

been helpful and you had as much fun as

play20:05

I did creating it for you all right

play20:07

that's it I will see you all in next

play20:09

week's video

play20:11

[Music]

play20:19

peace

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
API HackingCybersecurityWeb SecurityHacking TutorialVulnerability AssessmentCTF ChallengesAPI ExploitationSecurity TestingWeb ApplicationHacker Training