-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcoinfo.py
127 lines (111 loc) · 4.79 KB
/
coinfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/python
# coding:utf-8
import requests
import argparse
from collections import namedtuple
class CollectionInfo(object):
"""docstring for CoInfo.
.hg https://github.com/kost/dvcs-ripper
index.bak
index.php.bak
index.php.
.index.php
index.php~
index.pyc
.index.php.swp
.index.php.swpx
.index.php.swm
index.tar.gz
index.rar
index.zip
www.rar
www.zip
.svn https://pan.baidu.com/s/1mrNpB
.git
.DS_Store https://github.com/lijiejie/ds_store_exp
.index.php.swo
.index.php.swn
robots.txt
phpstorm/ .idea/workspace.xml
CVS http://www.am0s.com/CVS/Root 返回根信息 http://www.am0s.com/CVS/Entries 返回所有文件的结构
bk clone http://url/name dir
WEB-INF/web.xml
/WEB-INF/web.xml:Web应用程序配置文件,描述了 servlet 和其他的应用组件配置及命名规则。
/WEB-INF/classes/:含了站点所有用的 class 文件,包括 servlet class 和非servlet class。
/WEB-INF/lib/:存放web应用需要的各种JAR文件,放置仅在这个应用中要求使用的jar文件,如数据库驱动jar文件
/WEB-INF/src/:源码目录,按照包名结构放置各个java文件。
/WEB-INF/database.properties:数据库配置文件。
"""
def __init__(self,url='',file=''):
self.url = url
self.file = file
self.fileBackList = ['.bak','.','~','.pyc','.swp','.swpx','.swm','.swo','.swn']
self.fileList = ['.viminfo','index.bak','index.tar.gz','index.zip','index.rar','www.tar.gz','www.rar','www.zip','.svn','.git','.DS_Store',
'robots.txt','.idea/','.hg','www.7z','WEB-INF/web.xml','WEB-INF/classes/','WEB-INF/lib/','WEB-INF/src/',
'WEB-INF/database.properties','CVS/','CVS/Root','CVS/Entries','phpMyAdmin','phpmyadmin']
self.vimBackList = ['','~','.swp','.swpx','.swm','.swo','.swn']
self.UrlList = []
self.getUrlList()
self.Row = namedtuple("Row",["url","status_code"])
self.table = []
def getUrlList(self):
for file in self.fileBackList:
self.UrlList.append(self.url.rstrip('/')+'/'+self.file+file)
for file in self.fileList:
self.UrlList.append(self.url.rstrip('/')+'/'+file)
for file in self.vimBackList :
self.UrlList.append(self.url.rstrip('/')+'/'+'.'+self.file+file)
def printSelf(self):
for i in self.UrlList:
print(i)
def sendRequest(self,cookies="",agent=""):
cookies = cookies
User_Agent = agent if agent is not "" else "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
header = {
"User-Agent":User_Agent,
"Cookie":cookies
}
for url in self.UrlList:
res = requests.get(url,headers=header)
print(url ,res.status_code)
if res.status_code != 404:
self.table.append(self.Row(url,res.status_code))
def pprinttable(self):
rows = self.table
if len(rows) > 0:
headers = rows[0]._fields
lens = []
for i in range(len(rows[0])):
lens.append(len(max([x[i] for x in rows] + [headers[i]],key=lambda x:len(str(x)))))
formats = []
hformats = []
for i in range(len(rows[0])):
if isinstance(rows[0][i], int):
formats.append("%%%dd" % lens[i])
else:
formats.append("%%-%ds" % lens[i])
hformats.append("%%-%ds" % lens[i])
pattern = " | ".join(formats)
hpattern = "|"+" | ".join(hformats)+"|"
separator = "+"+"-+-".join(['-' * n for n in lens])+"+"
print(separator)
print(hpattern % tuple(headers))
print(separator)
_u = lambda t: t.decode('UTF-8', 'replace') if isinstance(t, str) else t
for line in rows:
# print separator
print(hpattern % tuple(t for t in line))
print(separator)
# elif len(rows) == 1:
# row = rows[0]
# hwidth = len(max(row._fields,key=lambda x: len(x)))
# for i in range(len(row)):
# print "%*s = %s" % (hwidth,row._fields[i],row[i])
if __name__ == '__main__':
parse = argparse.ArgumentParser("python coinfo.py")
parse.add_argument("-u",'--url',required=True,type=str,default='',help="The start url to find back files.")
parse.add_argument('-f','--file',type=str,default='index.php',help='The file name to find!')
args = parse.parse_args()
coll = CollectionInfo(args.url,args.file)
coll.sendRequest()
coll.pprinttable()