Skip to content

Commit

Permalink
Merge pull request #12 from abusix/dependency-update-2024-03-27
Browse files Browse the repository at this point in the history
Dependency update 2024 03 27
  • Loading branch information
JenksJM authored Mar 27, 2024
2 parents 1fc2bde + 6e9f11c commit 4b4f785
Show file tree
Hide file tree
Showing 126 changed files with 2,818 additions and 2,504 deletions.
17 changes: 13 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

---
version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "pip"
directory: "/docs"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/docker"
schedule:
interval: "weekly"
19 changes: 10 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,27 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
if: ${{ (github.event_name != 'pull_request') && (github.repository == 'cowrie/cowrie') }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

# $(DOCKER) buildx build --platform ${PLATFORM} -t ${IMAGE}:${TAG} --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile --push .
- name: Build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
push: false
load: true
Expand All @@ -72,11 +71,13 @@ jobs:
docker run -d --rm cowrie:test
- name: Build and push
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v4
if: ${{ (github.event_name != 'pull_request') && (github.repository == 'cowrie/cowrie') }}
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
load: false
sbom: true
provenance: true
tags: cowrie/cowrie:latest
6 changes: 3 additions & 3 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.8", "pypy-3.9"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.9", "pypy-3.10"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ formats:
sphinx:
configuration: docs/conf.py

build:
os: ubuntu-22.04
tools:
python: "3.11"

# Optionally Python version and requirements required to build your docs
python:
version: 3.8
install:
- requirements: docs/requirements.txt
- method: pip
Expand Down
10 changes: 1 addition & 9 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,12 @@ Running using Supervisord (OPTIONAL)
On Debian, put the below in /etc/supervisor/conf.d/cowrie.conf::

[program:cowrie]
command=/home/cowrie/cowrie/bin/cowrie start
command=/home/cowrie/cowrie/bin/cowrie start -n
directory=/home/cowrie/cowrie/
user=cowrie
autorestart=true
redirect_stderr=true

Update the bin/cowrie script, change::

DAEMONIZE=""

to::

DAEMONIZE="-n"

Configure Additional Output Plugins (OPTIONAL)
**********************************************

Expand Down
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,23 @@ TAG=$(shell git rev-parse --short=8 HEAD)
docker-build: docker/Dockerfile ## Build Docker image
-$(DOCKER) buildx create --name cowrie-builder
$(DOCKER) buildx use cowrie-builder
$(DOCKER) buildx build --platform ${PLATFORM} -t ${IMAGE}:${TAG} -t ${IMAGE}:latest --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile --push .
$(DOCKER) buildx build --sbom=true --provenance=true --platform ${PLATFORM} -t ${IMAGE}:${TAG} -t ${IMAGE}:latest --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile .

.PHONY: docker-run
docker-run: docker-start ## Run Docker container
.PHONY: docker-load
docker-load: docker-build ## Load Docker image
-$(DOCKER) buildx create --name cowrie-builder
$(DOCKER) buildx use cowrie-builder
$(DOCKER) buildx build --sbom=true --provenance=true --load -t ${IMAGE}:${TAG} -t ${IMAGE}:latest --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile .

.PHONY: docker-push
docker-push: docker-build ## Push Docker image to Docker Hub
.PHONY: docker-build ## Push Docker image
docker-push: ## Push Docker image to Docker Hub
-$(DOCKER) buildx create --name cowrie-builder
@echo "Pushing image to GitHub Docker Registry...\n"
$(DOCKER) push $(IMAGE):$(TAG)
$(DOCKER) tag $(IMAGE):$(TAG) $(IMAGE):latest
$(DOCKER) push $(IMAGE):latest
$(DOCKER) buildx use cowrie-builder
$(DOCKER) buildx build --sbom=true --provenance=true --platform ${PLATFORM} -t ${IMAGE}:${TAG} -t ${IMAGE}:latest --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile --push .

.PHONY: docker-run
docker-run: docker-start ## Run Docker container

.PHONY: docker-start
docker-start: docker-create-volumes ## Start Docker container
Expand Down
129 changes: 5 additions & 124 deletions bin/asciinema
Original file line number Diff line number Diff line change
@@ -1,131 +1,12 @@
#!/usr/bin/env python

import getopt
import json
import os
import struct
import sys
from os import path

OP_OPEN, OP_CLOSE, OP_WRITE, OP_EXEC = 1, 2, 3, 4
TYPE_INPUT, TYPE_OUTPUT, TYPE_INTERACT = 1, 2, 3

COLOR_INTERACT = "\033[36m"
COLOR_INPUT = "\033[33m"
COLOR_RESET = "\033[0m"


def playlog(fd, settings):
thelog = {}
thelog["version"] = 1
thelog["width"] = 80
thelog["height"] = 24
thelog["duration"] = 0.0
thelog["command"] = "/bin/bash"
thelog["title"] = "Cowrie Recording"
theenv = {}
theenv["TERM"] = "xterm256-color"
theenv["SHELL"] = "/bin/bash"
thelog["env"] = theenv
stdout = []
thelog["stdout"] = stdout

ssize = struct.calcsize("<iLiiLL")

currtty, prevtime, prefdir = 0, 0, 0
sleeptime = 0.0

color = None

while 1:
try:
(op, tty, length, dir, sec, usec) = struct.unpack("<iLiiLL", fd.read(ssize))
data = fd.read(length)
except struct.error:
break

if currtty == 0:
currtty = tty

if str(tty) == str(currtty) and op == OP_WRITE:
# the first stream seen is considered 'output'
if prefdir == 0:
prefdir = dir
if dir == TYPE_INTERACT:
color = COLOR_INTERACT
elif dir == TYPE_INPUT:
color = COLOR_INPUT
if dir == prefdir:
curtime = float(sec) + float(usec) / 1000000
if prevtime != 0:
sleeptime = curtime - prevtime
prevtime = curtime
if settings["colorify"] and color:
sys.stdout.write(color)

# rtrox: While playback works properly
# with the asciinema client, upload
# causes mangling of the data due to
# newlines being misinterpreted without
# carriage returns.
data = data.replace(b"\n", b"\r\n").decode("UTF-8")

thedata = [sleeptime, data]
thelog["duration"] += sleeptime
stdout.append(thedata)

if settings["colorify"] and color:
sys.stdout.write(COLOR_RESET)
color = None

elif str(tty) == str(currtty) and op == OP_CLOSE:
break

if settings["output"] == "":
json.dump(thelog, sys.stdout, indent=4)
else:
with open(settings["output"], "w") as outfp:
json.dump(thelog, outfp, indent=4)


def help(verbose=False):
print(
"usage: %s [-c] [-o output] <tty-log-file> <tty-log-file>..."
% os.path.basename(sys.argv[0])
)

if verbose:
print(
" -c colorify the output based on what streams are being received"
)
print(" -h display this help")
print(" -o write to the specified output file")
cowriepath = path.dirname(sys.argv[0]) + "/../src"
sys.path.append(cowriepath)

from cowrie.scripts import asciinema # noqa: E402

if __name__ == "__main__":
settings = {"colorify": 0, "output": ""}

try:
optlist, args = getopt.getopt(sys.argv[1:], "hco:")
except getopt.GetoptError as error:
sys.stderr.write(f"{sys.argv[0]}: {error}\n")
help()
sys.exit(1)

for o, a in optlist:
if o == "-h":
help()
if o == "-c":
settings["colorify"] = True
if o == "-o":
settings["output"] = a

if len(args) < 1:
help()
sys.exit(2)

for logfile in args:
try:
logfd = open(logfile, "rb")
playlog(logfd, settings)
except OSError as e:
sys.stderr.write(f"{sys.argv[0]}: {e}\n")
asciinema.run()
12 changes: 12 additions & 0 deletions bin/createdynamicprocess
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python

import sys
from os import path

cowriepath = path.dirname(sys.argv[0]) + "/../src"
sys.path.append(cowriepath)

from cowrie.scripts import createdynamicprocess # noqa: E402

if __name__ == "__main__":
createdynamicprocess.run()
56 changes: 0 additions & 56 deletions bin/createdynamicprocess.py

This file was deleted.

Loading

0 comments on commit 4b4f785

Please sign in to comment.