Skip to content

Commit

Permalink
add extentd fuction
Browse files Browse the repository at this point in the history
  • Loading branch information
sowish committed Aug 3, 2016
1 parent 027a7a3 commit c9346a2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 94 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/
report/*.html
report/*.html
*.pyc
87 changes: 0 additions & 87 deletions 1.txt

This file was deleted.

33 changes: 32 additions & 1 deletion LNScan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def parse_args():
parser.add_argument('--ip', type=str, help='ip addresses like 192.168.1.1/24')
parser.add_argument('--port', type=str, default='', help='user single quotes to split the ports,\
like 80,21, default 8 ports')
parser.add_argument('--extend', type=str, default='', help='extend the given ips by ip masks ,such as "30"')
if len(sys.argv) == 1:
sys.argv.append('-h')
_args = parser.parse_args()
Expand Down Expand Up @@ -136,12 +137,43 @@ def scan(url, s_results, _ports, _lock):
s_results.put((_results, _hosts))


def ip_into_int(ip):
# (((((192 * 256) + 168) * 256) + 1) * 256) + 13
return reduce(lambda x, y: (x << 8)+y, map(int, ip.split('.')))


def is_internal_ip(ip):
if ip == '127.0.0.1':
return True
ip = ip_into_int(ip)
net_a = ip_into_int('10.255.255.255') >> 24
net_b = ip_into_int('172.31.255.255') >> 20
net_c = ip_into_int('192.168.255.255') >> 16
return ip >> 24 == net_a or ip >> 20 == net_b or ip >> 16 == net_c


def ip_extend(ini_list, extend):
print "domains are been extended..."
extend_all_ips = []
for _domain in ini_list:
ip = socket.gethostbyname(_domain)
if is_internal_ip(ip):
continue
__ip = ip+"/"+extend
extend_ips = ip_parse(__ip)
extend_all_ips += extend_ips
extend_last_ips = list(set(ini_list + extend_all_ips))
return extend_last_ips


if __name__ == '__main__':
args = parse_args()
if args.ip:
ip_lists = ip_parse(args.ip)
else:
ip_lists = ip_revive(args.f)
if args.extend:
ip_lists = ip_extend(ip_lists, args.extend)
ports = args.port
if ports:
ports = ports.split(',')
Expand All @@ -157,7 +189,6 @@ def scan(url, s_results, _ports, _lock):
s_results, s_hosts = ip_Queue.get()
ip_info = dict(ip_info, **s_results)
next_ips += s_hosts

q_results = multiprocessing.Manager().Queue() # start BBScan
lock = multiprocessing.Manager().Lock()
pool = multiprocessing.Pool(10)
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LNScan(Local Network Scanner),作为一个内部网络扫描器,仅是为了
- 支持指定ip段,或者文件导入(ip/域名)
- 敏感文件扫描支持多web端口
- 扫描结束后生成格式鲜明的html报告,方便查看
- 支持自定义扩展每个导入ip/doamin,如"--extentd 30",则扩展成4个

#### Usage

Expand All @@ -17,11 +18,12 @@ A WebScanner to scan local network.
By wps2015(http://wps2015.org)

optional arguments:
-h, --help show this help message and exit
-v show program's version number and exit
-f F import the file of ip/domain list
--ip IP ip addresses like 192.168.1.1/24
--port PORT user single quotes to split the ports,like 80,21, default 8 ports
-h, --help show this help message and exit
-v show program's version number and exit
-f F import the file of ip/domain list
--ip IP ip addresses like 192.168.1.1/24
--port PORT user single quotes to split the ports, like 80,21, default 8 ports
--extend EXTEND extend the given ips by ip masks ,such as "30"
```
#### Other
if you have any bug , please remind me in the Issues.

0 comments on commit c9346a2

Please sign in to comment.