nmaping 1.9__tar.gz → 2.1__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.
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nmaping
3
- Version: 1.9
3
+ Version: 2.1
4
4
  Summary: An automation and network scanning utility tool.
5
5
  Author-email: "Mr. Tan" <mrtanvai@gmail.com>
6
6
  License: Custom License
7
7
  Project-URL: Homepage, https://github.com/Mr74nX/nmaping
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Operating System :: POSIX :: Linux
10
- Requires-Python: >=3.13
10
+ Requires-Python: >=3.9
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: requests
13
13
 
@@ -0,0 +1,5 @@
1
+ __version__ = "2.0"
2
+
3
+ from .nmap import main
4
+
5
+ __all__ = ["main"]
@@ -0,0 +1,288 @@
1
+ #!/usr/bin/env python3
2
+ # NmapEasy - Powerful Nmap wrapper toolkit
3
+ # Author: Mr Tan | https://github.com/Mr74nX
4
+
5
+ import os
6
+ import re
7
+ import sys
8
+ import time
9
+ import shutil
10
+ import platform
11
+ import argparse
12
+ import subprocess
13
+ from datetime import datetime
14
+
15
+ try:
16
+ import requests
17
+ except ImportError:
18
+ requests = None
19
+
20
+ # ------------------------- Colors -------------------------
21
+ red = "\x1b[38;5;196m"
22
+ green = "\033[38;5;156m"
23
+ blue = "\033[38;5;75m"
24
+ white = "\033[38;5;231m"
25
+ orange = "\033[38;5;208m"
26
+ cyan = "\033[1;36m"
27
+ reset = "\033[0m"
28
+
29
+ # ------------------------- Paths -------------------------
30
+ BASE_DIR = os.path.join(os.path.expanduser("~"), ".nmapeasy")
31
+ RESULTS_DIR = os.path.join(BASE_DIR, "results")
32
+ HISTORY_FILE = os.path.join(BASE_DIR, "history.log")
33
+
34
+ os.makedirs(RESULTS_DIR, exist_ok=True)
35
+
36
+ # ------------------------- Version -------------------------
37
+ def get_version():
38
+ if requests is None:
39
+ return "1.0"
40
+ try:
41
+ return requests.get(
42
+ "https://raw.githubusercontent.com/Mr74nX/Nmap-scaning/main/version.txt",
43
+ timeout=5,
44
+ ).text.strip()
45
+ except Exception:
46
+ return "1.0"
47
+
48
+ version = get_version()
49
+
50
+ def clear():
51
+ os.system("cls" if platform.system() == "Windows" else "clear")
52
+
53
+ author_data = f"{orange}Author{white}: {green}Mr Tan\n{orange}GitHub{white}: {blue}https://github.com/Mr74nX"
54
+ logo = f"""{red}
55
+ ███▄ █ ███▄ ▄███▓ ▄▄▄ ██▓███
56
+ ██ ▀█ █ ▓██▒▀█▀ ██▒▒████▄ ▓██░ ██▒
57
+ ▓██ ▀█ ██▒▓██ ▓██░▒██ ▀█▄ ▓██░ ██▓▒
58
+ ▓██▒ ▐▌██▒▒██ ▒██ ░██▄▄▄▄██ ▒██▄█▓▒ ▒
59
+ ▒██░ ▓██░▒██▒ ░██▒ ▓█ ▓██▒▒██▒ ░ ░
60
+ ░ ▒░ ▒ ▒ ░ ▒░ ░ ░ ▒▒ ▓▒█░▒▓▒░ ░ ░
61
+ ░ ░░ ░ ▒░░ ░ ░ ▒ ▒▒ ░░▒ ░
62
+ ░ ░ ░ ░ ░ ░ ▒ ░░
63
+ ░ ░ ░ ░
64
+ {cyan}v{white}={orange}{version}
65
+ {author_data}
66
+
67
+ """
68
+
69
+ # ------------------------- Validation -------------------------
70
+ IP_RE = re.compile(r"^(\d{1,3}\.){3}\d{1,3}(/\d{1,2})?$")
71
+ HOSTNAME_RE = re.compile(r"^[a-zA-Z0-9]([a-zA-Z0-9\-\.]{0,253})[a-zA-Z0-9]$")
72
+
73
+ def validate_target(target: str) -> bool:
74
+ target = target.strip()
75
+ if not target:
76
+ return False
77
+ if IP_RE.match(target):
78
+ parts = target.split("/")[0].split(".")
79
+ return all(0 <= int(p) <= 255 for p in parts)
80
+ return bool(HOSTNAME_RE.match(target)) or target == "localhost"
81
+
82
+ def prompt_target() -> str:
83
+ while True:
84
+ target = input(f"{orange}=>{green} Enter the target IP or domain{white}:{blue} ").strip()
85
+ if validate_target(target):
86
+ return target
87
+ print(f"{red}=> Invalid target. Try again (e.g. 192.168.1.1 or example.com)")
88
+
89
+ def check_nmap_installed() -> bool:
90
+ return shutil.which("nmap") is not None
91
+
92
+ def authorization_gate(target: str) -> bool:
93
+ print(f"\n{orange}=>{red} LEGAL WARNING{white}: Only scan systems you own or have explicit permission to test.")
94
+ ans = input(f"{orange}=>{green} Confirm you are authorized to scan {blue}{target}{green} (y/n){white}: ").strip().lower()
95
+ return ans == "y"
96
+
97
+ # ------------------------- History / Output -------------------------
98
+ def log_history(target: str, scan_name: str, cmd: str, duration: float):
99
+ ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
100
+ with open(HISTORY_FILE, "a", encoding="utf-8") as f:
101
+ f.write(f"[{ts}] target={target} scan={scan_name} duration={duration:.1f}s cmd={cmd}\n")
102
+
103
+ def output_path(target: str, scan_name: str) -> str:
104
+ ts = datetime.now().strftime("%Y%m%d_%H%M%S")
105
+ safe_target = re.sub(r"[^a-zA-Z0-9_.-]", "_", target)
106
+ safe_scan = re.sub(r"[^a-zA-Z0-9_.-]", "_", scan_name)
107
+ return os.path.join(RESULTS_DIR, f"{safe_target}_{safe_scan}_{ts}.txt")
108
+
109
+ def get_timing_template() -> str:
110
+ print(f"\n{orange}==={green} Select Nmap Timing Template {orange}===")
111
+ print(f"{orange}0{white}.{green} Paranoid {red}({orange}0 {white}-{green} Very Slow, bypass IDS{red}){white}")
112
+ print(f"{orange}1{white}.{green} Sneaky {red}({orange}1 {white}- {green}Slow{red}){white}")
113
+ print(f"{orange}2{white}.{green} Polite {red}({orange}2 {white}- {green}Moderate{red}){white}")
114
+ print(f"{orange}3{white}.{green} Normal {red}({orange}3 {white}- {green}Default Speed{red}){white}")
115
+ print(f"{orange}4{white}.{green} Aggressive {red}({orange}4 {white}- {green}Fast & Recommended{red}){white}")
116
+ print(f"{orange}5{white}.{green} Insane {red}({orange}5 {white}- {green}Extremely Fast{red}){white}")
117
+ t_choice = input(f"\n{orange}=>{green} Choose Speed {red}({green}0-5, Default is 3{red}){white}:{green} ").strip()
118
+ return f"-T{t_choice}" if t_choice in "012345" else "-T3"
119
+
120
+ # ------------------------- Scan Profiles -------------------------
121
+ # name : nmap args template ({port} substituted if present)
122
+ SCAN_PROFILES = {
123
+ "1": ("SYN Scan", "-sS"),
124
+ "2": ("Version Detection", "-sV"),
125
+ "3": ("Vulnerability Scan", "--script vuln"),
126
+ "4": ("OS Detection", "-O"),
127
+ "5": ("No Port (Host Discovery)", "-sn"),
128
+ "6": ("Specific Port", "-p {port}"),
129
+ "7": ("Top 1000 Ports", "--top-ports 1000"),
130
+ "8": ("UDP Scan", "-sU"),
131
+ "9": ("Aggressive Scan", "-A"),
132
+ "10": ("Firewall/ACK Detection", "-sA"),
133
+ "11": ("Default Script Scan", "-sC"),
134
+ "12": ("Traceroute", "--traceroute"),
135
+ "13": ("All Ports", "-p-"),
136
+ "14": ("Ping Scan", "-sP"),
137
+ "15": ("No Ping Scan", "-Pn"),
138
+ "16": ("TCP Connect", "-sT"),
139
+ "17": ("Xmas Scan", "-sX"),
140
+ "18": ("FIN Scan", "-sF"),
141
+ "19": ("Null Scan", "-sN"),
142
+ "20": ("Custom (enter your own flags)", None),
143
+ "21": ("Full Deep Scan (slow, everything)",
144
+ "-A -sS -sV --script vuln -O --top-ports 1000 -sU -sC --traceroute -p-"),
145
+ }
146
+
147
+ # ------------------------- Core Runner -------------------------
148
+ def run_scan(target: str, scan_id: str, timing: str, save: bool = True):
149
+ name, args_template = SCAN_PROFILES[scan_id]
150
+
151
+ if args_template is None:
152
+ args_template = input(f"{orange}=>{green} Enter custom nmap flags{white}: ").strip()
153
+
154
+ if "{port}" in args_template:
155
+ port = input(f"{orange}=>{green} Enter the port number/range{white}:{blue} ").strip()
156
+ args_template = args_template.format(port=port)
157
+
158
+ cmd = f"nmap {args_template} {timing} {target}"
159
+ print(f"\n{orange}=>{green} Running {blue}{name}{green} on {blue}{target}{green} | {orange}{timing}{white}")
160
+ print(f"{orange}=>{white} {cmd}\n")
161
+
162
+ start = time.time()
163
+ try:
164
+ result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
165
+ output = result.stdout + result.stderr
166
+ except Exception as e:
167
+ output = f"Error running scan: {e}"
168
+ duration = time.time() - start
169
+
170
+ print(output)
171
+ print(f"{orange}=>{green} Done in {orange}{duration:.1f}s{white}")
172
+
173
+ log_history(target, name, cmd, duration)
174
+
175
+ if save:
176
+ path = output_path(target, name)
177
+ with open(path, "w", encoding="utf-8") as f:
178
+ f.write(f"Command: {cmd}\nDuration: {duration:.1f}s\n\n{output}")
179
+ print(f"{orange}=>{green} Saved to {blue}{path}{white}")
180
+
181
+ def show_history(limit: int = 15):
182
+ clear()
183
+ print(logo)
184
+ if not os.path.exists(HISTORY_FILE):
185
+ print(f"{red}=> No scan history yet.")
186
+ else:
187
+ with open(HISTORY_FILE, encoding="utf-8") as f:
188
+ lines = f.readlines()[-limit:]
189
+ for line in lines:
190
+ print(f"{green}{line.strip()}{white}")
191
+ input(f"\n{orange}=>{green} Press Enter to menu...")
192
+
193
+ # ------------------------- Interactive Menu -------------------------
194
+ def print_menu():
195
+ clear()
196
+ print(logo)
197
+ print(f"{orange}=> {green}Welcome to NmapEasy")
198
+ for key in [str(i) for i in range(1, 22)]:
199
+ name = SCAN_PROFILES[key][0]
200
+ print(f"{orange}{key}{white}.{green} {name}")
201
+ print(f"{orange}H{white}.{green} View Scan History")
202
+ print(f"{orange}0{white}.{green} Exit")
203
+
204
+ def menu():
205
+ if not check_nmap_installed():
206
+ print(f"{red}=> Nmap is not installed or not in PATH. Install it first (e.g. apt install nmap).")
207
+ sys.exit(1)
208
+
209
+ while True:
210
+ print_menu()
211
+ choice = input(f"{orange}=>{green} Enter your choice{white}:{green} ").strip().upper()
212
+
213
+ if choice == "0":
214
+ print(f"{red}Exiting...")
215
+ sys.exit()
216
+ elif choice == "H":
217
+ show_history()
218
+ continue
219
+ elif choice in SCAN_PROFILES:
220
+ clear()
221
+ print(logo)
222
+ target = prompt_target()
223
+ if not authorization_gate(target):
224
+ print(f"{red}=> Authorization not confirmed. Aborting scan.")
225
+ time.sleep(2)
226
+ continue
227
+ timing = get_timing_template()
228
+ run_scan(target, choice, timing)
229
+ input(f"\n{orange}=>{green} Press Enter to menu...")
230
+ else:
231
+ print(f"{red}Invalid choice. Please try again.")
232
+ time.sleep(1.5)
233
+
234
+ # ------------------------- CLI Mode -------------------------
235
+ def cli_main():
236
+ parser = argparse.ArgumentParser(description="NmapEasy - Powerful Nmap wrapper toolkit")
237
+ parser.add_argument("-t", "--target", help="Target IP or domain")
238
+ parser.add_argument("-s", "--scan", help="Scan profile ID (see --list)")
239
+ parser.add_argument("-T", "--timing", default="-T3", help="Timing template, e.g. -T4 (default -T3)")
240
+ parser.add_argument("-p", "--port", help="Port(s) for scan profile 6")
241
+ parser.add_argument("--no-save", action="store_true", help="Don't save output to a file")
242
+ parser.add_argument("--list", action="store_true", help="List all scan profiles and exit")
243
+ parser.add_argument("-y", "--yes", action="store_true", help="Skip authorization confirmation prompt")
244
+ args = parser.parse_args()
245
+
246
+ if args.list:
247
+ print(logo)
248
+ for key, (name, _) in SCAN_PROFILES.items():
249
+ print(f"{orange}{key}{white}: {green}{name}")
250
+ return
251
+
252
+ if not args.target or not args.scan:
253
+ menu()
254
+ return
255
+
256
+ if not check_nmap_installed():
257
+ print(f"{red}=> Nmap is not installed or not in PATH.")
258
+ sys.exit(1)
259
+
260
+ if not validate_target(args.target):
261
+ print(f"{red}=> Invalid target.")
262
+ sys.exit(1)
263
+
264
+ if args.scan not in SCAN_PROFILES:
265
+ print(f"{red}=> Unknown scan profile. Use --list to see options.")
266
+ sys.exit(1)
267
+
268
+ if not args.yes and not authorization_gate(args.target):
269
+ print(f"{red}=> Authorization not confirmed. Aborting.")
270
+ sys.exit(1)
271
+
272
+ name, template = SCAN_PROFILES[args.scan]
273
+ if template and "{port}" in template:
274
+ if not args.port:
275
+ print(f"{red}=> This profile needs --port.")
276
+ sys.exit(1)
277
+ SCAN_PROFILES[args.scan] = (name, template.format(port=args.port))
278
+
279
+ run_scan(args.target, args.scan, args.timing, save=not args.no_save)
280
+
281
+ def main():
282
+ if len(sys.argv) > 1:
283
+ cli_main()
284
+ else:
285
+ menu()
286
+
287
+ if __name__ == "__main__":
288
+ main()
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nmaping
3
- Version: 1.9
3
+ Version: 2.1
4
4
  Summary: An automation and network scanning utility tool.
5
5
  Author-email: "Mr. Tan" <mrtanvai@gmail.com>
6
6
  License: Custom License
7
7
  Project-URL: Homepage, https://github.com/Mr74nX/nmaping
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Operating System :: POSIX :: Linux
10
- Requires-Python: >=3.13
10
+ Requires-Python: >=3.9
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: requests
13
13
 
@@ -1,7 +1,7 @@
1
1
  README.md
2
2
  pyproject.toml
3
3
  nmaping/__init__.py
4
- nmaping/nmap.cpython-313-x86_64-linux-gnu.so
4
+ nmaping/nmap.py
5
5
  nmaping.egg-info/PKG-INFO
6
6
  nmaping.egg-info/SOURCES.txt
7
7
  nmaping.egg-info/dependency_links.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ nmaping = nmaping.nmap:main
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nmaping"
7
- version = "1.9"
7
+ version = "2.1"
8
8
  authors = [
9
9
  { name="Mr. Tan", email="mrtanvai@gmail.com" },
10
10
  ]
11
11
  description = "An automation and network scanning utility tool."
12
12
  readme = "README.md"
13
- requires-python = ">=3.13"
13
+ requires-python = ">=3.9"
14
14
  dependencies = [
15
15
  "requests",
16
16
  ]
@@ -28,8 +28,5 @@ Homepage = "https://github.com/Mr74nX/nmaping"
28
28
  where = ["."]
29
29
  include = ["nmaping*"]
30
30
 
31
- [tool.setuptools.package-data]
32
- nmaping = ["*.so"]
33
-
34
31
  [project.scripts]
35
- nmaping = "nmaping.nmap:menu"
32
+ nmaping = "nmaping.nmap:main"
@@ -1 +0,0 @@
1
- from .nmap import *
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- nmaping = nmaping.nmap:menu
File without changes
File without changes