Giter Club home page Giter Club logo

ncp2-package-reverse-engineering's Introduction

NCP2 package reverse engineering

Let's pack/unpack NCP2 package!

무엇인가요?

몇몇 아기가 읽는 책을 보면 Dotcode(또는 Ncode) 라는 미세한 코드가 인쇄되어 있는 것을 볼 수 있을것이다.

이 코드는 펜 형태 또는 자동차 형태의 스캐너를 통해 읽을 수 있고, 이 코드가 매칭되는 음성을 들려주는 방식으로 교육용으로 널리 사용중이다.

(아마도 스캐너는 일반 키보드 마우스랑 동일한 방식으로 스캔하여 edge detection 해서 코드를 읽는 것 같다.)

이 스캐너에 들어가는 파일들은 일정한 형식을 가진 ncp 또는 ncp2 라는 확장자의 파일로 제한없이 배포되고 있는데, 이 파일 안에 있는 음성 파일에 어떤 내용이 들어있나 보고 직접 휴대폰으로 틀 수 있지 않을까 해서 이 unpacker를 작성했다.

왜 하나?

리버스엔지니어링은 아주 재미없는 작업이지만, ncp2 패키지에 있는 mp3가 필요하여 작업하게 되었다. 패키지 파일을 열고 계산기 두들기다 보니 어느센가 간단한 명세서까지 작성할 수 있었다. 이왕 시작한 김에 unpacker까지 설계해보자!

어떤 걸로 작성할까?

C언어로 개발하면 더 재밌고 머리아프겠지만, 파이썬도 손에 더 익힐 겸 파이썬 3.9로 개발할 계획이다.

개발 완료 후기

막상 개발해보니 너무 잘 동작하여 나중에 생각나면 조금 더 다듬어 볼 예정.

내가 원하는 음원은 잘 추출할 수 있었다. 찾아보니 ncp 라는 패키지 파일도 거의 동일한지 별 조치 없이 추출이 가능했다. 나중에 ncp 패키지를 사용하는 여러 다른 디바이스들끼리 파일 호환이 되도록 packing하는 프로그램을 작성해볼까 한다.

그리고 코드는... 재사용을 고려할 필요가 없어서 친절한 형태는 아니고 일단 클래스로 묶어놓기만 했다.

어려운 코드가 아니니 누군가 참고하려면 금방 이해할 수 있을 것이다.

지금까지의 작업

v2022.3.17.0 음원 추출 완료

샘플로 ncp2파일 하나를 지정하여 분석한 (러프한)명세서. FTBL 명령의 경우 내부 file list 구조에 대한 명세가 필요하다. (이미 분석은 완료했지만 문서 구조가 잡히면 정리)

각 바이트 구간별로 설명을 적어놨으나 뇌피셜이다.

# 1~4 (4)
# NPQF (If 'RIFF' then 'RIFFNPQF' and add 4 more bytes each bytes of below list.)

# 5~12 (8) Unknown
# 01002004 03000300

# 13~24 (12) Unknown string
# ARESNPQ_Test

# 25~32 Zero padding
# 00000000 00000000

# 33~40 command start
# 50536110 64000000 : PSa(0x01)D

# 41~44 command
# INFO

# 45~48 size of command (byte)
# 2C000000 = 44
########################## 49~92 data block of command
# 49~52 Unknown
# 01000000

# 53~56 count of list
# 26000000

# 57~92 unknown
# 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
########################## end

# 89~92 zero padding
# 00000000

# 93~96 command end
# 00005045 : PE

# 97~104 command start
# 50536110 64000000 : PSa(0x01)D

# 105~108 command
# FTBL

# 109~112 size of command (byte)
# 80090000 = 2432
########################## 113~2544 data block of command 
[64 bytes loop]
~108  file name
~4  file size
~4 00000000 : zero padding
~4 file length
~4 file_length repeat
~4 zero padding
[continue...]
########################## end

# 2545~2548 command end
# 00005045 : PE

# 2549~2556 command start
# 50536110 64000000 : PSa(0x01)D

# 2557~2560 command
# DATA

# 2561~2564 size of command (byte)
# 9C092E00 = 3017116
########################## 2564~3019680 data block of command
########################## end
# 3019681~3019684 command end
# 00005045 : PE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.