All Projects → nexdrew → Rekcod

nexdrew / Rekcod

Licence: isc
docker inspect 🔍 → docker run 🏃

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Rekcod

One Lin3r
Gives you one-liners that aids in penetration testing operations, privilege escalation and more
Stars: ✭ 1,259 (+397.63%)
Mutual labels:  reverse
Reverseextension
A UITableView extension that enables cell insertion from the bottom of a table view.
Stars: ✭ 1,631 (+544.66%)
Mutual labels:  reverse
Revshellgen
Reverse shell generator written in Python 3.
Stars: ✭ 190 (-24.9%)
Mutual labels:  reverse
Ble Security Attack Defence
✨ Purpose only! The dangers of Bluetooth Low Energy(BLE)implementations: Unveiling zero day vulnerabilities and security flaws in modern Bluetooth LE stacks.
Stars: ✭ 88 (-65.22%)
Mutual labels:  reverse
Computer Virus
👻计算机病毒以及相应的专杀工具的研发
Stars: ✭ 109 (-56.92%)
Mutual labels:  reverse
Charon Spring Boot Starter
Reverse proxy implementation in form of a Spring Boot starter.
Stars: ✭ 155 (-38.74%)
Mutual labels:  reverse
Flatlist React
A helpful utility component to handle lists in react like a champ
Stars: ✭ 34 (-86.56%)
Mutual labels:  reverse
Ziptastic Jquery Plugin
This is a jQuery plugin that shows how Ziptastic could be used.
Stars: ✭ 244 (-3.56%)
Mutual labels:  reverse
Vm80a
i8080 precise replica in Verilog, based on reverse engineering of real die
Stars: ✭ 114 (-54.94%)
Mutual labels:  reverse
Gotools
Plugin for Ghidra to assist reversing Golang binaries
Stars: ✭ 167 (-33.99%)
Mutual labels:  reverse
Reverse Engineering
Reverse-Engineered Tools Count-106
Stars: ✭ 94 (-62.85%)
Mutual labels:  reverse
Easyiterator
🏃 Iterators made easy! Zero cost abstractions for designing and using C++ iterators.
Stars: ✭ 107 (-57.71%)
Mutual labels:  reverse
Androidreversenotes
Android逆向笔记---从入门到入土
Stars: ✭ 163 (-35.57%)
Mutual labels:  reverse
Shellpop
Pop shells like a master.
Stars: ✭ 1,279 (+405.53%)
Mutual labels:  reverse
Reverse Engineering Tutorials
Some Reverse Engineering Tutorials for Beginners
Stars: ✭ 217 (-14.23%)
Mutual labels:  reverse
Ioswechatfakelocation
A tweak that can fake location info in WeChat
Stars: ✭ 56 (-77.87%)
Mutual labels:  reverse
Reverse Shell Generator
Web-based reverse shell generator
Stars: ✭ 128 (-49.41%)
Mutual labels:  reverse
Gdbghidra
gdbghidra - a visual bridge between a GDB session and GHIDRA
Stars: ✭ 251 (-0.79%)
Mutual labels:  reverse
Kedge
kEdge - Kubernetes Edge Proxy for gRPC and HTTP Microservices
Stars: ✭ 244 (-3.56%)
Mutual labels:  reverse
Ctf
some experience in CTFs
Stars: ✭ 165 (-34.78%)
Mutual labels:  reverse

rekcod

docker inspect → docker run

Build Status Coverage Status JavaScript Style Guide Standard Version Dependabot Badge Docker Pulls Docker Image Size

Reverse engineer a docker run command from an existing container (via docker inspect).

rekcod can turn any of the following into a docker run command:

  1. container ids/names (rekcod will call docker inspect)
  2. path to file containing docker inspect output
  3. raw JSON (pass the docker inspect output directly)

Each docker run command can be used to duplicate the containers.

This is not super robust, but it should cover most arguments needed. See Fields Supported below.

When passing container ids/names, this module calls docker inspect directly, and the user running it should be able to as well.

(If you didn't notice, the dumb name for this package is just "docker" in reverse.)

Install and Usage

CLI

If you have Node installed:

$ npm i -g rekcod

If you only have Docker installed:

$ docker pull nexdrew/rekcod
$ alias rekcod="docker run --rm -i -v /var/run/docker.sock:/var/run/docker.sock nexdrew/rekcod"

Or you can simply run this, no installation required:

$ docker run --rm -i -v /var/run/docker.sock:/var/run/docker.sock nexdrew/rekcod <container>

Containers

# containers as arguments
$ rekcod container-one 6653931e39f2 happy_torvalds

docker run --name container-one ...

docker run --name stinky_jones ...

docker run --name happy_torvalds ...
# pipe in containers
$ docker ps -aq | rekcod

docker run --name container-one ...

docker run --name stinky_jones ...

docker run --name happy_torvalds ...

Files

If you are using the Node CLI - i.e. you installed rekcod via npm or yarn - you can pass file names or file contents to rekcod as is, since the Node CLI will have access to files on the host file system:

# file names as arguments (Node CLI example)
$ docker inspect container-one > one.json
$ docker inspect 6653931e39f2 happy_torvalds > two.json
$ rekcod one.json two.json

docker run --name container-one ...

docker run --name stinky_jones ...

docker run --name happy_torvalds ...
# pipe in file names (Node CLI example)
$ docker inspect container-one > one.json
$ docker inspect 6653931e39f2 happy_torvalds > two.json
$ ls *.json | rekcod

If you are using the Docker-only version of rekcod - i.e. you are using docker run to run the nexdrew/rekcod image - then note that you'll need to bind mount files from the host file system as volumes on the rekcod container in order for the containerized executable to read them:

# file names as arguments (Docker-only example)
$ docker inspect container-one > one.json
$ docker run --rm -i -v /var/run/docker.sock:/var/run/docker.sock -v `pwd`/one.json:/one.json nexdrew/rekcod /one.json

docker run --name container-one ...

Otherwise, as long as you read the file from the host system, you can pipe the contents of a file to rekcod and either installation method will work:

# pipe in file contents (works for Node CLI or Docker-only alias)
$ cat one.json | rekcod

JSON

$ docker inspect container-one 6653931e39f2 | rekcod

docker run --name container-one ...

docker run --name stinky_jones ...

Module

$ npm i --save rekcod

Containers via async reckod()

const rekcod = require('rekcod')
// single container
rekcod('container-name', (err, run) => {
  if (err) return console.error(err)
  console.log(run[0].command)
})
// multiple containers
rekcod(['another-name', '6653931e39f2', 'happy_torvalds'], (err, run) => {
  if (err) return console.error(err)
  run.forEach((r) => {
    console.log('\n', r.command)
  })
})

File via async rekcod.readFile()

const rekcod = require('rekcod')
rekcod.readFile('docker-inspect.json', (err, run) => {
  if (err) return console.error(err)
  run.forEach((r) => {
    console.log('\n', r.command)
  })
})

Parse a JSON string via sync rekcod.parse()

const fs = require('fs')
const rekcod = require('rekcod')
let array
try {
  array = rekcod.parse(fs.readFileSync('docker-inspect.json', 'utf8'))
} catch (err) {
  return console.error(err)
}
array.forEach((r) => {
  console.log('\n', r.command)
})

Fields Supported

rekcod will translate the following docker inspect fields into the listed docker run arguments.

docker inspect docker run
Name --name
HostConfig.Privileged --privileged
HostConfig.Runtime --runtime
HostConfig.Binds -v
HostConfig.VolumesFrom --volumes-from
HostConfig.PortBindings -p
HostConfig.Links --link
HostConfig.PublishAllPorts -P
HostConfig.NetworkMode --net
HostConfig.UTSMode --uts
HostConfig.RestartPolicy --restart
HostConfig.ExtraHosts --add-host
HostConfig.GroupAdd --group-add
HostConfig.PidMode --pid
HostConfig.SecurityOpt --security-opt
Config.Hostname -h
Config.Domainname --domainname
Config.ExposedPorts --expose
Config.Labels -l
Config.Env -e
Config.Attach* !== true -d
Config.AttachStdin -a stdin
Config.AttachStdout -a stdout
Config.AttachStderr -a stderr
Config.Tty -t
Config.OpenStdin -i
Config.Entrypoint --entrypoint
Config.Image || Image image name or id
Config.Cmd command and args

Prior to version 0.2.0, rekcod always assumed -d for detached mode, but it now uses that only when all stdio options are not attached. I believe this is the correct behavior, but let me know if it causes you problems. A side effect of this is that the -d shows up much later in the docker run command than it used to, but it will still be there. ❤

License

ISC © Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].