SnakeScan 1.6.2__tar.gz → 1.6.3__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SnakeScan
3
- Version: 1.6.2
3
+ Version: 1.6.3
4
4
  Summary: IPv4 address scanner for collecting address information.Use carefully for your network safety.Use to get IPV4 from IPV6 address.Don't use it to scan IPV6 because it's not designed for it.
5
5
  Author: Den*Ram
6
6
  Requires-Python: >=3.7
@@ -24,7 +24,6 @@ SnakeScan.run()
24
24
  ## Help
25
25
  - -l need internet to view public ip you device
26
26
  - -t threading port search
27
- - -s single port search
28
27
  - -i information about host
29
28
  - -help in host /-help port in host
30
29
  - -check [host] scan subnet in ip
@@ -43,8 +42,8 @@ SnakeScan.run()
43
42
  ```
44
43
  ## Added CLI command line use snake or Snake
45
44
  ```
46
- usage: Snake [-h] [-sp] [-v] [-i] [-p PORTS] [-s SINGLE]
47
- [-t] [-ch] [-l]
45
+ usage: snake [-h] [-sp] [-v] [-i] [-p PORTS] [-t] [-ch]
46
+ [-l]
48
47
  [host]
49
48
 
50
49
  Snake - It's a command line module SnakeScan. Use him for
@@ -54,16 +53,19 @@ positional arguments:
54
53
  host
55
54
 
56
55
  options:
57
- -h, --help show this help message and exit
58
- -sp, --speed speed scan
59
- -v, --version version
60
- -i, --info ip info
61
- -p, --ports PORTS ports
62
- -s, --single SINGLE single scan
63
- -t, --thread fast scan
64
- -ch, --check scan subnet
65
- -l, --local view you public ip - need internet
56
+ -h, --help show this help message and exit
57
+ -sp, --speed speed scan
58
+ -v, --version version
59
+ -i, --info ip info
60
+ -p, --ports PORTS range ports to scan host
61
+ -t, --thread fast scan
62
+ -ch, --check scan subnet
63
+ -l, --local view you public ip - need internet
66
64
  ```
65
+ ## Attributes
66
+ ```
67
+ --p:snake -p 80,443,3437,20-1000
68
+ --p:[20]-1000 will start from [21]-[1000]
67
69
  ## Added Info about ipv6
68
70
  ```
69
71
  snake 2001:db8:: -i or snake [2001:4860:4860::8888] -i
@@ -9,7 +9,6 @@ SnakeScan.run()
9
9
  ## Help
10
10
  - -l need internet to view public ip you device
11
11
  - -t threading port search
12
- - -s single port search
13
12
  - -i information about host
14
13
  - -help in host /-help port in host
15
14
  - -check [host] scan subnet in ip
@@ -28,8 +27,8 @@ SnakeScan.run()
28
27
  ```
29
28
  ## Added CLI command line use snake or Snake
30
29
  ```
31
- usage: Snake [-h] [-sp] [-v] [-i] [-p PORTS] [-s SINGLE]
32
- [-t] [-ch] [-l]
30
+ usage: snake [-h] [-sp] [-v] [-i] [-p PORTS] [-t] [-ch]
31
+ [-l]
33
32
  [host]
34
33
 
35
34
  Snake - It's a command line module SnakeScan. Use him for
@@ -39,16 +38,19 @@ positional arguments:
39
38
  host
40
39
 
41
40
  options:
42
- -h, --help show this help message and exit
43
- -sp, --speed speed scan
44
- -v, --version version
45
- -i, --info ip info
46
- -p, --ports PORTS ports
47
- -s, --single SINGLE single scan
48
- -t, --thread fast scan
49
- -ch, --check scan subnet
50
- -l, --local view you public ip - need internet
41
+ -h, --help show this help message and exit
42
+ -sp, --speed speed scan
43
+ -v, --version version
44
+ -i, --info ip info
45
+ -p, --ports PORTS range ports to scan host
46
+ -t, --thread fast scan
47
+ -ch, --check scan subnet
48
+ -l, --local view you public ip - need internet
51
49
  ```
50
+ ## Attributes
51
+ ```
52
+ --p:snake -p 80,443,3437,20-1000
53
+ --p:[20]-1000 will start from [21]-[1000]
52
54
  ## Added Info about ipv6
53
55
  ```
54
56
  snake 2001:db8:: -i or snake [2001:4860:4860::8888] -i
@@ -1,4 +1,5 @@
1
1
  import sys
2
+ import string
2
3
  import argparse
3
4
  import socket
4
5
  import ipaddress
@@ -91,7 +92,27 @@ def is_port_open_threads(host, port):
91
92
  print(f"Closed{colored('|X|','red')}-->|{port}|")
92
93
  else:
93
94
  print(f"Open{colored('|√|','green')}-->{ports.get(port)}|{port}|")
94
-
95
+ def Ports(str=""):
96
+ rangeports=[]
97
+ port=[]
98
+ str=str.split(",")
99
+ for p in range(len(str)):
100
+ if "-" in str[p]:
101
+ rangeports.append(str[p])
102
+ else:
103
+ port.append(str[p])
104
+ for n in range(len(port)):
105
+ for i in string.punctuation:
106
+ if i in port[n]:
107
+ port[n]=port[n].replace(i,"")
108
+ for r in range(len(rangeports)):
109
+ rangeport=rangeports[r].split("-")
110
+ try:
111
+ return rangeport,port
112
+ except Exception as e:
113
+ rangeport=""
114
+ return rangeport,port
115
+ sys.exit()
95
116
 
96
117
  def SnakeArgs():
97
118
  parser = argparse.ArgumentParser(
@@ -101,8 +122,7 @@ def SnakeArgs():
101
122
  parser.add_argument("-sp", "--speed", action="store_true", help="speed scan")
102
123
  parser.add_argument("-v", "--version", action="store_true", help="version")
103
124
  parser.add_argument("-i", "--info", action="store_true", help="ip info")
104
- parser.add_argument("-p", "--ports", help="ports")
105
- parser.add_argument("-s", "--single", help="single scan")
125
+ parser.add_argument("-p", "--ports", help="range ports to scan host")
106
126
  parser.add_argument("-t", "--thread", action="store_true", help="fast scan")
107
127
  parser.add_argument("-ch", "--check", action="store_true", help="scan subnet")
108
128
  parser.add_argument(
@@ -138,72 +158,55 @@ if host.startswith("https://"):
138
158
  if host == "None":
139
159
  host = "localhost"
140
160
  if SnakeArgs().ports:
161
+ rangeports,port_user=Ports(port_user)
162
+ for i in range(len(port_user)):
163
+ port_user[i]=int(port_user[i])
164
+ for port in range(len(port_user)):
165
+ if is_port_open(host, port_user[port]):
166
+ print(
167
+ f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
168
+ )
169
+ else:
170
+ try:
171
+ print(
172
+ f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
173
+ )
174
+ except:
175
+ print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
141
176
  try:
142
- length = int(port_user)
143
- except:
144
- port_user = "100"
145
- print(f"{colored('[!]','red')}Port:invalid value")
146
- for i in range(0, len(port_user)):
147
- if port_user[i] == " ":
148
- port_user = 100
149
- port_user = int(port_user)
150
- length = port_user
151
- length = int(length) + 1
152
- for port in tqdm(range(1, length)):
153
- if is_port_open(host, port):
154
- for name in ports:
155
- if port == name:
156
- OpenPorts = [port]
157
- portsopen += 1
158
- else:
159
- portsclosed += 1
160
- if port_user != "":
161
- if int(port_user) == port:
162
- if port_user == "":
163
- pass
164
- elif int(port_user) == port:
165
- if is_port_open(host, port):
166
- Bool = True
167
- boolean += 1
177
+ if int(rangeports[0]) > int(rangeports[1]):
178
+ rangesave1=rangeports[0]
179
+ rangesave2=rangeports[1]
180
+ rangeports[1]=rangesave1
181
+ rangeports[0]=rangesave2
182
+ for port in tqdm(range(int(rangeports[0]) + 1, int(rangeports[1])+1)):
183
+ if is_port_open(host, port):
184
+ for name in ports:
185
+ if port == name:
186
+ OpenPorts = [port]
187
+ portsopen += 1
168
188
  else:
169
- Bool = False
170
- if boolean == 1:
171
- pass
172
- for i in OpenPorts:
173
- print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
174
- print(f"{host}".center(60, "-"))
175
- print(f"Closed{colored('|X|','red')}:{portsclosed}")
176
- portsclosed = 0
177
- print(f"Open{colored('|√|','green')}:{portsopen}")
178
- portsopen = 0
179
- print("-" * 60)
189
+ portsclosed += 1
190
+ if OpenPorts:
191
+ for i in OpenPorts:
192
+ print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
193
+ print(f"{host}".center(60, "-"))
194
+ print(f"Closed{colored('|X|','red')}:{portsclosed}")
195
+ portsclosed = 0
196
+ print(f"Open{colored('|√|','green')}:{portsopen}")
197
+ portsopen = 0
198
+ print("-" * 60)
199
+ else:
200
+ print(f"{host}".center(60, "-"))
201
+ print(f"Closed{colored('|X|','red')}:{portsclosed}")
202
+ portsclosed = 0
203
+ print(f"Open{colored('|√|','green')}:{portsopen}")
204
+ portsopen = 0
205
+ print("-" * 60)
206
+ except Exception as e:
207
+ sys.exit()
180
208
  if SnakeArgs().check:
181
209
  Check_network(host)
182
- if SnakeArgs().single:
183
- port_user = SnakeArgs().single.split(",")
184
-
185
- port_list = port_user
186
- port_user = []
187
- for i in range(len(port_list)):
188
- try:
189
- port_user.append(int(port_list[i]))
190
- except:
191
- print(f"{port_list[i]}-->Invalid value")
192
-
193
- for port in range(len(port_user)):
194
- if is_port_open(host, port_user[port]):
195
- print(
196
- f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
197
- )
198
- else:
199
- try:
200
- print(
201
- f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
202
- )
203
- except:
204
- print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
205
-
206
-
207
210
  if SnakeArgs().local:
208
211
  local = ""
209
212
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -1,14 +1,11 @@
1
1
  import ipaddress
2
2
  import subprocess
3
3
  import platform
4
- from threading import Thread
5
4
  import socket
6
5
  from termcolor import colored
7
-
6
+ from concurrent.futures import ThreadPoolExecutor
8
7
  global threads
9
8
  threads = []
10
-
11
-
12
9
  def Check_network(host):
13
10
  def check_host(host):
14
11
  try:
@@ -28,7 +25,6 @@ def Check_network(host):
28
25
  except Exception as e:
29
26
  print(f"Check error {ip}: {e}")
30
27
  return False
31
-
32
28
  try:
33
29
  print("".center(60, "-"))
34
30
  try:
@@ -48,11 +44,12 @@ def Check_network(host):
48
44
  network_str = network
49
45
  network = ipaddress.ip_network(network_str)
50
46
  print(f"Checking the IP addresses in the subset {network_str}...")
51
- for ip in network.hosts():
52
- t = Thread(target=check_host, kwargs={"host": host})
53
- t.start()
54
- threads.append(t)
55
- for t in threads:
56
- t.join()
47
+ with ThreadPoolExecutor(max_workers=None) as executor:
48
+ try:
49
+ for ip in network.hosts():
50
+ future = executor.submit(check_host, ip)
51
+ future.result()
52
+ except Exception as e:
53
+ print(e)
57
54
  except ValueError as e:
58
55
  print(f"Error creating network object {e}")
@@ -1,6 +1,6 @@
1
1
  """IPv4 address scanner for collecting address information.Use carefully for your network safety.Use to get IPV4 from IPV6 address.Don't use it to scan IPV6 because it's not designed for it. """
2
2
 
3
- __version__ = "1.6.2"
3
+ __version__ = "1.6.3"
4
4
  import socket
5
5
  import ipaddress
6
6
  from art import tprint
@@ -35,11 +35,11 @@ def run():
35
35
  portsopen = 0
36
36
  portsclosed = 0
37
37
  Run_now = True
38
- Bool = True
39
- boolsd = True
38
+
39
+
40
40
  global num
41
41
  num = 0
42
- boolean = 0
42
+
43
43
  OpenPorts = []
44
44
  threads = []
45
45
  ports = {
@@ -84,7 +84,26 @@ def run():
84
84
  8080: "Tomcat",
85
85
  10000: "Webmin",
86
86
  }
87
-
87
+ def Ports(str=""):
88
+ rangeports=[]
89
+ port=[]
90
+ str=str.split(",")
91
+ for p in range(len(str)):
92
+ if "-" in str[p]:
93
+ rangeports.append(str[p])
94
+ else:
95
+ port.append(str[p])
96
+ for n in range(len(port)):
97
+ for i in string.punctuation:
98
+ if i in port[n]:
99
+ port[n]=port[n].replace(i,"")
100
+ for r in range(len(rangeports)):
101
+ rangeport=rangeports[r].split("-")
102
+ try:
103
+ return rangeport,port
104
+ except Exception as e:
105
+ print("Error: invalid value")
106
+ sys.exit()
88
107
  def is_port_open(host, port):
89
108
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
90
109
  try:
@@ -229,33 +248,7 @@ def run():
229
248
  t.start()
230
249
  for t in threads:
231
250
  t.join()
232
- if "-s" in str(port_user):
233
- port_user = port_single.strip("-s")
234
- port_user = port_user.split()
235
- port_list = port_user
236
- port_user = []
237
- for i in range(len(port_list)):
238
- try:
239
- port_user.append(int(port_list[i]))
240
- except:
241
- print(f"{port_list[i]}-->Invalid value")
242
- break
243
- for port in range(len(port_user)):
244
- if is_port_open(host, port_user[port]):
245
- print(
246
- f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
247
- )
248
- else:
249
- try:
250
- print(
251
- f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
252
- )
253
- except:
254
- print(
255
- f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|"
256
- )
257
-
258
- continue
251
+
259
252
 
260
253
  else:
261
254
  if "-t" in port_user:
@@ -274,32 +267,42 @@ def run():
274
267
  length = port_user
275
268
  print(f"{colored('|!|','red')}Listening {host} please wait...")
276
269
  # |----------------starting---------------------|
277
- length = int(length) + 1
278
- for port in tqdm(range(1, length)):
270
+ rangeports,port_user=Ports(port_user)
271
+ for i in range(len(port_user)):
272
+ port_user[i]=int(port_user[i])
273
+ for port in range(len(port_user)):
274
+ if is_port_open(host, port_user[port]):
275
+ print(
276
+ f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
277
+ )
278
+ else:
279
+ try:
280
+ print(
281
+ f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
282
+ )
283
+ except:
284
+ print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
285
+ for port in tqdm(range(int(rangeports[0]), int(rangeports[1])+1)):
279
286
  if is_port_open(host, port):
280
287
  for name in ports:
281
288
  if port == name:
282
289
  OpenPorts = [port]
283
290
  portsopen += 1
284
291
  else:
285
- portsclosed += 1
286
- if port_user != "":
287
- if int(port_user) == port:
288
- if port_user == "":
289
- pass
290
- elif int(port_user) == port:
291
- if is_port_open(host, port):
292
- Bool = True
293
- boolean += 1
294
- else:
295
- Bool = False
296
- if boolean == 1:
297
- pass
298
- for i in OpenPorts:
299
- print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
300
- print(f"{host}".center(60, "-"))
301
- print(f"Closed{colored('|X|','red')}:{portsclosed}")
302
- portsclosed = 0
303
- print(f"Open{colored('|√|','green')}:{portsopen}")
304
- portsopen = 0
305
- print("-" * 60)
292
+ portsclosed += 1
293
+ if OpenPorts:
294
+ for i in OpenPorts:
295
+ print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
296
+ print(f"{host}".center(60, "-"))
297
+ print(f"Closed{colored('|X|','red')}:{portsclosed}")
298
+ portsclosed = 0
299
+ print(f"Open{colored('|√|','green')}:{portsopen}")
300
+ portsopen = 0
301
+ print("-" * 60)
302
+ else:
303
+ print(f"{host}".center(60, "-"))
304
+ print(f"Closed{colored('|X|','red')}:{portsclosed}")
305
+ portsclosed = 0
306
+ print(f"Open{colored('|√|','green')}:{portsopen}")
307
+ portsopen = 0
308
+ print("-" * 60)
File without changes
File without changes