new automated detection testing

This commit is contained in:
P4T12ICK
2021-05-26 14:45:51 +02:00
parent 58b0385e5b
commit 3f7f50814d
2 changed files with 60 additions and 10 deletions
@@ -6,22 +6,18 @@ import argparse
from helpers import github_service, aws_service, attack_range_controller
ATTACK_RANGE_STATE_STORE = "attack-range-state-store"
def main(args):
parser = argparse.ArgumentParser(description="Attack Range Honeypot Service")
parser.add_argument("-a", "--action", required=True,
help="action")
parser.add_argument("-r", "--region", required=False,
help="aws region")
parser.add_argument("-n", "--name", required=True,
help="name of the honeypot")
parser = argparse.ArgumentParser(description="CI Detection Testing")
parser.add_argument("-a", "--action", required=True, help="action")
args = parser.parse_args()
region = args.region
name = args.name
action = args.action
if action == "build":
response = aws_service.get_entry_database(name)
if not response:
@@ -40,6 +36,8 @@ def main(args):
aws_service.delete_entry_database(name)
aws_service.delete_tf_state_store(data['region'], name)
elif action == "rebuild":
if __name__ == "__main__":
main(sys.argv[1:])
@@ -5,6 +5,58 @@ import os
import json
def create_entry_database(region, honeypot_name, state):
resource = boto3.resource('dynamodb', region_name="eu-central-1")
table = resource.Table("attack_range_honeypot")
response = table.put_item(Item= {
'name': honeypot_name,
'region': region,
'status': state
})
def update_entry_database(honeypot_name, password, state):
resource = boto3.resource('dynamodb', region_name="eu-central-1")
table = resource.Table("attack_range_honeypot")
response = table.update_item(
Key={
'name': honeypot_name
},
UpdateExpression="set #ts=:s, password=:p",
ExpressionAttributeValues={
':s': state,
':p': password
},
ExpressionAttributeNames={
"#ts": "status"
},
ReturnValues="UPDATED_NEW"
)
def delete_entry_database(honeypot_name):
resource = boto3.resource('dynamodb', region_name="eu-central-1")
table = resource.Table("attack_range_honeypot")
response = table.delete_item(
Key={
'name': honeypot_name
}
)
def get_entry_database(honeypot_name):
resource = boto3.resource('dynamodb', region_name="eu-central-1")
table = resource.Table("attack_range_honeypot")
response = table.get_item(
Key={
'name': honeypot_name
}
)
if 'Item' in response:
return response['Item']
else:
return {}
def create_tf_state_store(honeypot_name, region):
my_config = Config(region_name = region)