Command to add browser fingerprint data
This commit is contained in:
parent
cd4d8a4c3f
commit
ad0ad0a783
4 changed files with 6135 additions and 0 deletions
6094
data/user-agent.json
Normal file
6094
data/user-agent.json
Normal file
File diff suppressed because it is too large
Load diff
0
profiles/management/__init__.py
Normal file
0
profiles/management/__init__.py
Normal file
0
profiles/management/commands/__init__.py
Normal file
0
profiles/management/commands/__init__.py
Normal file
41
profiles/management/commands/import_browser_fp.py
Normal file
41
profiles/management/commands/import_browser_fp.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
""" Small module that import browser fingerprints into the databose,
|
||||||
|
based on the data listed in https://huit.re/user-agent-json.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.db import models
|
||||||
|
from profiles.models import BrowserFingerprint
|
||||||
|
|
||||||
|
def import_file(filename):
|
||||||
|
with open(filename, mode='r') as file:
|
||||||
|
data = json.load(file)
|
||||||
|
data = data[0]["list"]
|
||||||
|
for os_agent in data:
|
||||||
|
for useragent in os_agent["useragents"]:
|
||||||
|
import_useragent(useragent)
|
||||||
|
|
||||||
|
def import_useragent(useragent):
|
||||||
|
fingerprint = BrowserFingerprint(
|
||||||
|
description=useragent.get("description", ""),
|
||||||
|
useragent=useragent.get("useragent", ""),
|
||||||
|
appname=useragent.get("appname", ""),
|
||||||
|
appversion=useragent.get("appversion", ""),
|
||||||
|
platform=useragent.get("appversion", ""),
|
||||||
|
vendor=useragent.get("vendor", ""),
|
||||||
|
vendorsub=useragent.get("vendorsub", ""),
|
||||||
|
buildID=useragent.get("buildID", ""),
|
||||||
|
oscpu=useragent.get("oscpu", ""),
|
||||||
|
accept_encoding=useragent.get("accept_encoding", ""),
|
||||||
|
accept_default=useragent.get("accept_default", ""),
|
||||||
|
accept_lang=useragent.get("accept_lang", ""),
|
||||||
|
pixeldepth=int(useragent.get("pixeldepth", 0)),
|
||||||
|
colordepth=int(useragent.get("colordepth", 0)),
|
||||||
|
screens=useragent.get("screen", ""),
|
||||||
|
)
|
||||||
|
print(fingerprint)
|
||||||
|
fingerprint.save()
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
def handle(self, *args, **kwargs):
|
||||||
|
import_file("data/user-agent.json")
|
Loading…
Reference in a new issue