vysion 1.0.16__py3-none-any.whl → 2.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
vysion/model/model.py DELETED
@@ -1,184 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Copyright 2022 ByronLabs S.L.
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- """
17
- import hashlib
18
- import uuid
19
- from datetime import datetime
20
-
21
- from .enum import Enum
22
-
23
- try:
24
- from types import NoneType
25
- except:
26
- NoneType: type = type(None)
27
-
28
- import re
29
- from typing import List, Optional, Union
30
-
31
- from pydantic import BaseModel, Field # , constr
32
-
33
- from .enum import Network, Services
34
-
35
- NULL_UUID = uuid.UUID("00000000-0000-0000-0000-000000000000")
36
-
37
-
38
- class URL(BaseModel):
39
-
40
- protocol: Optional[str]
41
- domain: Optional[str]
42
- port: Optional[int] = Field(default_factory=lambda: -1)
43
- path: Optional[str]
44
- signature: uuid.UUID = Field(default_factory=lambda: NULL_UUID)
45
-
46
- raw: str
47
-
48
- @staticmethod
49
- def _parse_(url):
50
-
51
- """
52
- RFC3986
53
- scheme = $2
54
- authority = $4
55
- path = $5
56
- query = $7
57
- fragment = $9
58
- """
59
- regex = r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"
60
-
61
- res = re.match(regex, url)
62
-
63
- scheme = res[2]
64
- authority = res[4]
65
- path = res[5]
66
- query = res[7]
67
- fragment = res[9]
68
-
69
- return dict(
70
- scheme=scheme,
71
- authority=authority,
72
- path=path,
73
- query=query,
74
- fragment=fragment,
75
- )
76
-
77
- def _generate_signature_(self) -> uuid.UUID:
78
- return uuid.uuid5(uuid.NAMESPACE_URL, self.build())
79
-
80
- @classmethod
81
- def parse(cls, url, fix=False):
82
-
83
- # Saving the original url
84
- raw = url
85
-
86
- parsed = cls._parse_(url)
87
-
88
- # Elements
89
- scheme = parsed["scheme"]
90
- netloc = parsed["authority"]
91
- path = parsed["path"]
92
- query = parsed["query"]
93
- fragment = parsed["fragment"]
94
-
95
- # Build domain:port
96
- if netloc is not None:
97
- domain_port = (netloc.split(":") + [None])[:2]
98
- else:
99
- domain_port = [None, None]
100
-
101
- domain = domain_port[0]
102
- port = domain_port[1]
103
-
104
- # Normalize path: /path?query#fragment
105
- # Parse a URL into 6 components:
106
- # <protocol>://<domain>:<port>/<path>
107
- if query is not None:
108
-
109
- # Normalize query
110
- query_parts = [param.split("=") for param in query.split("&")]
111
- query_dict = {}
112
- for part in query_parts:
113
- if len(part) <= 1:
114
- query_dict[part[0]] = str()
115
- else:
116
- query_dict[part[0]] = part[1]
117
-
118
- query_keys = list(query_dict.keys())
119
- query_keys.sort()
120
- res_query_parts = [f"{k}={query_dict[k]}" for k in query_keys]
121
-
122
- res_query = "?" + "&".join(res_query_parts)
123
-
124
- path += res_query
125
-
126
- if fragment is not None:
127
- path += f"#{fragment}"
128
-
129
- # TODO Adapt restalker.link_extractors.UUF logic to fix URLs
130
- # TODO Detect network?
131
- result = cls(protocol=scheme, domain=domain, port=port, path=path, raw=raw)
132
-
133
- if fix:
134
- result._fix()
135
-
136
- return result
137
-
138
- def __init__(self, *args, **kwargs):
139
- super().__init__(*args, **kwargs)
140
- self.signature = self._generate_signature_()
141
-
142
- def build(self) -> str:
143
-
144
- url = self.path
145
-
146
- if self.domain is not None:
147
-
148
- if self.port is not None:
149
- url = f":{self.port}" + url
150
-
151
- url = f"{self.domain}" + url
152
-
153
- if self.protocol is not None:
154
-
155
- url = f"{self.protocol}://" + url
156
-
157
- return url
158
-
159
- def _fix(self, default_protocol=Services.http) -> None:
160
-
161
- if self.protocol is None:
162
- if self.port is None:
163
- self.protocol = default_protocol.name
164
- else:
165
- self.protocol = Services(self.port).name
166
-
167
- if self.port is None:
168
- self.port = Services[self.protocol].value
169
-
170
- if self.domain is None:
171
- path = self.path
172
- if path[0] == "/":
173
- path = path[1:]
174
- path_parts = path.split("/")
175
- self.domain = path_parts[0]
176
- self.path = "/" + "/".join(path_parts[1:])
177
-
178
- self.signature = self._generate_signature_()
179
-
180
- def __str__(self) -> str:
181
- return self.build()
182
-
183
- def __repr__(self):
184
- return self.build()
@@ -1,23 +0,0 @@
1
- vysion/__init__.py,sha256=yxJiM-S29q8GB3PBff9tV70P2nvydd8aKLEprLkXw5o,664
2
- vysion/client/__init__.py,sha256=aVHmBuetPdybp7TgcNzUx4HkxTjEuXYzSdDYiYfFQd0,630
3
- vysion/client/client.py,sha256=YYyeGat5YtDWQAWYGgnxreeSZktCg7_b3R8GmerSkDQ,10913
4
- vysion/client/error.py,sha256=-i_ixyZ1KlCvuEaooYX8lbK7GIwZ7S1bxlG8DtlgyR4,1176
5
- vysion/dto/__init__.py,sha256=ct8JxVMfJ0APiOTgr9ju-JIuBlXOrPkx7n2qISSXUts,605
6
- vysion/dto/dto.py,sha256=1RrmeieN4yx150MByMr-uIl2TsJtAvLjcXcB4cK4Dl0,10934
7
- vysion/dto/tag.py,sha256=_Dn4-_xiC1PD4udp3m4FsDdyHVCSgrq7NFJomjsMYtU,1503
8
- vysion/dto/util.py,sha256=6pRKNOsz5_3XgUyMfucsVchsaGUNox-3SJ_Het2yCL8,4456
9
- vysion/model/__init__.py,sha256=P3zJqw4eZtn1UFubOjBe16AFeVmKeViTtQmvd2Op_Ag,627
10
- vysion/model/enum/__init__.py,sha256=lhG6rgaYjrFBR8_IfJL0OoT0L7vooR5_ht4zUahQcOc,690
11
- vysion/model/enum/languages.py,sha256=q97e6PkOsXNJ9SxlW_Wl8QHC0BBDD10H3taxao_Zahg,4205
12
- vysion/model/enum/networks.py,sha256=02tasWnacnHDRT6oez9VI2qnCOHY6iI9q0UYLWDrpKo,789
13
- vysion/model/enum/ransom_groups.py,sha256=dRVJWfO0ylFLKdvgNhTI2sMN-M7Dtsng6ieiu8j6YJg,1527
14
- vysion/model/enum/services.py,sha256=x6CQhDrMlJY_kTCCeHStT2VtGgCG0G9JsIFR6JaEbXs,5569
15
- vysion/model/model.py,sha256=qk5V7z0MWXQaGdglVR3kO-8_Bwu784xa9RjUYAFRK6s,4778
16
- vysion/taxonomy/__init__.py,sha256=Bc364AYxRCyjIn26-XBPeEDCPe3Hma4r5RAI8R8eblU,635
17
- vysion/taxonomy/flavours.py,sha256=ubImHBE8v0zhzFy_2YozAQk2SzN1XDQwHAxb2RebtCo,2347
18
- vysion/taxonomy/taxonomy.py,sha256=8gg-jPwPc0yis5wpABTFkmKq8bFYJG2vHjHXR3ol2cY,12264
19
- vysion/version.py,sha256=vCKpGKIppwQBOyOQdqwyPjvmB6R68KLsfaZErJCVido,610
20
- vysion-1.0.16.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
21
- vysion-1.0.16.dist-info/METADATA,sha256=YEUcnB6C-5U4947YX5q7tVH9R-j1JhroCF1b_k5uJ4Q,2124
22
- vysion-1.0.16.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
23
- vysion-1.0.16.dist-info/RECORD,,