rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
filepath = os.path.join(env.ARCHIVE_OUTPUT_DIR, "eagle3d_"+self.version_to_filename(version)+".tar.gz")
filepath = os.path.join(env.ARCHIVE_OUTPUT_DIR, "eagle3d_"+release_safename+".tar.gz")
def release(self): quiet = config._get('quiet') version = config._get('version')
_bin = False _bin = config._getbin('todos') if not _bin: _bin = config._getbin('unix2dos') if _bin:
_unix2dos = False _unix2dos = config._getbin('todos') if not _unix2dos: _unix2dos = config._getbin('unix2dos') if _unix2dos:
def release(self): quiet = config._get('quiet') version = config._get('version')
subprocess_call([_bin, filepath])
retcode = subprocess_call([_unix2dos, filepath])
def release(self): quiet = config._get('quiet') version = config._get('version')
filepath = os.path.join(env.ARCHIVE_OUTPUT_DIR, "eagle3d_"+version_to_filename(version)+".zip")
filepath = os.path.join(env.ARCHIVE_OUTPUT_DIR, "eagle3d_"+release_safename+".zip")
def release(self): quiet = config._get('quiet') version = config._get('version')
parser.print_help()
optparser.parser.print_help()
def renderhtml(self):
command = """%CONVERT_BIN% -geometry %THUMB_SIZE_X%x%THUMB_SIZE_X% %THUMB_INPUT_FILEPATH% %THUMBNAIL_OUTPUT_FILEPATH%"""
command = """%CONVERT_BIN% -geometry %THUMB_SIZE_X%x%THUMB_SIZE_X% %THUMB_INPUT_FILEPATH% %THUMB_OUTPUT_FILEPATH%"""
def renderhtml(self): import eagle3d_templates
if fnmatch.fnmatch(f, "*"+render_extension):
if fnmatch.fnmatch(f, renderhtml_mask): if f in ["povpos.pov", "povpre.pov"]: continue
def renderhtml(self): import eagle3d_templates
if render_noclobber and os.path.exists(target_render_filepath):
if noclobber and os.path.exists(target_render_filepath):
def render(self): quiet = config._get('quiet') dryrun = config._get('dryrun') noclobber = config._get('render_noclobber')
if render_noclobber:
if noclobber:
def render(self): quiet = config._get('quiet') dryrun = config._get('dryrun') noclobber = config._get('render_noclobber')
print " TOOLDIR: %s"%env.TOOLDIR print " RELEASEDIR: %s"%env.RELEASEDIR
print " OUTDIR_3DPACK: %s"%env.OUTDIR_3DPACK
def dump(): print "PATHS:" print " WORKDIR: %s"%env.WORKDIR print " SCRIPTDIR: %s"%env.SCRIPTDIR print " ARCHIVE_OUTPUT_DIR: %s"%env.ARCHIVE_OUTPUT_DIR print " SRCDIR: %s"%env.SRCDIR print " OUTDIR_ROOT: %s"%env.OUTDIR_ROOT print " TOOLDIR: %s"%env.TOOLDIR print " RELEASEDIR: %s"%env.RELEASEDIR print " OUTDIR_I...
print " HASZIP: "+str(env.HASZIP) print " HASTODOS: "+str(env.HASTODOS) print " HASUNIX2DOS: "+str(env.HASUNIX2DOS)
print " HASZIP: %s"%str(env.HASZIP) print " HASTAR: %s"%str(env.HASTAR) print " HASGZIP: %s"%str(env.HASGZIP) print " HASBZIP2: %s"%str(env.HASBZIP2) print " HASTODOS: %s"%str(env.HASTODOS) print " HASUNIX2DOS: %s"%str(env.HASUNIX2DOS) print " HASDOS2UNIX: %s"%str(env.HASDOS2UNIX)
def dump(): print "PATHS:" print " WORKDIR: %s"%env.WORKDIR print " SCRIPTDIR: %s"%env.SCRIPTDIR print " ARCHIVE_OUTPUT_DIR: %s"%env.ARCHIVE_OUTPUT_DIR print " SRCDIR: %s"%env.SRCDIR print " OUTDIR_ROOT: %s"%env.OUTDIR_ROOT print " TOOLDIR: %s"%env.TOOLDIR print " RELEASEDIR: %s"%env.RELEASEDIR print " OUTDIR_I...
logger.info("VERIFYING BUILD") logger.info('')
def verify(): all_errors_found = 0
all_inc_macros = [] for rootdir, dirlist, filelist in os.walk(env.INCDIR): if rootdir != env.INCDIR: rootdir_rel = rootdir[len(env.WORKDIR)+1:] rootdir_basename = os.path.basename(rootdir) for rootdir2, dirlist2, filelist2 in os.walk(rootdir): filelist2.sort() for file in filelist2: if file in ["pre.pre", "pos.p...
logger.info("checking macro include file format...") class iterate_dir1(iterate_dir): all_errors_found = 0 all_inc_macros = [] def on_each_file(self, filepath): errors_found = 0 filepath_basename = os.path.basename(filepath) filepath_subdir = os.path.basename(os.path.dirname(filepath)) filepath_rel = os.path.join(fil...
def verify(): all_errors_found = 0
for i in all_inc_macros:
for i in it.all_inc_macros:
def verify(): all_errors_found = 0
for rootdir, dirlist, filelist in os.walk(env.INCDIR): filelist.sort() for inc in filelist: if inc in ["pre.pre", "pos.pos"]: continue filepath = os.path.join(rootdir, inc) filepath_rel = filepath[len(env.INCDIR)+1:] macro = '' if inc.endswith(INCLUDE_FILE_SUFFIX): macro = inc[:-len(INCLUDE_FILE_SUFFIX)]
class iterate_dir2(iterate_dir): all_errors_found = 0 def on_each_file(self, filepath):
def verify(): all_errors_found = 0
subdir = os.path.basename(os.path.dirname(filepath)) if not inc.startswith(INCLUDE_PREFIX_MAP[subdir]): logger.info(' '+filepath_rel+': file name is inconsistant with naming rules')
filepath_basename = os.path.basename(filepath) filepath_subdir = os.path.basename(os.path.dirname(filepath)) filepath_rel = os.path.join(filepath_subdir, filepath_basename) filepath_barename = '' if filepath.endswith(INCLUDE_EXTENSION): filepath_barename = filepath_basename[:-len(INCLUDE_EXTENSION)] if not filepath_...
def verify(): all_errors_found = 0
filepathHandle = open(filepath, 'r') capture_next_line = False line_index = 0 for line in filepathHandle: line = line.strip() if capture_next_line: if line_index == 1: if line != macro: logger.info(' '+filepath_rel+': file name is inconsistant with macro name: '+line+'; '+macro) errors_found = e...
if not filepath_barename.endswith(INCLUDE_SUFFIX): logger.info(filepath_rel+': file name is inconsistant with naming rules, expected suffix %s.'%INCLUDE_SUFFIX) errors_found = errors_found+1 f_inc_src = open(filepath, 'r') content = f_inc_src.read() f_inc_src.close() content = content.split("\n") index = 0 for i in m...
def verify(): all_errors_found = 0
logger.info(' '+filepath_rel+': no errors found')
logger.info(filepath_rel+': no errors found')
def verify(): all_errors_found = 0
all_errors_found = all_errors_found+errors_found
self.all_errors_found = self.all_errors_found+errors_found logger.info('') it = iterate_dir2() it.start(env.INCDIR)
def verify(): all_errors_found = 0
for rootdir, dirlist, filelist in os.walk(env.INCDIR): if rootdir != env.INCDIR: rootdir_rel = rootdir[len(env.WORKDIR)+1:] if not make.quiet: logger.info(" directory: "+rootdir_rel)
class iterate_dir1(iterate_dir): def on_each_rootdir_pre(self, rootdir):
def create(): make.clean()
for rootdir2, dirlist2, filelist2 in os.walk(rootdir): filelist2.sort() for file in filelist2: if file in ["pre.pre", "pos.pos"]: continue f_inc_src_filepath = os.path.join(rootdir2, file) f_inc_src_filepath_rel = f_inc_src_filepath[len(env.INCDIR)+1:] if not make.quiet: logger.info(" file: "+f_inc_src_filepath_r...
f_inc.close() def on_each_file(self, filepath): filepath_basename = os.path.basename(filepath) filepath_subdir = os.path.basename(os.path.dirname(filepath)) filepath_rel = os.path.join(filepath_subdir, filepath_basename) f_inc_filepath = os.path.join(env.OUTDIR_INC, "e3d_"+filepath_subdir)+".inc" f_inc = open(f_inc...
def create(): make.clean()
f_inc.write(f_inc_src_mainmacro[0]) f_inc.write(f_inc_src_mainmacro[1])
f_inc.write(i)
def create(): make.clean()
for i in make.parse_inc_src(f_inc_src_content, 5): f_inc.write(i) f_inc.write("\n") for i in make.parse_inc_src(f_inc_src_content, 3): if i.strip() == '': pass elif i[:2] == "//": f_inc.write(i) f_inc.write("\n") elif i[:1] == "(": f_inc.write(f_inc_src_mainmacro[0]) f_inc.write(i) f_inc.write("\n
f_inc.write("\n\n") f_inc.close() for i in make.parse_inc_src(content, 1): f_3dpack.write(i) f_3dpack.write("\n") macros = [] for i in make.parse_inc_src(content, 3): if i.strip() == '' or i[:2] == "//" or i[:1] == "(": pass else: i_split = i.split('(') if len(i_split)>1: i_split[1] = i_split[1].strip() if i_spl...
def create(): make.clean()
f_inc.write(" f_inc.write(i) f_inc.write("\n") f_inc.write("\n\n") for i in make.parse_inc_src(f_inc_src_content, 1): f_3dpack.write(i) f_3dpack.write("\n") macros = [] for i in make.parse_inc_src(f_inc_src_content, 3): if i.strip() == '' or i[:2] == "//" or i[:1] == "(": pass else: i_split = i.split('(') if le...
i_split[1] = i_split[1][:-1].strip().replace(' ', '') macros.append(i_split) for i in macros: if i[0] == '': continue matched = 0 if len(i)>1: for j in MACRO_PARAM_PATTERNS: if i[1] == j[0]: i[1] = j[1] matched = matched+1 if matched <1: logger.info("ERROR, unmatched argument string: "+i[0]+'('+i[1]+')') elif matched ...
def create(): make.clean()
pfile = open(self.filepath, 'wb')
if os.path.exists(self.filepath): os.remove(self.filepath) pfile = open(self.filepath, "w")
def write_config(self): pfile = open(self.filepath, 'wb') self.write(pfile) pfile.close()
def get_optionsparser(): parser = OptionParser(usage=None, version="%prog v"+SCRIPT_VERSION, add_help_option=False) parser.add_option("-h", "--help", action="store_true", dest="help", default=False, help="show basic help message and exit.") parser.add_option("--helpall", action="store_true", dest="helpall", default=Fa...
def get_optionsparser(): parser = OptionParser(usage=None, version="%prog v"+SCRIPT_VERSION, add_help_option=False) parser.add_option("-h", "--help", action="store_true", dest="help", default=False, help="show basic help message and exit.") parser.add_option("--helpall", action="store_true", dest="helpall", default=Fa...
parser = get_optionsparser() groups = get_optiongroups(parser) action, options = handle_command_line(parser, groups)
optparser = _OptionsParser() action, options = optparser.handle_command_line()
def handle_command_line(optionsparser, optiongroups): usage_string = """Usage: %prog [ACTION] [options] %prog is a administrative utility used to generate, test and release Eagle3D. Two options may be used without an action: --rewrite-config --recheck-config ACTION The administrative action to be performed."""...
statuses = api.user_timeline('pythonedinburgh', count=5)
try: statuses = api.user_timeline('pythonedinburgh', count=5) except tweepy.TweepError: return {}
def get_tweets(): tweets = memcache.get("tweets") if tweets is None: credentials = TwitterCredentials.all().get() if credentials: auth = tweepy.OAuthHandler(credentials.consumer_key, credentials.consumer_secret) auth.set_access_token(credentials.access_token, credentials.access_secret) api = tweepy.API(auth_handler=au...
root = Element('workseet', {'xml:space':'preserve',
root = Element('worksheet', {'xml:space':'preserve',
def write_worksheet(worksheet, string_table): root = Element('workseet', {'xml:space':'preserve', 'xmlns':'http://schemas.openxmlformats.org/spreadsheetml/2006/main', 'xmlns:r':'http://schemas.openxmlformats.org/officeDocument/2006/relationships'}) # sheet pr sheet_pr = SubElement(root, 'sheetPr') SubElement(sheet_pr...
self.worksheets = [Worksheet(self)]
self.worksheets = [] self.worksheets.append(Worksheet(self))
def __init__(self):
self.worksheets.insert(index = index, object = worksheet)
if index is None: index = len(self.worksheets) self.worksheets.insert(index, worksheet)
def add_sheet(self, worksheet, index = None):
self.worksheets.index(worksheet)
return self.worksheets.index(worksheet)
def get_index(self, worksheet):
for nr in self._named_ranges:
for nr in self._named_ranges.values():
def get_named_range(self, name):
dest_filename = osp.join(r'c:\data\temp', 'empty_book.xlsx')
dest_filename = osp.join(TMPDIR, 'empty_book.xlsx')
def test_write_empty_workbook(self):
destpath = op.join(TRASH_PATH, new_filename)
destpath = op.join(dst, new_filename)
def move_without_conflict(src, dst): filename = op.basename(src) destpath = op.join(dst, filename) counter = 0 while op.exists(destpath): counter += 1 base_name, ext = op.splitext(filename) new_filename = '{0} {1}{2}'.format(base_name, counter, ext) destpath = op.join(TRASH_PATH, new_filename) os.rename(src, destpath)
path = op.join(*op.split(path)[:-1])
path = op.split(path)[0]
def find_mount_point(path): # Even if something's wrong, "/" is a mount point, so the loop will exit. while not op.ismount(path): path = op.join(*op.split(path)[:-1]) return path
displacement = displacement*calc.recip_cell
def move_all_atoms(calc): yield 'calc_00_0', calc for numat, at in enumerate(calc.atoms): for direction in range(3): displacement = zeros((1,3)) displacement[0, direction] = disp_length[direction % len(disp_length)] displacement = displacement*calc.recip_cell for orientation in ['+', '-']: c = copy.deepcopy(calc) c.at...
s_ee = sorted(ee)
s_ee = sorted(abs(ee))
def safe_inv(matrix, threshold = 0, iterate_components = None): """ In a lot of places we need to safely invert a (almost) Hermitian matrix. This is the way we want to do that: by symmetrizing the matrix and skipping eigenvalues close to 0, """ (ee,vv) = linalg.eig( (matrix+matrix.T)/2. ) vv=mat(vv) s_ee = sorted(ee) ...
elif line.startswith(" Spin component "):
elif line.find("e<r>_ev") > 0:
def load_polarization(self, filename): """ This function tries to read Berry phase calculations from three files: filename+'_berry_1' filename+'_berry_2' filename+'_berry_3' If the files are not readable, no polarization attribute is set. On successful run this method fills the following attributes: - self.polarization...
self.berry_ev[kdirection-1].append( [ float(data[4]), float(data[5]), float(data[6]) ] )
self.berry_ev[kdirection-1].append( [ float(data[-5]), float(data[-4]), float(data[-3]) ] )
def load_polarization(self, filename): """ This function tries to read Berry phase calculations from three files: filename+'_berry_1' filename+'_berry_2' filename+'_berry_3' If the files are not readable, no polarization attribute is set. On successful run this method fills the following attributes: - self.polarization...
data = line.split()[2:]
data = [] while line.startswith(" ZVAL ="): data.extend( line.split()[2:] ) line = F.readline()
def load_from_outcar(self, filename): """ This function reads atom positions, unit cell, forces and stress tensor from the VASP OUTCAR file """ if os.access(filename, os.R_OK): F=file(filename) elif have_gzip and os.access(filename+'.gz', os.R_OK): F=gzip.open(filename+'.gz') else: raise Exception("Missing file") self....
extra['headers_arch_depends'] = packages_headers_arch[-1]['Depends'] = PackageRelation()
packages_headers_arch[-1]['Depends'].extend(PackageRelation()) extra['headers_arch_depends'] = packages_headers_arch[-1]['Depends']
def do_arch_packages(self, packages, makefile, arch, vars, makeflags, extra): headers_arch = self.templates["control.headers.arch"] packages_headers_arch = self.process_packages(headers_arch, vars)
method = getattr(handler, "_handle_incident_" + origin)
method = getattr(self, "_handle_incident_" + origin)
def handle_incident(self, icd): origin = icd.origin origin = origin.replace(".","_") try: method = getattr(handler, "_handle_incident_" + origin) except: return
del self.pending[con]
def connection_insert(self, icd, connection_type): con=icd.con r = self.cursor.execute("INSERT INTO connections (connection_timestamp, connection_type, connection_transport, connection_protocol, local_host, local_port, remote_host, remote_hostname, remote_port) VALUES (?,?,?,?,?,?,?,?,?)", (time.time(), connection_type...
logger.warn("fuck")
def handle_incident_dionaea_modules_python_mssql_cmd(self, icd): logger.warn("fuck") con = icd.con if con in self.attacks: attackid = self.attacks[con][1] self.cursor.execute("INSERT INTO mssql_commands (connection, mssql_command_status, mssql_command_cmd) VALUES (?,?,?)", (attackid, icd.status, icd.cmd)) self.dbh.comm...
self.state = 'USER'
self.state = 'NONE'
def __init__(self, ftp): connection.__init__(self, 'tcp') self.ftp = ftp self.state = 'USER' self.timeouts.sustain = 60
if self.state == 'USER':
if self.state == 'NONE':
def handle_io_in(self, data): dlen = len(data) lines = _linesep_regexp.split(data)#.decode('UTF-8'))
elif self.state == 'PASS': if c == 331 and s != b'-': self.cmd('PASS ' + self.ftp.passwd) self.state = 'WELCOME' elif self.state == 'WELCOME':
def handle_io_in(self, data): dlen = len(data) lines = _linesep_regexp.split(data)#.decode('UTF-8'))
self.__streamDumpFileIn = dumpDir + '{t}_{h}_{p}_%IO%.rtp'.format(
self.__streamDumpFileIn = dumpDir + '{t}_{h}_{p}_in.rtp'.format(
def __init__(self, address, port): connection.__init__(self, 'udp')
self.payload = cls(s)
self.payload = cls(s, _underlayer=self)
def decode_payload_as(self,cls): """Reassembles the payload and decode it using another packet class""" s = self.payload.build() self.payload = cls(s)
print(self.type + b" " + self.path.encode('utf-8') + b" " + self.version)
logger.debug(self.type + b" " + self.path.encode('utf-8') + b" " + self.version)
def print(self): print(self.type + b" " + self.path.encode('utf-8') + b" " + self.version) for i in self.headers: print(i + b":" + self.headers[i])
print(i + b":" + self.headers[i])
logger.debug(i + b":" + self.headers[i])
def print(self): print(self.type + b" " + self.path.encode('utf-8') + b" " + self.version) for i in self.headers: print(i + b":" + self.headers[i])
self.processors()
def handle_established(self):
print(data)
logger.debug(data)
def handle_io_in(self, data): print(data) if self.state == 'HEADER': eoh = data.find(b'\r\n\r\n') if eoh == -1: eoh = data.find(b'\n\n') if eoh == -1: return 0 header = data[0:eoh] self.header = httpreq(header) self.header.print() if self.header.type == b'GET': self.handle_GET() elif self.header.type == b'HEAD': self....
self.handle_GET()
self.handle_HEAD()
def handle_io_in(self, data): print(data) if self.state == 'HEADER': eoh = data.find(b'\r\n\r\n') if eoh == -1: eoh = data.find(b'\n\n') if eoh == -1: return 0 header = data[0:eoh] self.header = httpreq(header) self.header.print() if self.header.type == b'GET': self.handle_GET() elif self.header.type == b'HEAD': self....
elif self.header.type == b'PUT': self.handle_PUT()
elif self.header.type == b'OPTIONS': self.handle_OPTIONS() else: self.handle_unknown()
def handle_io_in(self, data): print(data) if self.state == 'HEADER': eoh = data.find(b'\r\n\r\n') if eoh == -1: eoh = data.find(b'\n\n') if eoh == -1: return 0 header = data[0:eoh] self.header = httpreq(header) self.header.print() if self.header.type == b'GET': self.handle_GET() elif self.header.type == b'HEAD': self....
pass
x = self.send_head() if x : self.copyfile(x)
def handle_POST(self): pass
print("root %s rpath %s fpath %s apath %s" % (self.root, rpath, fpath, apath))
logger.debug("root %s rpath %s fpath %s apath %s" % (self.root, rpath, fpath, apath))
def send_head(self): rpath = os.path.normpath(self.header.path) fpath = os.path.join(self.root, rpath[1:]) apath = os.path.abspath(fpath) print("root %s rpath %s fpath %s apath %s" % (self.root, rpath, fpath, apath)) if os.path.exists(apath): if os.path.isdir(apath): if not self.header.path.endswith('/'): self.send_res...
self.send_response(404, "File not found") self.end_headers() self.close()
return self.send_error(404)
def send_head(self): rpath = os.path.normpath(self.header.path) fpath = os.path.join(self.root, rpath[1:]) apath = os.path.abspath(fpath) print("root %s rpath %s fpath %s apath %s" % (self.root, rpath, fpath, apath)) if os.path.exists(apath): if os.path.isdir(apath): if not self.header.path.endswith('/'): self.send_res...
FieldLenField("SecurityBlobLength", 0, fmt='<H', length_of="SecurityBlob"),
FieldLenField("SecurityBlobLength", None, fmt='<H', length_of="SecurityBlob"),
def post_build(self, p, pay): self.LENGTH = len(pay) p = self.do_build() return p+pay
ConditionalField(StrFixedLenField("Padding", "\x00", length_from=lambda x:(x.SecurityBlobLength+1)%2), lambda x:x.underlayer.Flags2 & SMB_FLAGS2_UNICODE),
ConditionalField(StrLenField("Padding", "\x00", length_from=lambda x:(x.SecurityBlobLength+1)%2), lambda x:x.underlayer.Flags2 & SMB_FLAGS2_UNICODE),
def post_build(self, p, pay): self.LENGTH = len(pay) p = self.do_build() return p+pay
FieldLenField("SecurityBlobLength", 0, fmt='<H', length_of="SecurityBlob"),
FieldLenField("SecurityBlobLength", None, fmt='<H', length_of="SecurityBlob"),
def lengthfrom_Extrabytes(self): x = self.ByteCount x -= len(self.SecurityBlob) if hasattr(self,'Padding') and self.Padding != None: x -= len(self.Padding) x -= len(self.NativeOS) x -= len(self.NativeLanManager) return x
FieldLenField("PasswordLength", 0, fmt='<H', length_of="Password"), FieldLenField("UnicodePasswordLength", 0, fmt='<H', length_of="UnicodePassword"),
FieldLenField("PasswordLength", None, fmt='<H', length_of="Password"), FieldLenField("UnicodePasswordLength", None, fmt='<H', length_of="UnicodePassword"),
# def post_build(self, p, pay):
StrFixedLenField("Padding", "\x00", length_from=lambda x:(x.PasswordLength+1)%2),
StrLenField("Padding", "\x00", length_from=lambda x:(x.PasswordLength+1)%2),
# def post_build(self, p, pay):
' ' * intent, service['emu_service_url']))
' ' * indent, service['emu_service_url']))
def print_services(cursor, connection, indent): r = cursor.execute("SELECT * from emu_services WHERE connection = ?", (connection, )) services = resolve_result(r) for service in services: print("{:s} service: {:s}".format( ' ' * intent, service['emu_service_url']))
self.fileobj.unlink(self.fileobj.name)
def handle_timeout_listen(self): self.ftp.fail() self.fileobj.unlink(self.fileobj.name) return False
if 'urls' not in g_dionaea.config()['submit'][to]:
if 'urls' not in tos[to]:
def handle_incident(self, icd): logger.debug("submitting file") try: tos = g_dionaea.config()['submit'] except: return
for url in g_dionaea.config()['submit'][to]['urls']:
for url in tos[to]['urls']:
def handle_incident(self, icd): logger.debug("submitting file") try: tos = g_dionaea.config()['submit'] except: return
i.file = icd.file
def handle_incident(self, icd): logger.debug("submitting file") try: tos = g_dionaea.config()['submit'] except: return
for key in g_dionaea.config()['submit'][to]:
for key in tos[to]:
def handle_incident(self, icd): logger.debug("submitting file") try: tos = g_dionaea.config()['submit'] except: return
i.set(key, g_dionaea.config()['submit'][to][key])
if key == 'file_fieldname': i.set("file://" + tos[to][key], icd.file) continue i.set(key, tos[to][key])
def handle_incident(self, icd): logger.debug("submitting file") try: tos = g_dionaea.config()['submit'] except: return
print("k %s %s" % (type(k),k)) print("v %s %s" % (type(v),v))
def __new__(cls, name, bases, dct): rdict={} for k,v in dct.items(): print("k %s %s" % (type(k),k)) print("v %s %s" % (type(v),v)) if type(v) is int: v = cls.element_class(k,v) print("v %s %s" % (type(v),v)) dct[k] = v rdict[type(v)] = k dct["__rdict__"] = rdict return super(Enum_metaclass, cls).__new__(cls, name, base...
print("v %s %s" % (type(v),v))
def __new__(cls, name, bases, dct): rdict={} for k,v in dct.items(): print("k %s %s" % (type(k),k)) print("v %s %s" % (type(v),v)) if type(v) is int: v = cls.element_class(k,v) print("v %s %s" % (type(v),v)) dct[k] = v rdict[type(v)] = k dct["__rdict__"] = rdict return super(Enum_metaclass, cls).__new__(cls, name, base...
0x1b: "MS04-11",
0x1b: "MS03-39",
def handle_OpenSCManagerA(cls, con, p): # DWORD ROpenSCManagerA( # [in, string, unique, range(0, SC_MAX_COMPUTER_NAME_LENGTH)] SVCCTL_HANDLEA lpMachineName, # [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] LPSTR lpDatabaseName, # [in] DWORD dwDesiredAccess, # [out] LPSC_RPC_HANDLE lpScHandle # ); pass
self.bistream_prefix = 'smb-'
def __init__ (self): connection.__init__(self,"tcp") self.state = { 'lastcmd': None, 'readcount': 0, 'stop': False, } self.buf = b'' self.outbuf = None self.fids = {} self.bistream_prefix = 'smb-' self.printer = b'' # spoolss file "queue"
self.bistream_prefix = 'epmapper-'
def __init__ (self): connection.__init__(self,"tcp") smbd.__init__(self) self.bistream_prefix = 'epmapper-'
return x
eos = x.find('\0') return x[:eos]
def i2repr(self, pkt, x): if x is None: x = b'' elif type(x) is bytes: x=x.decode('utf-16') return x
FieldLenField("SecurityBlobLength", None, fmt='<H', length_of="SecurityBlob"),
FieldLenField("SecurityBlobLength", 0, fmt='<H', length_of="SecurityBlob"),
def post_build(self, p, pay): self.LENGTH = len(pay) p = self.do_build() return p+pay
FieldLenField("SecurityBlobLength", None, fmt='<H', length_of="SecurityBlob"),
FieldLenField("SecurityBlobLength", 0, fmt='<H', length_of="SecurityBlob"),
def lengthfrom_Extrabytes(self): x = self.ByteCount x -= len(self.SecurityBlob) if hasattr(self,'Padding') and self.Padding != None: x -= len(self.Padding) x -= len(self.NativeOS) x -= len(self.NativeLanManager) return x
FieldLenField("PasswordLength", None, fmt='<H', length_of="Password"), FieldLenField("UnicodePasswordLength", None, fmt='<H', length_of="UnicodePassword"),
FieldLenField("PasswordLength", 0, fmt='<H', length_of="Password"), FieldLenField("UnicodePasswordLength", 0, fmt='<H', length_of="UnicodePassword"),
# def post_build(self, p, pay):
StrLenField("Buffer", "\xff", length_from=lambda x:x.ByteCount),
StrLenField("Buffer", b"\xff", length_from=lambda x:x.ByteCount),
def lengthfrom_Pad1(self): if self.DataOffset == 0: return 0 r = self.underlayer.size() # underlayer size removed r += 5 # 5 byte vars r += 11*2 # 11 words r += 4 # 1 int r += self.SetupCount*2 # SetupCount words r += len(self.Pad) # Pad length r += self.ParamCount # ParamCount arguments return self.D...
StrLenField("FileName", "\xff", length_from=lambda x:x.ByteCount),
StrLenField("FileName", b"\xff", length_from=lambda x:x.ByteCount),
def lengthfrom_Pad1(self): if self.DataOffset == 0: return 0 r = self.underlayer.size() # underlayer size removed r += 5 # 5 byte vars r += 11*2 # 11 words r += 4 # 1 int r += self.SetupCount*2 # SetupCount words r += len(self.Pad) # Pad length r += self.ParamCount # ParamCount arguments return self.D...
FieldLenField("ByteCount", None, fmt='<H', length_of="NativeOS", adjust=lambda pkt,x: len(pkt.Padding) + len(pkt.NativeOS) + len(pkt.NativeLanManager) + len(pkt.PrimaryDomain)),
MultiFieldLenField("ByteCount", None, fmt='<H', length_of=("Padding","NativeOS", "NativeLanManager", "PrimaryDomain")),
# def post_build(self, p, pay):
SMBNullField("Filename","\\lsarpc", utf16=lambda x:x.underlayer.Flags2 & SMB_FLAGS2_UNICODE) ]
SMBNullField("Filename","\\lsarpc", utf16=lambda x:x.underlayer.Flags2 & SMB_FLAGS2_UNICODE), StrFixedLenField("Extrabytes", b'', length_from=lambda x:x.lengthfrom_Extrabytes()) ] def lengthfrom_Extrabytes(self): x = self.ByteCount if hasattr(self,'Padding') and self.Padding != None: x -= len(self.Padding) x -= len(sel...
def lengthof_Extrabytes(self): x = self.ByteCount x -= len(self.Password) if hasattr(self,'Padding') and self.Padding != None: x -= len(self.Padding) x -= len(self.Path) x -= len(self.Service) return x
query = query + "\tAND remote_host = {:s} \n".format(options.remote_host)
query = query + "\tAND remote_host = '{:s}' \n".format(options.remote_host)
def print_db(opts, args): dbh = sqlite3.connect(args[0]) cursor = dbh.cursor() offset = 0 limit = 1000 query = """
print_connection(c, 1)
print_connection(c, indent+1)
def recursive_print(cursor, connection, indent): result = cursor.execute("SELECT * from connections WHERE connection_parent = ?", (connection, )) connections = resolve_result(result) for c in connections: if c['connection'] == connection: continue print_connection(c, 1) print_p0fs(cursor, c['connection'], indent+2) pri...
logger.warn("SQL BATCH : {:.1024s}".format(cmd))
logger.debug("SQL BATCH : {:.1024s}".format(cmd))
def process(self, PacketType, p, data): r ='' rp = None if PacketType == TDS_TYPES_PRE_LOGIN: r = TDS_Prelogin_Response() #FIXME: any better way to initialise this? r.VersionToken.TokenType = 0x00 r.VersionToken.Offset = 26 r.VersionToken.Len = 6 r.EncryptionToken.TokenType = 0x01 r.EncryptionToken.Offset = 32 r.Encry...
c.connection,
c.connection AS connection,
def print_db(opts, args): dbh = sqlite3.connect(args[0]) cursor = dbh.cursor() offset = 0 limit = 1000 query = """
self.timeouts.sustain = 120
def handle_established(self): self.timeouts.sustain = 120
self.state['readcount'] = 0
def process(self, p): r = '' rp = None self.state['readcount'] = 0 #if self.state == STATE_START and p.getlayer(SMB_Header).Command == 0x72: Command = p.getlayer(SMB_Header).Command if Command == SMB_COM_NEGOTIATE: # Negociate Protocol -> Send response that supports minimal features in NT LM 0.12 dialect # (could be ra...
Command = p.getlayer(SMB_Header).Command
rstatus = 0 smbh = p.getlayer(SMB_Header) Command = smbh.Command
def process(self, p): r = '' rp = None self.state['readcount'] = 0 #if self.state == STATE_START and p.getlayer(SMB_Header).Command == 0x72: Command = p.getlayer(SMB_Header).Command if Command == SMB_COM_NEGOTIATE: # Negociate Protocol -> Send response that supports minimal features in NT LM 0.12 dialect # (could be ra...
self.process_dcerpc_packet(p.getlayer(SMB_Write_AndX_Request).Data)
def process(self, p): r = '' rp = None self.state['readcount'] = 0 #if self.state == STATE_START and p.getlayer(SMB_Header).Command == 0x72: Command = p.getlayer(SMB_Header).Command if Command == SMB_COM_NEGOTIATE: # Negociate Protocol -> Send response that supports minimal features in NT LM 0.12 dialect # (could be ra...
if p.getlayer(SMB_Read_AndX_Request).MaxCountLow < len(self.outbuf.build())-self.state['readcount'] : rdata.ByteCount = len(self.outbuf.build()) - self.state['readcount'] rdata.Bytes = self.outbuf.build()[ self.state['readcount']: self.state['readcount'] + p.getlayer(SMB_Read_AndX_Request).MaxCountLow ] self.state...
outbuf = self.outbuf.build() outbuflen = len(outbuf) smblog.info("MaxCountLow %i len(outbuf) %i readcount %i" %(h.MaxCountLow, outbuflen, self.state['readcount']) ) if h.MaxCountLow < outbuflen-self.state['readcount']: rdata.ByteCount = h.MaxCountLow newreadcount = self.state['readcount']+h.MaxCountLow else: newreadcou...
def process(self, p): r = '' rp = None self.state['readcount'] = 0 #if self.state == STATE_START and p.getlayer(SMB_Header).Command == 0x72: Command = p.getlayer(SMB_Header).Command if Command == SMB_COM_NEGOTIATE: # Negociate Protocol -> Send response that supports minimal features in NT LM 0.12 dialect # (could be ra...
smbh = SMB_Header()
smbh = SMB_Header(Status=rstatus)
def process(self, p): r = '' rp = None self.state['readcount'] = 0 #if self.state == STATE_START and p.getlayer(SMB_Header).Command == 0x72: Command = p.getlayer(SMB_Header).Command if Command == SMB_COM_NEGOTIATE: # Negociate Protocol -> Send response that supports minimal features in NT LM 0.12 dialect # (could be ra...
dcep.show()
try: dcep.show() except: return None
def process_dcerpc_packet(self, buf): if not isinstance(buf, DCERPC_Header): smblog.debug("got buf, make DCERPC_Header") dcep = DCERPC_Header(buf) else: dcep = buf
print(dcep.getlayer(Raw).underlayer.load) dcep.getlayer(Raw).underlayer.decode_payload_as(DCERPC_Auth_Verfier)
def process_dcerpc_packet(self, buf): if not isinstance(buf, DCERPC_Header): smblog.debug("got buf, make DCERPC_Header") dcep = DCERPC_Header(buf) else: dcep = buf
cls,pc,tag,sb = BER_identifier_dec(sb) l,sb = BER_len_dec(sb) if not (cls == BER_CLASS_APP and pc > 0 and tag == 0): if sb.startswith(b"NTLMSSP"): ntlmssp = NTLMSSP_Header(a) elif sb.startswith(b"\x04\x04") or sb.startswith(b"\x05\x04"): pass
if sb.startswith(b"NTLMSSP"): ntlmssp = NTLMSSP_Header(sb) ntlmssp.show() elif sb.startswith(b"\x04\x04") or sb.startswith(b"\x05\x04"): pass
def process(self, p): r = '' rp = None
gssapi = GSSAPI(sb) sb = gssapi.getlayer(Raw).load
def process(self, p): r = '' rp = None
spnego = SPNEGO(sb) spnego.show() sb = spnego.NegotiationToken.mechToken.__str__() cls,pc,tag,sb = BER_identifier_dec(sb) l,sb = BER_len_dec(sb) ntlmssp = NTLMSSP_Header(sb) ntlmssp.show() if False or ntlmssp is not None: if ntlmssp.MessageType == 1: r.Action = 0 ntlmnegotiate = ntlmssp.getlayer(NTLM_Negotiate) rntlmss...
if cls == BER_CLASS_APP and pc > 0 and tag == 0: gssapi = GSSAPI(sb) sb = gssapi.getlayer(Raw).load cls,pc,tag,sb = BER_identifier_dec(sb) l,sb = BER_len_dec(sb) spnego = SPNEGO(sb) spnego.show() sb = spnego.NegotiationToken.mechToken.__str__() cls,pc,tag,sb = BER_identifier_dec(sb) l,sb = BER_len_dec(sb) ntlmss...
def process(self, p): r = '' rp = None
rstatus = 0xc0000016
def process(self, p): r = '' rp = None