LoginSignup
2
5

More than 3 years have passed since last update.

【ホワイトハッカーへの道】今日のCTF①

Last updated at Posted at 2021-04-29

概要

素人がホワイトハッカーを目指した記録です.
1日1問を目指して頑張っていきます.

とりあえず,下記書籍を順番に解いていきます.

セキュリティコンテストチャレンジブック CTFで学ぼう!情報を守るための戦い方
https://book.mynavi.jp/ec/products/detail/id=42421

問題

image.png

解説動画

コード

書籍通りにコーディングしてもエラーで止まってしまいます.

Traceback (most recent call last):
  File "ex02_scapy001.py", line 33, in <module>
    main()
  File "ex02_scapy001.py", line 17, in main
    flag_utf8 += p['Raw'].load
TypeError: can only concatenate str (not "bytes") to str

そこで,下記の様にコードを変更してもらうと動きます.

ex02_scapy001.py

def main():
    packets = rdpcap("scapy_ex2.pcap")
    flag_utf8 = ""
    print("packets[0]")
    print(packets[0])
    for p in packets:
        if(p['IP'].src == '10.29.31.155'):
            #################################################
            # ↓書籍にはこう書いてある
            # flag_utf8 += p['Raw'].load

            #################################################
            # ↓ここを変更した
            flag_utf8 += str(binascii.hexlify(p['Raw'].load), 'utf-8')

    #################################################
    # ↓ここを変更した
    flag_hex = binascii.a2b_hex(flag_utf8)

    f = open('flag.jpg', 'wb')
    f.write(flag_hex)
    f.close()


if __name__ == '__main__':
    main()

おわりに

この調子でジャンジャン解いていきます.

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5