Skip to content

Commit

Permalink
修复数组越界问题
Browse files Browse the repository at this point in the history
  • Loading branch information
paradiseduo authored Nov 24, 2021
1 parent 82ce4ad commit 553c880
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions lib/Android/IPCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@ def scan(self):
continue
ip = item.strip().split(':')[-1]
arr = str(ip).split('.')
if arr[0].startswith('0') and len(arr[0]) > 1 \
or arr[1].startswith('0') and len(arr[1]) > 1 \
or arr[2].startswith('0') and len(arr[2]) > 1 \
or arr[3].startswith('0') and len(arr[3]) > 1:
continue
# 排除小于10开头的,大概率是版本号,不是IP
if len(arr[0]) == 1 and int(arr[0]) < 10:
continue
# 排除255开头的,忽略掩码地址
if len(arr[0]) == 3 and int(arr[0]) == 255:
continue
if ip not in ips:
ips.append(ip)
if len(arr) == 4:
if arr[0].startswith('0') and len(arr[0]) > 1 \
or arr[1].startswith('0') and len(arr[1]) > 1 \
or arr[2].startswith('0') and len(arr[2]) > 1 \
or arr[3].startswith('0') and len(arr[3]) > 1:
continue
# 排除小于10开头的,大概率是版本号,不是IP
if len(arr[0]) == 1 and int(arr[0]) < 10:
continue
# 排除255开头的,忽略掩码地址
if len(arr[0]) == 3 and int(arr[0]) == 255:
continue
if ip not in ips:
ips.append(ip)
Info(key=self.__class__, title=TITLE, level=LEVEL, info=INFO, result='\n'.join(ips)).description()


register(IPCheck)
register(IPCheck)

0 comments on commit 553c880

Please sign in to comment.