July 07, 2019

Nebula level12 write up

In this write up, some hints related to this challenge only will be mentioned.

여기서는 챌린지와과 관련된 몇 가지 힌트만이 언급됩니다.

Level12

About
There is a backdoor process listening on port 50001.

관련 사항.
백도어 프로세스가 50001번 포트에서 대기 중이다.

To do this level, log in as the level12 account with the password level12. Files for this level can be found in /home/flag12.

level12(pw: level12) 계정을 이용한다. 관련 파일은 /home/flag12에 있다.

Source code    소스코드.
local socket = require("socket")
local server = assert(socket.bind("127.0.0.1", 50001))

function hash(password)
  prog = io.popen("echo "..password.." | sha1sum", "r")
  data = prog:read("*all")
  prog:close()

  data = string.sub(data, 1, 40)

  return data
end

while 1 do
  local client = server:accept()
  client:send("Password: ")
  client:settimeout(60)
  local line, err = client:receive()
  if not err then
     print("trying " .. line) -- log from where ;\
     local h = hash(line)

     if h ~= "4754a4f4bd5787accd33de887b9250a0691dd198" then
         client:send("Better luck next time\n");
     else
         client:send("Congrats, your token is 413**CARRIER LOST**\n")
     end
  end

  client:close()
end

the insufficient filtering was treated several times at the previous level.

사용자 입력 값에 대한 필터링이 미흡한 경우는 이전 레벨에서 여러 번 다루었었다.

Look for execution of multiple instructions via semicolons.

세미콜론을 통해 다중 명령어를 실행할 수 있도록 구상한다.

Since there is no code to output the result of the command to the screen, it is necessary to save the result directly in a separate file through redirection.

명령어에 대한 결과를 화면에 출력하는 코드는 없기에, 리다이렉션을 통해 직접 그 결과를 별도 파일에 저장하도록 한다.

level12@nebula:/dev/pts$ nc 127.0.0.1 50001
Password: 1; ■■■■■■■■■■■■■■ho 1
Better luck next time
level12@nebula:/dev/pts$ ls -al /tmp
……
drwxrwxrwt 2 root   root    40 2019-06-09 07:02 .ICE-unix
-rw-r--r-- 1 flag12 flag12  59 2019-06-08 23:11 rst.txt
level12@nebula:/dev/pts$ cat /tmp/rst.txt
You have successfully executed getflag on a target account