repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_aerial_image.align_gt.measure.py | import sys
import os
import numpy as np
import test
# CHANGE to the path of your own read.py script:
sys.path.append("../../../data/AerialImageDataset")
import read
sys.path.append("../../utils")
import run_utils
import python_utils
import geo_utils
import polygon_utils
# --- Command-line FLAGS --- #
# --- --- #
... | 4,212 | 34.70339 | 135 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/model.py | import sys
import os
import time
import tensorflow as tf
import numpy as np
from tqdm import tqdm
import model_utils
# import model_utils_concat_interm_outputs
import loss_utils
sys.path.append("../evaluate_funcs") # Evaluation functions
import evaluate_utils
sys.path.append("../utils") # Mapalign utils
import vis... | 51,104 | 49.349754 | 212 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_bradbury_buildings.2_align.py | import sys
import os
import numpy as np
import test
sys.path.append("../../../data/bradbury_buildings_roads_height_dataset")
import read as read_bradbury_buildings
sys.path.append("../../utils")
import run_utils
import python_utils
# --- Params --- #
TEST_CONFIG_NAME = "config.test.bradbury_buildings"
KEEP_PROB =... | 4,322 | 35.948718 | 119 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_bradbury_buildings.3_detect_new_buildings.py | import sys
import os
import numpy as np
import config
import test
import config_test_bradbury_buildings as config_test
sys.path.append("../../../data/bradbury_buildings_roads_height_dataset")
import read
# --- Params --- #
# Models
DS_FAC_LIST = [
# 8,
# 4,
# 2,
1,
] # Must be in descending order
R... | 1,973 | 28.909091 | 255 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_aerial_image.2_align.py | import sys
import os
import numpy as np
import test
sys.path.insert(0, "../../../data/AerialImageDataset")
import read as read_inria
sys.path.append("../../utils")
import run_utils
import python_utils
# --- Params --- #
TEST_CONFIG_NAME = "config.test.aerial_image"
# Must be in descending order:
DS_FAC_LIST = [
... | 3,647 | 35.48 | 118 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_bradbury_buildings.1_generate_disps.py | import sys
import os
import numpy as np
import config_test_bradbury_buildings as config_test
import test
sys.path.append("../../utils")
import math_utils
import run_utils
import python_utils
sys.path.append("../../../data/bradbury_buildings_roads_height_dataset")
import read
# --- Params --- #
CONFIG_NAME = "confi... | 3,380 | 40.740741 | 132 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/config.py | import os
import sys
sys.path.append("../../utils")
import python_utils
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
# Dataset online processing
DATA_DIR = python_utils.choose_first_existing_path([
"/local/shared/epitome-polygon-deep-learning/data", # Try local node first
"/home/nigirard/epitome... | 4,751 | 31.326531 | 137 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/config_test_bradbury_buildings.py | import os
import numpy as np
import config
DATASET_RAW_DIR = os.path.join(config.DATA_DIR, "bradbury_buildings_roads_height_dataset/raw")
# IMAGES = [
# {
# "city": "SanFrancisco",
# "number": 1,
# },
# {
# "city": "SanFrancisco",
# "number": 2,
# },
# {
# ... | 1,304 | 21.5 | 114 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/6_test_building_height_estimation.py | import os.path
import numpy as np
import matplotlib.pyplot as plt
# --- Params --- #
BINS = 50
INPUT_BASE_DIRPATH = "3d_buildings/leibnitz"
# --- --- #
def compute_polygon_area(polygon):
return 0.5 * np.abs(
np.dot(polygon[:, 0], np.roll(polygon[:, 1], 1)) - np.dot(polygon[:, 1], np.roll(polygon[:, ... | 2,115 | 27.213333 | 108 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/multires_pipeline.py | import sys
import skimage.transform
import skimage.io
import numpy as np
import model
sys.path.append("../../utils")
import run_utils
import polygon_utils
import print_utils
def rescale_data(image, polygons, scale):
downsampled_image = skimage.transform.rescale(image, scale, order=3, preserve_range=True, multic... | 6,435 | 47.390977 | 186 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_aerial_image.1_generate_disps.py | import sys
import os
import numpy as np
from jsmin import jsmin
import json
import test
sys.path.append("../../../data/AerialImageDataset")
import read
sys.path.append("../../utils")
import math_utils
import run_utils
import python_utils
# --- Params --- #
CONFIG_NAME = "config"
TEST_CONFIG_NAME = "config.test.aer... | 3,360 | 39.987805 | 152 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_aerial_image.align_osm_gt.py | import sys
import os
import test
# CHANGE to you own test config file:
import config_test_inria as config_test
# CHANGE to the path of your own read.py script:
sys.path.append("../../../data/AerialImageDataset")
import read
# --- Params --- #
# Iteratively use these downsampling factors (should be in descending or... | 1,996 | 32.283333 | 137 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/4_compute_building_heights.py | import os.path
import sys
import math
import itertools
import numpy as np
import config
sys.path.append("../../utils")
import geo_utils
# --- Params --- #
DATASET_DIR = os.path.join(config.PROJECT_DIR, "../../../data/stereo_dataset")
RAW_DIR = os.path.join(DATASET_DIR, "raw/leibnitz")
INPUT_DIR = "test/stereo_datas... | 4,526 | 40.154545 | 174 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/download_pretrained.py | import os.path
import urllib.request
import zipfile
# --- Params --- #
ressource_filename_list = ["runs.igarss2019.zip"]
ressource_dirpath_url = "https://www-sop.inria.fr/members/Nicolas.Girard/downloads/mapalignment"
script_filepath = os.path.realpath(__file__)
zip_download_dirpath = os.path.join(os.path.dirname(sc... | 953 | 35.692308 | 102 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/1_train.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
import tensorflow as tf
import os
import model
sys.path.append(os.path.join("../dataset_utils"))
import dataset_multires
sys.path.append("../../utils")
import python_utils
import run_utils
# --- ... | 9,943 | 44.2 | 146 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/3_test_plot.2_align.py | import sys
import os
import matplotlib.pyplot as plt
import numpy as np
sys.path.append("../../utils")
import python_utils
# --- Params --- #
ACCURACIES_FILENAME_EXTENSION = ".accuracy.npy"
SOURCE_PARAMS_LIST = [
# # --- Stereo real disps --- #
# {
# "name": "Aligned image 1",
# "path": "tes... | 16,830 | 35.430736 | 180 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_stereo.py | import sys
import os
import numpy as np
import config
import test
sys.path.append("../../../data/stereo_dataset")
import read
# --- Params --- #
DATASET_DIR = os.path.join(config.PROJECT_DIR, "../../../data/stereo_dataset")
FILE_PARAMS = {
"raw_dataset_dir": os.path.join(DATASET_DIR, "raw"),
"gt_views": ["r... | 3,177 | 35.953488 | 207 | py |
mapalignment | mapalignment-master/projects/mapalign/mapalign_multires/2_test_aerial_image.align_gt.py | import sys
import os
import tensorflow as tf
import numpy as np
import test
# CHANGE to the path of your own read.py script:
sys.path.append("../../../data/AerialImageDataset")
import read
sys.path.append("../../utils")
import run_utils
import python_utils
# --- Command-line FLAGS --- #
flags = tf.app.flags
FLAGS... | 4,273 | 34.915966 | 157 | py |
mapalignment | mapalignment-master/projects/utils/tf_utils.py | import tensorflow as tf
from tensorflow.python.framework.ops import get_gradient_function
import math
import numpy as np
def get_tf_version():
return tf.__version__
def bytes_feature(value):
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
def int64_feature(value):
return tf.train... | 9,356 | 35.694118 | 155 | py |
mapalignment | mapalignment-master/projects/utils/viz_utils.py | import sys
import numpy as np
sys.path.append("../../utils")
import polygon_utils
import skimage.io
import cv2
def save_plot_image_polygon(filepath, image, polygons):
spatial_shape = image.shape[:2]
polygons_map = polygon_utils.draw_polygon_map(polygons, spatial_shape, fill=False, edges=True,
... | 1,610 | 34.021739 | 98 | py |
mapalignment | mapalignment-master/projects/utils/dataset_utils.py | import os
import tensorflow as tf
class TFRecordShardWriter:
def __init__(self, filepath_format, max_records_per_shard):
self.filepath_format = filepath_format
self.max_records_per_shard = max_records_per_shard
self.current_shard_record_count = 0 # To know when to switch to a new file
... | 1,079 | 36.241379 | 83 | py |
mapalignment | mapalignment-master/projects/utils/python_utils.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import errno
import json
from jsmin import jsmin
def module_exists(module_name):
try:
__import__(module_name)
except ImportError:
return False
else:
return True
def choose_first_existing_path(path_list):
for path in pat... | 2,600 | 24.5 | 136 | py |
mapalignment | mapalignment-master/projects/utils/image_utils.py | from io import BytesIO
import math
import numpy as np
from PIL import Image
import skimage.draw
import python_utils
CV2 = False
if python_utils.module_exists("cv2"):
import cv2
CV2 = True
if python_utils.module_exists("matplotlib.pyplot"):
import matplotlib.pyplot as plt
def get_image_size(filepath):
... | 8,487 | 34.514644 | 148 | py |
mapalignment | mapalignment-master/projects/utils/print_utils.py | class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
DEBUG = '\033[31;40m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def print_info(string):
print(bcolors.OKBLUE + string + bcolors.ENDC)
def print_suc... | 1,293 | 19.21875 | 65 | py |
mapalignment | mapalignment-master/projects/utils/polygon_utils.py | import math
import random
import numpy as np
import scipy.spatial
from PIL import Image, ImageDraw, ImageFilter
import skimage
import python_utils
if python_utils.module_exists("skimage.measure"):
from skimage.measure import approximate_polygon
if python_utils.module_exists("shapely"):
from shapely import g... | 42,079 | 36.437722 | 131 | py |
mapalignment | mapalignment-master/projects/utils/geo_utils.py | import numpy as np
import time
import json
import os.path
from osgeo import gdal, ogr
from osgeo import osr
import overpy
# from fiona.crs import from_epsg
# import fiona
from pyproj import Proj, transform
import polygon_utils
import math_utils
import print_utils
# --- Params --- #
QUERY_BASE = \
"""
<osm-s... | 12,156 | 32.86351 | 187 | py |
mapalignment | mapalignment-master/projects/utils/math_utils.py | import numpy as np
import time
import sklearn.datasets
import skimage.transform
import python_utils
import image_utils
# if python_utils.module_exists("matplotlib.pyplot"):
# import matplotlib.pyplot as plt
CV2 = False
if python_utils.module_exists("cv2"):
import cv2
CV2 = True
# import multiprocessing
... | 11,176 | 31.873529 | 147 | py |
mapalignment | mapalignment-master/projects/utils/run_utils.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import time
import datetime
from jsmin import jsmin
import json
import random
import print_utils
import python_utils
# Stolen from Docker:
NAME_SET = set([
# Muhammad ibn Jābir al-Ḥarrānī al-Battānī was a founding father of astronomy. https://en.wikipedia.o... | 39,862 | 59.216012 | 457 | py |
mapalignment | mapalignment-master/data/mapping_challenge_dataset/read.py | import sys
sys.path.append("../utils")
import visualization
from pycocotools.coco import COCO
from pycocotools import mask as cocomask
import numpy as np
import skimage.io as io
import matplotlib.pyplot as plt
import pylab
import random
import os
# --- Params --- #
FOLD_LIST = ["train", "val"]
IMAGES_DIRPATH_FORMAT... | 3,220 | 29.102804 | 103 | py |
mapalignment | mapalignment-master/data/AerialImageDataset/convert_npy_to_shp.py | import os.path
import sys
import read
FILE_DIRNAME = os.getcwd()
sys.path.append(os.path.join(FILE_DIRNAME, "../../projects/utils"))
import geo_utils
# --- Params --- #
RAW_DIRPATH = os.path.join(FILE_DIRNAME, "raw")
IMAGE_INFO_LIST = [
{
"city": "bloomington",
"numbers": list(range(1, 37)),
... | 2,189 | 25.071429 | 168 | py |
mapalignment | mapalignment-master/data/AerialImageDataset/fetch_gt_polygons.py | import sys
import os
import numpy as np
sys.path.append("../../../projects/utils")
import python_utils
import polygon_utils
import geo_utils
# --- Params --- #
DIR_PATH_LIST = ["./raw/train", "./raw/test"]
IMAGE_DIR_NAME = "images"
IMAGE_EXTENSION = "tif"
GT_POLYGONS_DIR_NAME = "gt_polygons"
# --- --- #
def lo... | 2,053 | 29.656716 | 115 | py |
mapalignment | mapalignment-master/data/AerialImageDataset/read.py | import os.path
import csv
import sys
import numpy as np
import skimage.io
CITY_METADATA_DICT = {
"bloomington": {
"fold": "test",
"pixelsize": 0.3,
"numbers": list(range(1, 37)),
},
"bellingham": {
"fold": "test",
"pixelsize": 0.3,
"numbers": list(range(1, 3... | 4,120 | 26.657718 | 115 | py |
mapalignment | mapalignment-master/data/bradbury_buildings_roads_height_dataset/download.py | import os.path
import urllib.request
import zipfile
BASE_URL = 'https://figshare.com/collections/Aerial_imagery_object_identification_dataset_for_building_and_road_detection_and_building_height_estimation/3290519'
FILE_URL_FORMAT = "https://ndownloader.figshare.com/articles/{}/versions/1"
FILE_METADATA_LIST = [
{
... | 1,842 | 24.957746 | 161 | py |
mapalignment | mapalignment-master/data/bradbury_buildings_roads_height_dataset/read.py | import os.path
import csv
import numpy as np
import skimage.io
CITY_METADATA_DICT = {
"Arlington": {
"pixelsize": 0.3,
"numbers": [1, 2, 3],
},
"Atlanta": {
"pixelsize": 0.1524,
"numbers": [1, 2, 3],
},
"Austin": {
"pixelsize": 0.1524,
"numbers": ... | 5,849 | 29.952381 | 118 | py |
cowrie | cowrie-master/setup.py | #!/usr/bin/env python
from setuptools import setup
try:
import twisted
except ImportError:
raise SystemExit("twisted not found. Make sure you "
"have installed the Twisted core package.")
setup(
packages=["cowrie", "twisted"],
include_package_data=True,
package_dir={"": "src... | 642 | 22.814815 | 88 | py |
cowrie | cowrie-master/src/twisted/plugins/cowrie_plugin.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 10,607 | 38.434944 | 110 | py |
cowrie | cowrie-master/src/cowrie/_version.py | """
Provides cowrie version information.
"""
# This file is auto-generated! Do not edit!
# Use `python -m incremental.update cowrie` to change this file.
from __future__ import annotations
from incremental import Version
__version__ = Version("cowrie", 2, 5, 0)
__all__: list[str] = ["__version__"]
| 303 | 20.714286 | 64 | py |
cowrie | cowrie-master/src/cowrie/__init__.py | # setup version
from ._version import __version__ as version
__version__: str = version.short()
| 97 | 18.6 | 44 | py |
cowrie | cowrie-master/src/cowrie/output/xmpp.py | from __future__ import annotations
import json
import string
from random import choice
from wokkel import muc
from wokkel.client import XMPPClient
from wokkel.xmppim import AvailablePresence
from twisted.application import service
from twisted.python import log
from twisted.words.protocols.jabber import jid
from twis... | 2,986 | 29.479592 | 84 | py |
cowrie | cowrie-master/src/cowrie/output/rethinkdblog.py | from __future__ import annotations
import time
from datetime import datetime
import rethinkdb as r
import cowrie.core.output
from cowrie.core.config import CowrieConfig
def iso8601_to_timestamp(value):
return time.mktime(datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ").timetuple())
RETHINK_DB_SEGMENT = "outp... | 1,526 | 30.163265 | 85 | py |
cowrie | cowrie-master/src/cowrie/output/reversedns.py | from __future__ import annotations
from functools import lru_cache
import ipaddress
from twisted.internet import defer
from twisted.names import client, error
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
class Output(cowrie.core.output.Output):
"""
Ou... | 3,128 | 28.242991 | 88 | py |
cowrie | cowrie-master/src/cowrie/output/mysql.py | """
MySQL output connector. Writes audit logs to MySQL database
"""
from __future__ import annotations
from twisted.enterprise import adbapi
from twisted.internet import defer
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
# For exceptions: https://dev.mysql.com... | 11,175 | 37.143345 | 102 | py |
cowrie | cowrie-master/src/cowrie/output/telegram.py | # Simple Telegram Bot logger
import treq
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
class Output(cowrie.core.output.Output):
"""
telegram output
"""
def start(self):
self.bot_token = CowrieConfig.get("output_telegram", "bot_token")
... | 2,326 | 34.8 | 86 | py |
cowrie | cowrie-master/src/cowrie/output/influx.py | from __future__ import annotations
import re
from influxdb import InfluxDBClient
from influxdb.exceptions import InfluxDBClientError
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
class Output(cowrie.core.output.Output):
"""
influx output
"""
d... | 7,285 | 31.968326 | 87 | py |
cowrie | cowrie-master/src/cowrie/output/virustotal.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 18,353 | 35.416667 | 117 | py |
cowrie | cowrie-master/src/cowrie/output/jsonlog.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 2,770 | 36.958904 | 75 | py |
cowrie | cowrie-master/src/cowrie/output/hpfeeds3.py | """
Output plugin for HPFeeds
"""
from __future__ import annotations
import json
import logging
from hpfeeds.twisted import ClientSessionService
from twisted.internet import endpoints, ssl
from twisted.internet import reactor
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import C... | 4,221 | 34.478992 | 87 | py |
cowrie | cowrie-master/src/cowrie/output/csirtg.py | from __future__ import annotations
import os
import sys
from datetime import datetime
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
token = CowrieConfig.get("output_csirtg", "token", fallback="a1b2c3d4")
if token == "a1b2c3d4":
log.msg("output_csirtg: token ... | 2,714 | 26.15 | 86 | py |
cowrie | cowrie-master/src/cowrie/output/mongodb.py | from __future__ import annotations
import pymongo
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
class Output(cowrie.core.output.Output):
"""
mongodb output
"""
def insert_one(self, collection, event):
try:
object_id = collec... | 5,057 | 37.318182 | 106 | py |
cowrie | cowrie-master/src/cowrie/output/discord.py | """
Simple Discord webhook logger
"""
from __future__ import annotations
import json
from io import BytesIO
from twisted.internet import reactor
from twisted.internet.ssl import ClientContextFactory
from twisted.web import client, http_headers
from twisted.web.client import FileBodyProducer
import cowrie.core.outpu... | 1,486 | 26.537037 | 75 | py |
cowrie | cowrie-master/src/cowrie/output/graylog.py | """
Simple Graylog HTTP Graylog Extended Log Format (GELF) logger.
"""
from __future__ import annotations
import json
import time
from io import BytesIO
from twisted.internet import reactor
from twisted.internet.ssl import ClientContextFactory
from twisted.web import client, http_headers
from twisted.web.client impo... | 1,607 | 26.254237 | 75 | py |
cowrie | cowrie-master/src/cowrie/output/abuseipdb.py | # MIT License
#
# Copyright (c) 2020 Benjamin Stephens <premier_contact@ben-stephens.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
#... | 18,525 | 36.275654 | 89 | py |
cowrie | cowrie-master/src/cowrie/output/datadog.py | """
Simple Datadog HTTP logger.
"""
from __future__ import annotations
import json
import platform
from io import BytesIO
from twisted.internet import reactor
from twisted.internet.ssl import ClientContextFactory
from twisted.python import log
from twisted.web import client, http_headers
from twisted.web.client impo... | 2,286 | 30.763889 | 86 | py |
cowrie | cowrie-master/src/cowrie/output/crashreporter.py | """
Cowrie Crashreport
This output plugin is not like the others.
It has its own emit() function and does not use cowrie eventid's
to avoid circular calls
"""
from __future__ import annotations
import json
import treq
from twisted.internet import defer
from twisted.logger._levels import LogLevel
from twisted.pytho... | 2,005 | 24.392405 | 86 | py |
cowrie | cowrie-master/src/cowrie/output/elasticsearch.py | # Simple elasticsearch logger
from __future__ import annotations
from typing import Any
from elasticsearch import Elasticsearch, NotFoundError
import cowrie.core.output
from cowrie.core.config import CowrieConfig
class Output(cowrie.core.output.Output):
"""
elasticsearch output
"""
index: str
... | 4,393 | 33.873016 | 94 | py |
cowrie | cowrie-master/src/cowrie/output/localsyslog.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 2,683 | 36.277778 | 78 | py |
cowrie | cowrie-master/src/cowrie/output/threatjammer.py | # Copyright 2022 by GOODDATA LABS SL
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | 7,010 | 32.545455 | 111 | py |
cowrie | cowrie-master/src/cowrie/output/dshield.py | """
Send SSH logins to SANS DShield.
See https://isc.sans.edu/ssh.html
"""
from __future__ import annotations
import base64
import hashlib
import hmac
import re
import time
import dateutil.parser
import requests
from twisted.internet import reactor
from twisted.internet import threads
from twisted.python import log... | 6,123 | 33.994286 | 100 | py |
cowrie | cowrie-master/src/cowrie/output/splunk.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
"""
Splunk HTTP Event Collector (HEC) Connector.
Not ready for production use.
JSON log file is still recommended way to go
"""
from __future__ import annotations
import json
from io import BytesIO
from typing import Any
from twisted.internet import react... | 3,647 | 30.179487 | 88 | py |
cowrie | cowrie-master/src/cowrie/output/sqlite.py | from __future__ import annotations
import sqlite3
from typing import Any
from twisted.enterprise import adbapi
from twisted.internet import defer
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
class Output(cowrie.core.output.Output):
"""
sqlite output
... | 7,367 | 33.919431 | 102 | py |
cowrie | cowrie-master/src/cowrie/output/textlog.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 2,383 | 38.733333 | 80 | py |
cowrie | cowrie-master/src/cowrie/output/redis.py | from __future__ import annotations
import json
from configparser import NoOptionError
import redis
import cowrie.core.output
from cowrie.core.config import CowrieConfig
SEND_METHODS = {
"lpush": lambda redis_client, key, message: redis_client.lpush(key, message),
"rpush": lambda redis_client, key, message: r... | 1,797 | 27.539683 | 87 | py |
cowrie | cowrie-master/src/cowrie/output/misp.py | from __future__ import annotations
import warnings
from functools import wraps
from pathlib import Path
from pymisp import MISPAttribute, MISPEvent, MISPSighting
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
try:
from pymisp import ExpandedPyMISP as PyMISP
... | 4,393 | 31.308824 | 85 | py |
cowrie | cowrie-master/src/cowrie/output/slack.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 2,394 | 35.287879 | 75 | py |
cowrie | cowrie-master/src/cowrie/output/cuckoo.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 5,799 | 33.52381 | 88 | py |
cowrie | cowrie-master/src/cowrie/output/malshare.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 3,275 | 31.117647 | 75 | py |
cowrie | cowrie-master/src/cowrie/output/s3.py | """
Send downloaded/uplaoded files to S3 (or compatible)
"""
from __future__ import annotations
from typing import Any
from configparser import NoOptionError
from botocore.exceptions import ClientError
from botocore.session import get_session
from twisted.internet import defer, threads
from twisted.python import l... | 3,019 | 29.505051 | 86 | py |
cowrie | cowrie-master/src/cowrie/output/socketlog.py | from __future__ import annotations
import json
import socket
import cowrie.core.output
from cowrie.core.config import CowrieConfig
class Output(cowrie.core.output.Output):
"""
socketlog output
"""
def start(self):
self.timeout = CowrieConfig.getint("output_socketlog", "timeout")
addr... | 1,156 | 25.906977 | 73 | py |
cowrie | cowrie-master/src/cowrie/output/greynoise.py | """
Send attackers IP to GreyNoise
"""
from __future__ import annotations
import treq
from twisted.internet import defer, error
from twisted.python import log
import cowrie.core.output
from cowrie.core.config import CowrieConfig
COWRIE_USER_AGENT = "Cowrie Honeypot"
GNAPI_URL = "https://api.greynoise.io/v3/communit... | 2,749 | 27.947368 | 109 | py |
cowrie | cowrie-master/src/cowrie/core/checkers.py | # Copyright (c) 2009-2014 Upi Tamminen <desaster@gmail.com>
# See the COPYRIGHT file for more information
"""
This module contains ...
"""
from __future__ import annotations
from sys import modules
from zope.interface import implementer
from twisted.conch import error
from twisted.conch.ssh import keys
from twiste... | 4,224 | 32.007813 | 112 | py |
cowrie | cowrie-master/src/cowrie/core/auth.py | # Copyright (c) 2009-2014 Upi Tamminen <desaster@gmail.com>
# See the COPYRIGHT file for more information
"""
This module contains authentication code
"""
from __future__ import annotations
import json
import re
from collections import OrderedDict
from os import path
from random import randint
from typing import Any... | 8,448 | 31.003788 | 88 | py |
cowrie | cowrie-master/src/cowrie/core/credentials.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 3,261 | 31.949495 | 80 | py |
cowrie | cowrie-master/src/cowrie/core/utils.py | # -*- test-case-name: cowrie.test.utils -*-
# Copyright (c) 2010-2014 Upi Tamminen <desaster@gmail.com>
# See the COPYRIGHT file for more information
from __future__ import annotations
import configparser
from typing import BinaryIO
from twisted.application import internet
from twisted.internet import endpoints
de... | 4,153 | 30 | 105 | py |
cowrie | cowrie-master/src/cowrie/core/realm.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 2,435 | 41 | 75 | py |
cowrie | cowrie-master/src/cowrie/core/config.py | # Copyright (c) 2009-2014 Upi Tamminen <desaster@gmail.com>
# See the COPYRIGHT file for more information
"""
This module contains code to deal with Cowrie's configuration
"""
from __future__ import annotations
import configparser
from os import environ
from os.path import abspath, dirname, exists, join
from typing... | 2,050 | 26.716216 | 100 | py |
cowrie | cowrie-master/src/cowrie/core/artifact.py | # Copyright (c) 2016 Michel Oosterhof <michel@oosterhof.net>
"""
This module contains code to handling saving of honeypot artifacts
These will typically be files uploaded to the honeypot and files
downloaded inside the honeypot, or input being piped in.
Code behaves like a normal Python file handle.
Example:
wi... | 2,319 | 24.217391 | 106 | py |
cowrie | cowrie-master/src/cowrie/core/cef.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 4,079 | 33.576271 | 75 | py |
cowrie | cowrie-master/src/cowrie/core/__init__.py | 0 | 0 | 0 | py | |
cowrie | cowrie-master/src/cowrie/core/output.py | # Copyright (c) 2015 Michel Oosterhof <michel@oosterhof.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, th... | 7,999 | 31.653061 | 88 | py |
cowrie | cowrie-master/src/cowrie/core/ttylog.py | # -*- test-case-name: cowrie.test.utils -*-
# Copyright (c) 2009-2014 Upi Tamminen <desaster@gmail.com>
# See the COPYRIGHT file for more information
"""
Should be compatible with user mode linux
"""
from __future__ import annotations
import hashlib
import struct
OP_OPEN, OP_CLOSE, OP_WRITE, OP_EXEC = 1, 2, 3, 4
T... | 2,437 | 25.215054 | 82 | py |
cowrie | cowrie-master/src/cowrie/telnet_proxy/server_transport.py | # Copyright (C) 2015, 2016 GoSecure Inc.
"""
Telnet Transport and Authentication for the Honeypot
@author: Olivier Bilodeau <obilodeau@gosecure.ca>
"""
from __future__ import annotations
import time
import uuid
from twisted.conch.telnet import TelnetTransport
from twisted.internet import reactor
from twisted.intern... | 7,303 | 34.629268 | 111 | py |
cowrie | cowrie-master/src/cowrie/telnet_proxy/client_transport.py | # Copyright (c) 2019 Guilherme Borges <guilhermerosasborges@gmail.com>
# All rights reserved.
from __future__ import annotations
from twisted.conch.telnet import TelnetTransport
from twisted.internet import protocol
from twisted.protocols.policies import TimeoutMixin
from twisted.python import log
class BackendTeln... | 2,253 | 30.746479 | 90 | py |
cowrie | cowrie-master/src/cowrie/telnet_proxy/__init__.py | 0 | 0 | 0 | py | |
cowrie | cowrie-master/src/cowrie/telnet_proxy/handler.py | from __future__ import annotations
import os
import re
import time
from twisted.python import log
from cowrie.core import ttylog
from cowrie.core.checkers import HoneypotPasswordChecker
from cowrie.core.config import CowrieConfig
def process_backspaces(s: bytes) -> bytes:
"""
Takes a user-input string that ... | 12,570 | 35.75731 | 122 | py |
cowrie | cowrie-master/src/cowrie/python/__init__.py | 0 | 0 | 0 | py | |
cowrie | cowrie-master/src/cowrie/python/logfile.py | # -*- test-case-name: cowrie.test.utils -*-
# Copyright (c) 2017 Michel Oosterhof <michel@oosterhof.net>
# See the COPYRIGHT file for more information
from __future__ import annotations
from os import environ
from twisted.logger import textFileLogObserver
from twisted.python import logfile
from cowrie.core.config ... | 1,281 | 27.488889 | 83 | py |
cowrie | cowrie-master/src/cowrie/telnet/userauth.py | # Copyright (C) 2015, 2016 GoSecure Inc.
"""
Telnet Transport and Authentication for the Honeypot
@author: Olivier Bilodeau <obilodeau@gosecure.ca>
"""
from __future__ import annotations
import struct
from twisted.conch.telnet import (
ECHO,
LINEMODE,
NAWS,
SGA,
AuthenticatingTelnetProtocol,
... | 4,827 | 31.186667 | 82 | py |
cowrie | cowrie-master/src/cowrie/telnet/factory.py | # Copyright (C) 2015, 2016 GoSecure Inc.
"""
Telnet Transport and Authentication for the Honeypot
@author: Olivier Bilodeau <obilodeau@gosecure.ca>
"""
from __future__ import annotations
import time
from twisted.cred import portal as tp
from twisted.internet import protocol
from twisted.plugin import IPlugin
from t... | 2,489 | 28.294118 | 93 | py |
cowrie | cowrie-master/src/cowrie/telnet/session.py | # Copyright (C) 2015, 2016 GoSecure Inc.
"""
Telnet User Session management for the Honeypot
@author: Olivier Bilodeau <obilodeau@gosecure.ca>
"""
from __future__ import annotations
import traceback
from zope.interface import implementer
from twisted.conch.ssh import session
from twisted.conch.telnet import ECHO, ... | 5,044 | 29.575758 | 116 | py |
cowrie | cowrie-master/src/cowrie/telnet/__init__.py | 0 | 0 | 0 | py | |
cowrie | cowrie-master/src/cowrie/telnet/transport.py | # Copyright (C) 2015, 2016 GoSecure Inc.
"""
Telnet Transport and Authentication for the Honeypot
@author: Olivier Bilodeau <obilodeau@gosecure.ca>
"""
from __future__ import annotations
import time
import uuid
from twisted.conch.telnet import AlreadyNegotiating, TelnetTransport
from twisted.protocols.policies imp... | 4,310 | 37.491071 | 117 | py |
cowrie | cowrie-master/src/cowrie/test/test_tftp.py | # Copyright (c) 2018 Michel Oosterhof
# See LICENSE for details.
from __future__ import annotations
import os
import unittest
from cowrie.shell.protocol import HoneyPotInteractiveProtocol
from cowrie.test.fake_server import FakeAvatar, FakeServer
from cowrie.test.fake_transport import FakeTransport
os.environ["COWRI... | 1,165 | 29.684211 | 81 | py |
cowrie | cowrie-master/src/cowrie/test/fake_transport.py | # Copyright (c) 2016 Dave Germiquet
# See LICENSE for details.
from __future__ import annotations
from collections.abc import Callable
from twisted.conch.insults import insults
from twisted.test import proto_helpers
class Container:
"""This class is placeholder for creating a fake interface.
@var host Cli... | 4,828 | 26.594286 | 84 | py |
cowrie | cowrie-master/src/cowrie/test/fake_server.py | # Copyright (c) 2016 Dave Germiquet
# See LICENSE for details.
from __future__ import annotations
from cowrie.shell import fs
class FakeServer:
"""FakeServer class.
@ivar hostname Servers Host Name
@ivar fs File System for cowrie to use
"""
def __init__(self):
self.arch = "linux-x64-ls... | 1,335 | 22.438596 | 78 | py |
cowrie | cowrie-master/src/cowrie/test/test_uniq.py | # Copyright (c) 2020 Peter Sufliarsky
# See LICENSE for details.
from __future__ import annotations
import os
import unittest
from cowrie.shell.protocol import HoneyPotInteractiveProtocol
from cowrie.test.fake_server import FakeAvatar, FakeServer
from cowrie.test.fake_transport import FakeTransport
os.environ["COWRI... | 1,619 | 30.764706 | 71 | py |
cowrie | cowrie-master/src/cowrie/test/test_cat.py | # Copyright (c) 2018 Michel Oosterhof
# See LICENSE for details.
from __future__ import annotations
import os
import unittest
from cowrie.shell.protocol import HoneyPotInteractiveProtocol
from cowrie.test.fake_server import FakeAvatar, FakeServer
from cowrie.test.fake_transport import FakeTransport
os.environ["COWRI... | 1,773 | 33.115385 | 86 | py |
cowrie | cowrie-master/src/cowrie/test/test_echo.py | # Copyright (c) 2018 Michel Oosterhof
# See LICENSE for details.
from __future__ import annotations
import os
import unittest
from cowrie.shell.protocol import HoneyPotInteractiveProtocol
from cowrie.test.fake_server import FakeAvatar, FakeServer
from cowrie.test.fake_transport import FakeTransport
os.environ["COWRI... | 5,836 | 38.707483 | 86 | py |
cowrie | cowrie-master/src/cowrie/test/test_base64.py | # Copyright (c) 2020 Peter Sufliarsky
# See LICENSE for details.
from __future__ import annotations
import os
import unittest
from cowrie.shell.protocol import HoneyPotInteractiveProtocol
from cowrie.test.fake_server import FakeAvatar, FakeServer
from cowrie.test.fake_transport import FakeTransport
os.environ["COWRI... | 1,383 | 30.454545 | 69 | py |
cowrie | cowrie-master/src/cowrie/test/proxy_compare.py | from __future__ import annotations
from backend_pool.ssh_exec import execute_ssh
from backend_pool.telnet_exec import execute_telnet
from twisted.internet import defer
class ProxyTestCommand:
"""
This class executes commands on Proxy instances and their backends (or either one of them).
If executing on ... | 3,172 | 30.107843 | 95 | py |
cowrie | cowrie-master/src/cowrie/test/test_ftpget.py | # Copyright (c) 2018 Michel Oosterhof
# See LICENSE for details.
from __future__ import annotations
import os
import unittest
from cowrie.shell.protocol import HoneyPotInteractiveProtocol
from cowrie.test.fake_server import FakeAvatar, FakeServer
from cowrie.test.fake_transport import FakeTransport
os.environ["COWR... | 1,588 | 28.981132 | 77 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.