INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Returns a new L { ImageBoundImportDescriptorEntry } object. | def parse(readDataInstance):
"""
Returns a new L{ImageBoundImportDescriptorEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{ImageBoundImportDescriptorEntry}.
@rtype: L{ImageBoundIm... |
Returns a new L { TLSDirectory } object. | def parse(readDataInstance):
"""
Returns a new L{TLSDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{TLSDirectory} object.
@rtype: L{TLSDirectory}
@return: A new {TLSDi... |
Returns a new L { TLSDirectory64 } object. | def parse(readDataInstance):
"""
Returns a new L{TLSDirectory64} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{TLSDirectory64} object.
@rtype: L{TLSDirectory64}
@return: A new ... |
Returns a new L { ImageLoadConfigDirectory64 } object. | def parse(readDataInstance):
"""
Returns a new L{ImageLoadConfigDirectory64} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{ImageLoadConfigDirectory64} object.
@rtype: L{ImageLoadConfig... |
Returns a new L { ImageBaseRelocationEntry } object. | def parse(readDataInstance):
"""
Returns a new L{ImageBaseRelocationEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to parse as a L{ImageBaseRelocationEntry} object.
@rtype: L{ImageBaseRelocationEntry}
... |
Returns a new L { ImageDebugDirectory } object. | def parse(readDataInstance):
"""
Returns a new L{ImageDebugDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A new L{ReadData} object with data to be parsed as a L{ImageDebugDirectory} object.
@rtype: L{ImageDebugDirectory}
... |
Returns a new L { ImageDebugDirectories } object. | def parse(readDataInstance, nDebugEntries):
"""
Returns a new L{ImageDebugDirectories} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageDebugDirectories} object.
@type nDebugEntries: in... |
Returns a new L { ImageImportDescriptorEntry } object. | def parse(readDataInstance):
"""
Returns a new L{ImageImportDescriptorEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageImportDescriptorEntry}.
@rtype: L{ImageImportDescriptorEntry... |
Returns a new L { ImageImportDescriptor } object. | def parse(readDataInstance, nEntries):
"""
Returns a new L{ImageImportDescriptor} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageImportDescriptor} object.
@type nEntries: int
... |
Returns a new L { ExportTableEntry } object. | def parse(readDataInstance):
"""
Returns a new L{ExportTableEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ExportTableEntry} object.
@rtype: L{ExportTableEntry}
@return: A ne... |
Returns a new L { ImageExportTable } object. | def parse(readDataInstance):
"""
Returns a new L{ImageExportTable} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageExportTable} object.
@rtype: L{ImageExportTable}
@return: A ne... |
Returns a new L { NETDirectory } object. | def parse(readDataInstance):
"""
Returns a new L{NETDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NETDirectory} object.
@rtype: L{NETDirectory}
@return: A new L{NETDirec... |
Returns a new L { NetDirectory } object. | def parse(readDataInstance):
"""
Returns a new L{NetDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetDirectory} object.
@rtype: L{NetDirectory}
@return: A new L{NetDirec... |
Returns a new L { NetMetaDataHeader } object. | def parse(readDataInstance):
"""
Returns a new L{NetMetaDataHeader} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataHeader} object.
@rtype: L{NetMetaDataHeader}
@return: A... |
Returns a new L { NetMetaDataStreamEntry } object. | def parse(readDataInstance):
"""
Returns a new L{NetMetaDataStreamEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataStreamEntry}.
@rtype: L{NetMetaDataStreamEntry}
@r... |
Returns a new L { NetMetaDataStreams } object. | def parse(readDataInstance, nStreams):
"""
Returns a new L{NetMetaDataStreams} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataStreams} object.
@type nStreams: int
@param... |
Returns a new L { NetMetaDataTableHeader } object. | def parse(readDataInstance):
"""
Returns a new L{NetMetaDataTableHeader} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataTableHeader} object.
@rtype: L{NetMetaDataTableHeader}
... |
Returns a new L { NetMetaDataTables } object. | def parse(readDataInstance, netMetaDataStreams):
"""
Returns a new L{NetMetaDataTables} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataTables} object.
@rtype: L{NetMetaDataTables... |
Returns a new L { NetResources } object. | def parse(readDataInstance):
"""
Returns a new L{NetResources} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetResources} object.
@rtype: L{NetResources}
@return: A new L{NetResources} object.
... |
Take address paths and verifies their accuracy client - side. | def verify_and_fill_address_paths_from_bip32key(address_paths, master_key, network):
'''
Take address paths and verifies their accuracy client-side.
Also fills in all the available metadata (WIF, public key, etc)
'''
assert network, network
wallet_obj = Wallet.deserialize(master_key, network=... |
Follows the solution path of the generalized lasso to find the best lambda value. | def solution_path(self):
'''Follows the solution path of the generalized lasso to find the best lambda value.'''
lambda_grid = np.exp(np.linspace(np.log(self.max_lambda), np.log(self.min_lambda), self.lambda_bins))
aic_trace = np.zeros((len(self.bins),lambda_grid.shape[0])) # The AIC score for e... |
Run the graph - fused logit lasso with a fixed lambda penalty. | def run(self, lam, initial_values=None):
'''Run the graph-fused logit lasso with a fixed lambda penalty.'''
if initial_values is not None:
if self.k == 0 and self.trails is not None:
betas, zs, us = initial_values
else:
betas, us = initial_values
... |
Calculates the log - likelihood of a Polya tree bin given the beta values. | def data_log_likelihood(self, successes, trials, beta):
'''Calculates the log-likelihood of a Polya tree bin given the beta values.'''
return binom.logpmf(successes, trials, 1.0 / (1 + np.exp(-beta))).sum() |
This method has to be module level function | def spawn_worker(params):
"""
This method has to be module level function
:type params: Params
"""
setup_logging(params)
log.info("Adding worker: idx=%s\tconcurrency=%s\tresults=%s", params.worker_index, params.concurrency,
params.report)
worker = Worker(params)
worker.star... |
: type params: Params | def run_nose(self, params):
"""
:type params: Params
"""
thread.set_index(params.thread_index)
log.debug("[%s] Starting nose iterations: %s", params.worker_index, params)
assert isinstance(params.tests, list)
# argv.extend(['--with-apiritif', '--nocapture', '--exe... |
: type sample: Sample | def _write_single_sample(self, sample):
"""
:type sample: Sample
"""
bytes = sample.extras.get("responseHeadersSize", 0) + 2 + sample.extras.get("responseBodySize", 0)
message = sample.error_msg
if not message:
message = sample.extras.get("responseMessage")
... |
when a test raises an uncaught exception: param test:: param error:: return: | def addError(self, test, error):
"""
when a test raises an uncaught exception
:param test:
:param error:
:return:
"""
# test_dict will be None if startTest wasn't called (i.e. exception in setUp/setUpClass)
# status=BROKEN
if self.current_sample is... |
Returns a L { Directory } - like object. | def parse(readDataInstance):
"""
Returns a L{Directory}-like object.
@type readDataInstance: L{ReadData}
@param readDataInstance: L{ReadData} object to read from.
@rtype: L{Directory}
@return: L{Directory} object.
"""
d = Directory()
... |
Returns a L { DataDirectory } - like object. | def parse(readDataInstance):
"""Returns a L{DataDirectory}-like object.
@type readDataInstance: L{ReadData}
@param readDataInstance: L{ReadData} object to read from.
@rtype: L{DataDirectory}
@return: The L{DataDirectory} object containing L{consts.IMAGE_NUMBEROF... |
Compute Pgens from a file and output to another file. | def main():
"""Compute Pgens from a file and output to another file."""
parser = OptionParser(conflict_handler="resolve")
parser.add_option('--humanTRA', '--human_T_alpha', action='store_true', dest='humanTRA', default=False, help='use default human TRA model (T cell alpha chain)')
parser.add_option('... |
Creates plateaus of constant value in the data. | def create_plateaus(data, edges, plateau_size, plateau_vals, plateaus=None):
'''Creates plateaus of constant value in the data.'''
nodes = set(edges.keys())
if plateaus is None:
plateaus = []
for i in range(len(plateau_vals)):
if len(nodes) == 0:
break
... |
Pretty - print a matrix or vector. | def pretty_str(p, decimal_places=2, print_zero=True, label_columns=False):
'''Pretty-print a matrix or vector.'''
if len(p.shape) == 1:
return vector_str(p, decimal_places, print_zero)
if len(p.shape) == 2:
return matrix_str(p, decimal_places, print_zero, label_columns)
raise Exception('... |
Pretty - print the matrix. | def matrix_str(p, decimal_places=2, print_zero=True, label_columns=False):
'''Pretty-print the matrix.'''
return '[{0}]'.format("\n ".join([(str(i) if label_columns else '') + vector_str(a, decimal_places, print_zero) for i, a in enumerate(p)])) |
Pretty - print the vector values. | def vector_str(p, decimal_places=2, print_zero=True):
'''Pretty-print the vector values.'''
style = '{0:.' + str(decimal_places) + 'f}'
return '[{0}]'.format(", ".join([' ' if not print_zero and a == 0 else style.format(a) for a in p])) |
Calculate the plateaus ( degrees of freedom ) of a graph of beta values in linear time. | def calc_plateaus(beta, edges, rel_tol=1e-4, verbose=0):
'''Calculate the plateaus (degrees of freedom) of a graph of beta values in linear time.'''
if not isinstance(edges, dict):
raise Exception('Edges must be a map from each node to a list of neighbors.')
to_check = deque(range(len(beta)))
ch... |
Heuristic method to return the uniques within some precision in a numpy array | def nearly_unique(arr, rel_tol=1e-4, verbose=0):
'''Heuristic method to return the uniques within some precision in a numpy array'''
results = np.array([arr[0]])
for x in arr:
if np.abs(results - x).min() > rel_tol:
results = np.append(results, x)
return results |
Create edge lists for an arbitrary hypercube. TODO: this is probably not the fastest way. | def hypercube_edges(dims, use_map=False):
'''Create edge lists for an arbitrary hypercube. TODO: this is probably not the fastest way.'''
edges = []
nodes = np.arange(np.product(dims)).reshape(dims)
for i,d in enumerate(dims):
for j in range(d-1):
for n1, n2 in zip(np.take(nodes, [j]... |
Calculate the k - th order trend filtering matrix given the oriented edge incidence matrix and the value of k. | def get_delta(D, k):
'''Calculate the k-th order trend filtering matrix given the oriented edge
incidence matrix and the value of k.'''
if k < 0:
raise Exception('k must be at least 0th order.')
result = D
for i in range(k):
result = D.T.dot(result) if i % 2 == 0 else D.dot(result)
... |
Decomposes the k - th order trend filtering matrix into a c - compatible set of arrays. | def decompose_delta(deltak):
'''Decomposes the k-th order trend filtering matrix into a c-compatible set
of arrays.'''
if not isspmatrix_coo(deltak):
deltak = coo_matrix(deltak)
dk_rows = deltak.shape[0]
dk_rowbreaks = np.cumsum(deltak.getnnz(1), dtype="int32")
dk_cols = deltak.col.astyp... |
Returns a sparse penalty matrix ( D ) from a list of edge pairs. Each edge can have an optional weight associated with it. | def matrix_from_edges(edges):
'''Returns a sparse penalty matrix (D) from a list of edge pairs. Each edge
can have an optional weight associated with it.'''
max_col = 0
cols = []
rows = []
vals = []
if type(edges) is defaultdict:
edge_list = []
for i, neighbors in edges.items... |
Get the Kolmogorov - Smirnov ( KS ) distance between two densities a and b. | def ks_distance(a, b):
'''Get the Kolmogorov-Smirnov (KS) distance between two densities a and b.'''
if len(a.shape) == 1:
return np.max(np.abs(a.cumsum() - b.cumsum()))
return np.max(np.abs(a.cumsum(axis=1) - b.cumsum(axis=1)), axis=1) |
Get the Total Variation ( TV ) distance between two densities a and b. | def tv_distance(a, b):
'''Get the Total Variation (TV) distance between two densities a and b.'''
if len(a.shape) == 1:
return np.sum(np.abs(a - b))
return np.sum(np.abs(a - b), axis=1) |
def jdFromDate ( dd mm yy ): Compute the ( integral ) Julian day number of day dd/ mm/ yyyy i. e. the number of days between 1/ 1/ 4713 BC ( Julian calendar ) and dd/ mm/ yyyy. | def jdFromDate(dd, mm, yy):
'''def jdFromDate(dd, mm, yy): Compute the (integral) Julian day number of
day dd/mm/yyyy, i.e., the number of days between 1/1/4713 BC
(Julian calendar) and dd/mm/yyyy.'''
a = int((14 - mm) / 12.)
y = yy + 4800 - a
m = mm + 12 * a - 3
jd = dd + int((153 * m + 2) ... |
def jdToDate ( jd ): Convert a Julian day number to day/ month/ year. jd is an integer. | def jdToDate(jd):
'''def jdToDate(jd): Convert a Julian day number to day/month/year.
jd is an integer.'''
if (jd > 2299160):
# After 5/10/1582, Gregorian calendar
a = jd + 32044
b = int((4 * a + 3) / 146097.)
c = a - int((b * 146097) / 4.)
else:
... |
def NewMoon ( k ): Compute the time of the k - th new moon after the new moon of 1/ 1/ 1900 13: 52 UCT ( measured as the number of days since 1/ 1/ 4713 BC noon UCT e. g. 2451545. 125 is 1/ 1/ 2000 15: 00 UTC. Returns a floating number e. g. 2415079. 9758617813 for k = 2 or 2414961. 935157746 for k = - 2. | def NewMoon(k):
'''def NewMoon(k): Compute the time of the k-th new moon after
the new moon of 1/1/1900 13:52 UCT (measured as the number of
days since 1/1/4713 BC noon UCT, e.g., 2451545.125 is 1/1/2000 15:00 UTC.
Returns a floating number, e.g., 2415079.9758617813 for k=2 or
2414961.935157746 for ... |
def SunLongitude ( jdn ): Compute the longitude of the sun at any time. Parameter: floating number jdn the number of days since 1/ 1/ 4713 BC noon. | def SunLongitude(jdn):
'''def SunLongitude(jdn): Compute the longitude of the sun at any time.
Parameter: floating number jdn, the number of days since 1/1/4713 BC noon.
'''
T = (jdn - 2451545.0) / 36525.
# Time in Julian centuries
# from 2000-01-01 12:00:00 GMT
T2 = T * T
dr = math.pi /... |
def getLunarMonth11 ( yy timeZone ): Find the day that starts the luner month 11of the given year for the given time zone. | def getLunarMonth11(yy, timeZone):
'''def getLunarMonth11(yy, timeZone): Find the day that starts the luner month
11of the given year for the given time zone.'''
# off = jdFromDate(31, 12, yy) \
# - 2415021.076998695
off = jdFromDate(31, 12, yy) - 2415021.
k = int(off / 29.530588853)... |
def getLeapMonthOffset ( a11 timeZone ): Find the index of the leap month after the month starting on the day a11. | def getLeapMonthOffset(a11, timeZone):
'''def getLeapMonthOffset(a11, timeZone): Find the index of the leap month
after the month starting on the day a11.'''
k = int((a11 - 2415021.076998695) / 29.530588853 + 0.5)
last = 0
i = 1 # start with month following lunar month 11
arc = getSunLongitude(... |
def S2L ( dd mm yy timeZone = 7 ): Convert solar date dd/ mm/ yyyy to the corresponding lunar date. | def S2L(dd, mm, yy, timeZone=7):
'''def S2L(dd, mm, yy, timeZone = 7): Convert solar date dd/mm/yyyy to
the corresponding lunar date.'''
dayNumber = jdFromDate(dd, mm, yy)
k = int((dayNumber - 2415021.076998695) / 29.530588853)
monthStart = getNewMoonDay(k + 1, timeZone)
if (monthStart > dayNumb... |
def L2S ( lunarD lunarM lunarY lunarLeap tZ = 7 ): Convert a lunar date to the corresponding solar date. | def L2S(lunarD, lunarM, lunarY, lunarLeap, tZ=7):
'''def L2S(lunarD, lunarM, lunarY, lunarLeap, tZ = 7): Convert a lunar date
to the corresponding solar date.'''
if (lunarM < 11):
a11 = getLunarMonth11(lunarY - 1, tZ)
b11 = getLunarMonth11(lunarY, tZ)
else:
a11 = getLunarMonth11(... |
Check for MZ signature. | def hasMZSignature(self, rd):
"""
Check for MZ signature.
@type rd: L{ReadData}
@param rd: A L{ReadData} object.
@rtype: bool
@return: True is the given L{ReadData} stream has the MZ signature. Otherwise, False.
"""
rd.setOffset(0)
sign = rd.rea... |
Check for PE signature. | def hasPESignature(self, rd):
"""
Check for PE signature.
@type rd: L{ReadData}
@param rd: A L{ReadData} object.
@rtype: bool
@return: True is the given L{ReadData} stream has the PE signature. Otherwise, False.
"""
rd.setOffset(0)
e_lfanew_offse... |
Performs validations over some fields of the PE structure to determine if the loaded file has a valid PE format. | def validate(self):
"""
Performs validations over some fields of the PE structure to determine if the loaded file has a valid PE format.
@raise PEException: If an invalid value is found into the PE instance.
"""
# Ange Albertini (@angie4771) can kill me for this! :)
... |
Returns data from a file. | def readFile(self, pathToFile):
"""
Returns data from a file.
@type pathToFile: str
@param pathToFile: Path to the file.
@rtype: str
@return: The data from file.
"""
fd = open(pathToFile, "rb")
data = fd.read()
fd.close()... |
Writes data from L { PE } object to a file. @rtype: str @return: The L { PE } stream data. | def write(self, filename = ""):
"""
Writes data from L{PE} object to a file.
@rtype: str
@return: The L{PE} stream data.
@raise IOError: If the file could not be opened for write operations.
"""
file_data = str(self)
if filename:
try:... |
Write data to a file. | def __write(self, thePath, theData):
"""
Write data to a file.
@type thePath: str
@param thePath: The file path.
@type theData: str
@param theData: The data to write.
"""
fd = open(thePath, "wb")
fd.write(theData)
fd.c... |
Updates the data in every L { Directory } object. | def _updateDirectoriesData(self, peStr):
"""
Updates the data in every L{Directory} object.
@type peStr: str
@param peStr: C{str} representation of the L{PE} object.
@rtype: str
@return: A C{str} representation of the L{PE} object.
"""
da... |
Returns the data between the last section header and the begenning of data from the first section. | def _getPaddingDataToSectionOffset(self):
"""
Returns the data between the last section header and the begenning of data from the first section.
@rtype: str
@return: Data between last section header and the begenning of the first section.
"""
start = self._getPad... |
Returns the digital signature within a digital signed PE file. | def _getSignature(self, readDataInstance, dataDirectoryInstance):
"""
Returns the digital signature within a digital signed PE file.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} instance containing a PE file data.
@type dataDirector... |
Returns the overlay data from the PE file. | def _getOverlay(self, readDataInstance, sectionHdrsInstance):
"""
Returns the overlay data from the PE file.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} instance containing the PE file data.
@type sectionHdrsInstance: L{SectionHead... |
Converts an offset to an RVA. | def getOffsetFromRva(self, rva):
"""
Converts an offset to an RVA.
@type rva: int
@param rva: The RVA to be converted.
@rtype: int
@return: An integer value representing an offset in the PE file.
"""
offset = -1
s = self.getSectio... |
Converts a RVA to an offset. | def getRvaFromOffset(self, offset):
"""
Converts a RVA to an offset.
@type offset: int
@param offset: The offset value to be converted to RVA.
@rtype: int
@return: The RVA obtained from the given offset.
"""
rva = -1
s = self.getS... |
Given an offset in the file tries to determine the section this offset belong to. | def getSectionByOffset(self, offset):
"""
Given an offset in the file, tries to determine the section this offset belong to.
@type offset: int
@param offset: Offset value.
@rtype: int
@return: An index, starting at 0, that represents the section the give... |
Given a string representing a section name tries to find the section index. | def getSectionIndexByName(self, name):
"""
Given a string representing a section name, tries to find the section index.
@type name: str
@param name: A section name.
@rtype: int
@return: The index, starting at 0, of the section.
"""
index = -1
... |
Given a RVA in the file tries to determine the section this RVA belongs to. | def getSectionByRva(self, rva):
"""
Given a RVA in the file, tries to determine the section this RVA belongs to.
@type rva: int
@param rva: RVA value.
@rtype: int
@return: An index, starting at 1, that represents the section the given RVA belongs to.
... |
Returns the offset to last section header present in the PE file. | def _getPaddingToSectionOffset(self):
"""
Returns the offset to last section header present in the PE file.
@rtype: int
@return: The offset where the end of the last section header resides in the PE file.
"""
return len(str(self.dosHeader) + str(self.dosStub) + s... |
Parse all the directories in the PE file. | def fullLoad(self):
"""Parse all the directories in the PE file."""
self._parseDirectories(self.ntHeaders.optionalHeader.dataDirectory, self.PE_TYPE) |
Populates the attributes of the L { PE } object. | def _internalParse(self, readDataInstance):
"""
Populates the attributes of the L{PE} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} instance with the data of a PE file.
"""
self.dosHeader = DosHeader.parse(readDataInstance)
... |
Adds a new section to the existing L { PE } instance. | def addSection(self, data, name =".pype32\x00", flags = 0x60000000):
"""
Adds a new section to the existing L{PE} instance.
@type data: str
@param data: The data to be added in the new section.
@type name: str
@param name: (Optional) The name for the new... |
Extends an existing section in the L { PE } instance. | def extendSection(self, sectionIndex, data):
"""
Extends an existing section in the L{PE} instance.
@type sectionIndex: int
@param sectionIndex: The index for the section to be extended.
@type data: str
@param data: The data to include in the section.
... |
Fixes the necessary fields in the PE file instance in order to create a valid PE32. i. e. SizeOfImage. | def _fixPe(self):
"""
Fixes the necessary fields in the PE file instance in order to create a valid PE32. i.e. SizeOfImage.
"""
sizeOfImage = 0
for sh in self.sectionHeaders:
sizeOfImage += sh.misc
self.ntHeaders.optionaHeader.sizeoOfImage.value = self._sectio... |
Align a value to C { FileAligment }. | def _adjustFileAlignment(self, value, fileAlignment):
"""
Align a value to C{FileAligment}.
@type value: int
@param value: The value to align.
@type fileAlignment: int
@param fileAlignment: The value to be used to align the C{value} parameter.
... |
Align a value to C { SectionAligment }. | def _adjustSectionAlignment(self, value, fileAlignment, sectionAlignment):
"""
Align a value to C{SectionAligment}.
@type value: int
@param value: The value to be aligned.
@type fileAlignment: int
@param fileAlignment: The value to be used as C{FileAlig... |
Returns a C { DWORD } from a given RVA. | def getDwordAtRva(self, rva):
"""
Returns a C{DWORD} from a given RVA.
@type rva: int
@param rva: The RVA to get the C{DWORD} from.
@rtype: L{DWORD}
@return: The L{DWORD} obtained at the given RVA.
"""
return datatypes.DWORD.parse(utils.... |
Returns a C { WORD } from a given RVA. | def getWordAtRva(self, rva):
"""
Returns a C{WORD} from a given RVA.
@type rva: int
@param rva: The RVA to get the C{WORD} from.
@rtype: L{WORD}
@return: The L{WORD} obtained at the given RVA.
"""
return datatypes.WORD.parse(utils.ReadDa... |
Returns a C { DWORD } from a given offset. | def getDwordAtOffset(self, offset):
"""
Returns a C{DWORD} from a given offset.
@type offset: int
@param offset: The offset to get the C{DWORD} from.
@rtype: L{DWORD}
@return: The L{DWORD} obtained at the given offset.
"""
return datatyp... |
Returns a C { WORD } from a given offset. | def getWordAtOffset(self, offset):
"""
Returns a C{WORD} from a given offset.
@type offset: int
@param offset: The offset to get the C{WORD} from.
@rtype: L{WORD}
@return: The L{WORD} obtained at the given offset.
"""
return datatypes.WO... |
Returns a C { QWORD } from a given RVA. | def getQwordAtRva(self, rva):
"""
Returns a C{QWORD} from a given RVA.
@type rva: int
@param rva: The RVA to get the C{QWORD} from.
@rtype: L{QWORD}
@return: The L{QWORD} obtained at the given RVA.
"""
return datatypes.QWORD.parse(utils.... |
Returns a C { QWORD } from a given offset. | def getQwordAtOffset(self, offset):
"""
Returns a C{QWORD} from a given offset.
@type offset: int
@param offset: The offset to get the C{QWORD} from.
@rtype: L{QWORD}
@return: The L{QWORD} obtained at the given offset.
"""
return datatyp... |
Gets binary data at a given RVA. | def getDataAtRva(self, rva, size):
"""
Gets binary data at a given RVA.
@type rva: int
@param rva: The RVA to get the data from.
@type size: int
@param size: The size of the data to be obtained.
@rtype: str
@return: The data obt... |
Gets binary data at a given offset. | def getDataAtOffset(self, offset, size):
"""
Gets binary data at a given offset.
@type offset: int
@param offset: The offset to get the data from.
@type size: int
@param size: The size of the data to be obtained.
@rtype: str
@ret... |
Returns a L { String } object from a given RVA. | def readStringAtRva(self, rva):
"""
Returns a L{String} object from a given RVA.
@type rva: int
@param rva: The RVA to get the string from.
@rtype: L{String}
@return: A new L{String} object from the given RVA.
"""
d = self.getDataAtRva(r... |
Determines if the current L { PE } instance is an Executable file. | def isExe(self):
"""
Determines if the current L{PE} instance is an Executable file.
@rtype: bool
@return: C{True} if the current L{PE} instance is an Executable file. Otherwise, returns C{False}.
"""
if not self.isDll() and not self.isDriver() and ( consts.IMAGE... |
Determines if the current L { PE } instance is a Dynamic Link Library file. | def isDll(self):
"""
Determines if the current L{PE} instance is a Dynamic Link Library file.
@rtype: bool
@return: C{True} if the current L{PE} instance is a DLL. Otherwise, returns C{False}.
"""
if (consts.IMAGE_FILE_DLL & self.ntHeaders.fileHeader.characterist... |
Determines if the current L { PE } instance is a driver (. sys ) file. | def isDriver(self):
"""
Determines if the current L{PE} instance is a driver (.sys) file.
@rtype: bool
@return: C{True} if the current L{PE} instance is a driver. Otherwise, returns C{False}.
"""
modules = []
imports = self.ntHeaders.optionalHeader.dataDi... |
Determines if the current L { PE } instance is a PE32 file. | def isPe32(self):
"""
Determines if the current L{PE} instance is a PE32 file.
@rtype: bool
@return: C{True} if the current L{PE} instance is a PE32 file. Otherwise, returns C{False}.
"""
if self.ntHeaders.optionalHeader.magic.value == consts.PE32:
re... |
Determines if the current L { PE } instance is a PE64 file. | def isPe64(self):
"""
Determines if the current L{PE} instance is a PE64 file.
@rtype: bool
@return: C{True} if the current L{PE} instance is a PE64 file. Otherwise, returns C{False}.
"""
if self.ntHeaders.optionalHeader.magic.value == consts.PE64:
re... |
Determines if the current L { PE } instance is bounded i. e. has a C { BOUND_IMPORT_DIRECTORY }. | def isPeBounded(self):
"""
Determines if the current L{PE} instance is bounded, i.e. has a C{BOUND_IMPORT_DIRECTORY}.
@rtype: bool
@return: Returns C{True} if the current L{PE} instance is bounded. Otherwise, returns C{False}.
"""
boundImportsDir = self.ntHeaders... |
Determines if the current L { PE } instance has the NXCOMPAT ( Compatible with Data Execution Prevention ) flag enabled. @see: U { http:// msdn. microsoft. com/ en - us/ library/ ms235442. aspx } | def isNXEnabled(self):
"""
Determines if the current L{PE} instance has the NXCOMPAT (Compatible with Data Execution Prevention) flag enabled.
@see: U{http://msdn.microsoft.com/en-us/library/ms235442.aspx}
@rtype: bool
@return: Returns C{True} if the current L{PE} instance has t... |
Determines if the current L { PE } instance has CFG ( Control Flow Guard ) flag enabled. @see: U { http:// blogs. msdn. com/ b/ vcblog/ archive/ 2014/ 12/ 08/ visual - studio - 2015 - preview - work - in - progress - security - feature. aspx } @see: U { https:// msdn. microsoft. com/ en - us/ library/ dn919635%%28v = v... | def isCFGEnabled(self):
"""
Determines if the current L{PE} instance has CFG (Control Flow Guard) flag enabled.
@see: U{http://blogs.msdn.com/b/vcblog/archive/2014/12/08/visual-studio-2015-preview-work-in-progress-security-feature.aspx}
@see: U{https://msdn.microsoft.com/en-us/library/dn... |
Determines if the current L { PE } instance has the DYNAMICBASE ( Use address space layout randomization ) flag enabled. @see: U { http:// msdn. microsoft. com/ en - us/ library/ bb384887. aspx } | def isASLREnabled(self):
"""
Determines if the current L{PE} instance has the DYNAMICBASE (Use address space layout randomization) flag enabled.
@see: U{http://msdn.microsoft.com/en-us/library/bb384887.aspx}
@rtype: bool
@return: Returns C{True} if the current L{PE} instance has... |
Determines if the current L { PE } instance has the SAFESEH ( Image has Safe Exception Handlers ) flag enabled. @see: U { http:// msdn. microsoft. com/ en - us/ library/ 9a89h429. aspx } | def isSAFESEHEnabled(self):
"""
Determines if the current L{PE} instance has the SAFESEH (Image has Safe Exception Handlers) flag enabled.
@see: U{http://msdn.microsoft.com/en-us/library/9a89h429.aspx}
@rtype: bool
@return: Returns C{True} if the current L{PE} instance has the S... |
Parses all the directories in the L { PE } instance. | def _parseDirectories(self, dataDirectoryInstance, magic = consts.PE32):
"""
Parses all the directories in the L{PE} instance.
@type dataDirectoryInstance: L{DataDirectory}
@param dataDirectoryInstance: A L{DataDirectory} object with the directories data.
@type ... |
Parses the C { IMAGE_RESOURCE_DIRECTORY } directory. | def _parseResourceDirectory(self, rva, size, magic = consts.PE32):
"""
Parses the C{IMAGE_RESOURCE_DIRECTORY} directory.
@type rva: int
@param rva: The RVA where the C{IMAGE_RESOURCE_DIRECTORY} starts.
@type size: int
@param size: The size of the C{IMAG... |
Parses the C { IMAGE_EXCEPTION_DIRECTORY } directory. | def _parseExceptionDirectory(self, rva, size, magic = consts.PE32):
"""
Parses the C{IMAGE_EXCEPTION_DIRECTORY} directory.
@type rva: int
@param rva: The RVA where the C{IMAGE_EXCEPTION_DIRECTORY} starts.
@type size: int
@param size: The size of the C{I... |
Parses the delay imports directory. | def _parseDelayImportDirectory(self, rva, size, magic = consts.PE32):
"""
Parses the delay imports directory.
@type rva: int
@param rva: The RVA where the delay imports directory starts.
@type size: int
@param size: The size of the delay imports directo... |
Parses the bound import directory. | def _parseBoundImportDirectory(self, rva, size, magic = consts.PE32):
"""
Parses the bound import directory.
@type rva: int
@param rva: The RVA where the bound import directory starts.
@type size: int
@param size: The size of the bound import directory.... |
Parses IMAGE_LOAD_CONFIG_DIRECTORY. | def _parseLoadConfigDirectory(self, rva, size, magic = consts.PE32):
"""
Parses IMAGE_LOAD_CONFIG_DIRECTORY.
@type rva: int
@param rva: The RVA where the IMAGE_LOAD_CONFIG_DIRECTORY starts.
@type size: int
@param size: The size of the IMAGE_LOAD_CONFIG_... |
Parses the TLS directory. | def _parseTlsDirectory(self, rva, size, magic = consts.PE32):
"""
Parses the TLS directory.
@type rva: int
@param rva: The RVA where the TLS directory starts.
@type size: int
@param size: The size of the TLS directory.
@type magic: int
... |
Parses the relocation directory. | def _parseRelocsDirectory(self, rva, size, magic = consts.PE32):
"""
Parses the relocation directory.
@type rva: int
@param rva: The RVA where the relocation directory starts.
@type size: int
@param size: The size of the relocation directory.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.