
# Python 명령줄 Ghidra 디컴파일러
이 Python 명령줄 도구는 바이너리의 모든 함수를 디컴파일하여 개별 C 파일로 디렉터리에 작성합니다:```mermaid
flowchart LR
a(filename ) --> b[ghidrecomp] a2[(Symbol Server)] --> b
b --> e(Ghidra Project Files) b --> output
subgraph output
subgraph decompilations direction LR i(func1.c) h(func2.c) f(funcB.c) end
subgraph callgraphs direction LR j(callgraph1.md) k(callgraph2.md) l(callgraphN.md) end
subgraph bsim-xml direction LR n(sig-md5-bin1.xml) m(sig-md5-bin2.xml) o(sig-md5-binN.xml) end
end
또는 단일 파일 `C` 및 헤더 파일을 `--cppexport`와 함께 사용하십시오:```mermaid
flowchart LR
a(filename ) --> b[ghidrecomp]
a2[(Symbol Server)] --> b
b --> e(Ghidra Project Files)
b --> singlefile
subgraph singlefile
direction LR
s1(all_funcs.c)
s2(all_funcs.h)
end
이 도구의 주요 목적은 디컴파일 결과를 연구 및 분석에 활용하는 것입니다. 이 도구는 디컴파일을 위해 Ghidra에 의존하며, pyghidra를 통해 jpype로 Ghidra와 통신합니다.
이 모든 기능은 궁극적으로 Ghidra가 제공합니다
-o OUTPUT_PATH)--cppexport)-s SYMBOLS_PATH)
--sym-file-path)--filter)--gdt)--sast)
usage: ghidrecomp [-h] [--cppexport] [--filter FILTERS] [--project-path PROJECT_PATH] [--gdt [GDT]] [-o OUTPUT_PATH] [-v] [--skip-cache] [--sym-file-path SYM_FILE_PATH | -s SYMBOLS_PATH | --skip-symbols] [-t THREAD_COUNT] [--va] [--fa] [--max-ram-percent MAX_RAM_PERCENT] [--print-flags] [--callgraphs] [--callgraph-filter CALLGRAPH_FILTER] [--mdd MAX_DISPLAY_DEPTH] [--max-time-cg-gen MAX_TIME_CG_GEN] [--cg-direction {calling,called,both}] [--bsim] [--bsim-sig-path BSIM_SIG_PATH] [--bsim-template BSIM_TEMPLATE] [--bsim-cat BSIM_CAT] [--sast] [--semgrep-rules SEMGREP_RULES] [--codeql-rules CODEQL_RULES] bin
ghidrecomp - A Command Line Ghidra Decompiler
positional arguments: bin Path to binary used for analysis
options: -h, --help show this help message and exit --cppexport Use Ghidras CppExporter to decompile to single file (default: False) --filter FILTERS Regex match for function name (default: None) --project-path PROJECT_PATH Path to base ghidra projects (default: ghidra_projects) --gdt [GDT] Additional GDT to apply (default: None) -o OUTPUT_PATH, --output-path OUTPUT_PATH Location for all decompilations (default: ghidrecomps) -v, --version show program's version number and exit --skip-cache Skip cached and genearate new decomp and callgraphs. (default: False) --sym-file-path SYM_FILE_PATH Specify single pdb symbol file for bin (default: None) -s SYMBOLS_PATH, --symbols-path SYMBOLS_PATH Path for local symbols directory (default: symbols) --skip-symbols Do not apply symbols (default: False) -t THREAD_COUNT, --thread-count THREAD_COUNT Threads to use for processing. Defaults to cpu count (default: 12) --va Enable verbose analysis (default: False) --fa Force new analysis (even if already analyzed) (default: False)
JVM Options: --max-ram-percent MAX_RAM_PERCENT Set JVM Max Ram % of host RAM (default: 50.0) --print-flags Print JVM flags at start (default: False)
Callgraph Options: --callgraphs Generate callgraph markdown (default: False) --callgraph-filter CALLGRAPH_FILTER Only generate callgraphs for functions matching filter (default: .) --mdd MAX_DISPLAY_DEPTH, --max-display-depth MAX_DISPLAY_DEPTH Max Depth for graph generation (default: None) --max-time-cg-gen MAX_TIME_CG_GEN Max time in seconds to wait for callgraph gen. (default: 5) --cg-direction {calling,called,both} Direction for callgraph. (default: calling)
BSim Options: --bsim Generate BSim function feature vector signatures (default: False) --bsim-sig-path BSIM_SIG_PATH Path to store BSim xml sigs (default: bsim-xmls) --bsim-template BSIM_TEMPLATE BSim database template (default: medium_nosize) --bsim-cat BSIM_CAT BSim category. (type:value) --bsim-cat color:red (default: None)
SAST Options: --sast Run SAST scanning on decompiled code with semgrep and CodeQL (default: False) --semgrep-rules SEMGREP_RULES Path to local semgrep rule file or directory (can be specified multiple times, default: p/c) (default: None) --codeql-rules CODEQL_RULES Comma-separated paths to local CodeQL query directories (placeholder) (default: None)
## 출력 파일 트리