Coder Social home page Coder Social logo

panther's Introduction

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

# 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_64-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:

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.

panther's People

Contributors

tontinton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

acodervic

panther's Issues

need more example for pan

Thanks for you build this project , It is amazing ! We need more example for pan ,Like : Call syscall in linux(execute a commandline ) ?
Thanks !

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.