Skip to content

Commit

Permalink
cleanup and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
glaslos committed Feb 20, 2022
1 parent 1c2382e commit 4124892
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 38 deletions.
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -4,3 +4,6 @@ build-docker:

run-docker:
docker run -it -p 80:8800 -p 102:10201 -p 502:5020 -p 161:16100/udp -p 47808:47808/udp -p 623:6230/udp -p 21:2121 -p 69:6969/udp -p 44818:44818 --network=bridge --name conpot conpot:latest

format:
black .
2 changes: 1 addition & 1 deletion conpot/core/internal_interface.py
Expand Up @@ -40,7 +40,7 @@ def __getattr__(self, attr):


class Interface(object):
""" Conpot's internal interface """
"""Conpot's internal interface"""

def __init__(self):
self.network = Network()
Expand Down
2 changes: 1 addition & 1 deletion conpot/protocols/IEC104/frames.py
Expand Up @@ -210,7 +210,7 @@ def __init__(self, name, default):

class NormValueField(LESignedShortField):
def i2repr(self, pkt, x):
normalized = 2 * ((x + 2 ** 15) / ((2 ** 15 + 2 ** 15.0) - 1)) - 1
normalized = 2 * ((x + 2**15) / ((2**15 + 2**15.0) - 1)) - 1
return self.i2h(pkt, normalized)


Expand Down
9 changes: 6 additions & 3 deletions conpot/protocols/ftp/ftp_server.py
Expand Up @@ -15,15 +15,18 @@
# Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import logging

from os import R_OK, W_OK
from datetime import datetime

from lxml import etree
import conpot.core as conpot_core
from gevent.server import StreamServer

from conpot.protocols.ftp.ftp_utils import ftp_commands, FTPException
from conpot.protocols.ftp.ftp_handler import FTPCommandChannel
from conpot.core.protocol_wrapper import conpot_protocol
from datetime import datetime
import logging
import conpot.core as conpot_core

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion conpot/protocols/ftp/ftp_utils.py
Expand Up @@ -17,7 +17,7 @@


class FTPException(Exception):
"""General FTP related exceptions. """
"""General FTP related exceptions."""

pass

Expand Down
2 changes: 1 addition & 1 deletion conpot/protocols/http/command_responder.py
Expand Up @@ -18,6 +18,7 @@
import logging
import time
import random
import os

from datetime import datetime

Expand All @@ -26,7 +27,6 @@

import http.server
import http.client
import os
from lxml import etree
from conpot.helpers import str_to_bytes
import conpot.core as conpot_core
Expand Down
3 changes: 2 additions & 1 deletion conpot/protocols/http/web_server.py
Expand Up @@ -16,8 +16,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import os
from conpot.protocols.http.command_responder import CommandResponder
import logging

from conpot.protocols.http.command_responder import CommandResponder
from conpot.core.protocol_wrapper import conpot_protocol

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions conpot/protocols/snmp/databus_mediator.py
Expand Up @@ -26,7 +26,7 @@

class DatabusMediator(object):
def __init__(self, oid_mappings):
""" initiate variables """
"""initiate variables"""

self.evasion_table = {} # stores the number of requests
self.start_time = datetime.now()
Expand Down Expand Up @@ -78,7 +78,7 @@ def set_value(self, OID, value):
self.databus.set_value(self.oid_map[OID], value)

def update_evasion_table(self, client_ip):
""" updates dynamic evasion table """
"""updates dynamic evasion table"""

# get current minute as epoch..
now = datetime.now()
Expand Down
2 changes: 1 addition & 1 deletion conpot/protocols/tftp/tftp_handler.py
Expand Up @@ -21,7 +21,7 @@ def handle(self, pkt, raddress, rport):


class TFTPServerState(TFTPState):
"""The base class for server states. """
"""The base class for server states."""

# We had to rewrite the because -- had to check os.* wrappers.
vfs, data_fs = None, None
Expand Down
15 changes: 6 additions & 9 deletions conpot/tests/helpers/s7comm_client.py
Expand Up @@ -48,15 +48,12 @@ def __init__(self, data=""):
self.data = data

def pack(self):
return (
pack(
"!BBH",
3, # version
0, # reserved
len(bytes(self.data)) + 4, # packet size
)
+ str_to_bytes(bytes(self.data))
)
return pack(
"!BBH",
3, # version
0, # reserved
len(bytes(self.data)) + 4, # packet size
) + str_to_bytes(bytes(self.data))

def unpack(self, packet):
try:
Expand Down
2 changes: 1 addition & 1 deletion conpot/tests/test_tftp.py
Expand Up @@ -29,7 +29,7 @@ def tearDown(self):

@freeze_time("2018-07-15 17:51:17")
def test_tftp_upload(self):
"""Testing TFTP upload files. """
"""Testing TFTP upload files."""
self.client.upload("test.txt", self._test_file)
_, _data_fs = conpot_core.get_vfs("tftp")
[_file] = [
Expand Down
18 changes: 9 additions & 9 deletions docker-compose.yml
Expand Up @@ -3,13 +3,13 @@ services:
conpot:
build: ./
ports:
- "80:8800" #SCADA UI, http
- "102:10201" #S7Comm
- "502:5020" #Modbus
- "161:16100/udp" #SNMP
- "47808:47808/udp" #Bacnet
- "623:6230/udp" #IPMI
- "21:2121" #FTP
- "69:6969/udp" #TFTP
- "44818:44818" #EN/IP
- "80:8800" #SCADA UI, http
- "102:10201" #S7Comm
- "502:5020" #Modbus
- "161:16100/udp" #SNMP
- "47808:47808/udp" #Bacnet
- "623:6230/udp" #IPMI
- "21:2121" #FTP
- "69:6969/udp" #TFTP
- "44818:44818" #EN/IP
restart: always
12 changes: 6 additions & 6 deletions docs/source/conf.py
Expand Up @@ -47,8 +47,8 @@
master_doc = "index"

# General information about the project.
project = u"Conpot"
copyright = u"2018, MushMush Foundation"
project = "Conpot"
copyright = "2018, MushMush Foundation"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -192,7 +192,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
("index", "Conpot.tex", u"Conpot Documentation", u"MushMush Foundation", "manual"),
("index", "Conpot.tex", "Conpot Documentation", "MushMush Foundation", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -220,7 +220,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", "conpot", u"Conpot Documentation", [u"MushMush Foundation"], 1)]
man_pages = [("index", "conpot", "Conpot Documentation", ["MushMush Foundation"], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -235,8 +235,8 @@
(
"index",
"Conpot",
u"Conpot Documentation",
u"MushMush Foundation",
"Conpot Documentation",
"MushMush Foundation",
"Conpot",
"ICS/SCADA honeypot.",
"Miscellaneous",
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -30,7 +30,6 @@
include_package_data=True,
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
description="""Conpot is an ICS honeypot with the goal to collect intelligence about the motives
and methods of adversaries targeting industrial control systems""",
description="""Conpot is an ICS honeypot with the goal to collect intelligence about the motives and methods of adversaries targeting industrial control systems""",
install_requires=open("requirements.txt").read().splitlines(),
)

0 comments on commit 4124892

Please sign in to comment.