Web Application Advanced Hacking
Web Application Advanced Hacking
B
follow me :
follow me : Linkedin :link: https://www.linkedin.com/in/
mahmoud-ibrahim-9b5364244
github:https://github.com/Az0x7
lass myClass
c
{
public $name = "demo";
function __construct()
{
#...some PHP code...#
- example - php }
}
print serialize(new myClass this script will
serialize the PHP
class to the following string:
Chapter 1: Deserialization Attacks O:7:"myClass":1{s:4:"name";s:4:"demo";}
ip
T oSQL databases provide APIs in a variety of
N
During an assessment, it’s always languages with various relationship
recommended to check the sen- models, which each offer different features
sitive information that may be stored inside and restrictions
the JWT, as it is just
base64-encoded data and thus very easy to or example, the equivalent of the
F
oSQL databases such as MongoDB don’t
N
decode. Also note that previously illustrated query for a NoSQL MongoDB JSON
use traditional SQL syntax; however, they
it’s possible to automate these tests using the array database is shown
are still potentially vulnerable to injection
JWT_Tool from GitHub: below:
attacks
https://github.com/ticarpi/jwt_tool db.users.find({username: '<USER>', password: '<PWD>'});
In many web applications, developers need raphQL was developed by Facebook in
G
Bypass Transfer Money Limit to create custom solutions to handle around 2012, and publicly released in 2015.
certain requirements of the business unit. For It’s a specification for an open source data
example, in payment applications, query language (DQL) and API engine
Borrow Money Without Return
there may be a need to ensure that services with implementations in many languages.
Bypass Business Limit
are provided based on age thresholds, GraphQL is just a client facing query
Get Better Yearly Rates
or to check that payments made by language, not a backend database query
customers do not exceed their current language (like MongoDB, MySQL, etc.). This
Discount Checkout Flaws account means that the client first interacts with the
balance. GraphQL layer, which in turn interacts
with arbitrary code and ultimately ends up
talking to the database. The idea behind
GraphQL is that you don’t need to query
erver-Side Request Forgery (SSRF)
S
multiple REST APIs and send multiple
vulnerabilities allow the trust relationship
requests to different endpoints on the API to
between vulnerable applications and the
query data from the backend database
backend system to be abused, giving an
like you do with GraphQL—you only need to
attacker access to internal resources that are
send one request to query the backend.
not intended to be exposed. This can
result in unauthorized access of sensitive
he first step of GraphQL discovery is to
T
data, actions, and interfaces in the internal
search the interactive GraphQL endpoints
network, including internal DB admin or
that allow us to execute queries. First look
control panel interfaces. Usually, to find
for common GraphQL endpoint paths
this type of vulnerability, all we need is to
such as these:
tamper with URL-based interfaces such
/graphql/Chapter
as updating, fetching, and validating data
/graphql/console/
inputs (update image profile URL, update Detect GraphQL endpoints
/graphql.php
remote URL resource, etc.).
/graphiql/
Chapter 4: API Hacking GraphQL /graphiql.php
If you don’t have Burp Pro edition or you
/api/grpahsql
don’t want to use the Python module,
/api/grpahsql/grpahsql.php
there’s a better tool that automates the
/api/<company>-grpahsql
process of finding and escalating SSRF-based SSRF Exploitation with SSRFmap
/<company>-graphsql
vulnerabilities. You can download it from
GitHub here:
fter discovering a GraphQL endpoint, the
A
https://github.com/swisskyrepo/SSRFmap
next step is to fully understand the
schema in order to know how to query it.
ost cloud service providers (e.g., Amazon
M
Fortunately, GraphQL allows us to discover
AWS) give access to the internal metadata Enumerate GraphQL schema
its schema by using its introspection system.
REST (Representational State Transfer) API,
With this system, we can receive
from where important configuration and
information about the server’s available
sensitive data can be extracted. This allows
queries, types, fields, and more.
the attack surface to be extended, so that
you can perform lateral attacks on other
ip
T
services and instances within the cloud
Issuing the introspection query by hand and
environment. Cloud-based SSRF figuring everything out by
reading the response can be a painful and
ou may find more accurate API endpoints in the following
Y
time-consuming task. I highly
GitHub
recommend downloading and installing (even
Project:
locally) this GraphQL-
https://github.com/cujanovic/SSRF-Testing/blob/master/
IDE project from GitHub (https://github.com/
cloud-
andev-software/graphql-
metadata.txt
ide), which will fetch everything
automatically and save you some time.
imilarly to Blind SQL injection techniques,
S
you can escalate a successful XXE (XML
External Entity) attack on a target application
to access internal resources by creating loud storage provides a solution for storing
C
an external DTD (Document Type Definition) SSRF Out-of-Band with XXE static files such as photos, videos,
within the original XML request. Thus, documents, and almost any other type of file
you’ll be able to make an additional request or asset. Instead of organizing files in a
to local resources and read the contents Chapter 6: Server-Side Request Forgery hierarchical directory, object storage systems
of the local files. organize files in such a way that each
file is called an object, and any number of
In Local File Inclusion (LFI) attacks, the objects can be uploaded to the storage.
application uses URL input as a path to Every file has a unique link, and is delivered
include files as part of its logical flow. through the vendor CDN (Content
Therefore, it is possible to load the contents Delivery Network)
of
SSRF with Local File Inclusion
local files by using different URL scheme here are two key-players in this field,
T
protocols; hence, an attacker can exfiltrate Amazon Web Service (AWS), with S3 buckets;
the source code or data from the internal and DigitalOcean, with Spaces. Both vendors
resources with no need to create a SSRF provide a similar concept of file storage
listener or remote server. and management.
ommand
C
aws s3 ls s3://[bucketname] let’s say that our S3 bucket is at testmeplz.s3.amazonaws.com.
aws s3 mv yourfile The
s3://[bucketname]/test-file.txt command would look like this:
or this type of test, you should configure
F
aws s3 rm aws s3 ls s3://testmeplz.s3.amazonaws.com –no-sign-request
the AWS CLI (Command Line Interface)
s3://[bucketname]/test-file.svg However, as some buckets are hosted in specific regions, we will
in your machine to connect and S3 bucket
aws s3 mv yourfile need to specify the
commands from the CLI.
s3://[bucketname] bucket region in some cases, as follows:
Once you’ve installed it, you need to
Description aws s3 ls s3://testmeplz.s3.amazonaws.com –no-sign-request
configure it with an access key, as described
Try to list all files within the S3 –region us-
here: https://aws.amazon.com/developers/
Misconfigured S3 buckets bucket example, west-2
access-keys/
Move local file to the remote S3
Then, you will be able to check if the bucket
bucket emember that S3 buckets share a global
R
lacks proper ACLs (Access Control
Delete remote file from the S3 namespace, meaning that no two buckets
Lists) for either the buckets or objects, by
bucket can share the same name. For example:
inspecting the response from the following
Upload file with public-read demo1 and demo2 are two different buckets
commands to see whether they return
permission, and are not necessarily related to the same
“AccessDenied” errors:
useful in case the object provides company.
an
“AccessDenied” error when
accessing it
uring an engagement, there’s usually not enough time to try most of the
D
methods
here manually. However, you can use many online tools that are available to
download from GitHub to help enumerate and discover cloud storage content. I
would like to mention a few that I’ve had a great experience with:
For Amazon S3 buckets, try the “AWSBucketDump” tool by Jordan Potti:
Automate hunting for cloud storage https://github.com/jordanpotti/AWSBucketDump
For DigitalOcean Spaces, try the “Spaces-Finder” tool by Appsecco:
https://github.com/appsecco/spaces-finder
For GCP Storage, try the “GCPBucketBrute” tool by RhinoSecurityLabs:
https://github.com/RhinoSecurityLabs/GCPBucketBrute
For Azure Storage, try the “MicroBurst” tool by NetSPI:
https://github.com/NetSPI/MicroBurst