repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
secdev/scapy
scapy/route.py
Route.delt
def delt(self, *args, **kargs): """delt(host|net, gw|dev)""" self.invalidate_cache() route = self.make_route(*args, **kargs) try: i = self.routes.index(route) del(self.routes[i]) except ValueError: warning("no matching route found")
python
def delt(self, *args, **kargs): """delt(host|net, gw|dev)""" self.invalidate_cache() route = self.make_route(*args, **kargs) try: i = self.routes.index(route) del(self.routes[i]) except ValueError: warning("no matching route found")
[ "def", "delt", "(", "self", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "self", ".", "invalidate_cache", "(", ")", "route", "=", "self", ".", "make_route", "(", "*", "args", ",", "*", "*", "kargs", ")", "try", ":", "i", "=", "self", "."...
delt(host|net, gw|dev)
[ "delt", "(", "host|net", "gw|dev", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/route.py#L78-L86
train
secdev/scapy
scapy/route.py
Route.route
def route(self, dst=None, verbose=conf.verb): """Returns the IPv4 routes to a host. parameters: - dst: the IPv4 of the destination host returns: (iface, output_ip, gateway_ip) - iface: the interface used to connect to the host - output_ip: the outgoing IP that will be...
python
def route(self, dst=None, verbose=conf.verb): """Returns the IPv4 routes to a host. parameters: - dst: the IPv4 of the destination host returns: (iface, output_ip, gateway_ip) - iface: the interface used to connect to the host - output_ip: the outgoing IP that will be...
[ "def", "route", "(", "self", ",", "dst", "=", "None", ",", "verbose", "=", "conf", ".", "verb", ")", ":", "dst", "=", "dst", "or", "\"0.0.0.0\"", "# Enable route(None) to return default route", "if", "isinstance", "(", "dst", ",", "bytes", ")", ":", "try",...
Returns the IPv4 routes to a host. parameters: - dst: the IPv4 of the destination host returns: (iface, output_ip, gateway_ip) - iface: the interface used to connect to the host - output_ip: the outgoing IP that will be used - gateway_ip: the gateway IP that will be ...
[ "Returns", "the", "IPv4", "routes", "to", "a", "host", ".", "parameters", ":", "-", "dst", ":", "the", "IPv4", "of", "the", "destination", "host" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/route.py#L128-L178
train
secdev/scapy
scapy/arch/windows/native.py
open_icmp_firewall
def open_icmp_firewall(host): """Temporarily open the ICMP firewall. Tricks Windows into allowing ICMP packets for a short period of time (~ 1 minute)""" # We call ping with a timeout of 1ms: will return instantly with open(os.devnull, 'wb') as DEVNULL: return subprocess.Popen("ping -4 -w 1 -n 1...
python
def open_icmp_firewall(host): """Temporarily open the ICMP firewall. Tricks Windows into allowing ICMP packets for a short period of time (~ 1 minute)""" # We call ping with a timeout of 1ms: will return instantly with open(os.devnull, 'wb') as DEVNULL: return subprocess.Popen("ping -4 -w 1 -n 1...
[ "def", "open_icmp_firewall", "(", "host", ")", ":", "# We call ping with a timeout of 1ms: will return instantly", "with", "open", "(", "os", ".", "devnull", ",", "'wb'", ")", "as", "DEVNULL", ":", "return", "subprocess", ".", "Popen", "(", "\"ping -4 -w 1 -n 1 %s\"",...
Temporarily open the ICMP firewall. Tricks Windows into allowing ICMP packets for a short period of time (~ 1 minute)
[ "Temporarily", "open", "the", "ICMP", "firewall", ".", "Tricks", "Windows", "into", "allowing", "ICMP", "packets", "for", "a", "short", "period", "of", "time", "(", "~", "1", "minute", ")" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/windows/native.py#L203-L211
train
secdev/scapy
scapy/layers/tls/handshake.py
TLSClientHello.tls_session_update
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the client_random along with the raw string representing this handshake message. """ super(TLSClientHello, self).tls_session_update(msg_str) self.tls_session.advertised_tls_version = self...
python
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the client_random along with the raw string representing this handshake message. """ super(TLSClientHello, self).tls_session_update(msg_str) self.tls_session.advertised_tls_version = self...
[ "def", "tls_session_update", "(", "self", ",", "msg_str", ")", ":", "super", "(", "TLSClientHello", ",", "self", ")", ".", "tls_session_update", "(", "msg_str", ")", "self", ".", "tls_session", ".", "advertised_tls_version", "=", "self", ".", "version", "self"...
Either for parsing or building, we store the client_random along with the raw string representing this handshake message.
[ "Either", "for", "parsing", "or", "building", "we", "store", "the", "client_random", "along", "with", "the", "raw", "string", "representing", "this", "handshake", "message", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L280-L298
train
secdev/scapy
scapy/layers/tls/handshake.py
TLSServerHello.tls_session_update
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the session_id, the cipher suite (if recognized), the compression method, and finally we instantiate ...
python
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the session_id, the cipher suite (if recognized), the compression method, and finally we instantiate ...
[ "def", "tls_session_update", "(", "self", ",", "msg_str", ")", ":", "super", "(", "TLSClientHello", ",", "self", ")", ".", "tls_session_update", "(", "msg_str", ")", "self", ".", "tls_session", ".", "tls_version", "=", "self", ".", "version", "self", ".", ...
Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the session_id, the cipher suite (if recognized), the compression method, and finally we instantiate the pending write and read connection states. Usual...
[ "Either", "for", "parsing", "or", "building", "we", "store", "the", "server_random", "along", "with", "the", "raw", "string", "representing", "this", "handshake", "message", ".", "We", "also", "store", "the", "session_id", "the", "cipher", "suite", "(", "if", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L354-L399
train
secdev/scapy
scapy/layers/tls/handshake.py
TLS13ServerHello.tls_session_update
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the cipher suite (if recognized), and finally we instantiate the write and read connection states. ...
python
def tls_session_update(self, msg_str): """ Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the cipher suite (if recognized), and finally we instantiate the write and read connection states. ...
[ "def", "tls_session_update", "(", "self", ",", "msg_str", ")", ":", "super", "(", "TLSClientHello", ",", "self", ")", ".", "tls_session_update", "(", "msg_str", ")", "s", "=", "self", ".", "tls_session", "s", ".", "tls_version", "=", "self", ".", "version"...
Either for parsing or building, we store the server_random along with the raw string representing this handshake message. We also store the cipher suite (if recognized), and finally we instantiate the write and read connection states.
[ "Either", "for", "parsing", "or", "building", "we", "store", "the", "server_random", "along", "with", "the", "raw", "string", "representing", "this", "handshake", "message", ".", "We", "also", "store", "the", "cipher", "suite", "(", "if", "recognized", ")", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L415-L451
train
secdev/scapy
scapy/layers/tls/handshake.py
TLSServerKeyExchange.build
def build(self, *args, **kargs): """ We overload build() method in order to provide a valid default value for params based on TLS session if not provided. This cannot be done by overriding i2m() because the method is called on a copy of the packet. The 'params' field is built ac...
python
def build(self, *args, **kargs): """ We overload build() method in order to provide a valid default value for params based on TLS session if not provided. This cannot be done by overriding i2m() because the method is called on a copy of the packet. The 'params' field is built ac...
[ "def", "build", "(", "self", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "fval", "=", "self", ".", "getfieldval", "(", "\"params\"", ")", "if", "fval", "is", "None", ":", "s", "=", "self", ".", "tls_session", "if", "s", ".", "pwcs", ":", ...
We overload build() method in order to provide a valid default value for params based on TLS session if not provided. This cannot be done by overriding i2m() because the method is called on a copy of the packet. The 'params' field is built according to key_exchange.server_kx_msg_cls whi...
[ "We", "overload", "build", "()", "method", "in", "order", "to", "provide", "a", "valid", "default", "value", "for", "params", "based", "on", "TLS", "session", "if", "not", "provided", ".", "This", "cannot", "be", "done", "by", "overriding", "i2m", "()", ...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L689-L746
train
secdev/scapy
scapy/layers/tls/handshake.py
TLSServerKeyExchange.post_dissection
def post_dissection(self, pkt): """ While previously dissecting Server*DHParams, the session server_kx_pubkey should have been updated. XXX Add a 'fixed_dh' OR condition to the 'anonymous' test. """ s = self.tls_session if s.prcs and s.prcs.key_exchange.no_ske: ...
python
def post_dissection(self, pkt): """ While previously dissecting Server*DHParams, the session server_kx_pubkey should have been updated. XXX Add a 'fixed_dh' OR condition to the 'anonymous' test. """ s = self.tls_session if s.prcs and s.prcs.key_exchange.no_ske: ...
[ "def", "post_dissection", "(", "self", ",", "pkt", ")", ":", "s", "=", "self", ".", "tls_session", "if", "s", ".", "prcs", "and", "s", ".", "prcs", ".", "key_exchange", ".", "no_ske", ":", "pkt_info", "=", "pkt", ".", "firstlayer", "(", ")", ".", "...
While previously dissecting Server*DHParams, the session server_kx_pubkey should have been updated. XXX Add a 'fixed_dh' OR condition to the 'anonymous' test.
[ "While", "previously", "dissecting", "Server", "*", "DHParams", "the", "session", "server_kx_pubkey", "should", "have", "been", "updated", "." ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L748-L767
train
secdev/scapy
scapy/layers/tls/handshake.py
_TLSCKExchKeysField.m2i
def m2i(self, pkt, m): """ The client_kx_msg may be either None, EncryptedPreMasterSecret (for RSA encryption key exchange), ClientDiffieHellmanPublic, or ClientECDiffieHellmanPublic. When either one of them gets dissected, the session context is updated accordingly. """ ...
python
def m2i(self, pkt, m): """ The client_kx_msg may be either None, EncryptedPreMasterSecret (for RSA encryption key exchange), ClientDiffieHellmanPublic, or ClientECDiffieHellmanPublic. When either one of them gets dissected, the session context is updated accordingly. """ ...
[ "def", "m2i", "(", "self", ",", "pkt", ",", "m", ")", ":", "tmp_len", "=", "self", ".", "length_from", "(", "pkt", ")", "tbd", ",", "rem", "=", "m", "[", ":", "tmp_len", "]", ",", "m", "[", "tmp_len", ":", "]", "s", "=", "pkt", ".", "tls_sess...
The client_kx_msg may be either None, EncryptedPreMasterSecret (for RSA encryption key exchange), ClientDiffieHellmanPublic, or ClientECDiffieHellmanPublic. When either one of them gets dissected, the session context is updated accordingly.
[ "The", "client_kx_msg", "may", "be", "either", "None", "EncryptedPreMasterSecret", "(", "for", "RSA", "encryption", "key", "exchange", ")", "ClientDiffieHellmanPublic", "or", "ClientECDiffieHellmanPublic", ".", "When", "either", "one", "of", "them", "gets", "dissected...
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/tls/handshake.py#L923-L942
train
secdev/scapy
scapy/modules/nmap.py
nmap_fp
def nmap_fp(target, oport=80, cport=81): """nmap fingerprinting nmap_fp(target, [oport=80,] [cport=81,]) -> list of best guesses with accuracy """ sigs = nmap_sig(target, oport, cport) return nmap_search(sigs)
python
def nmap_fp(target, oport=80, cport=81): """nmap fingerprinting nmap_fp(target, [oport=80,] [cport=81,]) -> list of best guesses with accuracy """ sigs = nmap_sig(target, oport, cport) return nmap_search(sigs)
[ "def", "nmap_fp", "(", "target", ",", "oport", "=", "80", ",", "cport", "=", "81", ")", ":", "sigs", "=", "nmap_sig", "(", "target", ",", "oport", ",", "cport", ")", "return", "nmap_search", "(", "sigs", ")" ]
nmap fingerprinting nmap_fp(target, [oport=80,] [cport=81,]) -> list of best guesses with accuracy
[ "nmap", "fingerprinting", "nmap_fp", "(", "target", "[", "oport", "=", "80", "]", "[", "cport", "=", "81", "]", ")", "-", ">", "list", "of", "best", "guesses", "with", "accuracy" ]
3ffe757c184017dd46464593a8f80f85abc1e79a
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/nmap.py#L198-L203
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
process_kwargs
def process_kwargs(obj, kwargs): ''' Convenience wrapper around binwalk.core.module.Modules.kwargs. @obj - The class object (an instance of a sub-class of binwalk.core.module.Module). @kwargs - The kwargs provided to the object's __init__ method. Returns None. ''' with Modules() as m: ...
python
def process_kwargs(obj, kwargs): ''' Convenience wrapper around binwalk.core.module.Modules.kwargs. @obj - The class object (an instance of a sub-class of binwalk.core.module.Module). @kwargs - The kwargs provided to the object's __init__ method. Returns None. ''' with Modules() as m: ...
[ "def", "process_kwargs", "(", "obj", ",", "kwargs", ")", ":", "with", "Modules", "(", ")", "as", "m", ":", "kwargs", "=", "m", ".", "kwargs", "(", "obj", ",", "kwargs", ")", "return", "kwargs" ]
Convenience wrapper around binwalk.core.module.Modules.kwargs. @obj - The class object (an instance of a sub-class of binwalk.core.module.Module). @kwargs - The kwargs provided to the object's __init__ method. Returns None.
[ "Convenience", "wrapper", "around", "binwalk", ".", "core", ".", "module", ".", "Modules", ".", "kwargs", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L996-L1007
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
show_help
def show_help(fd=sys.stdout): ''' Convenience wrapper around binwalk.core.module.Modules.help. @fd - An object with a write method (e.g., sys.stdout, sys.stderr, etc). Returns None. ''' with Modules() as m: fd.write(m.help())
python
def show_help(fd=sys.stdout): ''' Convenience wrapper around binwalk.core.module.Modules.help. @fd - An object with a write method (e.g., sys.stdout, sys.stderr, etc). Returns None. ''' with Modules() as m: fd.write(m.help())
[ "def", "show_help", "(", "fd", "=", "sys", ".", "stdout", ")", ":", "with", "Modules", "(", ")", "as", "m", ":", "fd", ".", "write", "(", "m", ".", "help", "(", ")", ")" ]
Convenience wrapper around binwalk.core.module.Modules.help. @fd - An object with a write method (e.g., sys.stdout, sys.stderr, etc). Returns None.
[ "Convenience", "wrapper", "around", "binwalk", ".", "core", ".", "module", ".", "Modules", ".", "help", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L1010-L1019
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Module.next_file
def next_file(self, close_previous=True): ''' Gets the next file to be scanned (including pending extracted files, if applicable). Also re/initializes self.status. All modules should access the target file list through this method. ''' fp = None # Ensure files ar...
python
def next_file(self, close_previous=True): ''' Gets the next file to be scanned (including pending extracted files, if applicable). Also re/initializes self.status. All modules should access the target file list through this method. ''' fp = None # Ensure files ar...
[ "def", "next_file", "(", "self", ",", "close_previous", "=", "True", ")", ":", "fp", "=", "None", "# Ensure files are close to prevent IOError (too many open files)", "if", "close_previous", ":", "try", ":", "self", ".", "previous_next_file_fp", ".", "close", "(", "...
Gets the next file to be scanned (including pending extracted files, if applicable). Also re/initializes self.status. All modules should access the target file list through this method.
[ "Gets", "the", "next", "file", "to", "be", "scanned", "(", "including", "pending", "extracted", "files", "if", "applicable", ")", ".", "Also", "re", "/", "initializes", "self", ".", "status", ".", "All", "modules", "should", "access", "the", "target", "fil...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L386-L447
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Module.clear
def clear(self, results=True, errors=True): ''' Clears results and errors lists. ''' if results: self.results = [] if errors: self.errors = []
python
def clear(self, results=True, errors=True): ''' Clears results and errors lists. ''' if results: self.results = [] if errors: self.errors = []
[ "def", "clear", "(", "self", ",", "results", "=", "True", ",", "errors", "=", "True", ")", ":", "if", "results", ":", "self", ".", "results", "=", "[", "]", "if", "errors", ":", "self", ".", "errors", "=", "[", "]" ]
Clears results and errors lists.
[ "Clears", "results", "and", "errors", "lists", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L449-L456
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Module.result
def result(self, r=None, **kwargs): ''' Validates a result, stores it in self.results and prints it. Accepts the same kwargs as the binwalk.core.module.Result class. @r - An existing instance of binwalk.core.module.Result. Returns an instance of binwalk.core.module.Result. ...
python
def result(self, r=None, **kwargs): ''' Validates a result, stores it in self.results and prints it. Accepts the same kwargs as the binwalk.core.module.Result class. @r - An existing instance of binwalk.core.module.Result. Returns an instance of binwalk.core.module.Result. ...
[ "def", "result", "(", "self", ",", "r", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "r", "is", "None", ":", "r", "=", "Result", "(", "*", "*", "kwargs", ")", "# Add the name of the current module to the result", "r", ".", "module", "=", "self...
Validates a result, stores it in self.results and prints it. Accepts the same kwargs as the binwalk.core.module.Result class. @r - An existing instance of binwalk.core.module.Result. Returns an instance of binwalk.core.module.Result.
[ "Validates", "a", "result", "stores", "it", "in", "self", ".", "results", "and", "prints", "it", ".", "Accepts", "the", "same", "kwargs", "as", "the", "binwalk", ".", "core", ".", "module", ".", "Result", "class", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L458-L503
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Module.error
def error(self, **kwargs): ''' Stores the specified error in self.errors. Accepts the same kwargs as the binwalk.core.module.Error class. Returns None. ''' exception_header_width = 100 e = Error(**kwargs) e.module = self.__class__.__name__ self...
python
def error(self, **kwargs): ''' Stores the specified error in self.errors. Accepts the same kwargs as the binwalk.core.module.Error class. Returns None. ''' exception_header_width = 100 e = Error(**kwargs) e.module = self.__class__.__name__ self...
[ "def", "error", "(", "self", ",", "*", "*", "kwargs", ")", ":", "exception_header_width", "=", "100", "e", "=", "Error", "(", "*", "*", "kwargs", ")", "e", ".", "module", "=", "self", ".", "__class__", ".", "__name__", "self", ".", "errors", ".", "...
Stores the specified error in self.errors. Accepts the same kwargs as the binwalk.core.module.Error class. Returns None.
[ "Stores", "the", "specified", "error", "in", "self", ".", "errors", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L505-L526
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Module.header
def header(self): ''' Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT. Returns None. ''' self.config.display.format_strings(self.HEADER_FORMAT, self.RESULT_FORMAT) self.config.display.add_custom_header(self.VERBOSE_FORMAT, self.VERBOSE) ...
python
def header(self): ''' Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT. Returns None. ''' self.config.display.format_strings(self.HEADER_FORMAT, self.RESULT_FORMAT) self.config.display.add_custom_header(self.VERBOSE_FORMAT, self.VERBOSE) ...
[ "def", "header", "(", "self", ")", ":", "self", ".", "config", ".", "display", ".", "format_strings", "(", "self", ".", "HEADER_FORMAT", ",", "self", ".", "RESULT_FORMAT", ")", "self", ".", "config", ".", "display", ".", "add_custom_header", "(", "self", ...
Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT. Returns None.
[ "Displays", "the", "scan", "header", "as", "defined", "by", "self", ".", "HEADER", "and", "self", ".", "HEADER_FORMAT", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L528-L540
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Module.main
def main(self): ''' Responsible for calling self.init, initializing self.config.display, and calling self.run. Returns the value returned from self.run. ''' self.status = self.parent.status self.modules = self.parent.executed_modules # A special exception for th...
python
def main(self): ''' Responsible for calling self.init, initializing self.config.display, and calling self.run. Returns the value returned from self.run. ''' self.status = self.parent.status self.modules = self.parent.executed_modules # A special exception for th...
[ "def", "main", "(", "self", ")", ":", "self", ".", "status", "=", "self", ".", "parent", ".", "status", "self", ".", "modules", "=", "self", ".", "parent", ".", "executed_modules", "# A special exception for the extractor module, which should be allowed to", "# over...
Responsible for calling self.init, initializing self.config.display, and calling self.run. Returns the value returned from self.run.
[ "Responsible", "for", "calling", "self", ".", "init", "initializing", "self", ".", "config", ".", "display", "and", "calling", "self", ".", "run", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L556-L605
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Modules.list
def list(self, attribute="run"): ''' Finds all modules with the specified attribute. @attribute - The desired module attribute. Returns a list of modules that contain the specified attribute, in the order they should be executed. ''' import binwalk.modules modul...
python
def list(self, attribute="run"): ''' Finds all modules with the specified attribute. @attribute - The desired module attribute. Returns a list of modules that contain the specified attribute, in the order they should be executed. ''' import binwalk.modules modul...
[ "def", "list", "(", "self", ",", "attribute", "=", "\"run\"", ")", ":", "import", "binwalk", ".", "modules", "modules", "=", "{", "}", "for", "(", "name", ",", "module", ")", "in", "inspect", ".", "getmembers", "(", "binwalk", ".", "modules", ")", ":...
Finds all modules with the specified attribute. @attribute - The desired module attribute. Returns a list of modules that contain the specified attribute, in the order they should be executed.
[ "Finds", "all", "modules", "with", "the", "specified", "attribute", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L692-L725
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Modules.help
def help(self): ''' Generates formatted help output. Returns the help string. ''' modules = {} help_string = "\n" help_string += "Binwalk v%s\n" % binwalk.__version__ help_string += "Craig Heffner, ReFirmLabs\n" help_string += "https://github.com/...
python
def help(self): ''' Generates formatted help output. Returns the help string. ''' modules = {} help_string = "\n" help_string += "Binwalk v%s\n" % binwalk.__version__ help_string += "Craig Heffner, ReFirmLabs\n" help_string += "https://github.com/...
[ "def", "help", "(", "self", ")", ":", "modules", "=", "{", "}", "help_string", "=", "\"\\n\"", "help_string", "+=", "\"Binwalk v%s\\n\"", "%", "binwalk", ".", "__version__", "help_string", "+=", "\"Craig Heffner, ReFirmLabs\\n\"", "help_string", "+=", "\"https://git...
Generates formatted help output. Returns the help string.
[ "Generates", "formatted", "help", "output", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L727-L768
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Modules.execute
def execute(self, *args, **kwargs): ''' Executes all appropriate modules according to the options specified in args/kwargs. Returns a list of executed module objects. ''' run_modules = [] orig_arguments = self.arguments if args or kwargs: self._set_a...
python
def execute(self, *args, **kwargs): ''' Executes all appropriate modules according to the options specified in args/kwargs. Returns a list of executed module objects. ''' run_modules = [] orig_arguments = self.arguments if args or kwargs: self._set_a...
[ "def", "execute", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "run_modules", "=", "[", "]", "orig_arguments", "=", "self", ".", "arguments", "if", "args", "or", "kwargs", ":", "self", ".", "_set_arguments", "(", "list", "(", "ar...
Executes all appropriate modules according to the options specified in args/kwargs. Returns a list of executed module objects.
[ "Executes", "all", "appropriate", "modules", "according", "to", "the", "options", "specified", "in", "args", "/", "kwargs", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L770-L796
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Modules.run
def run(self, module, dependency=False, kwargs={}): ''' Runs a specific module. ''' try: obj = self.load(module, kwargs) if isinstance(obj, binwalk.core.module.Module) and obj.enabled: obj.main() self.status.clear() # ...
python
def run(self, module, dependency=False, kwargs={}): ''' Runs a specific module. ''' try: obj = self.load(module, kwargs) if isinstance(obj, binwalk.core.module.Module) and obj.enabled: obj.main() self.status.clear() # ...
[ "def", "run", "(", "self", ",", "module", ",", "dependency", "=", "False", ",", "kwargs", "=", "{", "}", ")", ":", "try", ":", "obj", "=", "self", ".", "load", "(", "module", ",", "kwargs", ")", "if", "isinstance", "(", "obj", ",", "binwalk", "."...
Runs a specific module.
[ "Runs", "a", "specific", "module", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L798-L829
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Modules.argv
def argv(self, module, argv=sys.argv[1:]): ''' Processes argv for any options specific to the specified module. @module - The module to process argv for. @argv - A list of command line arguments (excluding argv[0]). Returns a dictionary of kwargs for the specified module. ...
python
def argv(self, module, argv=sys.argv[1:]): ''' Processes argv for any options specific to the specified module. @module - The module to process argv for. @argv - A list of command line arguments (excluding argv[0]). Returns a dictionary of kwargs for the specified module. ...
[ "def", "argv", "(", "self", ",", "module", ",", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", ")", ":", "kwargs", "=", "{", "'enabled'", ":", "False", "}", "last_priority", "=", "{", "}", "parser", "=", "argparse", ".", "ArgumentParser", "("...
Processes argv for any options specific to the specified module. @module - The module to process argv for. @argv - A list of command line arguments (excluding argv[0]). Returns a dictionary of kwargs for the specified module.
[ "Processes", "argv", "for", "any", "options", "specific", "to", "the", "specified", "module", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L872-L953
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Modules.kwargs
def kwargs(self, obj, kwargs): ''' Processes a module's kwargs. All modules should use this for kwarg processing. @obj - An instance of the module (e.g., self) @kwargs - The kwargs passed to the module Returns None. ''' if hasattr(obj, "KWARGS"): ...
python
def kwargs(self, obj, kwargs): ''' Processes a module's kwargs. All modules should use this for kwarg processing. @obj - An instance of the module (e.g., self) @kwargs - The kwargs passed to the module Returns None. ''' if hasattr(obj, "KWARGS"): ...
[ "def", "kwargs", "(", "self", ",", "obj", ",", "kwargs", ")", ":", "if", "hasattr", "(", "obj", ",", "\"KWARGS\"", ")", ":", "for", "module_argument", "in", "obj", ".", "KWARGS", ":", "if", "has_key", "(", "kwargs", ",", "module_argument", ".", "name",...
Processes a module's kwargs. All modules should use this for kwarg processing. @obj - An instance of the module (e.g., self) @kwargs - The kwargs passed to the module Returns None.
[ "Processes", "a", "module", "s", "kwargs", ".", "All", "modules", "should", "use", "this", "for", "kwarg", "processing", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L955-L977
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
Modules.status_server
def status_server(self, port): ''' Starts the progress bar TCP service on the specified port. This service will only be started once per instance, regardless of the number of times this method is invoked. Failure to start the status service is considered non-critical; that is, ...
python
def status_server(self, port): ''' Starts the progress bar TCP service on the specified port. This service will only be started once per instance, regardless of the number of times this method is invoked. Failure to start the status service is considered non-critical; that is, ...
[ "def", "status_server", "(", "self", ",", "port", ")", ":", "if", "self", ".", "status_server_started", "==", "False", ":", "self", ".", "status_server_started", "=", "True", "try", ":", "self", ".", "status_service", "=", "binwalk", ".", "core", ".", "sta...
Starts the progress bar TCP service on the specified port. This service will only be started once per instance, regardless of the number of times this method is invoked. Failure to start the status service is considered non-critical; that is, a warning will be displayed to the user, but...
[ "Starts", "the", "progress", "bar", "TCP", "service", "on", "the", "specified", "port", ".", "This", "service", "will", "only", "be", "started", "once", "per", "instance", "regardless", "of", "the", "number", "of", "times", "this", "method", "is", "invoked",...
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L979-L993
train
ReFirmLabs/binwalk
src/binwalk/plugins/unpfs.py
PFSCommon._make_short
def _make_short(self, data, endianness): """Returns a 2 byte integer.""" data = binwalk.core.compat.str2bytes(data) return struct.unpack('%sH' % endianness, data)[0]
python
def _make_short(self, data, endianness): """Returns a 2 byte integer.""" data = binwalk.core.compat.str2bytes(data) return struct.unpack('%sH' % endianness, data)[0]
[ "def", "_make_short", "(", "self", ",", "data", ",", "endianness", ")", ":", "data", "=", "binwalk", ".", "core", ".", "compat", ".", "str2bytes", "(", "data", ")", "return", "struct", ".", "unpack", "(", "'%sH'", "%", "endianness", ",", "data", ")", ...
Returns a 2 byte integer.
[ "Returns", "a", "2", "byte", "integer", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L10-L13
train
ReFirmLabs/binwalk
src/binwalk/plugins/unpfs.py
PFS._get_fname_len
def _get_fname_len(self, bufflen=128): """Returns the number of bytes designated for the filename.""" buff = self.meta.peek(bufflen) strlen = buff.find('\0') for i, b in enumerate(buff[strlen:]): if b != '\0': return strlen+i return bufflen
python
def _get_fname_len(self, bufflen=128): """Returns the number of bytes designated for the filename.""" buff = self.meta.peek(bufflen) strlen = buff.find('\0') for i, b in enumerate(buff[strlen:]): if b != '\0': return strlen+i return bufflen
[ "def", "_get_fname_len", "(", "self", ",", "bufflen", "=", "128", ")", ":", "buff", "=", "self", ".", "meta", ".", "peek", "(", "bufflen", ")", "strlen", "=", "buff", ".", "find", "(", "'\\0'", ")", "for", "i", ",", "b", "in", "enumerate", "(", "...
Returns the number of bytes designated for the filename.
[ "Returns", "the", "number", "of", "bytes", "designated", "for", "the", "filename", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L33-L40
train
ReFirmLabs/binwalk
src/binwalk/plugins/unpfs.py
PFS._get_node
def _get_node(self): """Reads a chunk of meta data from file and returns a PFSNode.""" data = self.meta.read(self.node_size) return PFSNode(data, self.endianness)
python
def _get_node(self): """Reads a chunk of meta data from file and returns a PFSNode.""" data = self.meta.read(self.node_size) return PFSNode(data, self.endianness)
[ "def", "_get_node", "(", "self", ")", ":", "data", "=", "self", ".", "meta", ".", "read", "(", "self", ".", "node_size", ")", "return", "PFSNode", "(", "data", ",", "self", ".", "endianness", ")" ]
Reads a chunk of meta data from file and returns a PFSNode.
[ "Reads", "a", "chunk", "of", "meta", "data", "from", "file", "and", "returns", "a", "PFSNode", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L42-L45
train
ReFirmLabs/binwalk
src/binwalk/plugins/unpfs.py
PFS.entries
def entries(self): """Returns file meta-data entries one by one.""" self.meta.seek(self.file_list_start) for i in range(0, self.num_files): yield self._get_node()
python
def entries(self): """Returns file meta-data entries one by one.""" self.meta.seek(self.file_list_start) for i in range(0, self.num_files): yield self._get_node()
[ "def", "entries", "(", "self", ")", ":", "self", ".", "meta", ".", "seek", "(", "self", ".", "file_list_start", ")", "for", "i", "in", "range", "(", "0", ",", "self", ".", "num_files", ")", ":", "yield", "self", ".", "_get_node", "(", ")" ]
Returns file meta-data entries one by one.
[ "Returns", "file", "meta", "-", "data", "entries", "one", "by", "one", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L51-L55
train
ReFirmLabs/binwalk
src/binwalk/plugins/unpfs.py
PFSNode._decode_fname
def _decode_fname(self): """Extracts the actual string from the available bytes.""" self.fname = self.fname[:self.fname.find('\0')] self.fname = self.fname.replace('\\', '/')
python
def _decode_fname(self): """Extracts the actual string from the available bytes.""" self.fname = self.fname[:self.fname.find('\0')] self.fname = self.fname.replace('\\', '/')
[ "def", "_decode_fname", "(", "self", ")", ":", "self", ".", "fname", "=", "self", ".", "fname", "[", ":", "self", ".", "fname", ".", "find", "(", "'\\0'", ")", "]", "self", ".", "fname", "=", "self", ".", "fname", ".", "replace", "(", "'\\\\'", "...
Extracts the actual string from the available bytes.
[ "Extracts", "the", "actual", "string", "from", "the", "available", "bytes", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/unpfs.py#L73-L76
train
ReFirmLabs/binwalk
src/binwalk/core/magic.py
Signature._generate_regex
def _generate_regex(self, line): ''' Generates a regular expression from the magic bytes of a signature. The regex is used by Magic._analyze. @line - The first SignatureLine object of the signature. Returns a compile regular expression. ''' restr = "" #...
python
def _generate_regex(self, line): ''' Generates a regular expression from the magic bytes of a signature. The regex is used by Magic._analyze. @line - The first SignatureLine object of the signature. Returns a compile regular expression. ''' restr = "" #...
[ "def", "_generate_regex", "(", "self", ",", "line", ")", ":", "restr", "=", "\"\"", "# Strings and single byte signatures are taken at face value;", "# multi-byte integer values are turned into regex strings based", "# on their data type size and endianness.", "if", "line", ".", "t...
Generates a regular expression from the magic bytes of a signature. The regex is used by Magic._analyze. @line - The first SignatureLine object of the signature. Returns a compile regular expression.
[ "Generates", "a", "regular", "expression", "from", "the", "magic", "bytes", "of", "a", "signature", ".", "The", "regex", "is", "used", "by", "Magic", ".", "_analyze", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L302-L375
train
ReFirmLabs/binwalk
src/binwalk/core/magic.py
Magic._filtered
def _filtered(self, text): ''' Tests if a string should be filtered out or not. @text - The string to check against filter rules. Returns True if the string should be filtered out, i.e., not displayed. Returns False if the string should be displayed. ''' filtere...
python
def _filtered(self, text): ''' Tests if a string should be filtered out or not. @text - The string to check against filter rules. Returns True if the string should be filtered out, i.e., not displayed. Returns False if the string should be displayed. ''' filtere...
[ "def", "_filtered", "(", "self", ",", "text", ")", ":", "filtered", "=", "None", "# Text is converted to lower case first, partially for historical", "# purposes, but also because it simplifies writing filter rules", "# (e.g., don't have to worry about case sensitivity).", "text", "=",...
Tests if a string should be filtered out or not. @text - The string to check against filter rules. Returns True if the string should be filtered out, i.e., not displayed. Returns False if the string should be displayed.
[ "Tests", "if", "a", "string", "should", "be", "filtered", "out", "or", "not", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L436-L471
train
ReFirmLabs/binwalk
src/binwalk/core/magic.py
Magic._do_math
def _do_math(self, offset, expression): ''' Parses and evaluates complex expressions, e.g., "(4.l+12)", "(6*32)", etc. @offset - The offset inside self.data that the current signature starts at. @expressions - The expression to evaluate. Returns an integer value that is th...
python
def _do_math(self, offset, expression): ''' Parses and evaluates complex expressions, e.g., "(4.l+12)", "(6*32)", etc. @offset - The offset inside self.data that the current signature starts at. @expressions - The expression to evaluate. Returns an integer value that is th...
[ "def", "_do_math", "(", "self", ",", "offset", ",", "expression", ")", ":", "# Does the expression contain an offset (e.g., \"(4.l+12)\")?", "if", "'.'", "in", "expression", "and", "'('", "in", "expression", ":", "replacements", "=", "{", "}", "for", "period", "in...
Parses and evaluates complex expressions, e.g., "(4.l+12)", "(6*32)", etc. @offset - The offset inside self.data that the current signature starts at. @expressions - The expression to evaluate. Returns an integer value that is the result of the evaluated expression.
[ "Parses", "and", "evaluates", "complex", "expressions", "e", ".", "g", ".", "(", "4", ".", "l", "+", "12", ")", "(", "6", "*", "32", ")", "etc", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L473-L546
train
ReFirmLabs/binwalk
src/binwalk/core/magic.py
Magic._analyze
def _analyze(self, signature, offset): ''' Analyzes self.data for the specified signature data at the specified offset . @signature - The signature to apply to the data. @offset - The offset in self.data to apply the signature to. Returns a dictionary of tags parsed from the...
python
def _analyze(self, signature, offset): ''' Analyzes self.data for the specified signature data at the specified offset . @signature - The signature to apply to the data. @offset - The offset in self.data to apply the signature to. Returns a dictionary of tags parsed from the...
[ "def", "_analyze", "(", "self", ",", "signature", ",", "offset", ")", ":", "description", "=", "[", "]", "max_line_level", "=", "0", "previous_line_end", "=", "0", "tags", "=", "{", "'id'", ":", "signature", ".", "id", ",", "'offset'", ":", "offset", "...
Analyzes self.data for the specified signature data at the specified offset . @signature - The signature to apply to the data. @offset - The offset in self.data to apply the signature to. Returns a dictionary of tags parsed from the data.
[ "Analyzes", "self", ".", "data", "for", "the", "specified", "signature", "data", "at", "the", "specified", "offset", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L548-L771
train
ReFirmLabs/binwalk
src/binwalk/core/magic.py
Magic.scan
def scan(self, data, dlen=None): ''' Scan a data block for matching signatures. @data - A string of data to scan. @dlen - If specified, signatures at offsets larger than dlen will be ignored. Returns a list of SignatureResult objects. ''' results = [] ma...
python
def scan(self, data, dlen=None): ''' Scan a data block for matching signatures. @data - A string of data to scan. @dlen - If specified, signatures at offsets larger than dlen will be ignored. Returns a list of SignatureResult objects. ''' results = [] ma...
[ "def", "scan", "(", "self", ",", "data", ",", "dlen", "=", "None", ")", ":", "results", "=", "[", "]", "matched_offsets", "=", "set", "(", ")", "# Since data can potentially be quite a large string, make it available to other", "# methods via a class attribute so that it ...
Scan a data block for matching signatures. @data - A string of data to scan. @dlen - If specified, signatures at offsets larger than dlen will be ignored. Returns a list of SignatureResult objects.
[ "Scan", "a", "data", "block", "for", "matching", "signatures", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L783-L841
train
ReFirmLabs/binwalk
src/binwalk/core/magic.py
Magic.load
def load(self, fname): ''' Load signatures from a file. @fname - Path to signature file. Returns None. ''' # Magic files must be ASCII, else encoding issues can arise. fp = open(fname, "r") lines = fp.readlines() self.parse(lines) fp.clos...
python
def load(self, fname): ''' Load signatures from a file. @fname - Path to signature file. Returns None. ''' # Magic files must be ASCII, else encoding issues can arise. fp = open(fname, "r") lines = fp.readlines() self.parse(lines) fp.clos...
[ "def", "load", "(", "self", ",", "fname", ")", ":", "# Magic files must be ASCII, else encoding issues can arise.", "fp", "=", "open", "(", "fname", ",", "\"r\"", ")", "lines", "=", "fp", ".", "readlines", "(", ")", "self", ".", "parse", "(", "lines", ")", ...
Load signatures from a file. @fname - Path to signature file. Returns None.
[ "Load", "signatures", "from", "a", "file", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L843-L855
train
ReFirmLabs/binwalk
src/binwalk/core/magic.py
Magic.parse
def parse(self, lines): ''' Parse signature file lines. @lines - A list of lines from a signature file. Returns None. ''' signature = None for line in lines: # Split at the first comment delimiter (if any) and strip the # result ...
python
def parse(self, lines): ''' Parse signature file lines. @lines - A list of lines from a signature file. Returns None. ''' signature = None for line in lines: # Split at the first comment delimiter (if any) and strip the # result ...
[ "def", "parse", "(", "self", ",", "lines", ")", ":", "signature", "=", "None", "for", "line", "in", "lines", ":", "# Split at the first comment delimiter (if any) and strip the", "# result", "line", "=", "line", ".", "split", "(", "'#'", ")", "[", "0", "]", ...
Parse signature file lines. @lines - A list of lines from a signature file. Returns None.
[ "Parse", "signature", "file", "lines", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/magic.py#L857-L904
train
ReFirmLabs/binwalk
src/binwalk/modules/general.py
General._set_verbosity
def _set_verbosity(self): ''' Sets the appropriate verbosity. Must be called after self._test_target_files so that self.target_files is properly set. ''' # If more than one target file was specified, enable verbose mode; else, there is # nothing in some outputs to indicat...
python
def _set_verbosity(self): ''' Sets the appropriate verbosity. Must be called after self._test_target_files so that self.target_files is properly set. ''' # If more than one target file was specified, enable verbose mode; else, there is # nothing in some outputs to indicat...
[ "def", "_set_verbosity", "(", "self", ")", ":", "# If more than one target file was specified, enable verbose mode; else, there is", "# nothing in some outputs to indicate which scan corresponds to which", "# file.", "if", "len", "(", "self", ".", "target_files", ")", ">", "1", "...
Sets the appropriate verbosity. Must be called after self._test_target_files so that self.target_files is properly set.
[ "Sets", "the", "appropriate", "verbosity", ".", "Must", "be", "called", "after", "self", ".", "_test_target_files", "so", "that", "self", ".", "target_files", "is", "properly", "set", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/general.py#L159-L168
train
ReFirmLabs/binwalk
src/binwalk/modules/general.py
General.file_name_filter
def file_name_filter(self, fp): ''' Checks to see if a file should be scanned based on file name include/exclude filters. Most useful for matryoshka scans where only certian files are desired. @fp - An instances of binwalk.common.BlockFile Returns True if the file should be sca...
python
def file_name_filter(self, fp): ''' Checks to see if a file should be scanned based on file name include/exclude filters. Most useful for matryoshka scans where only certian files are desired. @fp - An instances of binwalk.common.BlockFile Returns True if the file should be sca...
[ "def", "file_name_filter", "(", "self", ",", "fp", ")", ":", "if", "self", ".", "file_name_include_regex", "and", "not", "self", ".", "file_name_include_regex", ".", "search", "(", "fp", ".", "name", ")", ":", "return", "False", "if", "self", ".", "file_na...
Checks to see if a file should be scanned based on file name include/exclude filters. Most useful for matryoshka scans where only certian files are desired. @fp - An instances of binwalk.common.BlockFile Returns True if the file should be scanned, False if not.
[ "Checks", "to", "see", "if", "a", "file", "should", "be", "scanned", "based", "on", "file", "name", "include", "/", "exclude", "filters", ".", "Most", "useful", "for", "matryoshka", "scans", "where", "only", "certian", "files", "are", "desired", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/general.py#L170-L184
train
ReFirmLabs/binwalk
src/binwalk/modules/general.py
General.open_file
def open_file(self, fname, length=None, offset=None, swap=None, block=None, peek=None): ''' Opens the specified file with all pertinent configuration settings. ''' if length is None: length = self.length if offset is None: offset = self.offset if s...
python
def open_file(self, fname, length=None, offset=None, swap=None, block=None, peek=None): ''' Opens the specified file with all pertinent configuration settings. ''' if length is None: length = self.length if offset is None: offset = self.offset if s...
[ "def", "open_file", "(", "self", ",", "fname", ",", "length", "=", "None", ",", "offset", "=", "None", ",", "swap", "=", "None", ",", "block", "=", "None", ",", "peek", "=", "None", ")", ":", "if", "length", "is", "None", ":", "length", "=", "sel...
Opens the specified file with all pertinent configuration settings.
[ "Opens", "the", "specified", "file", "with", "all", "pertinent", "configuration", "settings", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/general.py#L186-L203
train
ReFirmLabs/binwalk
src/binwalk/modules/general.py
General._open_target_files
def _open_target_files(self): ''' Checks if the target files can be opened. Any files that cannot be opened are removed from the self.target_files list. ''' # Validate the target files listed in target_files for tfile in self.files: # Ignore directories. ...
python
def _open_target_files(self): ''' Checks if the target files can be opened. Any files that cannot be opened are removed from the self.target_files list. ''' # Validate the target files listed in target_files for tfile in self.files: # Ignore directories. ...
[ "def", "_open_target_files", "(", "self", ")", ":", "# Validate the target files listed in target_files", "for", "tfile", "in", "self", ".", "files", ":", "# Ignore directories.", "if", "not", "self", ".", "subclass", "==", "io", ".", "FileIO", "or", "not", "os", ...
Checks if the target files can be opened. Any files that cannot be opened are removed from the self.target_files list.
[ "Checks", "if", "the", "target", "files", "can", "be", "opened", ".", "Any", "files", "that", "cannot", "be", "opened", "are", "removed", "from", "the", "self", ".", "target_files", "list", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/general.py#L205-L222
train
ReFirmLabs/binwalk
src/binwalk/modules/signature.py
Signature.validate
def validate(self, r): ''' Called automatically by self.result. ''' if self.show_invalid: r.valid = True elif r.valid: if not r.description: r.valid = False if r.size and (r.size + r.offset) > r.file.size: r.val...
python
def validate(self, r): ''' Called automatically by self.result. ''' if self.show_invalid: r.valid = True elif r.valid: if not r.description: r.valid = False if r.size and (r.size + r.offset) > r.file.size: r.val...
[ "def", "validate", "(", "self", ",", "r", ")", ":", "if", "self", ".", "show_invalid", ":", "r", ".", "valid", "=", "True", "elif", "r", ".", "valid", ":", "if", "not", "r", ".", "description", ":", "r", ".", "valid", "=", "False", "if", "r", "...
Called automatically by self.result.
[ "Called", "automatically", "by", "self", ".", "result", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/signature.py#L107-L134
train
ReFirmLabs/binwalk
src/binwalk/core/plugin.py
Plugins.list_plugins
def list_plugins(self): ''' Obtain a list of all user and system plugin modules. Returns a dictionary of: { 'user' : { 'modules' : [list, of, module, names], 'descriptions' : {'module_name' : 'modul...
python
def list_plugins(self): ''' Obtain a list of all user and system plugin modules. Returns a dictionary of: { 'user' : { 'modules' : [list, of, module, names], 'descriptions' : {'module_name' : 'modul...
[ "def", "list_plugins", "(", "self", ")", ":", "plugins", "=", "{", "'user'", ":", "{", "'modules'", ":", "[", "]", ",", "'descriptions'", ":", "{", "}", ",", "'enabled'", ":", "{", "}", ",", "'path'", ":", "None", ",", "}", ",", "'system'", ":", ...
Obtain a list of all user and system plugin modules. Returns a dictionary of: { 'user' : { 'modules' : [list, of, module, names], 'descriptions' : {'module_name' : 'module pydoc string'}, ...
[ "Obtain", "a", "list", "of", "all", "user", "and", "system", "plugin", "modules", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/plugin.py#L132-L206
train
ReFirmLabs/binwalk
src/binwalk/modules/entropy.py
Entropy.shannon
def shannon(self, data): ''' Performs a Shannon entropy analysis on a given block of data. ''' entropy = 0 if data: length = len(data) seen = dict(((chr(x), 0) for x in range(0, 256))) for byte in data: seen[byte] += 1 ...
python
def shannon(self, data): ''' Performs a Shannon entropy analysis on a given block of data. ''' entropy = 0 if data: length = len(data) seen = dict(((chr(x), 0) for x in range(0, 256))) for byte in data: seen[byte] += 1 ...
[ "def", "shannon", "(", "self", ",", "data", ")", ":", "entropy", "=", "0", "if", "data", ":", "length", "=", "len", "(", "data", ")", "seen", "=", "dict", "(", "(", "(", "chr", "(", "x", ")", ",", "0", ")", "for", "x", "in", "range", "(", "...
Performs a Shannon entropy analysis on a given block of data.
[ "Performs", "a", "Shannon", "entropy", "analysis", "on", "a", "given", "block", "of", "data", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/entropy.py#L221-L239
train
ReFirmLabs/binwalk
src/binwalk/modules/entropy.py
Entropy.gzip
def gzip(self, data, truncate=True): ''' Performs an entropy analysis based on zlib compression ratio. This is faster than the shannon entropy analysis, but not as accurate. ''' # Entropy is a simple ratio of: <zlib compressed size> / <original # size> e = float(f...
python
def gzip(self, data, truncate=True): ''' Performs an entropy analysis based on zlib compression ratio. This is faster than the shannon entropy analysis, but not as accurate. ''' # Entropy is a simple ratio of: <zlib compressed size> / <original # size> e = float(f...
[ "def", "gzip", "(", "self", ",", "data", ",", "truncate", "=", "True", ")", ":", "# Entropy is a simple ratio of: <zlib compressed size> / <original", "# size>", "e", "=", "float", "(", "float", "(", "len", "(", "zlib", ".", "compress", "(", "str2bytes", "(", ...
Performs an entropy analysis based on zlib compression ratio. This is faster than the shannon entropy analysis, but not as accurate.
[ "Performs", "an", "entropy", "analysis", "based", "on", "zlib", "compression", "ratio", ".", "This", "is", "faster", "than", "the", "shannon", "entropy", "analysis", "but", "not", "as", "accurate", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/entropy.py#L241-L253
train
ReFirmLabs/binwalk
src/binwalk/plugins/tar.py
TarPlugin.nts
def nts(self, s): """ Convert a null-terminated string field to a python string. """ # Use the string up to the first null char. p = s.find("\0") if p == -1: return s return s[:p]
python
def nts(self, s): """ Convert a null-terminated string field to a python string. """ # Use the string up to the first null char. p = s.find("\0") if p == -1: return s return s[:p]
[ "def", "nts", "(", "self", ",", "s", ")", ":", "# Use the string up to the first null char.", "p", "=", "s", ".", "find", "(", "\"\\0\"", ")", "if", "p", "==", "-", "1", ":", "return", "s", "return", "s", "[", ":", "p", "]" ]
Convert a null-terminated string field to a python string.
[ "Convert", "a", "null", "-", "terminated", "string", "field", "to", "a", "python", "string", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/tar.py#L13-L21
train
ReFirmLabs/binwalk
src/binwalk/plugins/tar.py
TarPlugin.nti
def nti(self, s): """ Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0x80): try: n = int(self.nts(s) or "0", 8) except ValueError: ...
python
def nti(self, s): """ Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0x80): try: n = int(self.nts(s) or "0", 8) except ValueError: ...
[ "def", "nti", "(", "self", ",", "s", ")", ":", "# There are two possible encodings for a number field, see", "# itn() below.", "if", "s", "[", "0", "]", "!=", "chr", "(", "0x80", ")", ":", "try", ":", "n", "=", "int", "(", "self", ".", "nts", "(", "s", ...
Convert a number field to a python number.
[ "Convert", "a", "number", "field", "to", "a", "python", "number", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/tar.py#L23-L39
train
ReFirmLabs/binwalk
src/binwalk/core/common.py
debug
def debug(msg): ''' Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag. ''' if DEBUG: sys.stderr.write("DEBUG: " + msg + "\n") sys.stderr.flush()
python
def debug(msg): ''' Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag. ''' if DEBUG: sys.stderr.write("DEBUG: " + msg + "\n") sys.stderr.flush()
[ "def", "debug", "(", "msg", ")", ":", "if", "DEBUG", ":", "sys", ".", "stderr", ".", "write", "(", "\"DEBUG: \"", "+", "msg", "+", "\"\\n\"", ")", "sys", ".", "stderr", ".", "flush", "(", ")" ]
Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag.
[ "Displays", "debug", "messages", "to", "stderr", "only", "if", "the", "Python", "interpreter", "was", "invoked", "with", "the", "-", "O", "flag", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L30-L36
train
ReFirmLabs/binwalk
src/binwalk/core/common.py
file_md5
def file_md5(file_name): ''' Generate an MD5 hash of the specified file. @file_name - The file to hash. Returns an MD5 hex digest string. ''' md5 = hashlib.md5() with open(file_name, 'rb') as f: for chunk in iter(lambda: f.read(128 * md5.block_size), b''): md5.update(c...
python
def file_md5(file_name): ''' Generate an MD5 hash of the specified file. @file_name - The file to hash. Returns an MD5 hex digest string. ''' md5 = hashlib.md5() with open(file_name, 'rb') as f: for chunk in iter(lambda: f.read(128 * md5.block_size), b''): md5.update(c...
[ "def", "file_md5", "(", "file_name", ")", ":", "md5", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "file_name", ",", "'rb'", ")", "as", "f", ":", "for", "chunk", "in", "iter", "(", "lambda", ":", "f", ".", "read", "(", "128", "*", ...
Generate an MD5 hash of the specified file. @file_name - The file to hash. Returns an MD5 hex digest string.
[ "Generate", "an", "MD5", "hash", "of", "the", "specified", "file", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L71-L85
train
ReFirmLabs/binwalk
src/binwalk/core/common.py
file_size
def file_size(filename): ''' Obtains the size of a given file. @filename - Path to the file. Returns the size of the file. ''' # Using open/lseek works on both regular files and block devices fd = os.open(filename, os.O_RDONLY) try: return os.lseek(fd, 0, os.SEEK_END) excep...
python
def file_size(filename): ''' Obtains the size of a given file. @filename - Path to the file. Returns the size of the file. ''' # Using open/lseek works on both regular files and block devices fd = os.open(filename, os.O_RDONLY) try: return os.lseek(fd, 0, os.SEEK_END) excep...
[ "def", "file_size", "(", "filename", ")", ":", "# Using open/lseek works on both regular files and block devices", "fd", "=", "os", ".", "open", "(", "filename", ",", "os", ".", "O_RDONLY", ")", "try", ":", "return", "os", ".", "lseek", "(", "fd", ",", "0", ...
Obtains the size of a given file. @filename - Path to the file. Returns the size of the file.
[ "Obtains", "the", "size", "of", "a", "given", "file", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L88-L106
train
ReFirmLabs/binwalk
src/binwalk/core/common.py
get_quoted_strings
def get_quoted_strings(quoted_string): ''' Returns a string comprised of all data in between double quotes. @quoted_string - String to get quoted data from. Returns a string of quoted data on success. Returns a blank string if no quoted data is present. ''' try: # This regex grabs ...
python
def get_quoted_strings(quoted_string): ''' Returns a string comprised of all data in between double quotes. @quoted_string - String to get quoted data from. Returns a string of quoted data on success. Returns a blank string if no quoted data is present. ''' try: # This regex grabs ...
[ "def", "get_quoted_strings", "(", "quoted_string", ")", ":", "try", ":", "# This regex grabs all quoted data from string.", "# Note that this gets everything in between the first and last double quote.", "# This is intentional, as printed (and quoted) strings from a target file may contain", "...
Returns a string comprised of all data in between double quotes. @quoted_string - String to get quoted data from. Returns a string of quoted data on success. Returns a blank string if no quoted data is present.
[ "Returns", "a", "string", "comprised", "of", "all", "data", "in", "between", "double", "quotes", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L126-L146
train
ReFirmLabs/binwalk
src/binwalk/core/common.py
unique_file_name
def unique_file_name(base_name, extension=''): ''' Creates a unique file name based on the specified base name. @base_name - The base name to use for the unique file name. @extension - The file extension to use for the unique file name. Returns a unique file string. ''' idcount = 0 if...
python
def unique_file_name(base_name, extension=''): ''' Creates a unique file name based on the specified base name. @base_name - The base name to use for the unique file name. @extension - The file extension to use for the unique file name. Returns a unique file string. ''' idcount = 0 if...
[ "def", "unique_file_name", "(", "base_name", ",", "extension", "=", "''", ")", ":", "idcount", "=", "0", "if", "extension", "and", "not", "extension", ".", "startswith", "(", "'.'", ")", ":", "extension", "=", "'.%s'", "%", "extension", "fname", "=", "ba...
Creates a unique file name based on the specified base name. @base_name - The base name to use for the unique file name. @extension - The file extension to use for the unique file name. Returns a unique file string.
[ "Creates", "a", "unique", "file", "name", "based", "on", "the", "specified", "base", "name", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L149-L169
train
ReFirmLabs/binwalk
src/binwalk/core/common.py
strings
def strings(filename, minimum=4): ''' A strings generator, similar to the Unix strings utility. @filename - The file to search for strings in. @minimum - The minimum string length to search for. Yeilds printable ASCII strings from filename. ''' result = "" with BlockFile(filename) as...
python
def strings(filename, minimum=4): ''' A strings generator, similar to the Unix strings utility. @filename - The file to search for strings in. @minimum - The minimum string length to search for. Yeilds printable ASCII strings from filename. ''' result = "" with BlockFile(filename) as...
[ "def", "strings", "(", "filename", ",", "minimum", "=", "4", ")", ":", "result", "=", "\"\"", "with", "BlockFile", "(", "filename", ")", "as", "f", ":", "while", "True", ":", "(", "data", ",", "dlen", ")", "=", "f", ".", "read_block", "(", ")", "...
A strings generator, similar to the Unix strings utility. @filename - The file to search for strings in. @minimum - The minimum string length to search for. Yeilds printable ASCII strings from filename.
[ "A", "strings", "generator", "similar", "to", "the", "Unix", "strings", "utility", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/common.py#L172-L197
train
ReFirmLabs/binwalk
src/binwalk/core/compat.py
bytes2str
def bytes2str(bs): ''' For cross compatibility between Python 2 and Python 3 strings. ''' if isinstance(bs, type(b'')) and PY_MAJOR_VERSION > 2: return bs.decode('latin1') else: return bs
python
def bytes2str(bs): ''' For cross compatibility between Python 2 and Python 3 strings. ''' if isinstance(bs, type(b'')) and PY_MAJOR_VERSION > 2: return bs.decode('latin1') else: return bs
[ "def", "bytes2str", "(", "bs", ")", ":", "if", "isinstance", "(", "bs", ",", "type", "(", "b''", ")", ")", "and", "PY_MAJOR_VERSION", ">", "2", ":", "return", "bs", ".", "decode", "(", "'latin1'", ")", "else", ":", "return", "bs" ]
For cross compatibility between Python 2 and Python 3 strings.
[ "For", "cross", "compatibility", "between", "Python", "2", "and", "Python", "3", "strings", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/compat.py#L60-L67
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.create_rule
def create_rule(self, txtrule=None, regex=None, extension=None, cmd=None, codes=[0, None], recurse=True): ''' Adds a set of rules to the extraction rule list. @txtrule - Rule string, or list of rule strings, in the format <regular expression>:<file extension>[:<command to run>] @regex...
python
def create_rule(self, txtrule=None, regex=None, extension=None, cmd=None, codes=[0, None], recurse=True): ''' Adds a set of rules to the extraction rule list. @txtrule - Rule string, or list of rule strings, in the format <regular expression>:<file extension>[:<command to run>] @regex...
[ "def", "create_rule", "(", "self", ",", "txtrule", "=", "None", ",", "regex", "=", "None", ",", "extension", "=", "None", ",", "cmd", "=", "None", ",", "codes", "=", "[", "0", ",", "None", "]", ",", "recurse", "=", "True", ")", ":", "rules", "=",...
Adds a set of rules to the extraction rule list. @txtrule - Rule string, or list of rule strings, in the format <regular expression>:<file extension>[:<command to run>] @regex - If rule string is not specified, this is the regular expression string to use. @extension - If rule string is n...
[ "Adds", "a", "set", "of", "rules", "to", "the", "extraction", "rule", "list", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L301-L362
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.remove_rules
def remove_rules(self, description): ''' Remove all rules that match a specified description. @description - The description to match against. Returns the number of rules removed. ''' rm = [] description = description.lower() for i in range(0, len(self....
python
def remove_rules(self, description): ''' Remove all rules that match a specified description. @description - The description to match against. Returns the number of rules removed. ''' rm = [] description = description.lower() for i in range(0, len(self....
[ "def", "remove_rules", "(", "self", ",", "description", ")", ":", "rm", "=", "[", "]", "description", "=", "description", ".", "lower", "(", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "extract_rules", ")", ")", ":", "if...
Remove all rules that match a specified description. @description - The description to match against. Returns the number of rules removed.
[ "Remove", "all", "rules", "that", "match", "a", "specified", "description", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L364-L382
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.edit_rules
def edit_rules(self, description, key, value): ''' Edit all rules that match a specified description. @description - The description to match against. @key - The key to change for each matching rule. @value - The new key value for each matching rule. Retur...
python
def edit_rules(self, description, key, value): ''' Edit all rules that match a specified description. @description - The description to match against. @key - The key to change for each matching rule. @value - The new key value for each matching rule. Retur...
[ "def", "edit_rules", "(", "self", ",", "description", ",", "key", ",", "value", ")", ":", "count", "=", "0", "description", "=", "description", ".", "lower", "(", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "extract_rules"...
Edit all rules that match a specified description. @description - The description to match against. @key - The key to change for each matching rule. @value - The new key value for each matching rule. Returns the number of rules modified.
[ "Edit", "all", "rules", "that", "match", "a", "specified", "description", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L384-L403
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.get_rules
def get_rules(self, description=None): ''' Returns a list of extraction rules that match a given description. @description - The description to match against. Returns a list of extraction rules that match the given description. If no description is provided, a list of all rules...
python
def get_rules(self, description=None): ''' Returns a list of extraction rules that match a given description. @description - The description to match against. Returns a list of extraction rules that match the given description. If no description is provided, a list of all rules...
[ "def", "get_rules", "(", "self", ",", "description", "=", "None", ")", ":", "if", "description", ":", "rules", "=", "[", "]", "description", "=", "description", ".", "lower", "(", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", "...
Returns a list of extraction rules that match a given description. @description - The description to match against. Returns a list of extraction rules that match the given description. If no description is provided, a list of all rules are returned.
[ "Returns", "a", "list", "of", "extraction", "rules", "that", "match", "a", "given", "description", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L413-L431
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.load_from_file
def load_from_file(self, fname): ''' Loads extraction rules from the specified file. @fname - Path to the extraction rule file. Returns None. ''' try: # Process each line from the extract file, ignoring comments with open(fname, 'r') as f: ...
python
def load_from_file(self, fname): ''' Loads extraction rules from the specified file. @fname - Path to the extraction rule file. Returns None. ''' try: # Process each line from the extract file, ignoring comments with open(fname, 'r') as f: ...
[ "def", "load_from_file", "(", "self", ",", "fname", ")", ":", "try", ":", "# Process each line from the extract file, ignoring comments", "with", "open", "(", "fname", ",", "'r'", ")", "as", "f", ":", "for", "rule", "in", "f", ".", "readlines", "(", ")", ":"...
Loads extraction rules from the specified file. @fname - Path to the extraction rule file. Returns None.
[ "Loads", "extraction", "rules", "from", "the", "specified", "file", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L433-L449
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.load_defaults
def load_defaults(self): ''' Loads default extraction rules from the user and system extract.conf files. Returns None. ''' # Load the user extract file first to ensure its rules take precedence. extract_files = [ self.config.settings.user.extract, ...
python
def load_defaults(self): ''' Loads default extraction rules from the user and system extract.conf files. Returns None. ''' # Load the user extract file first to ensure its rules take precedence. extract_files = [ self.config.settings.user.extract, ...
[ "def", "load_defaults", "(", "self", ")", ":", "# Load the user extract file first to ensure its rules take precedence.", "extract_files", "=", "[", "self", ".", "config", ".", "settings", ".", "user", ".", "extract", ",", "self", ".", "config", ".", "settings", "."...
Loads default extraction rules from the user and system extract.conf files. Returns None.
[ "Loads", "default", "extraction", "rules", "from", "the", "user", "and", "system", "extract", ".", "conf", "files", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L451-L471
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.build_output_directory
def build_output_directory(self, path): ''' Set the output directory for extracted files. @path - The path to the file that data will be extracted from. Returns None. ''' # If we have not already created an output directory for this target # file, create one now...
python
def build_output_directory(self, path): ''' Set the output directory for extracted files. @path - The path to the file that data will be extracted from. Returns None. ''' # If we have not already created an output directory for this target # file, create one now...
[ "def", "build_output_directory", "(", "self", ",", "path", ")", ":", "# If we have not already created an output directory for this target", "# file, create one now", "if", "not", "has_key", "(", "self", ".", "extraction_directories", ",", "path", ")", ":", "basedir", "="...
Set the output directory for extracted files. @path - The path to the file that data will be extracted from. Returns None.
[ "Set", "the", "output", "directory", "for", "extracted", "files", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L490-L536
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.extract
def extract(self, offset, description, file_name, size, name=None): ''' Extract an embedded file from the target file, if it matches an extract rule. Called automatically by Binwalk.scan(). @offset - Offset inside the target file to begin the extraction. @description - Desc...
python
def extract(self, offset, description, file_name, size, name=None): ''' Extract an embedded file from the target file, if it matches an extract rule. Called automatically by Binwalk.scan(). @offset - Offset inside the target file to begin the extraction. @description - Desc...
[ "def", "extract", "(", "self", ",", "offset", ",", "description", ",", "file_name", ",", "size", ",", "name", "=", "None", ")", ":", "fname", "=", "''", "rule", "=", "None", "recurse", "=", "False", "command_line", "=", "''", "original_dir", "=", "os",...
Extract an embedded file from the target file, if it matches an extract rule. Called automatically by Binwalk.scan(). @offset - Offset inside the target file to begin the extraction. @description - Description of the embedded file to extract, as returned by libmagic. @file_name -...
[ "Extract", "an", "embedded", "file", "from", "the", "target", "file", "if", "it", "matches", "an", "extract", "rule", ".", "Called", "automatically", "by", "Binwalk", ".", "scan", "()", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L553-L676
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor._entry_offset
def _entry_offset(self, index, entries, description): ''' Gets the offset of the first entry that matches the description. @index - Index into the entries list to begin searching. @entries - Dictionary of result entries. @description - Case insensitive description. ...
python
def _entry_offset(self, index, entries, description): ''' Gets the offset of the first entry that matches the description. @index - Index into the entries list to begin searching. @entries - Dictionary of result entries. @description - Case insensitive description. ...
[ "def", "_entry_offset", "(", "self", ",", "index", ",", "entries", ",", "description", ")", ":", "description", "=", "description", ".", "lower", "(", ")", "for", "(", "offset", ",", "infos", ")", "in", "entries", "[", "index", ":", "]", ":", "for", ...
Gets the offset of the first entry that matches the description. @index - Index into the entries list to begin searching. @entries - Dictionary of result entries. @description - Case insensitive description. Returns the offset, if a matching description is found. Retu...
[ "Gets", "the", "offset", "of", "the", "first", "entry", "that", "matches", "the", "description", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L687-L704
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.match
def match(self, description): ''' Check to see if the provided description string matches an extract rule. Called internally by self.extract(). @description - Description string to check. Returns the associated rule dictionary if a match is found. Returns None if no mat...
python
def match(self, description): ''' Check to see if the provided description string matches an extract rule. Called internally by self.extract(). @description - Description string to check. Returns the associated rule dictionary if a match is found. Returns None if no mat...
[ "def", "match", "(", "self", ",", "description", ")", ":", "rules", "=", "[", "]", "ordered_rules", "=", "[", "]", "description", "=", "description", ".", "lower", "(", ")", "for", "rule", "in", "self", ".", "extract_rules", ":", "if", "rule", "[", "...
Check to see if the provided description string matches an extract rule. Called internally by self.extract(). @description - Description string to check. Returns the associated rule dictionary if a match is found. Returns None if no match is found.
[ "Check", "to", "see", "if", "the", "provided", "description", "string", "matches", "an", "extract", "rule", ".", "Called", "internally", "by", "self", ".", "extract", "()", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L706-L732
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor._parse_rule
def _parse_rule(self, rule): ''' Parses an extraction rule. @rule - Rule string. Returns an array of ['<case insensitive matching string>', '<file extension>', '<command to run>', '<comma separated return codes>', <recurse into extracted directories: True|False>]. ''' v...
python
def _parse_rule(self, rule): ''' Parses an extraction rule. @rule - Rule string. Returns an array of ['<case insensitive matching string>', '<file extension>', '<command to run>', '<comma separated return codes>', <recurse into extracted directories: True|False>]. ''' v...
[ "def", "_parse_rule", "(", "self", ",", "rule", ")", ":", "values", "=", "rule", ".", "strip", "(", ")", ".", "split", "(", "self", ".", "RULE_DELIM", ",", "4", ")", "if", "len", "(", "values", ")", ">=", "4", ":", "codes", "=", "values", "[", ...
Parses an extraction rule. @rule - Rule string. Returns an array of ['<case insensitive matching string>', '<file extension>', '<command to run>', '<comma separated return codes>', <recurse into extracted directories: True|False>].
[ "Parses", "an", "extraction", "rule", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L734-L756
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor._dd
def _dd(self, file_name, offset, size, extension, output_file_name=None): ''' Extracts a file embedded inside the target file. @file_name - Path to the target file. @offset - Offset inside the target file where the embedded file begins. @size - Numbe...
python
def _dd(self, file_name, offset, size, extension, output_file_name=None): ''' Extracts a file embedded inside the target file. @file_name - Path to the target file. @offset - Offset inside the target file where the embedded file begins. @size - Numbe...
[ "def", "_dd", "(", "self", ",", "file_name", ",", "offset", ",", "size", ",", "extension", ",", "output_file_name", "=", "None", ")", ":", "total_size", "=", "0", "# Default extracted file name is <displayed hex offset>.<extension>", "default_bname", "=", "\"%X\"", ...
Extracts a file embedded inside the target file. @file_name - Path to the target file. @offset - Offset inside the target file where the embedded file begins. @size - Number of bytes to extract. @extension - The file exension to assign to the extracte...
[ "Extracts", "a", "file", "embedded", "inside", "the", "target", "file", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L758-L835
train
ReFirmLabs/binwalk
src/binwalk/modules/extractor.py
Extractor.execute
def execute(self, cmd, fname, codes=[0, None]): ''' Execute a command against the specified file. @cmd - Command to execute. @fname - File to run command against. @codes - List of return codes indicating cmd success. Returns True on success, False on failure, or None ...
python
def execute(self, cmd, fname, codes=[0, None]): ''' Execute a command against the specified file. @cmd - Command to execute. @fname - File to run command against. @codes - List of return codes indicating cmd success. Returns True on success, False on failure, or None ...
[ "def", "execute", "(", "self", ",", "cmd", ",", "fname", ",", "codes", "=", "[", "0", ",", "None", "]", ")", ":", "tmp", "=", "None", "rval", "=", "0", "retval", "=", "True", "command_list", "=", "[", "]", "binwalk", ".", "core", ".", "common", ...
Execute a command against the specified file. @cmd - Command to execute. @fname - File to run command against. @codes - List of return codes indicating cmd success. Returns True on success, False on failure, or None if the external extraction utility could not be found.
[ "Execute", "a", "command", "against", "the", "specified", "file", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/modules/extractor.py#L837-L912
train
ReFirmLabs/binwalk
src/binwalk/core/display.py
Display._fix_unicode_list
def _fix_unicode_list(self, columns): ''' Convenience wrapper for self.log which is passed a list of format arguments. ''' if type(columns) in [list, tuple]: for i in range(0, len(columns)): try: columns[i] = self._fix_unicode(columns[i]) ...
python
def _fix_unicode_list(self, columns): ''' Convenience wrapper for self.log which is passed a list of format arguments. ''' if type(columns) in [list, tuple]: for i in range(0, len(columns)): try: columns[i] = self._fix_unicode(columns[i]) ...
[ "def", "_fix_unicode_list", "(", "self", ",", "columns", ")", ":", "if", "type", "(", "columns", ")", "in", "[", "list", ",", "tuple", "]", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "columns", ")", ")", ":", "try", ":", "columns"...
Convenience wrapper for self.log which is passed a list of format arguments.
[ "Convenience", "wrapper", "for", "self", ".", "log", "which", "is", "passed", "a", "list", "of", "format", "arguments", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/display.py#L51-L61
train
ReFirmLabs/binwalk
src/binwalk/core/display.py
Display._append_to_data_parts
def _append_to_data_parts(self, data, start, end): ''' Intelligently appends data to self.string_parts. For use by self._format. ''' try: while data[start] == ' ': start += 1 if start == end: end = len(data[start:]) ...
python
def _append_to_data_parts(self, data, start, end): ''' Intelligently appends data to self.string_parts. For use by self._format. ''' try: while data[start] == ' ': start += 1 if start == end: end = len(data[start:]) ...
[ "def", "_append_to_data_parts", "(", "self", ",", "data", ",", "start", ",", "end", ")", ":", "try", ":", "while", "data", "[", "start", "]", "==", "' '", ":", "start", "+=", "1", "if", "start", "==", "end", ":", "end", "=", "len", "(", "data", "...
Intelligently appends data to self.string_parts. For use by self._format.
[ "Intelligently", "appends", "data", "to", "self", ".", "string_parts", ".", "For", "use", "by", "self", ".", "_format", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/display.py#L155-L178
train
ReFirmLabs/binwalk
src/binwalk/core/display.py
Display._format_line
def _format_line(self, line): ''' Formats a line of text to fit in the terminal window. For Tim. ''' delim = '\n' offset = 0 self.string_parts = [] # Split the line into an array of columns, e.g., ['0', '0x00000000', # 'Some description here'] ...
python
def _format_line(self, line): ''' Formats a line of text to fit in the terminal window. For Tim. ''' delim = '\n' offset = 0 self.string_parts = [] # Split the line into an array of columns, e.g., ['0', '0x00000000', # 'Some description here'] ...
[ "def", "_format_line", "(", "self", ",", "line", ")", ":", "delim", "=", "'\\n'", "offset", "=", "0", "self", ".", "string_parts", "=", "[", "]", "# Split the line into an array of columns, e.g., ['0', '0x00000000',", "# 'Some description here']", "line_columns", "=", ...
Formats a line of text to fit in the terminal window. For Tim.
[ "Formats", "a", "line", "of", "text", "to", "fit", "in", "the", "terminal", "window", ".", "For", "Tim", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/display.py#L180-L230
train
ReFirmLabs/binwalk
src/binwalk/core/display.py
Display._configure_formatting
def _configure_formatting(self): ''' Configures output formatting, and fitting output to the current terminal width. Returns None. ''' self.format_strings(self.DEFAULT_FORMAT, self.DEFAULT_FORMAT) if self.fit_to_screen: try: import fcntl ...
python
def _configure_formatting(self): ''' Configures output formatting, and fitting output to the current terminal width. Returns None. ''' self.format_strings(self.DEFAULT_FORMAT, self.DEFAULT_FORMAT) if self.fit_to_screen: try: import fcntl ...
[ "def", "_configure_formatting", "(", "self", ")", ":", "self", ".", "format_strings", "(", "self", ".", "DEFAULT_FORMAT", ",", "self", ".", "DEFAULT_FORMAT", ")", "if", "self", ".", "fit_to_screen", ":", "try", ":", "import", "fcntl", "import", "struct", "im...
Configures output formatting, and fitting output to the current terminal width. Returns None.
[ "Configures", "output", "formatting", "and", "fitting", "output", "to", "the", "current", "terminal", "width", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/display.py#L232-L252
train
ReFirmLabs/binwalk
src/binwalk/core/settings.py
Settings._magic_signature_files
def _magic_signature_files(self, system_only=False, user_only=False): ''' Find all user/system magic signature files. @system_only - If True, only the system magic file directory will be searched. @user_only - If True, only the user magic file directory will be searched. Retu...
python
def _magic_signature_files(self, system_only=False, user_only=False): ''' Find all user/system magic signature files. @system_only - If True, only the system magic file directory will be searched. @user_only - If True, only the user magic file directory will be searched. Retu...
[ "def", "_magic_signature_files", "(", "self", ",", "system_only", "=", "False", ",", "user_only", "=", "False", ")", ":", "files", "=", "[", "]", "user_binarch", "=", "self", ".", "_user_path", "(", "self", ".", "BINWALK_MAGIC_DIR", ",", "self", ".", "BINA...
Find all user/system magic signature files. @system_only - If True, only the system magic file directory will be searched. @user_only - If True, only the user magic file directory will be searched. Returns a list of user/system magic signature files.
[ "Find", "all", "user", "/", "system", "magic", "signature", "files", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L56-L87
train
ReFirmLabs/binwalk
src/binwalk/core/settings.py
Settings.find_magic_file
def find_magic_file(self, fname, system_only=False, user_only=False): ''' Finds the specified magic file name in the system / user magic file directories. @fname - The name of the magic file. @system_only - If True, only the system magic file directory will be searched. @u...
python
def find_magic_file(self, fname, system_only=False, user_only=False): ''' Finds the specified magic file name in the system / user magic file directories. @fname - The name of the magic file. @system_only - If True, only the system magic file directory will be searched. @u...
[ "def", "find_magic_file", "(", "self", ",", "fname", ",", "system_only", "=", "False", ",", "user_only", "=", "False", ")", ":", "loc", "=", "None", "if", "not", "system_only", ":", "fpath", "=", "self", ".", "_user_path", "(", "self", ".", "BINWALK_MAGI...
Finds the specified magic file name in the system / user magic file directories. @fname - The name of the magic file. @system_only - If True, only the system magic file directory will be searched. @user_only - If True, only the user magic file directory will be searched. If sys...
[ "Finds", "the", "specified", "magic", "file", "name", "in", "the", "system", "/", "user", "magic", "file", "directories", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L89-L113
train
ReFirmLabs/binwalk
src/binwalk/core/settings.py
Settings._get_user_dir
def _get_user_dir(self): ''' Get the user's home directory. ''' try: # This should work in both Windows and Unix environments for envname in ['USERPROFILE', 'HOME']: user_dir = os.getenv(envname) if user_dir is not None: ...
python
def _get_user_dir(self): ''' Get the user's home directory. ''' try: # This should work in both Windows and Unix environments for envname in ['USERPROFILE', 'HOME']: user_dir = os.getenv(envname) if user_dir is not None: ...
[ "def", "_get_user_dir", "(", "self", ")", ":", "try", ":", "# This should work in both Windows and Unix environments", "for", "envname", "in", "[", "'USERPROFILE'", ",", "'HOME'", "]", ":", "user_dir", "=", "os", ".", "getenv", "(", "envname", ")", "if", "user_d...
Get the user's home directory.
[ "Get", "the", "user", "s", "home", "directory", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L125-L140
train
ReFirmLabs/binwalk
src/binwalk/core/settings.py
Settings._file_path
def _file_path(self, dirname, filename): ''' Builds an absolute path and creates the directory and file if they don't already exist. @dirname - Directory path. @filename - File name. Returns a full path of 'dirname/filename'. ''' if not os.path.exists(dirname):...
python
def _file_path(self, dirname, filename): ''' Builds an absolute path and creates the directory and file if they don't already exist. @dirname - Directory path. @filename - File name. Returns a full path of 'dirname/filename'. ''' if not os.path.exists(dirname):...
[ "def", "_file_path", "(", "self", ",", "dirname", ",", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "dirname", ")", ":", "try", ":", "os", ".", "makedirs", "(", "dirname", ")", "except", "KeyboardInterrupt", "as", "e", ":...
Builds an absolute path and creates the directory and file if they don't already exist. @dirname - Directory path. @filename - File name. Returns a full path of 'dirname/filename'.
[ "Builds", "an", "absolute", "path", "and", "creates", "the", "directory", "and", "file", "if", "they", "don", "t", "already", "exist", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L142-L169
train
ReFirmLabs/binwalk
src/binwalk/core/settings.py
Settings._user_path
def _user_path(self, subdir, basename=''): ''' Gets the full path to the 'subdir/basename' file in the user binwalk directory. @subdir - Subdirectory inside the user binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/basenam...
python
def _user_path(self, subdir, basename=''): ''' Gets the full path to the 'subdir/basename' file in the user binwalk directory. @subdir - Subdirectory inside the user binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/basenam...
[ "def", "_user_path", "(", "self", ",", "subdir", ",", "basename", "=", "''", ")", ":", "try", ":", "return", "self", ".", "_file_path", "(", "os", ".", "path", ".", "join", "(", "self", ".", "user_dir", ",", "self", ".", "BINWALK_USER_DIR", ",", "sub...
Gets the full path to the 'subdir/basename' file in the user binwalk directory. @subdir - Subdirectory inside the user binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/basename' file.
[ "Gets", "the", "full", "path", "to", "the", "subdir", "/", "basename", "file", "in", "the", "user", "binwalk", "directory", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L171-L185
train
ReFirmLabs/binwalk
src/binwalk/core/settings.py
Settings._system_path
def _system_path(self, subdir, basename=''): ''' Gets the full path to the 'subdir/basename' file in the system binwalk directory. @subdir - Subdirectory inside the system binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/b...
python
def _system_path(self, subdir, basename=''): ''' Gets the full path to the 'subdir/basename' file in the system binwalk directory. @subdir - Subdirectory inside the system binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/b...
[ "def", "_system_path", "(", "self", ",", "subdir", ",", "basename", "=", "''", ")", ":", "try", ":", "return", "self", ".", "_file_path", "(", "os", ".", "path", ".", "join", "(", "self", ".", "system_dir", ",", "subdir", ")", ",", "basename", ")", ...
Gets the full path to the 'subdir/basename' file in the system binwalk directory. @subdir - Subdirectory inside the system binwalk directory. @basename - File name inside the subdirectory. Returns the full path to the 'subdir/basename' file.
[ "Gets", "the", "full", "path", "to", "the", "subdir", "/", "basename", "file", "in", "the", "system", "binwalk", "directory", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/settings.py#L187-L201
train
ReFirmLabs/binwalk
src/binwalk/plugins/hilink.py
HilinkDecryptor._decrypt_and_extract
def _decrypt_and_extract(self, fname): ''' This does the extraction (e.g., it decrypts the image and writes it to a new file on disk). ''' with open(fname, "r") as fp_in: encrypted_data = fp_in.read() decrypted_data = self._hilink_decrypt(encrypted_data) ...
python
def _decrypt_and_extract(self, fname): ''' This does the extraction (e.g., it decrypts the image and writes it to a new file on disk). ''' with open(fname, "r") as fp_in: encrypted_data = fp_in.read() decrypted_data = self._hilink_decrypt(encrypted_data) ...
[ "def", "_decrypt_and_extract", "(", "self", ",", "fname", ")", ":", "with", "open", "(", "fname", ",", "\"r\"", ")", "as", "fp_in", ":", "encrypted_data", "=", "fp_in", ".", "read", "(", ")", "decrypted_data", "=", "self", ".", "_hilink_decrypt", "(", "e...
This does the extraction (e.g., it decrypts the image and writes it to a new file on disk).
[ "This", "does", "the", "extraction", "(", "e", ".", "g", ".", "it", "decrypts", "the", "image", "and", "writes", "it", "to", "a", "new", "file", "on", "disk", ")", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/hilink.py#L38-L48
train
ReFirmLabs/binwalk
src/binwalk/plugins/hilink.py
HilinkDecryptor._hilink_decrypt
def _hilink_decrypt(self, encrypted_firmware): ''' This does the actual decryption. ''' cipher = DES.new(self.DES_KEY, DES.MODE_ECB) p1 = encrypted_firmware[0:3] p2 = encrypted_firmware[3:] p2 += b"\x00" * (8 - (len(p2) % 8)) d1 = p1 + cipher.decrypt(p2)...
python
def _hilink_decrypt(self, encrypted_firmware): ''' This does the actual decryption. ''' cipher = DES.new(self.DES_KEY, DES.MODE_ECB) p1 = encrypted_firmware[0:3] p2 = encrypted_firmware[3:] p2 += b"\x00" * (8 - (len(p2) % 8)) d1 = p1 + cipher.decrypt(p2)...
[ "def", "_hilink_decrypt", "(", "self", ",", "encrypted_firmware", ")", ":", "cipher", "=", "DES", ".", "new", "(", "self", ".", "DES_KEY", ",", "DES", ".", "MODE_ECB", ")", "p1", "=", "encrypted_firmware", "[", "0", ":", "3", "]", "p2", "=", "encrypted...
This does the actual decryption.
[ "This", "does", "the", "actual", "decryption", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/hilink.py#L50-L63
train
ReFirmLabs/binwalk
src/binwalk/plugins/hilink.py
HilinkDecryptor.scan
def scan(self, result): ''' Validate signature results. ''' if self.enabled is True: if result.valid is True: if result.description.lower().startswith(self.SIGNATURE_DESCRIPTION) is True: # Read in the first 64 bytes of the suspected encryp...
python
def scan(self, result): ''' Validate signature results. ''' if self.enabled is True: if result.valid is True: if result.description.lower().startswith(self.SIGNATURE_DESCRIPTION) is True: # Read in the first 64 bytes of the suspected encryp...
[ "def", "scan", "(", "self", ",", "result", ")", ":", "if", "self", ".", "enabled", "is", "True", ":", "if", "result", ".", "valid", "is", "True", ":", "if", "result", ".", "description", ".", "lower", "(", ")", ".", "startswith", "(", "self", ".", ...
Validate signature results.
[ "Validate", "signature", "results", "." ]
a0c5315fd2bae167e5c3d8469ce95d5defc743c2
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/plugins/hilink.py#L65-L94
train
mukulhase/WebWhatsapp-Wrapper
sample/new_messages_observer.py
run
def run(): print("Environment", os.environ) try: os.environ["SELENIUM"] except KeyError: print("Please set the environment variable SELENIUM to Selenium URL") sys.exit(1) driver = WhatsAPIDriver(client='remote', command_executor=os.environ["SELENIUM"]) print("Waiting for QR"...
python
def run(): print("Environment", os.environ) try: os.environ["SELENIUM"] except KeyError: print("Please set the environment variable SELENIUM to Selenium URL") sys.exit(1) driver = WhatsAPIDriver(client='remote', command_executor=os.environ["SELENIUM"]) print("Waiting for QR"...
[ "def", "run", "(", ")", ":", "print", "(", "\"Environment\"", ",", "os", ".", "environ", ")", "try", ":", "os", ".", "environ", "[", "\"SELENIUM\"", "]", "except", "KeyError", ":", "print", "(", "\"Please set the environment variable SELENIUM to Selenium URL\"", ...
Locks the main thread while the subscription in running
[ "Locks", "the", "main", "thread", "while", "the", "subscription", "in", "running" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/sample/new_messages_observer.py#L8-L26
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.save_firefox_profile
def save_firefox_profile(self, remove_old=False): """Function to save the firefox profile to the permanant one""" self.logger.info("Saving profile from %s to %s" % (self._profile.path, self._profile_path)) if remove_old: if os.path.exists(self._profile_path): try: ...
python
def save_firefox_profile(self, remove_old=False): """Function to save the firefox profile to the permanant one""" self.logger.info("Saving profile from %s to %s" % (self._profile.path, self._profile_path)) if remove_old: if os.path.exists(self._profile_path): try: ...
[ "def", "save_firefox_profile", "(", "self", ",", "remove_old", "=", "False", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Saving profile from %s to %s\"", "%", "(", "self", ".", "_profile", ".", "path", ",", "self", ".", "_profile_path", ")", ")", ...
Function to save the firefox profile to the permanant one
[ "Function", "to", "save", "the", "firefox", "profile", "to", "the", "permanant", "one" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L111-L137
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.wait_for_login
def wait_for_login(self, timeout=90): """Waits for the QR to go away""" WebDriverWait(self.driver, timeout).until( EC.visibility_of_element_located((By.CSS_SELECTOR, self._SELECTORS['mainPage'])) )
python
def wait_for_login(self, timeout=90): """Waits for the QR to go away""" WebDriverWait(self.driver, timeout).until( EC.visibility_of_element_located((By.CSS_SELECTOR, self._SELECTORS['mainPage'])) )
[ "def", "wait_for_login", "(", "self", ",", "timeout", "=", "90", ")", ":", "WebDriverWait", "(", "self", ".", "driver", ",", "timeout", ")", ".", "until", "(", "EC", ".", "visibility_of_element_located", "(", "(", "By", ".", "CSS_SELECTOR", ",", "self", ...
Waits for the QR to go away
[ "Waits", "for", "the", "QR", "to", "go", "away" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L258-L262
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_qr
def get_qr(self, filename=None): """Get pairing QR code from client""" if "Click to reload QR code" in self.driver.page_source: self.reload_qr() qr = self.driver.find_element_by_css_selector(self._SELECTORS['qrCode']) if filename is None: fd, fn_png = tempfile.mks...
python
def get_qr(self, filename=None): """Get pairing QR code from client""" if "Click to reload QR code" in self.driver.page_source: self.reload_qr() qr = self.driver.find_element_by_css_selector(self._SELECTORS['qrCode']) if filename is None: fd, fn_png = tempfile.mks...
[ "def", "get_qr", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "\"Click to reload QR code\"", "in", "self", ".", "driver", ".", "page_source", ":", "self", ".", "reload_qr", "(", ")", "qr", "=", "self", ".", "driver", ".", "find_element_by_css...
Get pairing QR code from client
[ "Get", "pairing", "QR", "code", "from", "client" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L267-L280
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_contacts
def get_contacts(self): """ Fetches list of all contacts This will return chats with people from the address book only Use get_all_chats for all chats :return: List of contacts :rtype: list[Contact] """ all_contacts = self.wapi_functions.getAllContacts() ...
python
def get_contacts(self): """ Fetches list of all contacts This will return chats with people from the address book only Use get_all_chats for all chats :return: List of contacts :rtype: list[Contact] """ all_contacts = self.wapi_functions.getAllContacts() ...
[ "def", "get_contacts", "(", "self", ")", ":", "all_contacts", "=", "self", ".", "wapi_functions", ".", "getAllContacts", "(", ")", "return", "[", "Contact", "(", "contact", ",", "self", ")", "for", "contact", "in", "all_contacts", "]" ]
Fetches list of all contacts This will return chats with people from the address book only Use get_all_chats for all chats :return: List of contacts :rtype: list[Contact]
[ "Fetches", "list", "of", "all", "contacts", "This", "will", "return", "chats", "with", "people", "from", "the", "address", "book", "only", "Use", "get_all_chats", "for", "all", "chats" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L292-L302
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_my_contacts
def get_my_contacts(self): """ Fetches list of added contacts :return: List of contacts :rtype: list[Contact] """ my_contacts = self.wapi_functions.getMyContacts() return [Contact(contact, self) for contact in my_contacts]
python
def get_my_contacts(self): """ Fetches list of added contacts :return: List of contacts :rtype: list[Contact] """ my_contacts = self.wapi_functions.getMyContacts() return [Contact(contact, self) for contact in my_contacts]
[ "def", "get_my_contacts", "(", "self", ")", ":", "my_contacts", "=", "self", ".", "wapi_functions", ".", "getMyContacts", "(", ")", "return", "[", "Contact", "(", "contact", ",", "self", ")", "for", "contact", "in", "my_contacts", "]" ]
Fetches list of added contacts :return: List of contacts :rtype: list[Contact]
[ "Fetches", "list", "of", "added", "contacts" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L304-L312
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_all_chats
def get_all_chats(self): """ Fetches all chats :return: List of chats :rtype: list[Chat] """ chats = self.wapi_functions.getAllChats() if chats: return [factory_chat(chat, self) for chat in chats] else: return []
python
def get_all_chats(self): """ Fetches all chats :return: List of chats :rtype: list[Chat] """ chats = self.wapi_functions.getAllChats() if chats: return [factory_chat(chat, self) for chat in chats] else: return []
[ "def", "get_all_chats", "(", "self", ")", ":", "chats", "=", "self", ".", "wapi_functions", ".", "getAllChats", "(", ")", "if", "chats", ":", "return", "[", "factory_chat", "(", "chat", ",", "self", ")", "for", "chat", "in", "chats", "]", "else", ":", ...
Fetches all chats :return: List of chats :rtype: list[Chat]
[ "Fetches", "all", "chats" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L314-L325
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_unread
def get_unread(self, include_me=False, include_notifications=False, use_unread_count=False): """ Fetches unread messages :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_...
python
def get_unread(self, include_me=False, include_notifications=False, use_unread_count=False): """ Fetches unread messages :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_...
[ "def", "get_unread", "(", "self", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ",", "use_unread_count", "=", "False", ")", ":", "raw_message_groups", "=", "self", ".", "wapi_functions", ".", "getUnreadMessages", "(", "include_me", ...
Fetches unread messages :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_notifications: bool or None :param use_unread_count: If set uses chat's 'unreadCount' attribute to fetch ...
[ "Fetches", "unread", "messages", ":", "param", "include_me", ":", "Include", "user", "s", "messages", ":", "type", "include_me", ":", "bool", "or", "None", ":", "param", "include_notifications", ":", "Include", "events", "happening", "on", "chat", ":", "type",...
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L336-L357
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_unread_messages_in_chat
def get_unread_messages_in_chat(self, id, include_me=False, include_notifications=False): """ I fetch unread messages from an asked chat. :param id: chat id :type id: str ...
python
def get_unread_messages_in_chat(self, id, include_me=False, include_notifications=False): """ I fetch unread messages from an asked chat. :param id: chat id :type id: str ...
[ "def", "get_unread_messages_in_chat", "(", "self", ",", "id", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ")", ":", "# get unread messages", "messages", "=", "self", ".", "wapi_functions", ".", "getUnreadMessagesInChat", "(", "id", ...
I fetch unread messages from an asked chat. :param id: chat id :type id: str :param include_me: if user's messages are to be included :type include_me: bool :param include_notifications: if events happening on chat are to be included :type include_notifications: bool ...
[ "I", "fetch", "unread", "messages", "from", "an", "asked", "chat", "." ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L359-L386
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_all_messages_in_chat
def get_all_messages_in_chat(self, chat, include_me=False, include_notifications=False): """ Fetches messages in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_no...
python
def get_all_messages_in_chat(self, chat, include_me=False, include_notifications=False): """ Fetches messages in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_no...
[ "def", "get_all_messages_in_chat", "(", "self", ",", "chat", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ")", ":", "message_objs", "=", "self", ".", "wapi_functions", ".", "getAllMessagesInChat", "(", "chat", ".", "id", ",", "i...
Fetches messages in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_notifications: bool or None :return: List of messages in chat :rtype: list[Message]
[ "Fetches", "messages", "in", "chat" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L390-L405
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_all_message_ids_in_chat
def get_all_message_ids_in_chat(self, chat, include_me=False, include_notifications=False): """ Fetches message ids in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type incl...
python
def get_all_message_ids_in_chat(self, chat, include_me=False, include_notifications=False): """ Fetches message ids in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type incl...
[ "def", "get_all_message_ids_in_chat", "(", "self", ",", "chat", ",", "include_me", "=", "False", ",", "include_notifications", "=", "False", ")", ":", "return", "self", ".", "wapi_functions", ".", "getAllMessageIdsInChat", "(", "chat", ".", "id", ",", "include_m...
Fetches message ids in chat :param include_me: Include user's messages :type include_me: bool or None :param include_notifications: Include events happening on chat :type include_notifications: bool or None :return: List of message ids in chat :rtype: list[str]
[ "Fetches", "message", "ids", "in", "chat" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L407-L418
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_message_by_id
def get_message_by_id(self, message_id): """ Fetch a message :param message_id: Message ID :type message_id: str :return: Message or False :rtype: Message """ result = self.wapi_functions.getMessageById(message_id) if result: result =...
python
def get_message_by_id(self, message_id): """ Fetch a message :param message_id: Message ID :type message_id: str :return: Message or False :rtype: Message """ result = self.wapi_functions.getMessageById(message_id) if result: result =...
[ "def", "get_message_by_id", "(", "self", ",", "message_id", ")", ":", "result", "=", "self", ".", "wapi_functions", ".", "getMessageById", "(", "message_id", ")", "if", "result", ":", "result", "=", "factory_message", "(", "result", ",", "self", ")", "return...
Fetch a message :param message_id: Message ID :type message_id: str :return: Message or False :rtype: Message
[ "Fetch", "a", "message" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L420-L434
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_contact_from_id
def get_contact_from_id(self, contact_id): """ Fetches a contact given its ID :param contact_id: Contact ID :type contact_id: str :return: Contact or Error :rtype: Contact """ contact = self.wapi_functions.getContact(contact_id) if contact is Non...
python
def get_contact_from_id(self, contact_id): """ Fetches a contact given its ID :param contact_id: Contact ID :type contact_id: str :return: Contact or Error :rtype: Contact """ contact = self.wapi_functions.getContact(contact_id) if contact is Non...
[ "def", "get_contact_from_id", "(", "self", ",", "contact_id", ")", ":", "contact", "=", "self", ".", "wapi_functions", ".", "getContact", "(", "contact_id", ")", "if", "contact", "is", "None", ":", "raise", "ContactNotFoundError", "(", "\"Contact {0} not found\"",...
Fetches a contact given its ID :param contact_id: Contact ID :type contact_id: str :return: Contact or Error :rtype: Contact
[ "Fetches", "a", "contact", "given", "its", "ID" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L436-L450
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_chat_from_id
def get_chat_from_id(self, chat_id): """ Fetches a chat given its ID :param chat_id: Chat ID :type chat_id: str :return: Chat or Error :rtype: Chat """ chat = self.wapi_functions.getChatById(chat_id) if chat: return factory_chat(chat, ...
python
def get_chat_from_id(self, chat_id): """ Fetches a chat given its ID :param chat_id: Chat ID :type chat_id: str :return: Chat or Error :rtype: Chat """ chat = self.wapi_functions.getChatById(chat_id) if chat: return factory_chat(chat, ...
[ "def", "get_chat_from_id", "(", "self", ",", "chat_id", ")", ":", "chat", "=", "self", ".", "wapi_functions", ".", "getChatById", "(", "chat_id", ")", "if", "chat", ":", "return", "factory_chat", "(", "chat", ",", "self", ")", "raise", "ChatNotFoundError", ...
Fetches a chat given its ID :param chat_id: Chat ID :type chat_id: str :return: Chat or Error :rtype: Chat
[ "Fetches", "a", "chat", "given", "its", "ID" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L452-L465
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_chat_from_phone_number
def get_chat_from_phone_number(self, number, createIfNotFound = False): """ Gets chat by phone number Number format should be as it appears in Whatsapp ID For example, for the number: +972-51-234-5678 This function would receive: 972512345678 :param numbe...
python
def get_chat_from_phone_number(self, number, createIfNotFound = False): """ Gets chat by phone number Number format should be as it appears in Whatsapp ID For example, for the number: +972-51-234-5678 This function would receive: 972512345678 :param numbe...
[ "def", "get_chat_from_phone_number", "(", "self", ",", "number", ",", "createIfNotFound", "=", "False", ")", ":", "for", "chat", "in", "self", ".", "get_all_chats", "(", ")", ":", "if", "not", "isinstance", "(", "chat", ",", "UserChat", ")", "or", "number"...
Gets chat by phone number Number format should be as it appears in Whatsapp ID For example, for the number: +972-51-234-5678 This function would receive: 972512345678 :param number: Phone number :return: Chat :rtype: Chat
[ "Gets", "chat", "by", "phone", "number", "Number", "format", "should", "be", "as", "it", "appears", "in", "Whatsapp", "ID", "For", "example", "for", "the", "number", ":", "+", "972", "-", "51", "-", "234", "-", "5678", "This", "function", "would", "rec...
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L467-L492
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_status
def get_status(self): """ Returns status of the driver :return: Status :rtype: WhatsAPIDriverStatus """ if self.driver is None: return WhatsAPIDriverStatus.NotConnected if self.driver.session_id is None: return WhatsAPIDriverStatus.NotConn...
python
def get_status(self): """ Returns status of the driver :return: Status :rtype: WhatsAPIDriverStatus """ if self.driver is None: return WhatsAPIDriverStatus.NotConnected if self.driver.session_id is None: return WhatsAPIDriverStatus.NotConn...
[ "def", "get_status", "(", "self", ")", ":", "if", "self", ".", "driver", "is", "None", ":", "return", "WhatsAPIDriverStatus", ".", "NotConnected", "if", "self", ".", "driver", ".", "session_id", "is", "None", ":", "return", "WhatsAPIDriverStatus", ".", "NotC...
Returns status of the driver :return: Status :rtype: WhatsAPIDriverStatus
[ "Returns", "status", "of", "the", "driver" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L497-L518
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.contact_get_common_groups
def contact_get_common_groups(self, contact_id): """ Returns groups common between a user and the contact with given id. :return: Contact or Error :rtype: Contact """ for group in self.wapi_functions.getCommonGroups(contact_id): yield factory_chat(group, self...
python
def contact_get_common_groups(self, contact_id): """ Returns groups common between a user and the contact with given id. :return: Contact or Error :rtype: Contact """ for group in self.wapi_functions.getCommonGroups(contact_id): yield factory_chat(group, self...
[ "def", "contact_get_common_groups", "(", "self", ",", "contact_id", ")", ":", "for", "group", "in", "self", ".", "wapi_functions", ".", "getCommonGroups", "(", "contact_id", ")", ":", "yield", "factory_chat", "(", "group", ",", "self", ")" ]
Returns groups common between a user and the contact with given id. :return: Contact or Error :rtype: Contact
[ "Returns", "groups", "common", "between", "a", "user", "and", "the", "contact", "with", "given", "id", "." ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L520-L528
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.convert_to_base64
def convert_to_base64(self, path): """ :param path: file path :return: returns the converted string and formatted for the send media function send_media """ mime = magic.Magic(mime=True) content_type = mime.from_file(path) archive = '' with open(path, "rb...
python
def convert_to_base64(self, path): """ :param path: file path :return: returns the converted string and formatted for the send media function send_media """ mime = magic.Magic(mime=True) content_type = mime.from_file(path) archive = '' with open(path, "rb...
[ "def", "convert_to_base64", "(", "self", ",", "path", ")", ":", "mime", "=", "magic", ".", "Magic", "(", "mime", "=", "True", ")", "content_type", "=", "mime", ".", "from_file", "(", "path", ")", "archive", "=", "''", "with", "open", "(", "path", ","...
:param path: file path :return: returns the converted string and formatted for the send media function send_media
[ ":", "param", "path", ":", "file", "path", ":", "return", ":", "returns", "the", "converted", "string", "and", "formatted", "for", "the", "send", "media", "function", "send_media" ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L555-L567
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.send_media
def send_media(self, path, chatid, caption): """ converts the file to base64 and sends it using the sendImage function of wapi.js :param path: file path :param chatid: chatId to be sent :param caption: :return: """ imgBase64 = self.convert_to_base64(pa...
python
def send_media(self, path, chatid, caption): """ converts the file to base64 and sends it using the sendImage function of wapi.js :param path: file path :param chatid: chatId to be sent :param caption: :return: """ imgBase64 = self.convert_to_base64(pa...
[ "def", "send_media", "(", "self", ",", "path", ",", "chatid", ",", "caption", ")", ":", "imgBase64", "=", "self", ".", "convert_to_base64", "(", "path", ")", "filename", "=", "os", ".", "path", ".", "split", "(", "path", ")", "[", "-", "1", "]", "r...
converts the file to base64 and sends it using the sendImage function of wapi.js :param path: file path :param chatid: chatId to be sent :param caption: :return:
[ "converts", "the", "file", "to", "base64", "and", "sends", "it", "using", "the", "sendImage", "function", "of", "wapi", ".", "js", ":", "param", "path", ":", "file", "path", ":", "param", "chatid", ":", "chatId", "to", "be", "sent", ":", "param", "capt...
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L570-L580
train
mukulhase/WebWhatsapp-Wrapper
webwhatsapi/__init__.py
WhatsAPIDriver.get_profile_pic_from_id
def get_profile_pic_from_id(self, id): """ Get full profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str """ profile_pic = self.wapi_functions.getProfilePicFromId(id) if ...
python
def get_profile_pic_from_id(self, id): """ Get full profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str """ profile_pic = self.wapi_functions.getProfilePicFromId(id) if ...
[ "def", "get_profile_pic_from_id", "(", "self", ",", "id", ")", ":", "profile_pic", "=", "self", ".", "wapi_functions", ".", "getProfilePicFromId", "(", "id", ")", "if", "profile_pic", ":", "return", "b64decode", "(", "profile_pic", ")", "else", ":", "return", ...
Get full profile pic from an id The ID must be on your contact book to successfully get their profile picture. :param id: ID :type id: str
[ "Get", "full", "profile", "pic", "from", "an", "id", "The", "ID", "must", "be", "on", "your", "contact", "book", "to", "successfully", "get", "their", "profile", "picture", "." ]
81b918ee4e0cd0cb563807a72baa167f670d70cb
https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/81b918ee4e0cd0cb563807a72baa167f670d70cb/webwhatsapi/__init__.py#L623-L636
train