sniparinject 0.0.0.dev6__tar.gz → 0.0.0.dev8__tar.gz
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.
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/PKG-INFO +25 -12
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/setup.cfg +5 -6
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject/core/game.py +7 -13
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject/core/settings.py +2 -2
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject/network_sniffer.py +31 -8
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject.egg-info/PKG-INFO +25 -12
- sniparinject-0.0.0.dev8/sniparinject.egg-info/requires.txt +2 -0
- sniparinject-0.0.0.dev6/sniparinject.egg-info/requires.txt +0 -2
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/pyproject.toml +0 -0
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/setup.py +0 -0
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject/__init__.py +0 -0
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject/core/__init__.py +0 -0
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject/core/text_style.py +0 -0
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject/core/utility.py +0 -0
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject.egg-info/SOURCES.txt +0 -0
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject.egg-info/dependency_links.txt +0 -0
- {sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: sniparinject
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev8
|
|
4
4
|
Summary: Intercept and read the network packets to find useful information. Also, inject some data.
|
|
5
5
|
Home-page: https://github.com/airvzxf/sniparinject
|
|
6
6
|
Author: Israel Roldan
|
|
@@ -21,15 +21,17 @@ Classifier: Natural Language :: English
|
|
|
21
21
|
Classifier: Operating System :: POSIX :: Linux
|
|
22
22
|
Classifier: Operating System :: Unix
|
|
23
23
|
Classifier: Programming Language :: Python :: 3
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.
|
|
25
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
25
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
27
26
|
Classifier: Topic :: Games/Entertainment
|
|
28
27
|
Classifier: Topic :: Security
|
|
29
28
|
Classifier: Topic :: System :: Networking
|
|
30
29
|
Classifier: Topic :: System :: Networking :: Monitoring
|
|
31
|
-
Requires-Python: >=3.
|
|
30
|
+
Requires-Python: >=3.11
|
|
32
31
|
Description-Content-Type: text/markdown
|
|
32
|
+
Requires-Dist: PyYAML>=6.0.3
|
|
33
|
+
Requires-Dist: scapy>=2.7.0
|
|
34
|
+
Dynamic: description
|
|
33
35
|
|
|
34
36
|
# SniParInject
|
|
35
37
|
|
|
@@ -56,7 +58,7 @@ python3 -m pip install sniparinject
|
|
|
56
58
|
### As a developer
|
|
57
59
|
|
|
58
60
|
The only two special Python's packages that you need are `scapy` and
|
|
59
|
-
`PyYAML`, the suggested version of `Python` is `>= 3.
|
|
61
|
+
`PyYAML`, the suggested version of `Python` is `>= 3.11`. Follow the commands to
|
|
60
62
|
set up and install this package.
|
|
61
63
|
|
|
62
64
|
```bash
|
|
@@ -105,7 +107,7 @@ Network:
|
|
|
105
107
|
interface: enp4s0
|
|
106
108
|
|
|
107
109
|
Server:
|
|
108
|
-
|
|
110
|
+
ip: 52.174.196.146
|
|
109
111
|
port: 5122
|
|
110
112
|
|
|
111
113
|
Game:
|
|
@@ -171,20 +173,33 @@ rules.
|
|
|
171
173
|
|
|
172
174
|
### Examples
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
The required fields for the `Server` information are `ip`, `port` or both.
|
|
175
177
|
|
|
176
178
|
```yaml
|
|
177
179
|
Network:
|
|
178
180
|
interface: enp4s0
|
|
179
181
|
|
|
180
182
|
Server:
|
|
181
|
-
|
|
183
|
+
ip: 52.174.196.146
|
|
182
184
|
port: 5122
|
|
183
185
|
```
|
|
184
186
|
|
|
185
187
|
---
|
|
186
188
|
|
|
187
|
-
|
|
189
|
+
The default protocol is `TCP` but you can assign the `UDP`.
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
Network:
|
|
193
|
+
interface: enp4s0
|
|
194
|
+
|
|
195
|
+
Server:
|
|
196
|
+
protocol: UDP
|
|
197
|
+
port: 6666
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
This is the basic structure without any rule.
|
|
188
203
|
|
|
189
204
|
```yaml
|
|
190
205
|
Game:
|
|
@@ -477,5 +492,3 @@ Enjoy!
|
|
|
477
492
|
[ascii-mana-link]: https://asciinema.org/a/R0mxcmrpWHzX96NDJyc7kyTDB
|
|
478
493
|
|
|
479
494
|
[structs]: https://docs.python.org/3/library/struct.html#format-characters
|
|
480
|
-
|
|
481
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = sniparinject
|
|
3
|
-
version = 0.0.0.
|
|
3
|
+
version = 0.0.0.dev8
|
|
4
4
|
author = Israel Roldan
|
|
5
5
|
author_email = israel.alberto.rv@gmail.com
|
|
6
6
|
description = Intercept and read the network packets to find useful information. Also, inject some data.
|
|
@@ -23,8 +23,7 @@ classifiers =
|
|
|
23
23
|
Operating System :: POSIX :: Linux
|
|
24
24
|
Operating System :: Unix
|
|
25
25
|
Programming Language :: Python :: 3
|
|
26
|
-
Programming Language :: Python :: 3.
|
|
27
|
-
Programming Language :: Python :: 3.10
|
|
26
|
+
Programming Language :: Python :: 3.11
|
|
28
27
|
Programming Language :: Python :: Implementation :: PyPy
|
|
29
28
|
Topic :: Games/Entertainment
|
|
30
29
|
Topic :: Security
|
|
@@ -34,9 +33,9 @@ classifiers =
|
|
|
34
33
|
[options]
|
|
35
34
|
packages = find:
|
|
36
35
|
install_requires =
|
|
37
|
-
PyYAML>=
|
|
38
|
-
scapy>=2.
|
|
39
|
-
python_requires = >=3.
|
|
36
|
+
PyYAML>=6.0.3
|
|
37
|
+
scapy>=2.7.0
|
|
38
|
+
python_requires = >=3.11
|
|
40
39
|
|
|
41
40
|
[flake8]
|
|
42
41
|
max-line-length = 127
|
|
@@ -6,7 +6,6 @@ Parse the game data.
|
|
|
6
6
|
from struct import unpack
|
|
7
7
|
|
|
8
8
|
from scapy.compat import raw
|
|
9
|
-
from scapy.layers.inet import IP
|
|
10
9
|
from scapy.layers.l2 import Ether
|
|
11
10
|
from scapy.packet import Raw
|
|
12
11
|
|
|
@@ -21,15 +20,15 @@ class Game:
|
|
|
21
20
|
Parse the game data.
|
|
22
21
|
"""
|
|
23
22
|
|
|
24
|
-
def __init__(self, settings_path: str,
|
|
23
|
+
def __init__(self, settings_path: str, is_host: bool, packet: Ether):
|
|
25
24
|
"""
|
|
26
25
|
Parse the game data.
|
|
27
26
|
|
|
28
27
|
:type settings_path: str
|
|
29
28
|
:param settings_path: The file path with all the settings.
|
|
30
29
|
|
|
31
|
-
:type
|
|
32
|
-
:param
|
|
30
|
+
:type is_host: bool
|
|
31
|
+
:param is_host: Is this response by the host?
|
|
33
32
|
|
|
34
33
|
:type packet: Ether
|
|
35
34
|
:param packet: Ethernet packet.
|
|
@@ -37,17 +36,13 @@ class Game:
|
|
|
37
36
|
:rtype: None
|
|
38
37
|
:return: Nothing.
|
|
39
38
|
"""
|
|
40
|
-
ip_layer = packet.getlayer(IP)
|
|
41
39
|
raw_layer = packet.getlayer(Raw)
|
|
42
40
|
self.raw_data = raw(raw_layer)
|
|
43
41
|
self.raw_data_copy = raw(raw_layer)
|
|
44
42
|
self.settings_path = settings_path
|
|
45
|
-
self.request = 'node'
|
|
43
|
+
self.request = 'host' if is_host else 'node'
|
|
46
44
|
self.display_message = True
|
|
47
45
|
|
|
48
|
-
if host_ip == ip_layer.src:
|
|
49
|
-
self.request = 'host'
|
|
50
|
-
|
|
51
46
|
# pylint: disable=broad-except
|
|
52
47
|
def start(self) -> None:
|
|
53
48
|
"""
|
|
@@ -62,7 +57,6 @@ class Game:
|
|
|
62
57
|
error_message, error_location = self._extract_exception(error)
|
|
63
58
|
error_location = f'Class Game{error_location}'
|
|
64
59
|
self._print_error(error_message, error_location)
|
|
65
|
-
return
|
|
66
60
|
|
|
67
61
|
@staticmethod
|
|
68
62
|
def _extract_exception(error: Exception) -> tuple[str, str]:
|
|
@@ -100,7 +94,7 @@ class Game:
|
|
|
100
94
|
"""
|
|
101
95
|
message, extracted_location = self._extract_exception(error)
|
|
102
96
|
full_location = f'{location}{extracted_location}'
|
|
103
|
-
raise
|
|
97
|
+
raise RuntimeError(message, full_location)
|
|
104
98
|
|
|
105
99
|
def _print_error(self, error: str, location: str) -> None:
|
|
106
100
|
"""
|
|
@@ -169,8 +163,8 @@ class Game:
|
|
|
169
163
|
:rtype: dict
|
|
170
164
|
:return: The actions with the settings.
|
|
171
165
|
"""
|
|
172
|
-
settings_exception =
|
|
173
|
-
|
|
166
|
+
settings_exception = RuntimeError('The Game settings are missing.',
|
|
167
|
+
' -> Settings(...).get(\'Game\')')
|
|
174
168
|
|
|
175
169
|
general_settings = {}
|
|
176
170
|
try:
|
|
@@ -31,10 +31,10 @@ class Settings:
|
|
|
31
31
|
:rtype: dict
|
|
32
32
|
:return: The settings for Python usage.
|
|
33
33
|
"""
|
|
34
|
-
with open(self.config_file) as file:
|
|
34
|
+
with open(self.config_file, encoding='utf-8') as file:
|
|
35
35
|
settings = load(file, Loader=FullLoader)
|
|
36
36
|
|
|
37
37
|
if not settings:
|
|
38
|
-
raise
|
|
38
|
+
raise ValueError(f'Error: Not found settings in the file `{self.config_file}`.')
|
|
39
39
|
|
|
40
40
|
return settings
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"""
|
|
4
4
|
Start the sniff of the network packets.
|
|
5
5
|
"""
|
|
6
|
-
from scapy.layers.inet import TCP
|
|
6
|
+
from scapy.layers.inet import TCP, UDP, IP
|
|
7
7
|
from scapy.layers.l2 import Ether
|
|
8
8
|
from scapy.packet import Raw
|
|
9
9
|
from scapy.sendrecv import sniff
|
|
@@ -36,13 +36,16 @@ class NetworkSniffer:
|
|
|
36
36
|
print(settings)
|
|
37
37
|
|
|
38
38
|
self.interface = settings.get('Network').get('interface')
|
|
39
|
-
|
|
40
|
-
self.
|
|
39
|
+
protocol = settings.get('Server').get('protocol') or 'tcp'
|
|
40
|
+
self.protocol = protocol.lower()
|
|
41
|
+
self.host_ip = settings.get('Server').get('ip') or None
|
|
42
|
+
self.host_port = settings.get('Server').get('port') or None
|
|
41
43
|
print()
|
|
42
44
|
print('=== Network Sniffer ===')
|
|
43
45
|
print(f'Interface: {self.interface}')
|
|
44
|
-
print(f'
|
|
45
|
-
print(f'
|
|
46
|
+
print(f'Protocol: {self.protocol}')
|
|
47
|
+
print(f'Host IP: {self.host_ip}')
|
|
48
|
+
print(f'Host Port: {self.host_port}')
|
|
46
49
|
print()
|
|
47
50
|
|
|
48
51
|
def start(self) -> None:
|
|
@@ -52,9 +55,15 @@ class NetworkSniffer:
|
|
|
52
55
|
:rtype: None
|
|
53
56
|
:return: Nothing.
|
|
54
57
|
"""
|
|
58
|
+
sniffer_filter = self.protocol
|
|
59
|
+
if self.host_ip:
|
|
60
|
+
sniffer_filter += f' and host {self.host_ip}'
|
|
61
|
+
if self.host_port:
|
|
62
|
+
sniffer_filter += f' and port {self.host_port}'
|
|
63
|
+
|
|
55
64
|
sniff(
|
|
56
65
|
iface=self.interface,
|
|
57
|
-
filter=
|
|
66
|
+
filter=sniffer_filter,
|
|
58
67
|
count=0,
|
|
59
68
|
prn=self._sniff_data
|
|
60
69
|
)
|
|
@@ -69,5 +78,19 @@ class NetworkSniffer:
|
|
|
69
78
|
:rtype: None
|
|
70
79
|
:return: Nothing.
|
|
71
80
|
"""
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
ip_layer = packet.getlayer(IP)
|
|
82
|
+
if not ip_layer:
|
|
83
|
+
raise RuntimeError('Error: The IP layer not exists in this package.')
|
|
84
|
+
|
|
85
|
+
if not (packet.haslayer(TCP) or packet.haslayer(UDP)):
|
|
86
|
+
raise RuntimeError('Error: The protocol layer (TCP or UDP) not exists in this package.')
|
|
87
|
+
|
|
88
|
+
layer_type = packet.getlayer(UDP) if self.protocol == 'udp' else packet.getlayer(TCP)
|
|
89
|
+
|
|
90
|
+
if self.host_ip and self.host_port:
|
|
91
|
+
is_host = self.host_ip == ip_layer.src and self.host_port == layer_type.sport
|
|
92
|
+
else:
|
|
93
|
+
is_host = self.host_ip == ip_layer.src or self.host_port == layer_type.sport
|
|
94
|
+
|
|
95
|
+
if packet.haslayer(Raw):
|
|
96
|
+
Game(self.settings_path, is_host, packet).start()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: sniparinject
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev8
|
|
4
4
|
Summary: Intercept and read the network packets to find useful information. Also, inject some data.
|
|
5
5
|
Home-page: https://github.com/airvzxf/sniparinject
|
|
6
6
|
Author: Israel Roldan
|
|
@@ -21,15 +21,17 @@ Classifier: Natural Language :: English
|
|
|
21
21
|
Classifier: Operating System :: POSIX :: Linux
|
|
22
22
|
Classifier: Operating System :: Unix
|
|
23
23
|
Classifier: Programming Language :: Python :: 3
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.
|
|
25
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
25
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
27
26
|
Classifier: Topic :: Games/Entertainment
|
|
28
27
|
Classifier: Topic :: Security
|
|
29
28
|
Classifier: Topic :: System :: Networking
|
|
30
29
|
Classifier: Topic :: System :: Networking :: Monitoring
|
|
31
|
-
Requires-Python: >=3.
|
|
30
|
+
Requires-Python: >=3.11
|
|
32
31
|
Description-Content-Type: text/markdown
|
|
32
|
+
Requires-Dist: PyYAML>=6.0.3
|
|
33
|
+
Requires-Dist: scapy>=2.7.0
|
|
34
|
+
Dynamic: description
|
|
33
35
|
|
|
34
36
|
# SniParInject
|
|
35
37
|
|
|
@@ -56,7 +58,7 @@ python3 -m pip install sniparinject
|
|
|
56
58
|
### As a developer
|
|
57
59
|
|
|
58
60
|
The only two special Python's packages that you need are `scapy` and
|
|
59
|
-
`PyYAML`, the suggested version of `Python` is `>= 3.
|
|
61
|
+
`PyYAML`, the suggested version of `Python` is `>= 3.11`. Follow the commands to
|
|
60
62
|
set up and install this package.
|
|
61
63
|
|
|
62
64
|
```bash
|
|
@@ -105,7 +107,7 @@ Network:
|
|
|
105
107
|
interface: enp4s0
|
|
106
108
|
|
|
107
109
|
Server:
|
|
108
|
-
|
|
110
|
+
ip: 52.174.196.146
|
|
109
111
|
port: 5122
|
|
110
112
|
|
|
111
113
|
Game:
|
|
@@ -171,20 +173,33 @@ rules.
|
|
|
171
173
|
|
|
172
174
|
### Examples
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
The required fields for the `Server` information are `ip`, `port` or both.
|
|
175
177
|
|
|
176
178
|
```yaml
|
|
177
179
|
Network:
|
|
178
180
|
interface: enp4s0
|
|
179
181
|
|
|
180
182
|
Server:
|
|
181
|
-
|
|
183
|
+
ip: 52.174.196.146
|
|
182
184
|
port: 5122
|
|
183
185
|
```
|
|
184
186
|
|
|
185
187
|
---
|
|
186
188
|
|
|
187
|
-
|
|
189
|
+
The default protocol is `TCP` but you can assign the `UDP`.
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
Network:
|
|
193
|
+
interface: enp4s0
|
|
194
|
+
|
|
195
|
+
Server:
|
|
196
|
+
protocol: UDP
|
|
197
|
+
port: 6666
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
This is the basic structure without any rule.
|
|
188
203
|
|
|
189
204
|
```yaml
|
|
190
205
|
Game:
|
|
@@ -477,5 +492,3 @@ Enjoy!
|
|
|
477
492
|
[ascii-mana-link]: https://asciinema.org/a/R0mxcmrpWHzX96NDJyc7kyTDB
|
|
478
493
|
|
|
479
494
|
[structs]: https://docs.python.org/3/library/struct.html#format-characters
|
|
480
|
-
|
|
481
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sniparinject-0.0.0.dev6 → sniparinject-0.0.0.dev8}/sniparinject.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|