Skip to content

Commit

Permalink
Crowbar
Browse files Browse the repository at this point in the history
Crowbar
  • Loading branch information
galkan committed Oct 1, 2014
1 parent 3283e5a commit 3dfff03
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 20 deletions.
78 changes: 59 additions & 19 deletions lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def __init__(self):
print >> sys.stderr, err
sys.exit(1)


self.ip_list = []

if self.args.discover:
Expand Down Expand Up @@ -191,8 +190,7 @@ def openvpn(self):


if self.args.discover:
result = self.nmap.port_scan(self.args.server, port)
self.ip_list = result
self.ip_list = self.nmap.port_scan(self.args.server, port)


try:
Expand All @@ -208,9 +206,21 @@ def openvpn(self):

for ip in self.ip_list:
if self.args.username_file:
for user in open(self.args.username_file, "r").read().splitlines():
try:
userfile = open(self.args.username_file, "r").read().splitlines()
except:
print >> sys.stderr, "File: %s doesn't exists !!!"% self.args.username_file
sys.exit(1)

for user in userfile:
if self.args.passwd_file:
for password in open(self.args.passwd_file, "r").read().splitlines():
try:
passwdfile = open(self.args.passwd_file, "r").read().splitlines()
except:
print >> sys.stderr, "File: %s doesn't exists !!!"% self.args.passwd_file
sys.exit(1)

for password in passwdfile:
brute_file = tempfile.NamedTemporaryFile(mode='w+t')
brute_file.write(user + "\n")
brute_file.write(password + "\n")
Expand All @@ -222,7 +232,13 @@ def openvpn(self):
pool.add_task(self.openvpnlogin, ip, user, self.args.passwd, brute_file, port)
else:
if self.args.passwd_file:
for password in open(self.args.passwd_file, "r").read().splitlines():
try:
passwdfile = open(self.args.passwd_file, "r").read().splitlines()
except:
print >> sys.stderr, "File: %s doesn't exists !!!"% self.args.passwd_file
sys.exit(1)

for password in passwdfile:
brute_file = tempfile.NamedTemporaryFile(mode='w+t')
brute_file.write(self.args.username + "\n")
brute_file.write(password + "\n")
Expand Down Expand Up @@ -265,8 +281,8 @@ def vnckey(self, *options):
port = self.args.port

if self.args.discover:
result = self.nmap.port_scan(self.args.server, port)
self.ip_list = result
self.ip_list = self.nmap.port_scan(self.args.server, port)


if not os.path.isfile(self.args.passwd_file):
print >> sys.stderr, "Password file doesn't exists !!!"
Expand Down Expand Up @@ -315,27 +331,44 @@ def rdp(self):
port = self.args.port

if self.args.discover:
result = self.nmap.port_scan(self.args.server, port)
self.ip_list = result
self.ip_list = self.nmap.port_scan(self.args.server, port)


try:
pool = ThreadPool(int(self.args.thread))
except Exception, err:
print >> sys.stderr, err
sys.exit(1)


for ip in self.ip_list:
if self.args.username_file:
for user in open(self.args.username_file, "r").read().splitlines():
if self.args.passwd_file:
for password in open(self.args.passwd_file, "r").read().splitlines():
try:
userfile = open(self.args.username_file, "r").read().splitlines()
except:
print >> sys.stderr, "File: %s doesn't exists !!!"% self.args.username_file
sys.exit(1)

for user in userfile:
if self.args.passwd_file:
try:
passwdfile = open(self.args.passwd_file, "r").read().splitlines()
except:
print >> sys.stderr, "File: %s doesn't exists"% self.args.passwd_file
sys.exit(1)

for password in passwdfile:
pool.add_task(self.rdplogin, ip, user, password, port)
else:
pool.add_task(self.rdplogin, ip, user, self.args.passwd, port)
else:
if self.args.passwd_file:
for password in open(self.args.passwd_file, "r").read().splitlines():
try:
passwdfile = open(self.args.passwd_file, "r").read().splitlines()
except:
print >> sys.stderr, "File: %s doesn't exists"% self.args.passwd_file
sys.exit(1)

for password in passwdfile:
pool.add_task(self.rdplogin, ip, self.args.username, password, port)
else:
pool.add_task(self.rdplogin, ip, self.args.username, self.args.passwd, port)
Expand Down Expand Up @@ -373,18 +406,24 @@ def sshkey(self):
port = self.args.port

if self.args.discover:
result = self.nmap.port_scan(self.args.server, port)
self.ip_list = result
self.ip_list = self.nmap.port_scan(self.args.server, port)

try:
pool = ThreadPool(self.args.thread)
except Exception, err:
print >> sys.stderr, err
sys.exit(1)


for ip in self.ip_list:
if self.args.username_file:
for user in open(self.args.username_file, "r").read().splitlines():
try:
userfile = open(self.args.username_file, "r").read().splitlines()
except:
print >> sys.stderr, "File: %s doesn't exists !!!"% self.args.username_file
sys.exit(1)

for user in userfile:
if os.path.isdir(self.args.key_file):
for dirname, dirnames, filenames in os.walk(self.args.key_file):
for keyfile in filenames:
Expand Down Expand Up @@ -419,7 +458,8 @@ def run(self, brute_type):
if Main.is_success == 0:
print "No result is found ..."




def signal_handler(self, signal, frame):

print('Exit ...')
Expand Down
2 changes: 1 addition & 1 deletion lib/nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def port_scan(self, ip_list, port):

proc = subprocess.Popen([run_nmap], shell = True, stdout = subprocess.PIPE,)
stdout_value = str(proc.communicate())

for line in open(tmpfile_name,"r"):
if re.search(open_port, line):
ip = line[:-1].split(" ")[1]
Expand Down

0 comments on commit 3dfff03

Please sign in to comment.