Skip to content

Commit 29d64c8

Browse files
committed
Add option to set shareable to True for fingerprints uploaded to DDoS-DB
1 parent ec51d3a commit 29d64c8

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

config.ini.example

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
host=ddosdb.example.com
33
token=c2c0689dce8314c5267a4a1ffb81163494ab9ddb555ec3d7b45cb88110372a3b
44

5+
# By default fingerprints are set to not being shareable.
6+
# Meaning they will not be pushed onwards to other DDoS-DB instances
7+
# Uncomment if you do want fingerprints to be set to shareable by default
8+
# shareable=true
9+
510
# default protocol is https, but in case of a development DDoSDB instance without TLS: uncomment below
611
# protocol=http
712

src/attack.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,26 @@ def write_to_file(self, filename: Path):
240240
with open(filename, 'w') as file:
241241
json.dump(self.as_dict(anonymous=not self.show_target), file, indent=4)
242242

243-
def upload_to_ddosdb(self, host: str, token: str, protocol: str = 'https', noverify: bool = False) -> int:
243+
def upload_to_ddosdb(self,
244+
host: str,
245+
token: str,
246+
protocol: str = 'https',
247+
noverify: bool = False,
248+
shareable: bool = False) -> int:
244249
"""
245250
Upload fingerprint to a DDoS-DB instance
246251
:param host: hostname of the DDoS-DB instance, without schema (like db.example.com)
247252
:param token: DDoS-DB Authorization Token
248253
:param protocol: Protocol to use (http or https)
249254
:param noverify: (bool) ignore invalid TLS certificate
255+
:param shareable: (bool) allow the DDoS-DB to push fingerprint on to other DDoS-DB instances
250256
:return: HTTP response code
251257
"""
252258
LOGGER.info(f'Uploading fingerprint to DDoS-DB: {host}...')
253259

254-
fp_json = json.dumps(self.as_dict(anonymous=not self.show_target))
260+
fp_dict = self.as_dict(anonymous=not self.show_target)
261+
fp_dict['shareable'] = bool(shareable)
262+
fp_json = json.dumps(fp_dict)
255263
headers = {
256264
'Authorization': f'Token {token}'
257265
}
@@ -279,7 +287,7 @@ def upload_to_ddosdb(self, host: str, token: str, protocol: str = 'https', nover
279287
elif r.status_code == 413:
280288
LOGGER.critical('Fingerprint is too large to upload to this DDoS-DB instance.')
281289
elif r.status_code == 201:
282-
LOGGER.info(f'Upload success! URL: https://{host}/details?key={self.checksum}')
290+
LOGGER.info(f'Upload success! URL: {protocol}://{host}/details?key={self.checksum}')
283291
else:
284292
LOGGER.critical('DDoS-DB Internal Server Error.')
285293
LOGGER.critical('Error Code: {}'.format(r.status_code))

src/util.py

+1
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ def parse_config(file: Path, misp=False) -> dict[str, str]:
272272
'host': config.get(platform, 'host'),
273273
'token': config.get(platform, 'token'),
274274
'protocol': config.get(platform, 'protocol'),
275+
"shareable": "True" if config.getboolean(platform, 'shareable', fallback=False) else "False",
275276
}
276277

277278
except (NoSectionError, NoOptionError):

0 commit comments

Comments
 (0)