songining
Spring Mockito when().thenReturn ๊ณผ doReturn.when()์˜ ์ฐจ์ด
BACKEND/Spring 2022. 8. 1. 16:29

Typically, stubbing argument mismatch indicates user mistake when writing tests. Mockito fails early so that you can debug potential problem easily. However, there are legit scenarios when this exception generates false negative signal: - stubbing the same method multiple times using 'given().will()' or 'when().then()' API Please use 'will().given()' or 'doReturn().when()' API for stubbing. - st..

[Spring] detached entity passed to persist ์—๋Ÿฌ
BACKEND/Spring 2022. 5. 26. 02:32

detached entity passed to persist ๊ด€๋ จ ์—๋Ÿฌ๊ฐ€ ๋œจ๋Š” ๊ฒฝ์šฐ ์ด๋ฏธ ์ƒ์„ฑ๋˜์–ด ์žˆ๋Š” ๊ฐ์ฒด์˜ ๋ถ€๋ถ„์— ๋‹ค์‹œ ํ•œ๋ฒˆ ๋” ์„ค์ •์„ ํ•ด์ฃผ๊ฑฐ๋‚˜ ์ €์žฅ์„ ํ•ด์ฃผ๋ ค๊ณ  ํ•  ๋•Œ ์ƒ๊ธฐ๋Š” ๊ฒƒ! ์ฆ‰, ์—”ํ‹ฐํ‹ฐ ์ข…์†์„ฑ ๋ฌธ์ œ๊ฑฐ๋‚˜ ๊ฐ์ฒด ์ƒ์„ฑํ•  ๋•Œ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๊ฒƒ !! ์˜ˆ๋ฅผ ๋“ค๋ฉด 1) id ํ•„๋“œ์— @GeneratedValue๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ง€๋„๋ก ํ•ด๋†“๊ณ  ํ…Œ์ŠคํŠธํ•  ๋•Œ id ๊ฐ’์„ ์„ค์ •ํ•ด์คฌ๋‹ค๋˜๊ฐ€.. 2) ์—”ํ‹ฐํ‹ฐ๋“ค์˜ ์—ฐ๊ด€๊ด€๊ณ„๊ฐ€ ์กด์žฌํ•  ๋•Œ ํด๋ž˜์ŠคA ์˜ a1, a2 ์— ์—ฐ๊ด€๋œ ํด๋ž˜์ŠคB์— b1 ์ด ์žˆ์„ ๋•Œ (a1 + b1) ์ €์žฅํ•˜๊ณ  (a2 + b1) ์ €์žฅ๋˜์–ด ์ค‘๋ณต์œผ๋กœ ์ €์žฅ๋˜๋Š” ๊ฒฝ์šฐ (์ด๋Ÿฐ ๊ฒฝ์šฐ์—๋Š” cascade ๊ด€๋ จํ•ด์„œ ์„ค์ •์„ ์ œ๊ฑฐํ•ด์ฃผ๋˜๊ฐ€ ๋…๋ฆฝ์ ์œผ๋กœ ์‹คํ–‰๋˜๊ฒŒ ํ•ด์ฃผ๋ฉด ๋  ๋“ฏ!)

์„ธ์…˜๊ณผ JWT์˜ ์ฐจ์ด
BACKEND/Spring 2022. 5. 23. 23:38

JWT๋ž€? Json Web Token ์˜ ์•ฝ์ž๋กœ json ๊ฐ์ฒด์— ์‚ฌ์šฉ์ž์˜ ์ผ๋ถ€ ์ •๋ณด๋ฅผ ๋‹ด๋Š”๋‹ค. ์„ธ์…˜๊ณผ ๋‹ฌ๋ฆฌ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์„œ๋ฒ„๊ฐ€ ์ค€ ํ† ํฐ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๊ฐ€ ํ—ค๋”์— ์‹ค์–ด์„œ ๋ณด๋‚ด๋Š” ๋ฐฉ์‹ (๋‹จ์ˆœํ•˜๊ฒŒ ๋งํ•˜๋ฉด ํ† ํฐ ๊ธฐ๋ฐ˜ ์ธ์ฆ ๋ฐฉ์‹) Header : Signature๋ฅผ ํ•ด์‹ฑํ•˜๊ธฐ ์œ„ํ•œ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ •๋ณด๋“ค ๋‹ด๊ฒจ์žˆ์Œ Payload : ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ฃผ๊ณ ๋ฐ›๋Š”, ์‹œ์Šคํ…œ์—์„œ ์‹ค์ œ๋กœ ์‚ฌ์šฉ๋  ์ •๋ณด๋“ค์— ๋Œ€ํ•œ ๋‚ด์šฉ ๋‹ด๊ณ  ์žˆ์Œ Signature : ํ† ํฐ์˜ ์œ ํšจ์„ฑ ๊ฒ€์ฆ์„ ์œ„ํ•œ ๋ฌธ์ž์—ด (์œ ํšจํ•œ ํ† ํฐ์ธ์ง€ ๊ฒ€์ฆ) ์„ธ์…˜์€? ์„œ๋ฒ„์˜ ๋ฉ”๋ชจ๋ฆฌ์— ์ธ์ฆํ•œ ์œ ์ €์˜ ์ •๋ณด๋ฅผ ์ €์žฅํ•ด๋‘ ! ๊ทธ๋ฆฌ๊ณ  ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์ธ์ฆ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ํ†ต์‹ ํ•˜๋Š” ๋ฐฉ์‹ stateful service๋ž€ ์„ธ์…˜ ์ •๋ณด๋ฅผ ์„œ๋ฒ„์— ์ €์žฅํ•˜๊ณ  ์„ธ์…˜ ์ƒํƒœ์— ๋”ฐ๋ฅธ ์‘๋‹ต์„ ์ฃผ๋Š” ์„œ๋น„์Šค! -> EX) ์„ธ์…˜..

Django simple-jwt ๋กœ๊ทธ์ธ ์ปค์Šคํ…€ํ•˜๊ธฐ
BACKEND/Django 2022. 5. 8. 16:43

pip install djangorestframework-simplejwt settings.py simple-jwt ํ”„๋ ˆ์ž„์›Œํฌ ์‚ฌ์šฉ๊ณผ ๊ถŒํ•œ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•ด settings.py ์•ˆ์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถ”๊ฐ€ํ•ด์ค€๋‹ค. REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', ), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', ) } ์ปค์Šคํ…€ ์œ ์ € ๋ชจ๋ธ์„ ์‚ฌ์šฉ ๋ฐ simple-jwt ์ถ”๊ฐ€ ์˜ต์…˜์„ ์ฃผ๊ธฐ ์œ„ํ•ด ๋‹ค์Œ๋„ ์ถ”๊ฐ€ํ•œ๋‹ค. AUTH_USER_MODEL = "์•ฑ์ด๋ฆ„.CustomUser..

article thumbnail
<ํ•ดํ‚น: ๊ณต๊ฒฉ์˜ ์˜ˆ์ˆ > 5ํšŒ์ฐจ ์Šคํ„ฐ๋””
Hacking/System Hacking 2022. 5. 4. 21:18

ํž™์ด๋ž€ ? ์š”์ฒญ์— ๋”ฐ๋ผ ํ• ๋‹น๋˜๋ฉฐ chunk ํ˜•ํƒœ๋กœ ๋‚˜๋‰  ์ˆ˜ ์žˆ๋Š” ์ธ์ ‘ํ•œ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ ํž™์— ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹นํ•  ๋•Œ๋Š” malloc() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•จ malloc ํ•จ์ˆ˜์—๋Š” ํฌ๊ธฐ๋ฅผ ์ •ํ•˜๋Š” ์ธ์ž๊ฐ€ ํ•„์š”ํ•˜๊ณ , ๊ทธ ํฌ๊ธฐ๋งŒํผ ๊ณต๊ฐ„์„ ํž™ ์„ธ๊ทธ๋จผํŠธ์— ํ• ๋‹นํ•œ๋‹ค. (Top Chunk๋ฅผ ์‚ฌ์šฉํ•ด ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น) ๊ทธ๋ฆฌ๊ณ  ๋ณด์ด๋“œ ํฌ์ธํ„ฐ๋กœ ํ• ๋‹นํ•œ ๋ฉ”๋ชจ๋ฆฌ์˜ ์‹œ์ž‘์ฃผ์†Œ๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค. mallocํ•จ์ˆ˜๊ฐ€ ์–ด๋–ค ์ด์œ ๋กœ ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น์„ ํ•˜์ง€ ๋ชปํ•˜๊ฒŒ ๋˜๋ฉด 0๊ฐ’์„ ๋ฆฌํ„ดํ•œ๋‹ค. malloc์— ๋Œ€์‘ํ•˜๋Š” ํ•ด์ œ ํ•จ์ˆ˜๋Š” free()์ด๋‹ค. free ํ•จ์ˆ˜์—๋Š” ํฌ์ธํ„ฐ ์ธ์ž๊ฐ€ ํ•„์š”ํ•˜๊ณ , ๋‚˜์ค‘์— ๋‹ค์‹œ ๊ทธ ๊ณต๊ฐ„์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์ธ์ž ํฌ์ธํ„ฐ์˜ ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น์„ ํ•ด์ œํ•œ๋‹ค. char *char_ptr; // ํž™ ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น (mem_size ๋ฐ”์ดํŠธ ๋งŒํผ ํ• ๋‹น) char_ptr = (ch..

<ํ•ดํ‚น: ๊ณต๊ฒฉ์˜ ์˜ˆ์ˆ > 4ํšŒ์ฐจ ์Šคํ„ฐ๋””
Hacking/System Hacking 2022. 5. 3. 19:32

์ฑ…์„ ๋ณด๊ณ  ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค X86 ํ”„๋กœ์„ธ์„œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค. ๊ตฌ์กฐ์ฒด(structs) -> ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋ณ€์ˆ˜๋ฅผ ๊ทธ๋ฃน์œผ๋กœ ๋ฌถ์–ด ํ•˜๋‚˜์ฒ˜๋Ÿผ ๋‹ค๋ฃจ๋Š” ๊ฒƒ์ด ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด ๊ตฌ์กฐ์ฒด๋ผ๋Š” ๊ฒƒ์„ ์‚ฌ์šฉ -> ๊ตฌ์กฐ์ฒด๊ฐ€ ์ •์˜๋œ ํ›„์—๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ณ€์ˆ˜ ํƒ€์ž…์ด ๋˜๊ณ , ๊ตฌ์กฐ์ฒด ํƒ€์ž…์œผ๋กœ ๋ณ€์ˆ˜๋‚˜ ํฌ์ธํ„ฐ ์„ ์–ธ์ด ๊ฐ€๋Šฅํ•ด์ง struct ๊ตฌ์กฐ์ฒด์ด๋ฆ„ *ํฌ์ธํ„ฐ์ด๋ฆ„ = malloc(sizeof(struct ๊ตฌ์กฐ์ฒด์ด๋ฆ„));๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ตฌ์กฐ๋กœ ๊ตฌ์กฐ์ฒด ํฌ์ธํ„ฐ ์„ ์–ธ ๊ฐ€๋Šฅ ์‹œ๊ฐ„ ํ•จ์ˆ˜๋ฅผ ๋‹ค๋ฃฐ ๋•Œ /usr/include/time.h์— ์ •์˜๋˜์–ด ์žˆ๋Š” tm ๊ตฌ์กฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•˜๋‹ค. tm ๊ตฌ์กฐ์ฒด์˜ ์ •์˜ struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_y..

Django MVC ๊ตฌ์กฐ
BACKEND/Django 2022. 5. 2. 15:05

django-admin startproject tutorial # ์žฅ๊ณ  ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ cd tutorial # ๋ฃจํŠธ ํ”„๋กœ์ ํŠธ๋กœ ์ด๋™ ./manage.py startapp community # ์•ฑ ์ƒ์„ฑ ./manage.py migrate # ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ƒ์„ฑ ./manage.py createsuperuser # ๊ด€๋ฆฌ์ž ์ƒ์„ฑ ./manage.py runserver {port} # ์„œ๋ฒ„ ์—ฐ๊ฒฐ settings.py์— community ์•ฑ ์ถ”๊ฐ€ํ•ด์ฃผ์–ด์•ผํ•จ INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.message..

article thumbnail
<ํ•ดํ‚น: ๊ณต๊ฒฉ์˜ ์˜ˆ์ˆ > 3ํšŒ์ฐจ ์Šคํ„ฐ๋””
Hacking/System Hacking 2022. 5. 1. 16:08

์ฑ…์„ ๋ณด๊ณ  ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค X86 ํ”„๋กœ์„ธ์„œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค. C์–ธ์–ด์—์„œ ํŒŒ์ผ์— ์ ‘๊ทผํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” ํฌ๊ฒŒ 2๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค. 1. ํŒŒ์ผ ์„œ์ˆ ์ž (File Descriptor) 2. ํŒŒ์ผ ์ŠคํŠธ๋ฆผ (Filestream) - ํŒŒ์ผ ์ŠคํŠธ๋ฆผ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํ•˜๊ธฐ๋Š” ํŽธํ•˜์ง€๋งŒ ํŒŒ์ผ ์„œ์ˆ ์ž๊ฐ€ ์ข€ ๋” ์ง์ ‘์ ์ž„ ( ํŒŒ์ผ์„œ์ˆ ์ž๋Š” ๋กœ์šฐ๋ ˆ๋ฒจ, ํŒŒ์ผ ์ŠคํŠธ๋ฆผ์€ ํ•˜์ด๋ ˆ๋ฒจ ์ž…์ถœ๋ ฅ์ž„) ํŒŒ์ผ ์„œ์ˆ ์ž - open() : ํ•จ์ˆ˜๋ฅผ ์ฝ๊ฑฐ๋‚˜ ์“ธ ์ˆ˜ ์žˆ๊ฒŒ ํŒŒ์ผ์„ ์—ด๊ณ  ํŒŒ์ผ ์„œ์ˆ ์ž๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค. ํŒŒ์ผ ์„œ์ˆ ์ž๋Š” ๋‹จ์ˆœํ•œ ์ •์ˆ˜ ๊ฐ’์ด์ง€๋งŒ ์—ด๋ฆฐ ํŒŒ์ผ๋งˆ๋‹ค ๊ณ ์œ ํ•˜๋‹ค. ํŒŒ์ผ ์„œ์ˆ ์ž๋Š” ์—ด๋ฆฐ ํŒŒ์ผ์„ ๊ฐ€๋ฆฌํ‚ค๋Š” ํฌ์ธํ„ฐ์™€ ๊ฐ™์€ ์ธ์ž๋กœ ๋‹ค๋ฅธ ํ•จ์ˆ˜์—๊ฒŒ ๋„˜๊ฒจ์ง„๋‹ค. - close() : ํŒŒ์ผ ์„œ์ˆ ์ž๋ฅผ ์ธ์ž๋กœ ์‚ฌ์šฉ - read() : ํŒŒ์ผ ์„œ์ˆ ์ž, ์ฝ๊ฑฐ๋‚˜ ์“ธ ๋ฐ์ดํ„ฐ๋ฅผ ..

<ํ•ดํ‚น: ๊ณต๊ฒฉ์˜ ์˜ˆ์ˆ > 2ํšŒ์ฐจ ์Šคํ„ฐ๋””
Hacking/System Hacking 2022. 4. 28. 15:57

์ฑ…์„ ๋ณด๊ณ  ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค X86 ํ”„๋กœ์„ธ์„œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค. ๋ฉ”๋ชจ๋ฆฌ ์„ธ๊ทธ๋จผํŠธ ์ปดํŒŒ์ผ๋œ ํ”„๋กœ๊ทธ๋žจ ๋ฉ”๋ชจ๋ฆฌ๋Š” ์ฝ”๋“œ, ๋ฐ์ดํ„ฐ, bss, ํž™, ์Šคํƒ์˜ 5๊ฐœ์˜ ์„ธ๊ทธ๋จผํŠธ๋กœ ๋‚˜๋‰œ๋‹ค. ์ฝ”๋“œ ํ”„๋กœ๊ทธ๋žจ์˜ ๊ธฐ๊ณ„์–ด ๋ช…๋ น์ด ๋“ค์–ด์žˆ์Œ ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰๋˜๋ฉด EIP๋Š” ์ฝ”๋“œ ์„ธ๊ทธ๋จผํŠธ์˜ ๋งจ ์ฒ˜์Œ ์œ„์น˜๋กœ ์„ค์ •๋œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ํ”„๋กœ์„ธ์Šค๋Š” ๋‹ค์Œ ์ž‘์—…์„ ๋ฐ˜๋ณต ์‹คํ–‰ํ•œ๋‹ค. 1. EIP๊ฐ€ ๊ฐ€๋ฆฌํ‚ค๊ณ  ์žˆ๋Š” ๋ช…๋ น์„ ์ฝ๋Š”๋‹ค. 2. ๊ทธ ๋ช…๋ น์˜ ๊ธธ์ด๋ฅผ EIP์— ๋”ํ•œ๋‹ค. 3. 1๋‹จ๊ณ„์—์„œ ์ฝ์€ ๋ช…๋ น์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. 4. 1๋‹จ๊ณ„๋กœ ๋Œ์•„๊ฐ„๋‹ค. - ์ฝ”๋“œ ์„ธ๊ทธ๋จผํŠธ๋Š” ๋ณ€์ˆ˜๊ฐ€ ์•„๋‹Œ ์ฝ”๋“œ๋งŒ์„ ์ €์žฅํ•˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ ์“ฐ๊ธฐ๊ฐ€ ๊ธˆ์ง€๋˜์–ด์žˆ๋‹ค. (์‚ฌ์šฉ์ž๊ฐ€ ํ”„๋กœ๊ทธ๋žจ ์ฝ”๋“œ๋ฅผ ๋ณ€๊ฒฝํ•˜์ง€ ๋ชปํ•˜๊ฒŒ ๋ง‰๊ธฐ ์œ„ํ•จ) ์ฝ”๋“œ ์„ธ๊ทธ๋จผํŠธ์— ์“ฐ๋ ค๋Š” ์‹œ๋„๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ ์šด์˜์ฒด์ œ๊ฐ€ ๊ทธ ์‚ฌ์‹ค์„ ์‚ฌ์šฉ์ž์—๊ฒŒ ์•Œ๋ฆฌ๊ณ  ํ”„๋กœ๊ทธ๋žจ์€ ์ข…๋ฃŒ๋จ..

<ํ•ดํ‚น: ๊ณต๊ฒฉ์˜ ์˜ˆ์ˆ > 1ํšŒ์ฐจ ์Šคํ„ฐ๋””
Hacking/System Hacking 2022. 4. 25. 23:07

์ฑ…์„ ๋ณด๊ณ  ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค X86 ํ”„๋กœ์„ธ์„œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค. GDB ์กฐ์‚ฌ ๋ช…๋ น ํ˜•์‹ o : 8์ง„๋ฒ• x : 16์ง„๋ฒ• u : ๋ถ€ํ˜ธ๊ฐ€ ์—†๋Š” ํ‘œ์ค€ 10์ง„๋ฒ• t : 2์ง„๋ฒ• ๋ฉ”๋ชจ๋ฆฌ ๋‹จ์ผ ์œ ๋‹›์˜ ๊ธฐ๋ณธ ํฌ๊ธฐ๋Š” '์›Œ๋“œ' ๋ผ ๋ถˆ๋ฆฌ๋Š” 4 byte (32bit ํ™˜๊ฒฝ์—์„œ) b ๋‹จ์ผ ๋ฐ”์ดํŠธ h 2byte์˜ ํ•˜ํ”„์›Œ๋“œ w 4byte์˜ ์›Œ๋“œ g 8byte์˜ ์ž์ด์–ธํŠธ eip ๋ ˆ์ง€์Šคํ„ฐ : ํ”„๋กœ์„ธ์„œ๊ฐ€ ์ฝ๊ณ  ์žˆ๋Š” ํ˜„์žฌ ๋ช…๋ น์˜ ์œ„์น˜๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ๋ช…๋ น ํฌ์ธํ„ฐ ๋ ˆ์ง€์Šคํ„ฐ i r eip : eip ๋ ˆ์ง€์Šคํ„ฐ์˜ ํ˜„์žฌ ๋ฉ”๋ชจ๋ฆฌ ์ฃผ์†Œ x/x $eip : 16์ง„๋ฒ•์œผ๋กœ eip๊ฐ€ ๊ฐ–๊ณ  ์žˆ๋Š” ๊ฐ’ ์ถœ๋ ฅ ($eip๋Š” ๊ทธ ์ˆœ๊ฐ„ eip๊ฐ€ ๊ฐ–๊ณ  ์žˆ๋Š” ๊ฐ’์„ ์˜๋ฏธํ•œ๋‹ค.) x/xw $eip : 16์ง„๋ฒ•์œผ๋กœ 4byte๋งŒํผ ์ถœ๋ ฅ ( ๋ฆฌํ‹€์—”๋””์•ˆ x ) x/i $eip : eip ์œ„์น˜..

article thumbnail
[dreamhack] Return to Library
Hacking/System Hacking 2022. 4. 10. 23:49

Return Address Overwrite: ๋ฐ˜ํ™˜ ์ฃผ์†Œ๋ฅผ ์•…์„ฑ ํ•จ์ˆ˜์˜ ์ฃผ์†Œ๋กœ ๋ฎ์–ด์„œ ์…ธ ํš๋“ Stack Canary: ์Šคํƒ ํ”„๋ ˆ์ž„์˜ ๋ฐ˜ํ™˜ ์ฃผ์†Œ ์ „์— ๋žœ๋คํ•œ ์นด๋‚˜๋ฆฌ๋ฅผ ์ฃผ์ž…ํ•˜์—ฌ ๋ฐ˜ํ™˜ ์ฃผ์†Œ๋ฅผ ๋ฎ๊ธฐ ์–ด๋ ต๊ฒŒ ํ•จ Return to Shellcode: ์นด๋‚˜๋ฆฌ๋ฅผ ์šฐํšŒํ•˜๊ณ , ์…ธ ์ฝ”๋“œ๋ฅผ ์ฃผ์ž…ํ•œ ๋ฒ„ํผ์˜ ์ฃผ์†Œ๋กœ ๋ฐ˜ํ™˜ ์ฃผ์†Œ๋ฅผ ๋ฎ์–ด์„œ ์…ธ ํš๋“ ASLR: ์ž„์˜ ๋ฒ„ํผ์˜ ์ฃผ์†Œ๋ฅผ ์•Œ๊ธฐ ์–ด๋ ต๊ฒŒ ํ•จ NX: ๊ฐ ์„ธ๊ทธ๋จผํŠธ์— ๋ถˆํ•„์š”ํ•œ ์‹คํ–‰๊ถŒํ•œ์„ ์ œ๊ฑฐํ•จ์œผ๋กœ์จ ๊ณต๊ฒฉ์ž๊ฐ€ ์ž„์˜ ๋ฒ„ํผ์— ์ฃผ์ž…ํ•œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๊ธฐ ์–ด๋ ต๊ฒŒํ•จ Return to Library -> NX๋ฅผ ์šฐํšŒํ•˜๋Š” ๊ณต๊ฒฉ๊ธฐ๋ฒ• NX๋กœ ์ธํ•ด ์ฝ”๋“œ ์˜์—ญ ์™ธ์—๋Š” ์‹คํ–‰๊ถŒํ•œ์ด ์—†์–ด์ง€๊ธฐ ๋•Œ๋ฌธ์— ์‹คํ–‰๊ถŒํ•œ์ด ๋‚จ์•„์žˆ๋Š” ์ฝ”๋“œ ์˜์—ญ์œผ๋กœ ๋ฐ˜ํ™˜ ์ฃผ์†Œ๋ฅผ ๋ฎ๋Š” ๊ณต๊ฒฉ ๊ธฐ๋ฒ•์„ ๊ณ ์•ˆํ–ˆ๋‹ค. ํ”„๋กœ์„ธ์Šค์— ์‹คํ–‰ ๊ถŒํ•œ์ด ์žˆ๋Š” ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์€..

article thumbnail
[dreamhack] ssp_001 ๋ฌธ์ œํ’€์ด
Hacking/System Hacking 2022. 4. 4. 02:41

ํ™˜๊ฒฝ ์„ธํŒ… Ubuntu 16.04 Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x8048000) #include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void get_shell() { system("/bin/sh"); } void print_box(un..