| import logging
|
| import peewee
|
| from typing import Dict, Any
|
| from playhouse.shortcuts import model_to_dict
|
|
|
| db = peewee.SqliteDatabase('adware.db')
|
|
|
| class BaseModel(peewee.Model):
|
| class Meta:
|
| database = db
|
|
|
| class Payload(BaseModel):
|
| name = peewee.CharField()
|
| description = peewee.TextField()
|
| file_path = peewee.CharField()
|
|
|
| def to_dict(self):
|
| return model_to_dict(self)
|
|
|
| class DeploymentMethod(BaseModel):
|
| name = peewee.CharField()
|
| description = peewee.TextField()
|
| config_schema = peewee.TextField()
|
|
|
| def to_dict(self):
|
| return model_to_dict(self)
|
|
|
| class Adware(BaseModel):
|
| name = peewee.CharField()
|
| description = peewee.TextField()
|
| target_os = peewee.CharField()
|
| persistence_method = peewee.CharField()
|
| payload = peewee.ForeignKeyField(Payload, backref='adwares')
|
| deployment_method = peewee.ForeignKeyField(DeploymentMethod, backref='adwares')
|
| config = peewee.TextField()
|
|
|
| def to_dict(self):
|
| return model_to_dict(self)
|
|
|
| def create_tables():
|
| with db:
|
| db.create_tables([Payload, DeploymentMethod, Adware])
|
|
|
| if __name__ == '__main__':
|
| create_tables() |