• Revive the Tmux Sessions

    On the previous day, I accidently removed /tmp/tmux-1000/ directory. At first, there seems no problem with Tmux. But when I created another SSH connection, I saw this error message:

    $ tmux attach
    no sessions
    $ tmux list-sessions
    failed to connect to server
    

    But the Tmux prosesses were still there:

    $ ps -ef | grep tmux
    59277 16305  0 May06 pts/0    00:00:00 tmux attach
    

    Then I immediately noticed that the removing /tmp/tmux-1000/ things made the problem. And thankfully Tmux provides workaround. From the tmux manpage:

    -L socket-name

    tmux stores the server socket in a directory under /tmp (or TMPDIR if set); the default socket is named default. This option allows a different socket name to be specified, allowing several independent tmux servers to be run. Unlike -S a full path is not necessary: the sockets are all created in the same directory.

    If the socket is accidentally removed, the SIGUSR1 signal may be sent to the tmux server process to recreate it.

    Now we can revive our Tmux sessions by sending a signal to recreate sockets:

    killall -s SIGUSR1 tmux
    

    More simply, since the number of SIGUSR1 is 10:

    killall -10 tmux
    

    Then we can do tmux attach successfully. Yay!

  • Using Pinpoint with Docker

    Pinpoint

    Pinpoint is an open source APM (Application Performance Management) tool for large-scale distributed systems written in Java.

    Preliminary

    In this post, our goal is to run a sample Pinpoint instance with QuickStart scripts. You can find them on GitHub. Also note that we’re going to use Docker.

    Requirements

    First things first, install Docker.

    wget -qO- https://get.docker.com/ | sh
    

    You can verify docker is installed correctly.

    sudo docker run hello-world
    

    For more details, see the installation guides of Docker.

    Look into the Dockerfile

    In fact, I already made a Dockerfile for Pinpoint. You can see on yous/pinpoint-docker. From now on, I’ll describe the Dockerfile line by line.

    Read on →

  • Comparing binary files

    Seeing differences between files

    As using Git, looking changes of files with git diff is common. Always we can check the status of files with git status, including whether there is a new file that isn’t added to index, existence of changed files.

    I downloaded the syllabus of each course I registered before the start of the semester. This is the first week of semester, professors introduce their course with the adjusted syllabus. Of course I can access the updated ones, but I can’t sure that the files which already I have are the same with which I downloaded right before. I want to keep the old one and the new one both, avoid just overwriting them.

    Comparing binary files

    I just wanted to check whether two binary files are the same or not, no matter what the difference is.

    Windows

    You can use fc, file compare, which is Microsoft DOS command.

    fc /b file1 file2
    

    The /b flag is for a binary comparison. If two files are the same, it prints a message like ‘FC: no differences encountered’, if they’re not, it shows each byte of two files per line.

    Unix

    You can use cmp which compares two files byte by byte.

    cmp file1 file2
    

    When two files are the same, it prints no message and return 0. If they are different, it prints some message and return 1.

  • ChristmasCTF 2014 Write-up

    ChristmasCTF

    Read on →

  • SECCON CTF 2014: Easy Cipher Write-up

    Crypto100 - Easy Cipher

    87 101 108 1100011 0157 6d 0145 040 116 0157 100000 0164 104 1100101 32 0123 69 67 0103 1001111 1001110 040 062 060 49 064 100000 0157 110 6c 0151 1101110 101 040 0103 1010100 70 101110 0124 1101000 101 100000 1010011 1000101 67 0103 4f 4e 100000 105 1110011 040 116 1101000 0145 040 1100010 0151 103 103 0145 1110011 0164 100000 1101000 0141 99 6b 1100101 0162 32 0143 111 1101110 1110100 101 0163 0164 040 0151 0156 040 74 0141 1110000 1100001 0156 056 4f 0157 0160 115 44 040 0171 1101111 117 100000 1110111 0141 0156 1110100 32 0164 6f 32 6b 1101110 1101111 1110111 100000 0164 1101000 0145 040 0146 6c 97 1100111 2c 100000 0144 111 110 100111 116 100000 1111001 6f 117 63 0110 1100101 0162 0145 100000 1111001 111 117 100000 97 114 0145 46 1010011 0105 0103 67 79 1001110 123 87 110011 110001 67 110000 1001101 32 55 060 100000 110111 0110 110011 32 53 51 0103 0103 060 0116 040 5a 0117 73 0101 7d 1001000 0141 1110110 1100101 100000 102 0165 0156 33

    It looks like a set of numbers split with space. But there are multiple integer bases.

    nums = %w(87 101 108 1100011 0157 6d 0145 040 116 0157 100000 0164 104 1100101
              32 0123 69 67 0103 1001111 1001110 040 062 060 49 064 100000 0157 110
              6c 0151 1101110 101 040 0103 1010100 70 101110 0124 1101000 101 100000
              1010011 1000101 67 0103 4f 4e 100000 105 1110011 040 116 1101000 0145
              040 1100010 0151 103 103 0145 1110011 0164 100000 1101000 0141 99 6b
              1100101 0162 32 0143 111 1101110 1110100 101 0163 0164 040 0151 0156
              040 74 0141 1110000 1100001 0156 056 4f 0157 0160 115 44 040 0171
              1101111 117 100000 1110111 0141 0156 1110100 32 0164 6f 32 6b 1101110
              1101111 1110111 100000 0164 1101000 0145 040 0146 6c 97 1100111 2c
              100000 0144 111 110 100111 116 100000 1111001 6f 117 63 0110 1100101
              0162 0145 100000 1111001 111 117 100000 97 114 0145 46 1010011 0105
              0103 67 79 1001110 123 87 110011 110001 67 110000 1001101 32 55 060
              100000 110111 0110 110011 32 53 51 0103 0103 060 0116 040 5a 0117 73
              0101 7d 1001000 0141 1110110 1100101 100000 102 0165 0156 33)
    str = nums.map do |s|
      ord = if s.size >= 5
              s.to_i(2)
            elsif s =~ /[a-f]/
              s.to_i(16)
            elsif s.start_with?('0')
              s.to_i(8)
            else
              s.to_i
            end
      ord.chr
    end
    puts str.join
    

    Just run with Ruby:

    Welcome to the SECCON 2014 online CTF.The SECCON is the biggest hacker contest in Japan.Oops, you want to know the flag, don't you?Here you are.SECCON{W31C0M 70 7H3 53CC0N ZOIA}Have fun!
    

    Finally the flag is:

    SECCON{W31C0M 70 7H3 53CC0N ZOIA}