Git Product home page Git Product logo

karkinos's Introduction

Karkinos

A large library database to assist in binary exploitation on Linux. This tool can help identify unknown libraries by providing the location of known symbols, it can help locate the name of packages that contain a given library and it can find the debugging version of a library you are working with.

Once the library is identified you can dump useful information such as symbols (both exported symbols and special useful calculated locations that are useful for exploitation), gadgets for ROP chains or one shot (AKA magic gadgets or one gadgets) and their constraints.

The usage is inspired by the excellent libc-database.

It supports many architectures including:

  • x86 (i386 / amd64)
  • arm (arm / arm64)
  • mips (mips / mips64)
  • ppc (ppc / ppc64)
  • sparc (sparc / sparc64)
  • sh4
  • hppa
  • m68k
  • riscv

There are many libraries indexed over many distributions spanning many years. The libraries indexed are:

  • glibc
  • libstdc++
  • glibc-ld
  • libgcc
  • musl

Install

The preferred method is to just download and extract the latest release. Karkinos will manage updates by itself from that point on. Alternatively, you can clone this repository.

Once you have Karkinos through either method, you can then access the tool by running:

$ ./kark.py --help

On the first run it will attempt to extract the databases from the compressed files, you will need to have the xz and cat binaries installed and availible through the PATH env var.

Usage

usage: kark.py [-h] [--libdb {glibc,libstdc++}] [--distro DISTRO]
               [--arch {x86,amd64,i386,arm,arm64,mips,mips64,ppc,ppc64,sparc,sparc64,m68k,hppa,sh4}]
               [--endian {little,big}]
               {find,dump,info,update} ...

description:
  karkinos is a library database to assist with exploitation by helping to
  identify libraries from known offsets or to dump useful offsets from those
  identified libraries. Each database indexes symbols, gadgets and where
  possible one shot gadgets (AKA magic gadgets or one gadgets).

architectures indexed:
  - x86   (amd64, i386)
  - arm   (arm,   arm64)
  - mips  (mips,  mips64)
  - ppc   (ppc,   ppc64)
  - sparc (sparc, sparc64)
  - m68k
  - hppa
  - sh4
  - riscv

libraries indexed:
  - glibc
  - libstdc++
  - glibc-ld
  - libgcc
  - musl

commands:
  - find        find a library by symbol offsets, file, build id or file hash
  - dump        dump symbols/gadgets for a given library
  - info        print some information about a specific library
  - update      check for updates to the database
  - version     display version information and exit

positional arguments:
  {find,dump,info,update}
                        command to execute
  args                  arguments for specific command, see examples

optional arguments:
  -h, --help            show this help message and exit
  --libdb {glibc,libstdc++}
                        the library database to use
  --distro DISTRO       the linux distribution to filter in symbol search
  --arch {x86,amd64,i386,arm,arm64,mips,mips64,ppc,ppc64,sparc,sparc64,m68k,hppa,sh4}
                        architecture to filter in symbol search
  --endian {little,big}
                        endianess to filter in symbol search

examples:
  ./kark.py find fgets b20 puts 9c0 fwrite 8a0
  ./kark.py find 50390b2ae8aaa73c47745040f54e602f
  ./kark.py find b417c0ba7cc5cf06d1d1bed6652cedb9253c60d0
  ./kark.py find /lib/x86_64-linux-gnu/libc.so.6
  ./kark.py --arch arm --endian big find system 440
  ./kark.py --distro ubuntu fgets b20 puts 9c0
  ./kark.py dump centos_glibc-2.12-1.107.el6_4.2.x86_64
  ./kark.py dump opensuse_glibc-2.19-16.9.1.i686 fgets system str_bin_sh
  ./kark.py info ubuntu_libc6-udeb_2.27-3ubuntu1_amd64
  ./kark.py update

Screenshots

Karkinos

TODO

  • Make the database faster (queries are far from optimised)
  • Make the database smaller (schema is not optimal)
  • Clean the code up (was hobbled together very quickly)
  • More gadgets, more one shot gadgets
  • Make usable as a library (remove output, reorganise code)

Contact

@0xb0bb

karkinos's People

Contributors

0xb0bb 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

karkinos's Issues

glibc.db.xz having a mismatched hash

Running ./kark.py --help gives this-

❯ ./kark.py --help
downloading: https://raw.githubusercontent.com/0xb0bb/karkinos/master/db/libs.json (186b)
extracting:  glibc.db.xz
error: glibc.db.xz failed; mismatched hash
usage: kark.py [-h] [--libdb {glibc,libstdc++}] [--distro DISTRO]
               [--arch {x86,amd64,i386,arm,arm64,mips,mips64,ppc,ppc64,sparc,sparc64,m68k,hppa,sh4}]
               [--endian {little,big}]
               {find,dump,info,update,version} ...

All other commands give the same error

Script not working

I am on macOS Big Sur 11.6:

❯ ./kark.py --help
downloading: https://raw.githubusercontent.com/0xb0bb/karkinos/master/db/libs.json (162b)
extracting:  glibc.db.xz
xz: /Users/*****/****************/****/************/*/karkinos/db/glibc.db.xz: File format not recognized
error: glibc.db.xz failed; mismatched hash
❯ xz --version
xz (XZ Utils) 5.2.5
liblzma 5.2.5

What might be causing this?

update failed

when i tried to update the database, something went wrong..

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 852, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 337, in connect
cert = self.sock.getpeercert()
File "/usr/lib/python3.6/ssl.py", line 900, in getpeercert
self._check_connected()
File "/usr/lib/python3.6/ssl.py", line 864, in _check_connected
self.getpeername()
OSError: [Errno 107] Transport endpoint is not connected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/rigelyoung/.local/lib/python3.6/site-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 852, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 337, in connect
cert = self.sock.getpeercert()
File "/usr/lib/python3.6/ssl.py", line 900, in getpeercert
self._check_connected()
File "/usr/lib/python3.6/ssl.py", line 864, in _check_connected
self.getpeername()
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(107, 'Transport endpoint is not connected'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./kark.py", line 879, in
main()
File "./kark.py", line 874, in main
if not update(True):
File "./kark.py", line 479, in update
if not download(url, cwd+'/db/libs.json'):
File "./kark.py", line 440, in download
res = requests.head(url, headers=headers)
File "/usr/lib/python3/dist-packages/requests/api.py", line 98, in head
return request('head', url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 520, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 630, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError(107, 'Transport endpoint is not connected'))

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.