diff --git a/.gitignore b/.gitignore index 53ae117..857c6ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea/ -report/*.html \ No newline at end of file +report/*.html +*.pyc \ No newline at end of file diff --git a/1.txt b/1.txt deleted file mode 100644 index c83880f..0000000 --- a/1.txt +++ /dev/null @@ -1,87 +0,0 @@ -mail.rajax.me -pop.rajax.me -smtp.rajax.me -imap.rajax.me -email.rajax.me -portal.rajax.me -crm.rajax.me -sso.rajax.me -ads.rajax.me -im.rajax.me -mdm.rajax.me -pms.rajax.me -voip.rajax.me -act.rajax.me -int.rajax.me -pan.rajax.me -tl.rajax.me -fast.rajax.me -tss.rajax.me -visit.rajax.me -ehr.rajax.me -imt.rajax.me -prm.rajax.me -tos.rajax.me -wim.rajax.me -itsm.rajax.me -workflow.rajax.me -zc.ele.me -www.ele.me -venus.ele.me -v5.ele.me -v.ele.me -static2.ele.me -static.ele.me -sso.ele.me -smtp.ele.me -sms.ele.me -sip.ele.me -shop.ele.me -security.ele.me -sales.ele.me -s.ele.me -r.ele.me -pop.ele.me -ping.ele.me -pay.ele.me -pandora.ele.me -p.ele.me -openapi.ele.me -oauth.ele.me -mx2.ele.me -mx1.ele.me -mir.ele.me -mars.ele.me -marketing.ele.me -mail.ele.me -m.ele.me -lyncdiscover.ele.me -jobs.ele.me -imap.ele.me -huodong.ele.me -h5.ele.me -h.ele.me -grand.ele.me -games.ele.me -fe.ele.me -fbs.ele.me -fast.ele.me -family.ele.me -es.ele.me -email.ele.me -em.ele.me -ehr.ele.me -ef.ele.me -echo.ele.me -ea.ele.me -download.ele.me -docs.ele.me -dl.ele.me -coco.ele.me -bam.ele.me -autodiscover.ele.me -apollo.ele.me -api.ele.me -activity.ele.me -account.ele.me -18.ele.me diff --git a/LNScan.py b/LNScan.py index d2bcbe2..74c923d 100644 --- a/LNScan.py +++ b/LNScan.py @@ -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() @@ -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(',') @@ -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) diff --git a/README.md b/README.md index 081b4d9..5223a50 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ LNScan(Local Network Scanner),作为一个内部网络扫描器,仅是为了 - 支持指定ip段,或者文件导入(ip/域名) - 敏感文件扫描支持多web端口 - 扫描结束后生成格式鲜明的html报告,方便查看 +- 支持自定义扩展每个导入ip/doamin,如"--extentd 30",则扩展成4个 #### Usage @@ -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.