SnakeScan 1.9.4__tar.gz → 1.9.5__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,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SnakeScan
3
- Version: 1.9.4
3
+ Version: 1.9.5
4
4
  Summary: Unlock the potential of your network with this powerful IPv4 address scanner. Easily scan IP address ranges, identify active hosts, and even extract IPv4 addresses from IPv6 environments. Enhance your network monitoring, troubleshooting, and security analysis!
5
5
  Author: Den*Ram
6
6
  Requires-Python: >=3.7
7
7
  Description-Content-Type: text/markdown
8
8
  License-Expression: MIT
9
9
  License-File: LICENSE
10
- Requires-Dist: art
11
10
  Requires-Dist: tqdm
12
11
  Requires-Dist: termcolor
13
12
 
@@ -139,5 +138,5 @@ watcher.start() # Start monitoring!
139
138
 
140
139
  ---
141
140
 
142
- **Last Updated:** 1.9.4 (Bugs fix)
141
+ **Last Updated:** 1.9.5 (Added more detailed documentation when using the -h, --help argument, and an update will soon be available that will allow saving port information to a json file.)
143
142
 
@@ -126,4 +126,4 @@ watcher.start() # Start monitoring!
126
126
 
127
127
  ---
128
128
 
129
- **Last Updated:** 1.9.4 (Bugs fix)
129
+ **Last Updated:** 1.9.5 (Added more detailed documentation when using the -h, --help argument, and an update will soon be available that will allow saving port information to a json file.)
@@ -1,26 +1,32 @@
1
1
  import os
2
- import asyncio
3
- import configparser
4
- from pathlib import Path
5
- import json
6
2
  import sys
3
+ import json
7
4
  import string
8
- import argparse
9
5
  import socket
6
+ import asyncio
7
+ import argparse
10
8
  import ipaddress
11
- from art import tprint
9
+ import configparser
10
+ from re import compile
11
+ from tqdm import tqdm
12
+ from pathlib import Path
13
+ from threading import Thread
12
14
  from termcolor import colored
13
15
  from concurrent.futures import ThreadPoolExecutor
14
- from threading import Thread
15
- from tqdm import tqdm
16
16
  from SnakeScan.Check_subnet import Check_network
17
17
  from SnakeScan.Get_ssl import Get_ssl
18
18
 
19
+ save_port_stats = []
20
+ save = False
21
+
22
+ hosts = compile(r"http://|https://|http:|https:")
23
+
19
24
  excepthost = []
20
25
  OpenPorts = []
21
26
  threads = []
22
27
  portsopen = 0
23
28
  portsclosed = 0
29
+
24
30
  ports = {
25
31
  7: "ECHO",
26
32
  9: "DISCARD",
@@ -79,21 +85,26 @@ ports = {
79
85
 
80
86
 
81
87
  async def is_port_open_async(host, port):
88
+ if save:
89
+ port_stats = {"ip": "", "port": "", "service": "", "status": "", "type": "tcp"}
90
+ port_stats.update({"ip": host, "port": port})
82
91
  try:
83
92
  reader, writer = await asyncio.wait_for(
84
93
  asyncio.open_connection(host, port), timeout=1
85
94
  )
86
95
  except (OSError, asyncio.TimeoutError):
87
96
  try:
88
- print(
89
- f"Closed\033[31m|X|\033[0m-->\033[91m{ports.get(port)}\033[0m\033[31m|{port}|\033[0m"
90
- )
97
+ print(f"{ports.get(port)} -> {colored('|X|','red')} -> {f'{port}'}")
91
98
  except Exception:
92
- print(f"Closed\033[31m|X|\033[0m-->\033[31m|{port}|\033[0m")
99
+ print(f"{colored(f'{port}','red')}-->{colored(f'|X|','red')}")
100
+ if save:
101
+ port_stats.update({"status": "Close", "service": ports.get(port)})
102
+ save_port_stats.append(port_stats)
93
103
  else:
94
- print(
95
- f"Open\033[32m|√|\033[0m-->\033[92m{ports.get(port)}\033[0m\033[32m|{port}|\033[0m"
96
- )
104
+ print(f"{ports.get(port)} -> {colored('|√|','green')} -> {f'{port}'}")
105
+ if save:
106
+ port_stats.update({"status": "Open", "service": ports.get(port)})
107
+ save_port_stats.append(port_stats)
97
108
  writer.close()
98
109
  await writer.wait_closed()
99
110
 
@@ -217,36 +228,50 @@ else:
217
228
  if __name__ == "__main__":
218
229
  main()
219
230
 
220
- version = "1.9.4"
231
+ version = "1.9.5"
221
232
 
222
233
 
223
234
  def is_port_open(host, port):
235
+ if save:
236
+ port_stats = {"ip": "", "port": "", "service": "", "status": "", "type": "tcp"}
237
+ port_stats.update({"ip": host, "port": port})
224
238
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
225
239
  try:
226
240
  s.settimeout(1)
227
241
  s.connect((host, port))
228
242
  except (OSError, socket.timeout):
243
+ if save:
244
+ port_stats.update({"status": "Close", "service": ports.get(port)})
245
+ save_port_stats.append(port_stats)
229
246
  return False
230
247
  else:
248
+ if save:
249
+ port_stats.update({"status": "Open", "service": ports.get(port)})
250
+ save_port_stats.append(port_stats)
231
251
  return True
232
252
 
233
253
 
234
254
  def is_port_open_threads(host, port):
255
+ if save:
256
+ port_stats = {"ip": "", "port": "", "service": "", "status": "", "type": "tcp"}
257
+ port_stats.update({"ip": host, "port": port})
235
258
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
236
259
  try:
237
260
  s.settimeout(1)
238
261
  s.connect((host, port))
239
262
  except (OSError, socket.timeout):
263
+ if save:
264
+ port_stats.update({"status": "Close", "service": ports.get(port)})
265
+ save_port_stats.append(port_stats)
240
266
  try:
241
- print(
242
- f"Closed{colored('|X|','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')}"
243
- )
267
+ print(f"{ports.get(port)} -> {colored('|X|','red')} -> {f'{port}'}")
244
268
  except Exception as e:
245
- print(f"Closed{colored('|X|','red')}-->{colored(f'|{port}|','red')}")
269
+ print(f"{colored(f'{port}','red')}-->{colored(f'|X|','red')}")
246
270
  else:
247
- print(
248
- f"Open{colored('|√|','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')}"
249
- )
271
+ if save:
272
+ port_stats.update({"status": "Open", "service": ports.get(port)})
273
+ save_port_stats.append(port_stats)
274
+ print(f"{ports.get(port)} -> {colored('|√|','green')} -> {f'{port}'}")
250
275
 
251
276
 
252
277
  def Ports(str=""):
@@ -278,60 +303,83 @@ def Ports(str=""):
278
303
 
279
304
  def SnakeArgs():
280
305
  parser = argparse.ArgumentParser(
281
- description="SnakeScan - It's a command line library for scan and get information about ip."
306
+ description="SnakeScan is a command library / tool for performing port monitoring and maintenance tasks on the target system, it provides the ability to provide reliable protection against any threatening factors that can harm the user's system."
282
307
  )
283
308
  parser.add_argument("host", nargs="?", default="None")
284
309
  parser.add_argument(
285
310
  "-a",
286
311
  "--asynchrous",
287
312
  action="store_true",
288
- help="Use scan with asyncio",
313
+ help="Use only for Asynchronous scanning. **WARNING: uses only TCP type of ports.",
289
314
  )
290
315
  parser.add_argument(
291
316
  "-home",
292
317
  "--homedir",
293
318
  action="store_true",
294
- help="Show path to SnakeScan home directory",
319
+ help="Shows the path to the program folder that is used to store and use your own data. **Even after deleting, this folder will be created again. You can only transfer the data that it can read and use to the folder.",
295
320
  )
296
321
  parser.add_argument(
297
322
  "-d",
298
323
  "--dictonary",
299
324
  required=False,
300
325
  default="None",
301
- help="Use custom port dictionaries",
326
+ help="Specify the path to your own custom dictionaries with ports designations. **JSON format. Example: -d myFolder/tcp_ports.json,myFolder/udp_ports **Order: 1(TCP ports), 2(UDP ports). **WARNING: do not change the order, because this will lead to confusing the program and its incorrect operation. **Way to solve the problem: Use the -dr command to clear the paths you specified earlier.",
302
327
  )
303
328
  parser.add_argument(
304
- "-u", "--udp", action="store_true", help="Use UDP ports for scanning"
329
+ "-u",
330
+ "--udp",
331
+ action="store_true",
332
+ help="Changes the port type for all types of scanning to UDP. **WARNING: Does not change the port type for such scanning types: -A(Asynchronous), since only TCP port type is used.",
305
333
  )
306
334
  parser.add_argument(
307
335
  "-ds",
308
336
  "--dictshow",
309
337
  action="store_true",
310
- help="Shows paths to port dictionaries",
338
+ help="Displays paths to custom port dictionaries. **WARNING: Use if you need paths to your dictionaries.",
311
339
  )
312
340
  parser.add_argument(
313
341
  "-dr",
314
342
  "--dictremove",
315
343
  action="store_true",
316
- help="Removes user port dictionaries",
344
+ help="Removes custom port dictionaries from the program. **WARNING: Does not remove custom port dictionaries. **If you need to remove it, remove it manually.",
345
+ )
346
+ parser.add_argument(
347
+ "-gs",
348
+ "--getssl",
349
+ action="store_true",
350
+ help="Use to obtain an official SSL site certificate. **WARNING: Use to find the SSL certificate of the site you want.",
351
+ )
352
+ parser.add_argument(
353
+ "-v",
354
+ "--version",
355
+ action="store_true",
356
+ help="Use to find out the library version.",
317
357
  )
318
358
  parser.add_argument(
319
- "-gs", "--getssl", action="store_true", help="Get official ssl certificate"
359
+ "-i",
360
+ "--info",
361
+ action="store_true",
362
+ help="Use to collect host IP information. **Type, Version, Network, Subnet mask, Host, IP-address.",
363
+ )
364
+ parser.add_argument(
365
+ "-p",
366
+ "--ports",
367
+ help="Use to enter a range of ports. **Example: -p 10-20, -p 20-30,40-60, -p 100.",
320
368
  )
321
- parser.add_argument("-v", "--version", action="store_true", help="Library version")
322
369
  parser.add_argument(
323
- "-i", "--info", action="store_true", help="IP information about host"
370
+ "-t",
371
+ "--thread",
372
+ action="store_true",
373
+ help="Use to scan only with using ThreadPoolExecutor. **WARNING: If you use it in a place with the -u argument, then this will change the type of scanned ports to UDP.",
324
374
  )
325
- parser.add_argument("-p", "--ports", help="Range ports to scan host")
326
375
  parser.add_argument(
327
- "-t", "--thread", action="store_true", help="Scan with using ThreadPoolExecutor"
376
+ "-ch", "--check", action="store_true", help="Use to scan the IP subnet."
328
377
  )
329
- parser.add_argument("-ch", "--check", action="store_true", help="Scan ip subnet")
330
378
  parser.add_argument(
331
379
  "-l",
332
380
  "--local",
333
381
  action="store_true",
334
- help="View you public ip - need internet",
382
+ help="Use to view your current public IP address. **WARNING: To use this argument, you need to connect to the network to accurately determine the public address.",
335
383
  )
336
384
  args = parser.parse_args()
337
385
  return args
@@ -341,25 +389,7 @@ port_user = SnakeArgs().ports
341
389
  host = SnakeArgs().host.split(",")
342
390
  filepath = SnakeArgs().dictonary.split(",")
343
391
  for n in range(len(host)):
344
- if host[n].startswith("http://"):
345
- host[n] = host[n].strip()
346
- host[n] = host[n].split("http:")
347
- host[n] = host[n][1].strip("//")
348
- host[n] = host[n].split("/")
349
- host[n] = host[n][0]
350
- for i in range(len(host)):
351
- if host[n][i] == "/":
352
- host[n] = host[n][0:i]
353
- for n in range(len(host)):
354
- if host[n].startswith("https://"):
355
- host[n] = host[n].strip()
356
- host[n] = host[n].split("https:")
357
- host[n] = host[n][1].strip("//")
358
- host[n] = host[n].split("/")
359
- host[n] = host[n][0]
360
- for i in range(len(host)):
361
- if host[n][i] == "/":
362
- host[n] = host[n][0:i]
392
+ host[n] = hosts.sub("", host[n])
363
393
  if host[0] == "None":
364
394
  host[0] = "localhost"
365
395
  if filepath[0] != "None":
@@ -373,6 +403,15 @@ if filepath[0] != "None":
373
403
  if SnakeArgs().udp:
374
404
 
375
405
  def is_port_open(host, port, timeout=1):
406
+ if save:
407
+ port_stats = {
408
+ "ip": "",
409
+ "port": "",
410
+ "service": "",
411
+ "status": "",
412
+ "type": "udp",
413
+ }
414
+ port_stats.update({"ip": host, "port": port})
376
415
  try:
377
416
  sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
378
417
  sock.settimeout(timeout)
@@ -384,10 +423,19 @@ if SnakeArgs().udp:
384
423
  try:
385
424
  data, server = sock.recvfrom(4096)
386
425
  print(f"Response received: {data.decode()} from {server}")
426
+ if save:
427
+ port_stats.update({"status": "Open", "service": ports.get(port)})
428
+ save_port_stats.append(port_stats)
387
429
  is_open = True
388
430
  except socket.timeout:
431
+ if save:
432
+ port_stats.update({"status": "Close", "service": ports.get(port)})
433
+ save_port_stats.append(port_stats)
389
434
  is_open = False
390
435
  except ConnectionRefusedError:
436
+ if save:
437
+ port_stats.update({"status": "Close", "service": ports.get(port)})
438
+ save_port_stats.append(port_stats)
391
439
  is_open = False
392
440
 
393
441
  sock.close()
@@ -397,8 +445,21 @@ if SnakeArgs().udp:
397
445
  return None
398
446
  except socket.error as e:
399
447
  return False
448
+ else:
449
+ if save:
450
+ port_stats.update({"status": "Close", "service": ports.get(port)})
451
+ save_port_stats.append(port_stats)
400
452
 
401
453
  def is_port_open_threads(host, port, timeout=1):
454
+ if save:
455
+ port_stats = {
456
+ "ip": "",
457
+ "port": "",
458
+ "service": "",
459
+ "status": "",
460
+ "type": "udp",
461
+ }
462
+ port_stats.update({"ip": host, "port": port})
402
463
  try:
403
464
  sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
404
465
  sock.settimeout(timeout)
@@ -410,19 +471,26 @@ if SnakeArgs().udp:
410
471
  try:
411
472
  data, server = sock.recvfrom(4096)
412
473
  print(f"Response received: {data.decode()} from {server}")
413
- print(
414
- f"Open{colored('[√]','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')}"
415
- )
474
+ print(f"{ports.get(port)} -> {colored('|√|','green')} -> {f'{port}'}")
475
+ if save:
476
+ port_stats.update({"status": "Open", "service": ports.get(port)})
477
+ save_port_stats.append(port_stats)
416
478
  except socket.timeout:
417
- print(
418
- f"Closed{colored('[X]','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')}"
419
- )
479
+ print(f"{ports.get(port)} -> {colored('|X|','red')} -> {f'{port}'}")
420
480
  except ConnectionRefusedError:
421
481
  sock.close()
482
+ else:
483
+ if save:
484
+ port_stats.update({"status": "Close", "service": ports.get(port)})
485
+ save_port_stats.append(port_stats)
422
486
  except socket.gaierror:
423
487
  pass
424
488
  except socket.error as e:
425
489
  pass
490
+ else:
491
+ if save:
492
+ port_stats.update({"status": "Close", "service": ports.get(port)})
493
+ save_port_stats.append(port_stats)
426
494
 
427
495
  if ports_udp:
428
496
  ports = ports_udp
@@ -566,18 +634,12 @@ if SnakeArgs().ports:
566
634
  OpenPorts = []
567
635
  for port in range(len(port_user)):
568
636
  if is_port_open(host[n], port_user[port]):
569
- print(
570
- f"Open{colored('|√|','green')}{host[n]}-->{colored(f'{str(ports.get(port_user[port],''))}','light_green')}{colored(f'|{port_user[port]}|','green')}"
571
- )
637
+ print(f"{ports.get(port)} -> {colored('|√|','green')} -> {f'{port}'}")
572
638
  else:
573
639
  try:
574
- print(
575
- f"Closed{colored('|X|','red')}{host[n]}-->{colored(str(ports.get(port_user[port],'')),'light_red')}{colored(f'|{port_user[port]}|','red')}"
576
- )
640
+ print(f"{ports.get(port)} -> {colored('|X|','red')} -> {f'{port}'}")
577
641
  except:
578
- print(
579
- f"Closed{colored('|X|','red')}{host[n]}-->{colored(f'|{port_user[port]}|','red')}"
580
- )
642
+ print(f"{colored(f'{port}','red')}-->{colored(f'|X|','red')}")
581
643
  try:
582
644
  first = rangeports[::2]
583
645
  second = rangeports[1::2]
@@ -598,7 +660,7 @@ if SnakeArgs().ports:
598
660
  portsclosed += 1
599
661
  if OpenPorts:
600
662
  for i in OpenPorts:
601
- print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
663
+ print(f"{ports[i]} -> {colored('|√|','green')} -> {f'{i}'}")
602
664
  print(f"Closed{colored('|X|','red')}:{max(0,portsclosed - 1)}")
603
665
  print(f"Open{colored('|√|','green')}:{portsopen}")
604
666
  portsopen = 0
@@ -726,6 +788,7 @@ if SnakeArgs().version:
726
788
  if SnakeArgs().homedir:
727
789
  try:
728
790
  home = Path.home() / "SnakeScan"
791
+ home = home.expanduser()
729
792
  print(f"SnakeScan home directory: {home}")
730
793
  except Exception as e:
731
794
  print(e)
@@ -20,10 +20,10 @@ def Check_network(host):
20
20
  command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
21
21
  )
22
22
  if result.returncode == 0:
23
- print(f"{ip}-->{colored('|√|','green')}")
23
+ print(f"{ip}-->{colored(f'{result.stdout}','green')}")
24
24
  return True
25
25
  else:
26
- print(f"{ip}-->{colored('|X|','red')}")
26
+ print(f"{ip}-->{colored(f'{result.stdout}','red')}")
27
27
  return False
28
28
  except Exception as e:
29
29
  print(f"Check error {ip}: {e}")
@@ -1,6 +1,6 @@
1
1
  """Unlock the potential of your network with this powerful IPv4 address scanner. Easily scan IP address ranges, identify active hosts, and even extract IPv4 addresses from IPv6 environments. Enhance your network monitoring, troubleshooting, and security analysis!"""
2
2
 
3
- __version__ = "1.9.4"
3
+ __version__ = "1.9.5"
4
4
  import socket
5
5
  from time import sleep
6
6
  from termcolor import colored
@@ -12,7 +12,6 @@ license = "MIT"
12
12
  license-files = ["LICENSE"]
13
13
  dynamic = ["version","description"]
14
14
  dependencies = [
15
- "art",
16
15
  "tqdm",
17
16
  "termcolor",
18
17
  ]
File without changes