Skip to content

Commit

Permalink
🎃 fix domain
Browse files Browse the repository at this point in the history
  • Loading branch information
j3ers3 committed Jul 26, 2020
1 parent f2f93b4 commit 52ea7c8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
# 🍺 Cscan ![Stage](https://img.shields.io/badge/Release-STABLE-brightgreen.svg) [![Python 3.7](https://img.shields.io/badge/Python-3.7-yellow.svg)](http://www.python.org/download/) ![Build Status](https://img.shields.io/badge/Version-2.0-red.svg)

🔧 一款C段扫描工具,支持python3
🔧 一款C段扫描工具,支持python3.7以上

- ~~V1版本已废弃~~
- V2版本使用协程重构

> 线程过大会导致丢包
## Install
## 1. Install
```
git clone https://github.com/j3ers3/Cscan
pip3 install -r requirement.txt
配置端口
- web端口: Ports_web = [80, 8080]
- 非web端口:Ports_other = [21, 22, 3306]
```

## Usage
- C段扫描
## 2. 配置端口
- web端口: `Ports_web = [80, 8080]`
- 非web端口:`Ports_other = [21, 22, 3306]`

```

## 3. Usage
- C段扫描模式

```python
python3 cscanV2.py -i 192.168.0.1/24 -t 100
```
<img src="./media/15915372292964.jpg" width="500" height="450">


- 域名或ip文件扫描

```
```python
python3 cscanV2.py -f domain.txt -t 100
```
<img src="./media/15915374071366.jpg" width="600" height="400">

## ToDo
## 4. ToDo
- [ ] 优化输出
- [ ] 增加IP反查
27 changes: 20 additions & 7 deletions cscanV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
from time import time
import asyncio
from bs4 import BeautifulSoup


requests.packages.urllib3.disable_warnings()

__author__ = "whois"
__update__ = "2020/06/07"
__version__ = "v2.0.1"
"""
C段扫描,指定web端口和非web端口,获取标题,版本信息
Expand Down Expand Up @@ -62,10 +61,11 @@ def banner():
``:::::::::''""" + yellow + """
================= WEB Info Scan ==================
================= Code by whois ==================
================= Code by {0} ==================
================= {1} ==================
+++++++++++++++++++++++++++++++++++++++++++++++++++++
""" + end)
""".format(__author__, __version__) + end)


def get_info(url):
Expand All @@ -85,13 +85,14 @@ def get_info(url):

return info
except Exception as e:
#print(e)
print(e)
pass


# 将域名转化为ip
def url_to_ip(url):
domain = url.split('/')[0] if '://' not in url else url.split('//')[1].split('/')[0]
domain = domain.split(':')[0] if ':' in domain else domain # fix domain
try:
ip = gethostbyname(domain)
return ip
Expand Down Expand Up @@ -169,6 +170,13 @@ async def scan(mode, x, t):
tasks.append(asyncio.create_task(connet(ip, sem)))
await asyncio.wait(tasks)

'''
文件格式支持ip、域名
1.1.1.1:80
baidu.com:443
http:/1.1.1.1
http://www.baidu.com
'''
if mode == 'file':
with open(x, 'r') as f:
for line in f.readlines():
Expand All @@ -179,12 +187,13 @@ async def scan(mode, x, t):

await asyncio.wait(tasks)

print(blue + "\nFound {0} ports in {1} seconds\n".format(count, time() - time_start))
print(blue + "\nFound {0} in {1} seconds\n".format(count, time() - time_start))



if __name__ == '__main__':
def main():
banner()

parser = argparse.ArgumentParser(
usage='\ncscan -i 192.168.0.1/24 -t 100\ncscan -f url.txt -t 100',
description="CScan V2",
Expand All @@ -210,3 +219,7 @@ async def scan(mode, x, t):

if args.file:
asyncio.run(scan('file', args.file, args.threads))


if __name__ == '__main__':
main()
File renamed without changes.

0 comments on commit 52ea7c8

Please sign in to comment.