panther

所属分类:编译器/解释器
开发工具:Nim
文件大小:90KB
下载次数:0
上传日期:2021-04-17 17:55:09
上 传 者sh-1993
说明:  外壳代码编译器
(A shellcode compiler)

文件列表:
libLLVM-11.dll (134, 2021-04-18)
libLLVM-11.so (134, 2021-04-18)
logo.svg (14321, 2021-04-18)
main.pan (492, 2021-04-18)
panther.nimble (319, 2021-04-18)
src (0, 2021-04-18)
src\backend (0, 2021-04-18)
src\backend\backend.nim (423, 2021-04-18)
src\backend\llvm_backend.nim (22373, 2021-04-18)
src\common (0, 2021-04-18)
src\common\customerrors.nim (899, 2021-04-18)
src\common\types.nim (2930, 2021-04-18)
src\frontend (0, 2021-04-18)
src\frontend\analyzer.nim (20122, 2021-04-18)
src\frontend\arithmetic.nim (2674, 2021-04-18)
src\frontend\ast.nim (6168, 2021-04-18)
src\frontend\frontend.nim (2174, 2021-04-18)
src\frontend\lexer.nim (8325, 2021-04-18)
src\frontend\parser.nim (20633, 2021-04-18)
src\frontend\tokens.nim (1074, 2021-04-18)
src\ir (0, 2021-04-18)
src\ir\bytecodebuilder.nim (10023, 2021-04-18)
src\ir\opcodes.nim (2817, 2021-04-18)
src\ir\variables.nim (914, 2021-04-18)
src\llvm (0, 2021-04-18)
src\llvm\BitReader.nim (4074, 2021-04-18)
src\llvm\BitWriter.nim (2511, 2021-04-18)
src\llvm\Core.nim (156229, 2021-04-18)
src\llvm\DebugInfo.nim (59876, 2021-04-18)
src\llvm\Error.nim (2565, 2021-04-18)
src\llvm\IRReader.nim (1567, 2021-04-18)
src\llvm\Linker.nim (1624, 2021-04-18)
src\llvm\Support.nim (2578, 2021-04-18)
... ...

## Introduction The panther language is a language made for exploitations. It's main focus is **minimal code size** through code size optimizations and compiling directly to a **shellcode** (position independent code). ## Flow 1. **Lexer**: Parse text file into tokens 2. **Parser**: Parse tokens into AST 3. **Analyzer**: Validate that the AST is correct panther syntax 4. **Bytecode**: Parse AST into bytecode 5. **LLVM**: Parse bytecode into LLVM IR 6. **Optimizations + Backend**: llvm ## What can it do currently? Currently, the panther binary can compile a single file using the llvm backend, with minimal type inference and type checking. When running the panther compiler on ``main.pan`` ```bash # Compile the panther compiler nimble build -d:release # Panther compiles an object file, in this example I compile to a windows COFF ./panther c -i main.pan -o output.o -t x86_***-pe-windows-coff # Link the object file to an executable, needed to get rid of relocations ld -nostartfiles output.o -o output.exe # Extract the .shell section created by the compiler objcopy -j .shell -O binary output.exe shellcode.bin ``` When ``main.pan`` looks like: ```rust proc _start(); // First function in the shellcode proc fib(a: s32) -> s32 { if a < 2 { return a; } else { return fib(a - 1) + fib(a - 2); } } // The printf symbol predetermined by an address. // In the future I would like to add a feature of searching for a symbol at runtime. let printf = 0x402ba0 as proc(fmt: string, num1: s32, num2: s32); proc _start() { let i = 1; while i <= 15 { printf("%d: %d\n", i, fib(i)); i = i + 1; } } ``` Results in a shellcode (``shellcode.bin``) that prints the the first 15 fibonnaci numbers.

近期下载者

相关文件


收藏者