diff --git a/.circleci/config.yml b/.circleci/config.yml index 884345d0..d872a036 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,3 +1,4 @@ +--- version: 2 workflows: version: 2 diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 70fcc396..8053979b 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,2 @@ +--- patreon: micheloosterhof diff --git a/.github/workflows/pur.yml b/.github/workflows/pur.yml index c633a646..1cd58eb9 100644 --- a/.github/workflows/pur.yml +++ b/.github/workflows/pur.yml @@ -34,6 +34,14 @@ jobs: pur -r requirements.txt pur -r requirements-dev.txt pur --skip csirtgsdk -r requirements-output.txt + - name: pip install + run: | + pip install --upgrade -r requirements.txt + pip install --upgrade -r requirements-dev.txt + pip install --upgrade -r requirements-output.txt + - name: pip check + run: | + pip check - name: git diff run: | git diff diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index d387937f..cea6cdc0 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -1,6 +1,7 @@ +--- name: Tox -on: +on: # yamllint disable-line rule:truthy - push - pull_request @@ -11,16 +12,16 @@ jobs: matrix: python-version: [3.6, 3.7, 3.8, 3.9, pypy-3.7] steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install -r requirements.txt - python -m pip install -r requirements-dev.txt - pip install tox-gh-actions - - name: Test with tox - run: tox + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install -r requirements.txt + python -m pip install -r requirements-dev.txt + pip install tox-gh-actions + - name: Test with tox + run: tox diff --git a/.readthedocs.yml b/.readthedocs.yml index 06d26b22..eeac7964 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -13,12 +13,12 @@ formats: # Build documentation in the docs/ directory with Sphinx sphinx: - configuration: docs/conf.py + configuration: docs/conf.py # Optionally Python version and requirements required to build your docs python: - version: 3.8 - install: - - requirements: docs/requirements.txt - - method: pip - path: . + version: 3.8 + install: + - requirements: docs/requirements.txt + - method: pip + path: . diff --git a/.travis.yml b/.travis.yml index 85b4b427..41eb868b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +--- sudo: required group: stable dist: bionic @@ -27,7 +28,7 @@ before_script: - python setup.py build sdist bdist - make -C docs html script: - - PYTHONPATH=${TRAVIS_BUILD_DIR}/src trial cowrie + - PYTHONPATH=${TRAVIS_BUILD_DIR}/src trial cowrie notifications: email: false slack: diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 00000000..237e062d --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,10 @@ +--- +extends: + default + +rules: + line-length: disable + +ignore: | + .direnv + .tox diff --git a/docs/FAQ.rst b/docs/FAQ.rst index c4e8b6f2..92b3b3f7 100644 --- a/docs/FAQ.rst +++ b/docs/FAQ.rst @@ -15,3 +15,43 @@ time and effort. Cowrie tries to provide most common commands used by attackers of the honeypot. If you see attackers use a command that you'd like to see implemented, please let us know, or send a pull request. +How do I add or modify the default user? +**************************************** + +The default Cowrie users is called `phil` these days. Having the same +user always available is an easy way to identify Cowrie so it's recommend to change +this setup. You can modify it by doing the following:: + + $ vi honeyfs/etc/passwd + +And edit the userid. Then:: + + $ bin/fsctl share/cowrie/fs.pickle + fs.pickle:/$ mv /home/phil /home/joe + +And then restart Cowrie:: + + $ bin/cowrie restart + + +How do I add files to the file system? +************************************** + +The file system meta data is stored in the pickle file. The file +contents is stored in the `honeyfs` directory. To add a file, the +minimum action is to modify the pickle file. Doing this makes the +file show up in `ls` and other commands. But it won't have any +contents available. To add file contents, you'll need a file to +honeyfs. + +First add a file system entry, the `1024` here is the file size. The +`chown` commands only takes numerical uid's, they should match +entries in `honeyfs/etc/passwd`:: + + $ bin/fsctl share/cowrie/fs.pickle + fs.pickle:/$ touch /home/phil/myfile 1024 + fs.pickle:/$ chown 1000:1000 /home/phil/myfile + +Then create or copy a file in the `honeyfs`:: + + $ cp myfile /honeyfs/home/phil diff --git a/requirements-dev.txt b/requirements-dev.txt index c977aedf..175b8467 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,14 +4,17 @@ importlib_metadata==4.0.1; python_version<'3.8' mypy-extensions==0.4.3; platform_python_implementation=='CPython' mypy-zope==0.3.0; platform_python_implementation=='CPython' mypy==0.812; platform_python_implementation=='CPython' +pathspec==0.8.1 pipdeptree==2.0.0 pre-commit==2.12.1 pur==5.4.0 pyre-check==0.9.0 pytype==2021.4.15; platform_python_implementation=='CPython' pyupgrade==2.13.0 +pyyaml==5.4.1 setuptools==56.0.0 sphinx-copybutton==0.3.1 sphinx_rtd_theme==0.5.2 tox==3.23.0 twistedchecker==0.7.4 +yamllint==1.26.1 diff --git a/share/cowrie/fs.pickle b/share/cowrie/fs.pickle index 12e6c7cb..be88dbdb 100644 Binary files a/share/cowrie/fs.pickle and b/share/cowrie/fs.pickle differ diff --git a/src/cowrie/commands/apt.py b/src/cowrie/commands/apt.py index c25bc42b..244b61ec 100644 --- a/src/cowrie/commands/apt.py +++ b/src/cowrie/commands/apt.py @@ -142,8 +142,10 @@ pages for more information and options. % len(packages) ) self.write("Need to get %s.2kB of archives.\n" % (totalsize)) - self.write("After this operation, {:.1f}kB of additional disk space will be used.\n".format( - totalsize * 2.2) + self.write( + "After this operation, {:.1f}kB of additional disk space will be used.\n".format( + totalsize * 2.2 + ) ) i = 1 for p in packages: diff --git a/tox.ini b/tox.ini index 25e47334..630fe521 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ skipsdist = True envlist = lint,docs,py36,py37,py38,py39,py310,mypy,pytype,pyre deps = -r{toxinidir}/requirements.txt -skip_missing_interpreters=True +skip_missing_interpreters = True [gh-actions] python = @@ -10,7 +10,7 @@ python = 3.7: py37 3.8: py38 3.9: py39 - 3.9: lint, docs, mypy, pytype, pyre + 3.9: lint, docs, typing pypy-3.7: pypy3 [travis] @@ -19,7 +19,7 @@ python = 3.7: py37 3.8: py38 3.9: py39 - 3.9: lint, docs, mypy, pytype, pyre + 3.9: lint, docs, typing 3.10: py310 pypy3: pypy3 @@ -33,15 +33,20 @@ deps = commands = trial cowrie + [testenv:lint] deps = -r{toxinidir}/requirements.txt -r{toxinidir}/requirements-dev.txt +allowlist_externals = + yamllint commands = flake8 --ignore E203,E501,W503 --count --statistics {toxinidir}/src - twistedchecker -d W9002,W9202,W9204,W9208,W9402,C0301,C0103,W9001,C9302,W9401 {toxinidir}/src + yamllint {toxinidir} basepython = python3.9 + [testenv:docs] setenv = PYTHONPATH = {toxinidir}/src @@ -53,8 +58,9 @@ commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html basepython = python3.9 -[testenv:mypy] -description = run Mypy (static type checker) + +[testenv:typing] +description = run static type checkers deps = -r{toxinidir}/requirements.txt @@ -66,23 +72,5 @@ commands = --config-file="{toxinidir}/mypy.ini" \ {tty:--pretty:} \ {posargs:src} - -[testenv:pytype] -description = run Pytype (static type checker) - -deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements-dev.txt - -commands = - pytype --keep-going --jobs auto - -[testenv:pyre] -description = run Pyre (static type checker) - -deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements-dev.txt - -commands = - pyre --noninteractive analyze